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

Loading…
Cancel
Save