financialAccount.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <div>
  3. <basic-container>
  4. <avue-crud
  5. ref="crud"
  6. :data="data"
  7. :option="option"
  8. :table-loading="loading"
  9. @row-update="rowUpdate"
  10. @row-del="rowDel"
  11. @saveColumn="saveColumn"
  12. @resetColumn="resetColumn"
  13. >
  14. <template slot="menuLeft" slot-scope="{size}">
  15. <el-button type="primary"
  16. icon="el-icon-plus"
  17. size="small"
  18. :loading="submitButton"
  19. @click="entering"
  20. >录入
  21. </el-button>
  22. </template>
  23. <template slot-scope="{row,index}" slot="menu">
  24. <!-- <el-button-->
  25. <!-- type="text"-->
  26. <!-- size="small"-->
  27. <!-- icon="el-icon-edit"-->
  28. <!-- @click="rowCell(row,index)"-->
  29. <!-- >{{ row.$cellEdit ? '修改完成' : '修改' }}-->
  30. <!-- </el-button>-->
  31. <el-button
  32. type="text"
  33. icon="el-icon-delete"
  34. size="small"
  35. @click="rowDel(row,index)"
  36. >删除
  37. </el-button>
  38. </template>
  39. <template slot-scope="{row,index}" slot="corpId">
  40. <span v-if="row.$cellEdit" class="required_fields" style="float: left;line-height: 32px">*</span>
  41. <crop-select
  42. v-if="row.$cellEdit"
  43. v-model="corpId"
  44. corpType="KG"
  45. style="width: 100%"
  46. ></crop-select>
  47. </template>
  48. <template slot-scope="{row,index}" slot="belongToCorpId">
  49. <crop-select
  50. v-if="row.$cellEdit"
  51. v-model="row.belongToCorpId"
  52. corpType="GS"
  53. style="width: 100%"
  54. ></crop-select>
  55. <span v-else>{{ row.costType }}</span>
  56. </template>
  57. <template slot-scope="{row,index}" slot="costType">
  58. <span v-if="row.$cellEdit" class="required_fields">*</span>
  59. <breakdown-select
  60. v-if="row.$cellEdit"
  61. v-model="row.costType"
  62. style="width: 90%"
  63. :configuration="configuration">
  64. </breakdown-select>
  65. <span v-else>{{ row.costType }}</span>
  66. </template>
  67. <template slot-scope="{row,index}" slot="billNo">
  68. <el-select placeholder="请选择"
  69. v-if="row.$cellEdit"
  70. v-model="row.billNo"
  71. size="small"
  72. filterable
  73. allow-create
  74. default-first-option
  75. clearable>
  76. <el-option
  77. v-for="item in row.billNoList"
  78. :key="item"
  79. :label="item"
  80. :value="item"
  81. ></el-option>
  82. </el-select>
  83. <span v-else>{{ row.billNo }}</span>
  84. </template>
  85. <template slot-scope="{row,index}" slot="taxRate">
  86. <el-input
  87. v-model="row.taxRate"
  88. v-if="row.$cellEdit"
  89. size="small"
  90. oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d\d\d\d\d).*$/, "$1.$2")'
  91. autocomplete="off"
  92. >
  93. <i slot="suffix" style="margin-right: 10px;top:6px">%</i>
  94. </el-input>
  95. <span v-else>{{ row.taxRate }}</span>
  96. </template>
  97. <template slot-scope="{row,index}" slot="currency">
  98. <span v-if="row.$cellEdit" class="required_fields">*</span>
  99. <el-select v-if="row.$cellEdit" v-model="row.currency" size="small" placeholder="请选择" style="width: 90%" @change="currencyChange(row)" clearable filterable>
  100. <el-option v-for="(item,index) in currencyDic" :key="index" :label="item.dictValue" :value="item.dictValue"></el-option>
  101. </el-select>
  102. <span v-else>{{ row.currency }}</span>
  103. </template>
  104. <template slot-scope="{row,index}" slot="unit">
  105. <span v-if="row.$cellEdit" class="required_fields">*</span>
  106. <el-select v-if="row.$cellEdit" v-model="row.unit" size="small" style="width: 90%" placeholder="请选择" clearable filterable>
  107. <el-option v-for="(item,index) in unitDic" :key="index" :label="item.dictValue" :value="item.dictValue"></el-option>
  108. </el-select>
  109. <span v-else>{{ row.unit }}</span>
  110. </template>
  111. </avue-crud>
  112. <div class="dialogButton">
  113. <el-button size="small" :loading="submitButton" @click="$emit('choceFun')">取消</el-button>
  114. <el-button type="primary" size="small" :loading="submitButton" @click="submit()">确定</el-button>
  115. </div>
  116. </basic-container>
  117. <containerTitle title="历史账单"></containerTitle>
  118. <basic-container>
  119. <avue-crud :option="historyOption"
  120. :data="historyDataList"
  121. ref="historyCrud"
  122. v-model="historyForm"
  123. :page.sync="page"
  124. :table-loading="historyLoading"
  125. @on-load="onLoad">
  126. </avue-crud>
  127. </basic-container>
  128. </div>
  129. </template>
  130. <script>
  131. import {applyLoan, paymentApply} from "@/api/financialManagement/paymentRequest";
  132. import option from "./config/option.json"
  133. import historyOption from "../bill/config/application.json"
  134. import {getUserInfo} from "@/api/system/user";
  135. import { getBillList } from "@/api/financialManagement/paymentRequest";
  136. export default {
  137. name: "financialAccount",
  138. props: {
  139. billId:{
  140. type:String
  141. },
  142. billType: {
  143. type: String
  144. },
  145. srcType: {
  146. type: Number,
  147. default: 1,
  148. },
  149. billData: {
  150. type: Object
  151. },
  152. choceFun: {
  153. type: Function
  154. },
  155. arrList: {
  156. type: Array,
  157. default: []
  158. },
  159. checkData: {
  160. type: Object,
  161. default: {
  162. url: null,
  163. pageStatus: null,
  164. pageLabel: null,
  165. checkType: null
  166. },
  167. },
  168. },
  169. data(){
  170. return {
  171. data: [],
  172. corpId:'',
  173. option:option,
  174. loading:false,
  175. submitButton:false,
  176. currencyDic:[],
  177. unitDic:[],
  178. configuration: {
  179. multipleChoices: false,
  180. multiple: false,
  181. disabled: true,
  182. searchShow: true,
  183. collapseTags: false,
  184. placeholder: '请点击右边按钮选择',
  185. dicData: []
  186. },
  187. category: '',
  188. historyLoading:false,
  189. historyOption:historyOption,
  190. historyDataList:[],
  191. historyForm:{},
  192. page: {
  193. pageSize: 10,
  194. pagerCount: 1,
  195. total: 0,
  196. },
  197. }
  198. },
  199. created() {
  200. this.historyOption.searchShow = false
  201. getUserInfo().then(res=>{
  202. this.category = res.data.data.billType
  203. if (this.category == 2) {
  204. }
  205. })
  206. //币别
  207. this.getWorkDicts("currency").then(res => {
  208. this.currencyDic = res.data.data
  209. })
  210. this.getWorkDicts("unit").then(res => {
  211. this.unitDic = res.data.data
  212. })
  213. },
  214. mounted() {
  215. this.init()
  216. },
  217. watch:{
  218. billId(val, oldVal) {
  219. if(val != oldVal){
  220. this.onLoad(this.page)
  221. }
  222. },
  223. },
  224. methods:{
  225. init(){
  226. if(this.arrList.length === 0){
  227. this.corpId = this.billData.corpId
  228. this.$refs.crud.rowCellAdd(this.billData);
  229. }else{
  230. this.billData = this.arrList[0]
  231. this.corpId = this.arrList[0].corpId
  232. this.arrList.forEach(item=>{
  233. this.$refs.crud.rowCellAdd(item);
  234. })
  235. }
  236. //删除 提单号
  237. if(this.billData.optionType !== "JK"){
  238. this.option.column.forEach(item =>{
  239. if(item.prop === "billNo"){
  240. item.hide = true
  241. }else{
  242. item.hide = false
  243. }
  244. })
  245. }
  246. },
  247. currencyChange(row){
  248. this.currencyDic.forEach(item =>{
  249. if(item.dictValue === row.currency){
  250. row.exchangeRate = item.remark
  251. }
  252. })
  253. },
  254. rowCell(row,index){
  255. this.$refs.crud.rowCell(row, index)
  256. },
  257. rowDel(row,index){
  258. this.$confirm("确定将选择数据删除?", {
  259. confirmButtonText: "确定",
  260. cancelButtonText: "取消",
  261. type: "warning"
  262. }).then(() => {
  263. this.data.splice(index, 1);
  264. })
  265. },
  266. rowUpdate(row, index, done, loading) {
  267. done(row);
  268. },
  269. entering(){
  270. if(this.data.length !== 0){
  271. //取第一条数据的 合同号 以及客户
  272. let params = {
  273. ...this.billData,
  274. srcOrderno:this.data[0].srcOrderno,
  275. corpId:this.data[0].corpId
  276. }
  277. this.$refs.crud.rowCellAdd(params);
  278. }else{
  279. this.$refs.crud.rowCellAdd(this.billData);
  280. }
  281. },
  282. onLoad(page,params = {}) {
  283. this.historyLoading = true;
  284. params.srcParentId = this.billId
  285. params.flag = 1
  286. getBillList(page.currentPage, page.pageSize,params).then(res=>{
  287. this.historyDataList = res.data.data.records
  288. }).finally(()=>{
  289. this.historyLoading = false;
  290. })
  291. },
  292. submit(){
  293. for(let i = 0;i<this.data.length;i++){
  294. if (this.corpId === (null || "")) {
  295. return this.$message.error(`请输入第${i + 1}行的客户`);
  296. }
  297. if (this.data[i].costType === (null || "")) {
  298. return this.$message.error(`请输入第${i + 1}行的费用名称`);
  299. }
  300. if (this.data[i].accDate === (null || "")) {
  301. return this.$message.error(`请输入第${i + 1}行的合同日期`);
  302. }
  303. if (this.data[i].amount === (null || "")) {
  304. return this.$message.error(`请输入第${i + 1}行的金额`);
  305. }
  306. if (this.data[i].currency === (null || "")) {
  307. return this.$message.error(`请输入第${i + 1}行的币别`);
  308. }
  309. if (this.data[i].exchangeRate === (null || "")) {
  310. return this.$message.error(`请输入第${i + 1}行的汇率`);
  311. }
  312. if (this.data[i].taxRate === (null || "")) {
  313. return this.$message.error(`请输入第${i + 1}行的税率`);
  314. }
  315. }
  316. this.submitButton = true
  317. const itemsList = this.data.map(item => {
  318. item.corpId = this.corpId;
  319. item.tradeType = this.billData.optionType?this.billData.optionType: item.tradeType
  320. item.srcType = this.srcType
  321. return item
  322. })
  323. const params = {
  324. url: this.checkData.url,
  325. pageStatus: this.checkData.pageStatus,
  326. pageLabel: this.checkData.pageLabel,
  327. checkType: this.checkData.checkType,
  328. billType : this.billType,
  329. DC : this.billData.itemType === "采购"?"C":"D", //账单明细会根据D C区分采购 销售搜索
  330. itemsList: itemsList
  331. }
  332. // 采购申请货款 销售申请退款 都会走申请 走审核 => 付款申请
  333. if(this.billType === "申请"){
  334. applyLoan(params).then(res =>{
  335. if(res.data.success){
  336. this.$message.success("操作成功!")
  337. this.$emit("choceFun");
  338. //跳转付款申请页面
  339. // if(this.$store.getters.pqStatus){
  340. // this.$alert("无法自动跳,因为付费申请页面已存在!", "温馨提示", {
  341. // confirmButtonText: "确定",
  342. // type: 'warning',
  343. // callback: action => {
  344. // }
  345. // });
  346. // }else{
  347. // //关闭一下存在的列表页 跳转
  348. // this.$router.$avueRouter.closeTag('/financialManagement/paymentRequest/index');
  349. // this.$router.push({
  350. // path: "/financialManagement/paymentRequest/index",
  351. // query: {params: res.data.data.id},
  352. // });
  353. // }
  354. }
  355. }).finally(()=>{
  356. this.submitButton = false
  357. })
  358. }
  359. //采购退款结算 销售收款结算 不需申请请核 直接结算 => 结算
  360. if(this.billType === "收费"){
  361. paymentApply(params).then(res=>{
  362. if(res.data.success){
  363. this.$message.success("操作成功!")
  364. this.$emit("choceFun");
  365. }
  366. }).finally(()=>{
  367. this.submitButton = false
  368. })
  369. }
  370. },
  371. saveColumn(){
  372. },
  373. resetColumn(){
  374. },
  375. }
  376. }
  377. </script>
  378. <style scoped lang="scss">
  379. .required_fields{
  380. color: #F56C6C;
  381. display:inline-block;
  382. width: 7%
  383. }
  384. </style>