From f932a4960290583017d7a83cf8e7e6da156e991f Mon Sep 17 00:00:00 2001 From: caill <815519168@qq.com> Date: Thu, 13 Mar 2025 13:13:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contract/contract-add-or-update.vue | 62 +++++++++++++------ .../src/views/modules/contract/contract.vue | 2 +- .../modules/contract/temp-add-or-update.vue | 9 ++- 3 files changed, 50 insertions(+), 23 deletions(-) diff --git a/base-vue/src/views/modules/contract/contract-add-or-update.vue b/base-vue/src/views/modules/contract/contract-add-or-update.vue index 8b097a0..e444817 100644 --- a/base-vue/src/views/modules/contract/contract-add-or-update.vue +++ b/base-vue/src/views/modules/contract/contract-add-or-update.vue @@ -70,13 +70,10 @@ </el-col> <el-col :span="11"> <el-form-item label="总计"> - <el-input v-model="dataForm.code" placeholder="总计"></el-input> + <el-input v-model="dataForm.totalSum" placeholder="总计" disabled></el-input> </el-form-item> </el-col> </el-row> - <!-- <el-form-item label="物料信息" prop="materialJson"> - <el-input v-model="dataForm.materialJson" placeholder="物料信息"></el-input> - </el-form-item> --> </el-form> <el-table :data="materData" @@ -103,22 +100,31 @@ label="物料类型"> </el-table-column> <el-table-column - prop="isOn" header-align="center" align="center" + width="120" label="单价"> + <template slot-scope="scope"> + <el-input size="mini" v-model="scope.row.price" placeholder="请输入单价" @input="calculateTotal(scope.$index)" @blur="calculateTotal(scope.$index)"></el-input> + </template> </el-table-column> <el-table-column - prop="createTime" header-align="center" align="center" + width="120" label="价格系数"> + <template slot-scope="scope"> + <el-input size="mini" v-model="scope.row.coefficient" placeholder="请输入价格系数"></el-input> + </template> </el-table-column> <el-table-column - prop="createTime" header-align="center" align="center" + width="120" label="对外价格"> + <template slot-scope="scope"> + <el-input size="mini" v-model="scope.row.externalPrice" placeholder="请输入对外价格"></el-input> + </template> </el-table-column> <el-table-column header-align="center" @@ -126,14 +132,16 @@ width="120" label="数量"> <template slot-scope="scope"> - <el-input size="mini" v-model="scope.row.num"></el-input> + <el-input size="mini" v-model="scope.row.quantity" placeholder="请输入数量" @input="calculateTotal(scope.$index)" @blur="calculateTotal(scope.$index)"></el-input> </template> </el-table-column> <el-table-column - prop="createTime" header-align="center" align="center" label="总价"> + <template slot-scope="scope"> + {{ scope.row.total }} + </template> </el-table-column> <el-table-column fixed="right" @@ -244,9 +252,9 @@ isMaster: 0, contractNumber: '', clientId: '', - materialJson: '', isAcceptance: 0, - remarks: '' + remarks: '', + totalSum: 0 }, dataRule: { contractType: [ @@ -257,9 +265,6 @@ ], clientId: [ { required: true, message: '客户不能为空', trigger: 'blur' } - ], - materialJson: [ - { required: true, message: '物料信息不能为空', trigger: 'blur' } ] }, innerDataForm: { @@ -271,7 +276,15 @@ totalPage: 0, dataListLoading: false, dataListSelections: [], - materData: [{materialName: 'aaa'}] + materData: [] + } + }, + watch: { + materData: { + deep: true, + handler() { + this.calculateTotalSum() + } } }, created () { @@ -297,9 +310,10 @@ this.visible = true this.$nextTick(() => { this.$refs['dataForm'].resetFields() + this.materData = [] if (this.dataForm.contractId) { this.$http({ - url: this.$http.adornUrl(`/tickets/contract/info/${this.dataForm.contractId}`), + url: this.$http.adornUrl(`/flow/contract/list/${this.dataForm.contractId}`), method: 'get', params: this.$http.adornParams() }).then(({data}) => { @@ -320,12 +334,21 @@ this.innerVisible = true this.getDataList() }, + calculateTotal(index) { + const row = this.materData[index] + const price = parseFloat(row.price) || 0 + const quantity = parseFloat(row.quantity) || 0 + row.total = price * quantity + }, + calculateTotalSum() { + this.dataForm.totalSum = this.materData.reduce((sum, row) => sum + parseFloat(row.total || 0), 0) + }, // 表单提交 dataFormSubmit () { this.$refs['dataForm'].validate((valid) => { if (valid) { this.$http({ - url: this.$http.adornUrl(`/tickets/contract/${!this.dataForm.contractId ? 'save' : 'update'}`), + url: this.$http.adornUrl(`/flow/contract/${!this.dataForm.contractId ? 'save' : 'update'}`), method: 'post', data: this.$http.adornData({ 'contractId': this.dataForm.contractId || undefined, @@ -333,9 +356,10 @@ 'isMaster': this.dataForm.isMaster, 'contractNumber': this.dataForm.contractNumber, 'clientId': this.dataForm.clientId, - 'materialJson': this.dataForm.materialJson, + 'materialJson': JSON.stringify(this.materData), 'isAcceptance': this.dataForm.isAcceptance, - 'remarks': this.dataForm.remarks + 'remarks': this.dataForm.remarks, + 'totalSum': this.dataForm.totalSum }) }).then(({data}) => { if (data && data.code === 0) { diff --git a/base-vue/src/views/modules/contract/contract.vue b/base-vue/src/views/modules/contract/contract.vue index 7b3fa99..994fea3 100644 --- a/base-vue/src/views/modules/contract/contract.vue +++ b/base-vue/src/views/modules/contract/contract.vue @@ -193,7 +193,7 @@ type: 'warning' }).then(() => { this.$http({ - url: this.$http.adornUrl('/tickets/contract/delete'), + url: this.$http.adornUrl('/flow/contract/delete'), method: 'post', data: this.$http.adornData(ids, false) }).then(({data}) => { diff --git a/base-vue/src/views/modules/contract/temp-add-or-update.vue b/base-vue/src/views/modules/contract/temp-add-or-update.vue index 46673a4..c2ea979 100644 --- a/base-vue/src/views/modules/contract/temp-add-or-update.vue +++ b/base-vue/src/views/modules/contract/temp-add-or-update.vue @@ -102,12 +102,14 @@ export default { addAndPrint () { const LODOP = getLodop() LODOP.PRINT_INITA("0mm", "0mm", "213mm", "297mm", "打印合同模板") - LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4") - LODOP.ADD_PRINT_TEXT(0, 0, 700, 50, "产品供应合同") + LODOP.SET_PRINT_PAGESIZE(1, 2100, 2970, "A4") + LODOP.ADD_PRINT_TEXT(0, 0, '0', '0', '') // 获取弹窗内容并转换为 HTML 字符串 + const h1Content = `<h1>产品供销合同</h1>` const popupContent = document.getElementById('popupContent').innerHTML const printHtml = ` <style> + h1 {font-size: 14px;line-height: 1;font-weight: 700;text-align: center;margin-bottom: 30px;} .zd-row {width: 100%;display: flex;} .zd-col-12 {width: 50%;} .dialog_content {width: 100%;} @@ -117,10 +119,11 @@ export default { .det_table th, .det_table td {border: 1px solid #000;font-size: 10px; line-height: 23px; padding: 0; text-align: center} .det_table_1 th, .det_table_1 td {text-align:left} </style> + ${h1Content} ${popupContent} ` // 添加弹窗内容到打印任务 - LODOP.ADD_PRINT_HTM("30mm", "10mm", "RightMargin:10mm", "BottomMargin:10mm", printHtml) + LODOP.ADD_PRINT_HTM(0, '5%', '90%', '90%', printHtml) LODOP.PREVIEW()// 预览 }, }