addAccountDialog.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :visible.sync="addAccountDialogFlag"
  6. :title="title"
  7. :close-on-click-modal="false"
  8. width="70%"
  9. :maxable="true"
  10. :resizable="true"
  11. :before-close="cancel"
  12. >
  13. <!--采购表单表单-->
  14. <purchase-form
  15. @handleSearch="handleSearch"
  16. :dataForm.sync="dataForm"
  17. :datasource.sync="datasource"
  18. :dialogType="dialogType"
  19. ></purchase-form>
  20. <!-- 应付信息 -->
  21. <headerTitle title="应付信息" style="margin-top: 30px"></headerTitle>
  22. <payables-info
  23. ref="payablesInfoRef"
  24. :dataForm.sync="dataForm"
  25. :payablesList="payablesList"
  26. :dialogType="dialogType"
  27. ></payables-info>
  28. <headerTitle title="对账明细" style="margin-top: 30px"> </headerTitle>
  29. <account-detail-table
  30. ref="accountDetailTableRef"
  31. :datasource.sync="datasource"
  32. :dialogType="dialogType"
  33. :queryDimension="dataForm.queryDimension"
  34. @totalChange="handleTotalChange"
  35. @countChange="handleCountChange"
  36. @statementAmountChange="handleStatementAmountChange"
  37. ></account-detail-table>
  38. <div slot="footer" class="footer">
  39. <el-button
  40. v-if="dialogType !== 'view'"
  41. type="primary"
  42. @click="save"
  43. v-click-once
  44. >保存</el-button
  45. >
  46. <el-button
  47. v-if="dialogType !== 'view'"
  48. type="primary"
  49. @click="save('sub')"
  50. v-click-once
  51. >提交</el-button
  52. >
  53. <el-button @click="cancel">返回</el-button>
  54. </div>
  55. <process-submit-dialog
  56. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  57. v-if="processSubmitDialogFlag"
  58. ref="processSubmitDialogRef"
  59. @reload="reload"
  60. ></process-submit-dialog>
  61. </ele-modal>
  62. </template>
  63. <script>
  64. // import recorpayTableList from '@/views/saleManage/saleOrder/accountstatement/components/recorpayTableList.vue';
  65. // import InventoryTable from './inventoryTable.vue';
  66. import InventoryTable from '@/views/saleManage/saleOrder/accountstatement/components/inventoryTable.vue';
  67. import purchaseForm from './purchaseForm.vue';
  68. import payablesInfo from './payablesInfo.vue';
  69. import {
  70. getStatementRecordSummaryAPI,
  71. createAccountStatementAPI,
  72. accountstatementInfoAPI,
  73. accountstatementUpdateAPI
  74. } from '@/api/saleManage/accountstatement';
  75. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  76. import { paymentTypeOp } from '@/enum/dict';
  77. import AccountDetailTable from '@/views/saleManage/saleOrder/accountstatement/components/accountDetailTable.vue';
  78. export default {
  79. name: 'addAccountDialog',
  80. props: ['addAccountDialogFlag'],
  81. components: {
  82. processSubmitDialog,
  83. InventoryTable,
  84. purchaseForm,
  85. payablesInfo,
  86. AccountDetailTable
  87. // recorpayTableList
  88. },
  89. data() {
  90. return {
  91. businessId: '',
  92. fullscreen: false,
  93. datasource: [],
  94. recorpayList: [],
  95. // 应付信息初始明细(查询/编辑回填),由 payablesInfo 本地维护,提交时取回
  96. payablesList: [],
  97. dataForm: {
  98. sourceType: 1,
  99. dateType: 1,
  100. dateValue: '',
  101. contactId: '',
  102. contactName: '',
  103. sourceName: '',
  104. sourceId: '',
  105. type: '',
  106. year: '',
  107. quarter: '',
  108. month: '',
  109. dateTimeRange: [],
  110. orderNo: '',
  111. orderId: '',
  112. id: '',
  113. startDate: '',
  114. endDate: '',
  115. repliedFiles: [],
  116. queryDimension: 3,
  117. },
  118. title: '',
  119. processSubmitDialogFlag: false,
  120. dialogType: ''
  121. };
  122. },
  123. computed: {},
  124. methods: {
  125. handleTotalChange(total) {
  126. this.dataForm.amountTotalPrice = total;
  127. },
  128. handleCountChange(count) {
  129. this.dataForm.totalStatementCount = count;
  130. },
  131. // 明细表本次对账金额变化时,按销售单号同步到应收信息对应行
  132. handleStatementAmountChange(summaryMap) {
  133. if (this.$refs.payablesInfoRef) {
  134. this.$refs.payablesInfoRef.syncStatementAmount(summaryMap);
  135. }
  136. },
  137. open(dialogType, row, type = '') {
  138. this.businessId = row?.id || '';
  139. this.dialogType = dialogType;
  140. this.title =
  141. dialogType == 'add'
  142. ? '新增'
  143. : dialogType == 'update'
  144. ? '修改'
  145. : '详情';
  146. this.dataForm.type = type;
  147. if (this.dialogType !== 'add') {
  148. this.getInfo(row);
  149. }
  150. },
  151. //获取对账单详情
  152. async getInfo(row) {
  153. let data = await accountstatementInfoAPI(row.id);
  154. // this.recorpayList = data.recorpayList || [];
  155. data.orderTotalAmount = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.orderAmount * 100), 0) / 100;
  156. data.amountTotalPrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.statementAmount * 100), 0) / 100;
  157. data.amountCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.statementedAmount * 100), 0) / 100;
  158. data.amountUnCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100;
  159. this.datasource = data.orderList || [];
  160. // 编辑详情回填应付信息(兼容 payablesList / statPayable 两种字段)
  161. this.payablesList =
  162. data.payablesList ||
  163. (data.statPayable && data.statPayable.statPayableDetailList) ||
  164. [];
  165. this.dataForm = data;
  166. switch (this.dataForm.dateType) {
  167. case 1:
  168. this.$set(this.dataForm,'year',this.dataForm.dateValue)
  169. break;
  170. case 2:
  171. //2023年-四季度
  172. let data = this.dataForm.dateValue.split('年-');
  173. this.$set(this.dataForm,'year',data[0])
  174. this.$set(this.dataForm,'quarter',data[1])
  175. break;
  176. case 3:
  177. this.$set(this.dataForm,'month',this.dataForm.dateValue)
  178. break;
  179. default:
  180. this.dataForm.dateValue = '';
  181. this.$set(this.dataForm,'dateTimeRange',[
  182. this.dataForm.startDate,
  183. this.dataForm.endDate
  184. ])
  185. }
  186. this.$forceUpdate()
  187. },
  188. //关闭弹窗
  189. cancel() {
  190. this.$emit('update:addAccountDialogFlag', false);
  191. },
  192. //查询获取订单数据
  193. async handleSearch(params) {
  194. let searchQuery = {
  195. endDate: params.endDate,
  196. sourceId: params.sourceId,
  197. sourceType: params.sourceType,
  198. startDate: params.startDate,
  199. queryDimension: params.queryDimension,
  200. type: 2
  201. };
  202. let data = await getStatementRecordSummaryAPI(searchQuery);
  203. // this.recorpayList = data.recorpayList || [];
  204. this.datasource = data.productList || [];
  205. // 查询接口暂未返回预付信息时,先置空(由 payablesInfo 本地维护)
  206. this.payablesList = data.payablesList ||
  207. (data.statPayable && data.statPayable.statPayableDetailList) ||
  208. [];
  209. this.dataForm = {
  210. ...this.dataForm,
  211. ...data
  212. // amountPayablePrice: data.amountPayablePrice,
  213. // amountReceivablePrice: data.amountReceivablePrice,
  214. // amountTotalPrice: data.amountTotalPrice,
  215. // amountPayablePass: data.amountPayablePass,
  216. // amountReceivablePass: data.amountReceivablePass
  217. // orderTotalAmount: data.reduce((pre, cur) => pre + Math.round(+cur.orderAmount * 100), 0) / 100,
  218. // amountTotalPrice: data.reduce((pre, cur) => pre + Math.round(+cur.statementAmount * 100), 0) / 100,
  219. // amountCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.statementedAmount * 100), 0) / 100,
  220. // amountUnCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100
  221. };
  222. // if (!this.datasource.length) this.$message.warning('暂无订单信息');
  223. },
  224. //保存
  225. async save(is) {
  226. if (!this.datasource.length && !this.recorpayList.length && !this.payablesList.length)
  227. return this.$message.warning('暂无对账信息');
  228. let api =
  229. this.dialogType == 'add'
  230. ? createAccountStatementAPI
  231. : accountstatementUpdateAPI;
  232. // 提交时一次性取回应付信息(本地明细 + 汇总)
  233. const payablesData = this.$refs.payablesInfoRef
  234. ? this.$refs.payablesInfoRef.getSubmitData()
  235. : { payablesList: [], statementAdvanceTotalPrice: 0, receivedTotalPrice: 0 };
  236. let params = {
  237. ...this.dataForm,
  238. orderList: this.datasource,
  239. recorpayList: this.recorpayList,
  240. payablesList: payablesData.payablesList,
  241. totalAdvanceConfirmAmount: payablesData.statementAdvanceTotalPrice,
  242. totalPayableAmount: payablesData.receivedTotalPrice
  243. };
  244. let data = await api(params);
  245. if (is == 'sub') {
  246. await this.submit(data);
  247. return;
  248. // await submitAccountStatementApproveAPI(
  249. // {
  250. // businessId: data,
  251. // type: this.dataForm.type
  252. // }
  253. // )
  254. }
  255. this.$message.success('操作成功');
  256. this.reload();
  257. },
  258. async submit(res) {
  259. let data = await accountstatementInfoAPI(this.businessId || res);
  260. this.processSubmitDialogFlag = true;
  261. this.$nextTick(() => {
  262. let params = {
  263. businessId: data.id,
  264. businessKey: 'purchase_account_statement_approve',
  265. formCreateUserId: data.createUserId,
  266. variables: {
  267. businessCode: data.statementNo,
  268. type: data.type,
  269. businessName: data.contactName,
  270. businessType: '对账单'
  271. }
  272. // callBackMethodType : '1',
  273. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  274. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  275. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  276. // miniHandle : '',
  277. // miniView : '',
  278. };
  279. this.$refs.processSubmitDialogRef.init(params);
  280. });
  281. },
  282. // 对账明细本次对账金额变化时,按采购订单号同步到应付信息对应行
  283. handleDiscountPriceChange(statementAmount, tableIndex) {
  284. const order = this.datasource[tableIndex];
  285. if (!order || !order.orderNo) return;
  286. const summaryMap = { [order.orderNo]: statementAmount };
  287. if (this.$refs.payablesInfoRef) {
  288. this.$refs.payablesInfoRef.syncStatementAmount(summaryMap);
  289. }
  290. },
  291. reload() {
  292. this.cancel();
  293. //刷新主页面
  294. this.$emit('done');
  295. }
  296. }
  297. };
  298. </script>
  299. <style scoped lang="scss">
  300. ::v-deep.el-divider {
  301. margin: 10px;
  302. font-weight: bold;
  303. }
  304. </style>