| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- <template>
- <ele-modal
- custom-class="ele-dialog-form long-dialog-form"
- :centered="true"
- :visible.sync="addAccountDialogFlag"
- :title="title"
- :close-on-click-modal="false"
- width="70%"
- :maxable="true"
- :resizable="true"
- :before-close="cancel"
- >
- <!--采购表单表单-->
- <purchase-form
- @handleSearch="handleSearch"
- :dataForm.sync="dataForm"
- :datasource.sync="datasource"
- :dialogType="dialogType"
- ></purchase-form>
- <!-- 应付信息 -->
- <headerTitle title="应付信息" style="margin-top: 30px"></headerTitle>
- <payables-info
- ref="payablesInfoRef"
- :dataForm.sync="dataForm"
- :payablesList="payablesList"
- :dialogType="dialogType"
- ></payables-info>
- <headerTitle title="对账明细" style="margin-top: 30px"> </headerTitle>
- <account-detail-table
- ref="accountDetailTableRef"
- :datasource.sync="datasource"
- :dialogType="dialogType"
- :queryDimension="dataForm.queryDimension"
- @totalChange="handleTotalChange"
- @countChange="handleCountChange"
- @statementAmountChange="handleStatementAmountChange"
- ></account-detail-table>
- <div slot="footer" class="footer">
- <el-button
- v-if="dialogType !== 'view'"
- type="primary"
- @click="save"
- v-click-once
- >保存</el-button
- >
- <el-button
- v-if="dialogType !== 'view'"
- type="primary"
- @click="save('sub')"
- v-click-once
- >提交</el-button
- >
- <el-button @click="cancel">返回</el-button>
- </div>
- <process-submit-dialog
- :processSubmitDialogFlag.sync="processSubmitDialogFlag"
- v-if="processSubmitDialogFlag"
- ref="processSubmitDialogRef"
- @reload="reload"
- ></process-submit-dialog>
- </ele-modal>
- </template>
- <script>
- // import recorpayTableList from '@/views/saleManage/saleOrder/accountstatement/components/recorpayTableList.vue';
- // import InventoryTable from './inventoryTable.vue';
- import InventoryTable from '@/views/saleManage/saleOrder/accountstatement/components/inventoryTable.vue';
- import purchaseForm from './purchaseForm.vue';
- import payablesInfo from './payablesInfo.vue';
- import {
- getStatementRecordSummaryAPI,
- createAccountStatementAPI,
- accountstatementInfoAPI,
- accountstatementUpdateAPI
- } from '@/api/saleManage/accountstatement';
- import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
- import { paymentTypeOp } from '@/enum/dict';
- import AccountDetailTable from '@/views/saleManage/saleOrder/accountstatement/components/accountDetailTable.vue';
- export default {
- name: 'addAccountDialog',
- props: ['addAccountDialogFlag'],
- components: {
- processSubmitDialog,
- InventoryTable,
- purchaseForm,
- payablesInfo,
- AccountDetailTable
- // recorpayTableList
- },
- data() {
- return {
- businessId: '',
- fullscreen: false,
- saveLoading: false,
- datasource: [],
- recorpayList: [],
- statPayable: null,
- // 应付信息初始明细(查询/编辑回填),由 payablesInfo 本地维护,提交时取回
- payablesList: [],
- dataForm: {
- sourceType: 1,
- dateType: 1,
- dateValue: '',
- contactId: '',
- contactName: '',
- sourceName: '',
- sourceId: '',
- type: '',
- year: '',
- quarter: '',
- month: '',
- dateTimeRange: [],
- orderNo: '',
- orderId: '',
- id: '',
- startDate: '',
- endDate: '',
- repliedFiles: [],
- queryDimension: 3,
- },
- title: '',
- processSubmitDialogFlag: false,
- dialogType: ''
- };
- },
- computed: {},
- methods: {
- handleTotalChange(total) {
- this.dataForm.amountTotalPrice = total;
- },
- handleCountChange(count) {
- this.dataForm.totalStatementCount = count;
- },
- // 明细表本次对账金额变化时,按销售单号同步到应收信息对应行
- handleStatementAmountChange(summaryMap) {
- if (this.$refs.payablesInfoRef) {
- this.$refs.payablesInfoRef.syncStatementAmount(summaryMap);
- }
- },
- open(dialogType, row, type = '') {
- this.businessId = row?.id || '';
- this.dialogType = dialogType;
- this.title =
- dialogType == 'add'
- ? '新增'
- : dialogType == 'update'
- ? '修改'
- : '详情';
- this.dataForm.type = type;
- if (this.dialogType !== 'add') {
- this.getInfo(row);
- }
- },
- //获取对账单详情
- async getInfo(row) {
- let data = await accountstatementInfoAPI(row.id);
- // this.recorpayList = data.recorpayList || [];
- // data.orderTotalAmount = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.orderAmount * 100), 0) / 100;
- // data.amountTotalPrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.statementAmount * 100), 0) / 100;
- // data.amountCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.statementedAmount * 100), 0) / 100;
- // data.amountUnCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100;
- // this.datasource = data.orderList || [];
- // // 编辑详情回填应付信息(兼容 payablesList / statPayable 两种字段)
-
- // this.dataForm = data;
- this.datasource = data.productList || [];
-
- this.payablesList =
- (data.statPayable && data.statPayable.statPayableDetailList) ||
- [];
- // 保存查询到的完整 statPayable 对象,作为提交入参
- this.statPayable = data.statPayable || null;
- this.dataForm = {
- ...this.dataForm,
- ...data,
- };
- switch (this.dataForm.dateType) {
- case 1:
- this.$set(this.dataForm,'year',this.dataForm.dateValue)
-
- break;
- case 2:
- //2023年-四季度
- let data = this.dataForm.dateValue.split('年-');
- this.$set(this.dataForm,'year',data[0])
- this.$set(this.dataForm,'quarter',data[1])
- break;
- case 3:
- this.$set(this.dataForm,'month',this.dataForm.dateValue)
- break;
- default:
- this.dataForm.dateValue = '';
- this.$set(this.dataForm,'dateTimeRange',[
- this.dataForm.startDate,
- this.dataForm.endDate
- ])
- }
- this.$forceUpdate()
- },
- //关闭弹窗
- cancel() {
- this.$emit('update:addAccountDialogFlag', false);
- },
- //查询获取订单数据
- async handleSearch(params) {
- let searchQuery = {
- endDate: params.endDate,
- sourceId: params.sourceId,
- sourceType: params.sourceType,
- startDate: params.startDate,
- queryDimension: params.queryDimension,
- type: 2
- };
- let data = await getStatementRecordSummaryAPI(searchQuery);
- // this.recorpayList = data.recorpayList || [];
- this.datasource = data.productList || [];
- // 查询接口暂未返回预付信息时,先置空(由 payablesInfo 本地维护)
- this.payablesList =
- (data.statPayable && data.statPayable.statPayableDetailList) ||
- [];
- this.statPayable = data.statPayable || null;
- this.dataForm = {
- ...this.dataForm,
- ...data
- // amountPayablePrice: data.amountPayablePrice,
- // amountReceivablePrice: data.amountReceivablePrice,
- // amountTotalPrice: data.amountTotalPrice,
- // amountPayablePass: data.amountPayablePass,
- // amountReceivablePass: data.amountReceivablePass
- // orderTotalAmount: data.reduce((pre, cur) => pre + Math.round(+cur.orderAmount * 100), 0) / 100,
- // amountTotalPrice: data.reduce((pre, cur) => pre + Math.round(+cur.statementAmount * 100), 0) / 100,
- // amountCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.statementedAmount * 100), 0) / 100,
- // amountUnCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100
- };
-
- // if (!this.datasource.length) this.$message.warning('暂无订单信息');
- },
- //保存
- async save(is) {
- if (!this.datasource.length)
- return this.$message.warning('暂无对账信息');
- try {
- // 校验明细表与应付信息表单
- await this.$refs.accountDetailTableRef.getValidForm();
- await this.$refs.payablesInfoRef.validate();
- let api =
- this.dialogType == 'add'
- ? createAccountStatementAPI
- : accountstatementUpdateAPI;
- // 提交时一次性取回应付信息(本地明细 + 汇总),不再实时回写
- const payablesData = this.$refs.payablesInfoRef.getSubmitData();
- // statPayable 为完整数据容器,保存时以它为基准组装应付明细与汇总
- const statPayable = {
- statPayableDetailList: payablesData.payablesList,
- statementAdvanceTotalPrice:
- payablesData.statementAdvanceTotalPrice,
- receivedTotalPrice: payablesData.receivedTotalPrice
- };
- this.statPayable = statPayable;
- const statementAdvanceTotalPrice =
- payablesData.statementAdvanceTotalPrice;
- const receivedTotalPrice = payablesData.receivedTotalPrice;
- let params = {
- ...this.dataForm,
- statementAdvanceTotalPrice,
- receivedTotalPrice,
- totalAdvanceConfirmAmount: statementAdvanceTotalPrice,
- totalPayableAmount: receivedTotalPrice,
- productList: this.datasource,
- statPayable
- };
- this.saveLoading = true;
- let data = await api(params);
- if (is == 'sub') {
- await this.submit(data);
- return;
- }
- this.$message.success('操作成功');
- this.reload();
- this.saveLoading = false;
- } catch (error) {
- console.error('保存失败:', error);
- this.saveLoading = false;
- }
- },
- async submit(res) {
- let data = await accountstatementInfoAPI(this.businessId || res);
- this.processSubmitDialogFlag = true;
- this.$nextTick(() => {
- let params = {
- businessId: data.id,
- businessKey: 'purchase_account_statement_approve',
- formCreateUserId: data.createUserId,
- variables: {
- businessCode: data.statementNo,
- type: data.type,
- businessName: data.contactName,
- businessType: '对账单'
- }
- // callBackMethodType : '1',
- // callBackMethod : 'proTargetPlanApproveApiImpl.updatePlanApprovalStatus',
- // pcHandle : '/bpm/handleTask/components/project-manage/plan-manage/submit.vue',
- // pcView : '/bpm/handleTask/components/project-manage/plan-manage/detailDialog.vue',
- // miniHandle : '',
- // miniView : '',
- };
- this.$refs.processSubmitDialogRef.init(params);
- });
- },
- // 对账明细本次对账金额变化时,按采购订单号同步到应付信息对应行
- handleDiscountPriceChange(statementAmount, tableIndex) {
- const order = this.datasource[tableIndex];
- if (!order || !order.orderNo) return;
- const summaryMap = { [order.orderNo]: statementAmount };
- if (this.$refs.payablesInfoRef) {
- this.$refs.payablesInfoRef.syncStatementAmount(summaryMap);
- }
- },
- reload() {
- this.cancel();
- //刷新主页面
- this.$emit('done');
- }
- }
- };
- </script>
- <style scoped lang="scss">
- ::v-deep.el-divider {
- margin: 10px;
- font-weight: bold;
- }
- </style>
|