addAccountDialog.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. :recorpayList.sync="recorpayList"
  19. :dialogType="dialogType"
  20. ></purchase-form>
  21. <headerTitle title="对账明细" style="margin-top: 30px">
  22. <template v-slot>
  23. <el-row style="font-weight: 700; color: red">
  24. <span>总金额:</span>
  25. <span>{{ dataForm.orderTotalAmount || 0 }}</span>
  26. <el-divider direction="vertical"></el-divider>
  27. <span>已对账金额:</span>
  28. <span>{{ dataForm.amountCompletePrice || 0 }}</span>
  29. <el-divider direction="vertical"></el-divider>
  30. <span>未对账金额:</span>
  31. <span>{{ dataForm.amountUnCompletePrice || 0 }}</span>
  32. <el-divider direction="vertical"></el-divider>
  33. <span>本次对账总金额:</span>
  34. <span>{{ dataForm.amountTotalPrice || 0 }}</span>
  35. </el-row>
  36. </template>
  37. </headerTitle>
  38. <!-- <recorpayTableList
  39. ref="recorpayListRef"
  40. :dataForm="dataForm"
  41. :recorpayList.sync="recorpayList"
  42. :dialogType="dialogType"
  43. ></recorpayTableList> -->
  44. <inventoryTable
  45. ref="inventoryTableref"
  46. :datasource.sync="datasource"
  47. :dialogType="dialogType"
  48. type="purchase"
  49. ></inventoryTable>
  50. <div slot="footer" class="footer">
  51. <el-button
  52. v-if="dialogType !== 'view'"
  53. type="primary"
  54. @click="save"
  55. v-click-once
  56. >保存</el-button
  57. >
  58. <el-button
  59. v-if="dialogType !== 'view'"
  60. type="primary"
  61. @click="save('sub')"
  62. v-click-once
  63. >提交</el-button
  64. >
  65. <el-button @click="cancel">返回</el-button>
  66. </div>
  67. <process-submit-dialog
  68. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  69. v-if="processSubmitDialogFlag"
  70. ref="processSubmitDialogRef"
  71. @reload="reload"
  72. ></process-submit-dialog>
  73. </ele-modal>
  74. </template>
  75. <script>
  76. // import recorpayTableList from '@/views/saleManage/saleOrder/accountstatement/components/recorpayTableList.vue';
  77. // import InventoryTable from './inventoryTable.vue';
  78. import InventoryTable from '@/views/saleManage/saleOrder/accountstatement/components/inventoryTable.vue';
  79. import purchaseForm from './purchaseForm.vue';
  80. import {
  81. getStatementRecordListAPI,
  82. createAccountStatementAPI,
  83. accountstatementInfoAPI,
  84. accountstatementUpdateAPI
  85. } from '@/api/saleManage/accountstatement';
  86. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  87. export default {
  88. name: 'addAccountDialog',
  89. props: ['addAccountDialogFlag'],
  90. components: {
  91. processSubmitDialog,
  92. InventoryTable,
  93. purchaseForm,
  94. // recorpayTableList
  95. },
  96. data() {
  97. return {
  98. businessId: '',
  99. fullscreen: false,
  100. datasource: [],
  101. recorpayList: [],
  102. dataForm: {
  103. sourceType: 1,
  104. dateType: 1,
  105. dateValue: '',
  106. contactId: '',
  107. contactName: '',
  108. sourceName: '',
  109. sourceId: '',
  110. type: '',
  111. year: '',
  112. quarter: '',
  113. month: '',
  114. dateTimeRange: [],
  115. orderNo: '',
  116. orderId: '',
  117. id: '',
  118. startDate: '',
  119. endDate: '',
  120. repliedFiles: [],
  121. queryDimension: 3,
  122. },
  123. title: '',
  124. processSubmitDialogFlag: false,
  125. dialogType: ''
  126. };
  127. },
  128. computed: {},
  129. methods: {
  130. open(dialogType, row, type = '') {
  131. this.businessId = row?.id || '';
  132. this.dialogType = dialogType;
  133. this.title =
  134. dialogType == 'add'
  135. ? '新增'
  136. : dialogType == 'update'
  137. ? '修改'
  138. : '详情';
  139. this.dataForm.type = type;
  140. if (this.dialogType !== 'add') {
  141. this.getInfo(row);
  142. }
  143. },
  144. //获取对账单详情
  145. async getInfo(row) {
  146. let data = await accountstatementInfoAPI(row.id);
  147. // this.recorpayList = data.recorpayList || [];
  148. data.orderTotalAmount = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.orderAmount * 100), 0) / 100;
  149. data.amountTotalPrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.amountTotalPrice * 100), 0) / 100;
  150. data.amountCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.statementAmount * 100), 0) / 100;
  151. data.amountUnCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100;
  152. this.datasource = data.orderList || [];
  153. this.dataForm = data;
  154. switch (this.dataForm.dateType) {
  155. case 1:
  156. this.$set(this.dataForm,'year',this.dataForm.dateValue)
  157. break;
  158. case 2:
  159. //2023年-四季度
  160. let data = this.dataForm.dateValue.split('年-');
  161. this.$set(this.dataForm,'year',data[0])
  162. this.$set(this.dataForm,'quarter',data[1])
  163. break;
  164. case 3:
  165. this.$set(this.dataForm,'month',this.dataForm.dateValue)
  166. break;
  167. default:
  168. this.dataForm.dateValue = '';
  169. this.$set(this.dataForm,'dateTimeRange',[
  170. this.dataForm.startDate,
  171. this.dataForm.endDate
  172. ])
  173. }
  174. this.$forceUpdate()
  175. },
  176. //关闭弹窗
  177. cancel() {
  178. this.$emit('update:addAccountDialogFlag', false);
  179. },
  180. //查询获取订单数据
  181. async handleSearch(params) {
  182. let searchQuery = {
  183. endDate: params.endDate,
  184. sourceId: params.sourceId,
  185. sourceType: params.sourceType,
  186. startDate: params.startDate,
  187. queryDimension: params.queryDimension,
  188. type: 2
  189. };
  190. let data = await getStatementRecordListAPI(searchQuery);
  191. // this.recorpayList = data.recorpayList || [];
  192. this.datasource = data || [];
  193. this.dataForm = {
  194. ...this.dataForm,
  195. // amountPayablePrice: data.amountPayablePrice,
  196. // amountReceivablePrice: data.amountReceivablePrice,
  197. // amountTotalPrice: data.amountTotalPrice,
  198. // amountPayablePass: data.amountPayablePass,
  199. // amountReceivablePass: data.amountReceivablePass
  200. orderTotalAmount: data.reduce((pre, cur) => pre + Math.round(+cur.orderAmount * 100), 0) / 100,
  201. amountTotalPrice: data.reduce((pre, cur) => pre + Math.round(+cur.amountTotalPrice * 100), 0) / 100,
  202. amountCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.statementAmount * 100), 0) / 100,
  203. amountUnCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100
  204. };
  205. // if (!this.datasource.length) this.$message.warning('暂无订单信息');
  206. },
  207. //保存
  208. async save(is) {
  209. if (!this.datasource.length&&!this.recorpayList.length)
  210. return this.$message.warning('暂无对账信息');
  211. let api =
  212. this.dialogType == 'add'
  213. ? createAccountStatementAPI
  214. : accountstatementUpdateAPI;
  215. let params = {
  216. ...this.dataForm,
  217. orderList: this.datasource,
  218. recorpayList:this.recorpayList
  219. };
  220. let data = await api(params);
  221. if (is == 'sub') {
  222. await this.submit(data);
  223. return;
  224. // await submitAccountStatementApproveAPI(
  225. // {
  226. // businessId: data,
  227. // type: this.dataForm.type
  228. // }
  229. // )
  230. }
  231. this.$message.success('操作成功');
  232. this.reload();
  233. },
  234. async submit(res) {
  235. let data = await accountstatementInfoAPI(this.businessId || res);
  236. this.processSubmitDialogFlag = true;
  237. this.$nextTick(() => {
  238. let params = {
  239. businessId: data.id,
  240. businessKey: 'purchase_account_statement_approve',
  241. formCreateUserId: data.createUserId,
  242. variables: {
  243. businessCode: data.statementNo,
  244. type: data.type,
  245. businessName: data.contactName,
  246. businessType: '对账单'
  247. }
  248. // callBackMethodType : '1',
  249. // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
  250. // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
  251. // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
  252. // miniHandle : '',
  253. // miniView : '',
  254. };
  255. this.$refs.processSubmitDialogRef.init(params);
  256. });
  257. },
  258. reload() {
  259. this.cancel();
  260. //刷新主页面
  261. this.$emit('done');
  262. }
  263. }
  264. };
  265. </script>
  266. <style scoped lang="scss">
  267. ::v-deep.el-divider {
  268. margin: 10px;
  269. font-weight: bold;
  270. }
  271. </style>