Browse Source

采购价页面渲染

pull/12/head
pengda 3 weeks ago
parent
commit
8d40ef8f1f
  1. 65
      src/views/super/Ranking/Purchase.vue

65
src/views/super/Ranking/Purchase.vue

@ -10,14 +10,13 @@
@dialogVisibleChange="dialogVisibleChange"> @dialogVisibleChange="dialogVisibleChange">
<el-form :model="form" class="el-row demo-ruleForm" ref="formRef"> <el-form :model="form" class="el-row demo-ruleForm" ref="formRef">
<el-form-item label="检测类型" prop="type"> <el-form-item label="检测类型" prop="type">
<GuipSelect v-model="form.type" :options="type2nameOptions" <GuipSelect v-model="form.type" :options="type2nameOptions"/>
:defaultValue="type2name[form.type]"/>
</el-form-item> </el-form-item>
<el-form-item label="采购单价" prop="type" label-width="73px"> <el-form-item label="采购单价" prop="type" label-width="73px">
<div style="display: flex; align-items: center; gap: 8px; width: 100%;"> <div style="display: flex; align-items: center; gap: 8px; width: 100%;">
<GuipInput v-model="form.unit_price" style="flex: 1;" :default-value="form.unit_price"/> <GuipInput v-model="form.unit_price" style="flex: 1;"/>
<span> /</span> <span> /</span>
<GuipInput v-model="form.unit_num" style="flex: 1;" :default-value="form.unit_num"/> <GuipInput v-model="form.unit_num" style="flex: 1;"/>
<span>/</span> <span>/</span>
</div> </div>
</el-form-item> </el-form-item>
@ -25,29 +24,29 @@
<template v-if="type != 'purchase'"> <template v-if="type != 'purchase'">
<el-form-item label="阶段成本" prop="type" label-width="73px"> <el-form-item label="阶段成本" prop="type" label-width="73px">
<div style="display: flex; align-items: center; gap: 8px; width: 100%;"> <div style="display: flex; align-items: center; gap: 8px; width: 100%;">
<GuipInput v-model="form.cost" style="flex: 1;" :default-value="form.cost"/> <GuipInput v-model="form.cost" style="flex: 1;"/>
<span></span> <span></span>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="起止日期" prop="date" label-width="73px"> <el-form-item label="起止日期" prop="date" label-width="73px">
<el-date-picker v-model="form.date" type="daterange" range-separator="" <el-date-picker v-model="form.date" type="daterange" range-separator=""
start-placeholder="开始日期" start-placeholder="开始日期"
end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" end-placeholder="结束日期" value-format="yyyy-MM-dd"
style="width: 100%;" :default-value="form.date"> style="width: 100%;">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
</template> </template>
</el-form> </el-form>
</GuipDialog> </GuipDialog>
</div> </div>
<div class=" flex-common" v-if="type2nameOptions.length > 0"> <div class=" flex-common" v-if="type2filterOptions.length > 0">
<el-form> <el-form>
<el-table :data="tableData" style="width: 100%"> <el-table :data="tableData" style="width: 100%">
<template v-if="type == 'purchase'"> <template v-if="type == 'purchase'">
<el-table-column prop="type"> <el-table-column prop="type">
<template slot="header"> <template slot="header">
<GuipSelect class="custom-select" v-model="chktype" :options="type2nameOptions" <GuipSelect class="custom-select" v-model="chktype" :options="type2filterOptions"
defaultValue="检测类型" @change="changeSelectType"/> defaultValue="全部检测类型" @change="changeSelectType"/>
</template> </template>
<template slot-scope="scope"> <template slot-scope="scope">
@ -72,8 +71,8 @@
<template v-else> <template v-else>
<el-table-column prop="type"> <el-table-column prop="type">
<template slot="header"> <template slot="header">
<GuipSelect class="custom-select" v-model="chktype" :options="type2nameOptions" <GuipSelect class="custom-select" v-model="chktype" :options="type2filterOptions"
defaultValue="检测类型" @change="changeSelectType"/> defaultValue="全部检测类型" @change="changeSelectType"/>
</template> </template>
<template slot-scope="scope"> <template slot-scope="scope">
@ -169,8 +168,8 @@ export default {
unit_num: '', unit_num: '',
cost: '', cost: '',
date: '', date: '',
sdate: '', start_date: '',
edate: '', end_date: '',
}, },
} }
}, },
@ -181,12 +180,20 @@ export default {
type2nameOptions() { type2nameOptions() {
if(this.type2name.length == 0) return true if(this.type2name.length == 0) return true
return Object.entries(this.type2name).map(([value, label]) => ({
label,
value: Number(value) // value
}));
},
type2filterOptions() {
if(this.type2name.length == 0) return true
let options = Object.entries(this.type2name).map(([value, label]) => ({ let options = Object.entries(this.type2name).map(([value, label]) => ({
label, label,
value: Number(value) // value value: Number(value) // value
})); }));
return [{ label: '检测类型', value: '' }, ...options]; return [{ label: '全部检测类型', value: '' }, ...options];
} }
}, },
watch: { watch: {
@ -195,11 +202,11 @@ export default {
}, },
'form.date'(newVal) { 'form.date'(newVal) {
if (Array.isArray(newVal) && newVal.length === 2) { if (Array.isArray(newVal) && newVal.length === 2) {
this.form.sdate = this.formatDateTime(new Date(newVal[0])); this.form.start_date = this.formatDateTime(new Date(newVal[0]));
this.form.edate = this.formatDateTime(new Date(newVal[1])); this.form.end_date = this.formatDateTime(new Date(newVal[1]));
} else { } else {
this.form.sdate = ''; this.form.start_date = '';
this.form.edate = ''; this.form.end_date = '';
} }
} }
}, },
@ -266,13 +273,12 @@ export default {
unit_num: '', unit_num: '',
cost: '', cost: '',
date: '', date: '',
sdate: '', start_date: '',
edate: '', end_date: '',
} }
this.dialogVisible = true; this.dialogVisible = true;
}, // }, //
handleConfirm() { handleConfirm() {
console.log('提交成功:', this.form);
const that = this const that = this
if (!that.form.type) { if (!that.form.type) {
this.$message.warning('请选择检测类型'); this.$message.warning('请选择检测类型');
@ -295,10 +301,10 @@ export default {
this.$message.warning(response.info); this.$message.warning(response.info);
} else { } else {
if(that.form.id > 0){ if(that.form.id > 0){
this.$set(this.tableData, this.tableData.findIndex(item => item.id === this.form.id), {...this.form}); that.$set(this.tableData, this.tableData.findIndex(item => item.id === that.form.id), {...that.form});
}else{ }else{
that.form.id = response.data that.form.id = response.data
this.tableData.unshift(that.form); that.tableData.unshift(that.form);
} }
} }
this.dialogVisible = false; this.dialogVisible = false;
@ -313,7 +319,7 @@ export default {
return return
} }
if (!that.form.sdate || !that.form.edate) { if (!that.form.start_date || !that.form.end_date) {
this.$message.warning('请选择起止日期'); this.$message.warning('请选择起止日期');
return return
} }
@ -324,18 +330,19 @@ export default {
unit_price: that.form.unit_price, unit_price: that.form.unit_price,
unit_num: that.form.unit_num, unit_num: that.form.unit_num,
cost: that.form.cost, cost: that.form.cost,
sdate: that.form.sdate, sdate: that.form.start_date,
edate: that.form.edate, edate: that.form.end_date,
}).then(response => { }).then(response => {
this.$nextTick(() => { this.$nextTick(() => {
if (!response.status) { if (!response.status) {
this.$message.warning(response.info); this.$message.warning(response.info);
} else { } else {
if(that.form.id > 0){ if(that.form.id > 0){
this.$set(this.tableData, this.tableData.findIndex(item => item.id === this.form.id), {...this.form}); that.$set(this.tableData, this.tableData.findIndex(item => item.id === that.form.id), {...that.form});
}else{ }else{
that.form.id = response.data that.form.id = response.data
this.tableData.unshift(that.form); that.form.is_sync = 0
that.tableData.unshift(that.form);
} }
} }
this.dialogVisible = false; this.dialogVisible = false;

Loading…
Cancel
Save