更新0815
This commit is contained in:
parent
79e42866ef
commit
04105e6d4d
@ -31,7 +31,14 @@
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="数量" width="180" prop="itemCount"/>
|
||||
<el-table-column align="center" label="单价" width="180" prop="itemPrice"/>
|
||||
<el-table-column align="center" label="折扣" width="180" prop="itemDiscount" />
|
||||
<el-table-column align="center" label="折扣" width="180" prop="itemDiscount"/>
|
||||
<el-table-column align="center" label="毛利" width="180" prop="itemProfit" v-hasPermi="['repair:tick:profit']" v-if="listType === 'ware'"/>
|
||||
<el-table-column align="center" label="毛利率" width="180" prop="itemProfitRate"
|
||||
v-hasPermi="['repair:tick:profit']" v-if="listType === 'ware'">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.itemProfitRate">{{ scope.row.itemProfitRate * 100 }}%</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="金额" width="180" prop="itemMoney"/>
|
||||
<el-table-column align="center" label="施工人员" width="180" prop="repairNames"/>
|
||||
<el-table-column align="center" label="服务顾问" width="180" prop="saleName"/>
|
||||
@ -53,36 +60,36 @@
|
||||
<el-row :gutter="2">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="名称" prop="itemName">
|
||||
<el-input disabled v-model="item.itemName" />
|
||||
<el-input disabled v-model="item.itemName"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="施工人员" prop="repairNames">
|
||||
<el-input v-model="item.repairNames" disabled />
|
||||
<el-input v-model="item.repairNames" disabled/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="2">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="服务顾问" prop="saleName">
|
||||
<el-input v-model="item.saleName" disabled />
|
||||
<el-input v-model="item.saleName" disabled/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="数量" prop="itemCount">
|
||||
<el-input-number :step="1" :min="0" v-model="item.itemCount" />
|
||||
<el-input-number :step="1" :min="0" v-model="item.itemCount"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="2">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="单价" prop="itemPrice">
|
||||
<el-input-number :min="0" v-model="item.itemPrice" />
|
||||
<el-input-number :min="0" v-model="item.itemPrice"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="折扣" prop="itemDiscount">
|
||||
<DiscountInput v-model="item.itemDiscount" />
|
||||
<DiscountInput v-model="item.itemDiscount"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -125,7 +132,7 @@ export default {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
isEdit:{
|
||||
isEdit: {
|
||||
type: Boolean,
|
||||
}
|
||||
},
|
||||
@ -134,14 +141,14 @@ export default {
|
||||
loading: !(this.list && this.list.length) && !this.isEdit,
|
||||
dialogVisible: false,
|
||||
item: {},
|
||||
formRules:{
|
||||
formRules: {
|
||||
itemPrice: [{required: true, message: '单价不能为空', trigger: 'blur'}],
|
||||
itemCount: [{required: true, message: '数量不能为空', trigger: 'blur'}],
|
||||
itemDiscount: [{required: true, message: "折扣不能为空", trigger: 'blur'}]
|
||||
},
|
||||
formLoading: false,
|
||||
// 需要计算的列
|
||||
includeColumn: ['itemMoney', 'itemCount']
|
||||
includeColumn: ['itemMoney', 'itemCount', 'itemProfit', 'itemProfitRate']
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -159,7 +166,7 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async editItem(row){
|
||||
async editItem(row) {
|
||||
this.resetForm('formRef')
|
||||
try {
|
||||
const res = await getItemById(row.id)
|
||||
@ -167,40 +174,63 @@ export default {
|
||||
this.dialogVisible = true
|
||||
this.item['repair'] = null
|
||||
this.item['adviser'] = null
|
||||
}catch{}
|
||||
} catch {
|
||||
}
|
||||
},
|
||||
async submitForm(){
|
||||
async submitForm() {
|
||||
try {
|
||||
await this.$refs.formRef.validate()
|
||||
await updateById(this.item)
|
||||
this.dialogVisible = false
|
||||
this.$modal.msgSuccess("修改成功")
|
||||
this.$emit('success', this.item.ticketId)
|
||||
}catch{}
|
||||
} catch {
|
||||
}
|
||||
},
|
||||
getSummaries(param){
|
||||
const { columns, data } = param;
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = '合计';
|
||||
return;
|
||||
}
|
||||
const values = data.map(item => Number(item[column.property]));
|
||||
if (this.includeColumn.includes(column.property)) {
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr);
|
||||
if (!isNaN(value)) {
|
||||
return prev + curr;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
sums[index];
|
||||
}
|
||||
});
|
||||
return sums;
|
||||
getSummaries(param) {
|
||||
const {columns, data} = param;
|
||||
const sums = [];
|
||||
columns.forEach((column, index) => {
|
||||
if (index === 0) {
|
||||
sums[index] = '合计';
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.includeColumn.includes(column.property)) {
|
||||
const values = data.map(item => Number(item[column.property]));
|
||||
sums[index] = values.reduce((prev, curr) => {
|
||||
const value = Number(curr);
|
||||
if (!isNaN(value)) {
|
||||
return prev + curr;
|
||||
} else {
|
||||
return prev;
|
||||
}
|
||||
}, 0);
|
||||
|
||||
// 特殊处理毛利率字段
|
||||
if (column.property === 'itemProfitRate') {
|
||||
// 计算总毛利率 = (总毛利 / 总金额) * 100%
|
||||
const totalProfit = data.reduce((sum, item) => {
|
||||
const profit = Number(item.itemProfit);
|
||||
return !isNaN(profit) ? sum + profit : sum;
|
||||
}, 0);
|
||||
|
||||
const totalMoney = data.reduce((sum, item) => {
|
||||
const money = Number(item.itemMoney);
|
||||
return !isNaN(money) ? sum + money : sum;
|
||||
}, 0);
|
||||
|
||||
if (totalMoney !== 0) {
|
||||
sums[index] = ((totalProfit / totalMoney) * 100).toFixed(2) + '%';
|
||||
} else {
|
||||
sums[index] = '0%';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return sums;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -245,6 +245,22 @@
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
<div v-hasPermi="['repair:tick:profit']">
|
||||
<el-descriptions class="margin-top" :column="2" :size="'medium'" border style="margin-bottom: 1rem">
|
||||
<el-descriptions-item>
|
||||
<template slot="label">
|
||||
含工时项目毛利率
|
||||
</template>
|
||||
{{ otherInfo.profitRate * 100 }}%
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item>
|
||||
<template slot="label">
|
||||
不含工时项目的毛利率
|
||||
</template>
|
||||
{{ otherInfo.profitRateNo * 100}}%
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</el-card>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">关闭</el-button>
|
||||
@ -272,7 +288,8 @@ export default {
|
||||
others: [],
|
||||
allList: [],
|
||||
totalCount: 0,
|
||||
totalMoney: 0
|
||||
totalMoney: 0,
|
||||
otherInfo:{}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -285,6 +302,7 @@ export default {
|
||||
this.wares = this.allList.filter(item => item.ware)
|
||||
this.others = this.allList.filter(item => item.other)
|
||||
this.info = row
|
||||
this.otherInfo = res.data
|
||||
this.dialogVisible = true
|
||||
},
|
||||
async changeShow() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user