|
@@ -45,9 +45,9 @@
|
|
|
<el-select v-else
|
|
|
v-model="dataForm.applierId"
|
|
|
remote
|
|
|
- filterable
|
|
|
- :remote-method="remoteApplier"
|
|
|
- @change="onApplierChanged"
|
|
|
+ filterable
|
|
|
+ :remote-method="remoteApplier"
|
|
|
+ @change="onApplierChanged"
|
|
|
placeholder="请选择">
|
|
|
<el-option
|
|
|
v-for="item in optionsApplier"
|
|
@@ -157,6 +157,9 @@
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</el-row>
|
|
|
+ <el-row>
|
|
|
+ <span>合计(含税): {{totalAmount}}</span>
|
|
|
+ </el-row>
|
|
|
<el-row v-if="!display" style="text-align: center; margin-top: 10px;">
|
|
|
<el-button type="primary" icon="el-icon-plus" @click="addMaterial"></el-button>
|
|
|
</el-row>
|
|
@@ -192,6 +195,7 @@
|
|
|
optionsApplier: [],
|
|
|
materialDetails: [],
|
|
|
addMaterialVisible: false,
|
|
|
+ totalAmount: 0,
|
|
|
dataRule: {
|
|
|
purchaseType: [{ required: true, message: '请选择采购类别', trigger: 'change' }],
|
|
|
applierId: [{ required: true, message: '请选择申请人', trigger: 'change' }]
|
|
@@ -227,6 +231,17 @@
|
|
|
if (data.data.details) {
|
|
|
this.materialDetails = []
|
|
|
this.materialDetails = data.data.details
|
|
|
+ this.calTotal()
|
|
|
+ }
|
|
|
+ // 获取申请人
|
|
|
+ if (data.data.applierId) {
|
|
|
+ this.optionsApplier = []
|
|
|
+ this.optionsApplier.push({
|
|
|
+ code: data.data.applierId,
|
|
|
+ value: data.data.applierName,
|
|
|
+ orgId: data.data.orgId,
|
|
|
+ orgName: data.data.deptName
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -238,10 +253,12 @@
|
|
|
dataFormSubmit () {
|
|
|
this.$refs['dataForm'].validate((valid) => {
|
|
|
if (valid) {
|
|
|
+ // 添加采购物品明细
|
|
|
+ this.dataForm.details = this.materialDetails
|
|
|
this.$http({
|
|
|
- url: this.$http.adornUrl(`/biz-service/purchase/save`),
|
|
|
+ url: !this.id ? this.$http.adornUrl(`/biz-service/purchase/save`) : this.$http.adornUrl(`/biz-service/purchase/update`),
|
|
|
method: 'post',
|
|
|
- data: this.$http.adornData({...this.dataForm, orgId: this.orgId})
|
|
|
+ data: this.$http.adornData(this.dataForm)
|
|
|
}).then(({data}) => {
|
|
|
if (data && data.code === '200') {
|
|
|
this.$message({
|
|
@@ -294,6 +311,7 @@
|
|
|
},
|
|
|
deleteMaterialHandle (id) {
|
|
|
this.materialDetails.splice(this.materialDetails.findIndex((item) => item.id === id))
|
|
|
+ this.calTotal()
|
|
|
},
|
|
|
addMaterialCallback (data) {
|
|
|
if (!data) return
|
|
@@ -303,11 +321,20 @@
|
|
|
this.materialDetails.splice(i)
|
|
|
}
|
|
|
this.materialDetails.push(data)
|
|
|
+ this.calTotal()
|
|
|
+ },
|
|
|
+ calTotal () {
|
|
|
+ let total = 0
|
|
|
+ if (this.materialDetails) {
|
|
|
+ this.materialDetails.forEach((item) => {
|
|
|
+ total += item.taxAmount ? Number(item.taxAmount) : 0
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.totalAmount = total
|
|
|
},
|
|
|
// 百分比
|
|
|
formatPercent (row) {
|
|
|
if (!row.taxRate) return ''
|
|
|
- console.log('taxRate: ' + row.taxRate)
|
|
|
let str = (Number(row.taxRate * 100)).toFixed(0)
|
|
|
str += '%'
|
|
|
return str
|