This commit is contained in:
2025-03-13 13:13:47 +08:00
parent 2743598faa
commit f932a49602
3 changed files with 50 additions and 23 deletions

View File

@@ -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) {