新增global,缓存职位信息

This commit is contained in:
huangdeliang
2021-02-23 15:09:17 +08:00
parent 6b50ddcfdd
commit df52ea8f2d
20 changed files with 2333 additions and 1812 deletions

View File

@ -3,28 +3,51 @@
<el-dialog :title="title" :visible.sync="open" width="550px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="调理项目" prop="projectId">
<el-select v-model="form.projectId" placeholder="请选择调理项目" filterable clearable size="small">
<el-option v-for="dict in conditioningProjectIdOption"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"/>
<el-select
v-model="form.projectId"
placeholder="请选择调理项目"
filterable
clearable
size="small"
>
<el-option
v-for="dict in conditioningProjectIdOption"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
<!--<el-form-item label="客户姓名" prop="name">
<el-input v-model="form.name" placeholder="请输入客户姓名"/>
</el-form-item>-->
<el-form-item label="金额" prop="amount" style="width: 300px;">
<el-input v-model="form.amount" placeholder="请输入金额"/>
<el-form-item label="金额" prop="amount" style="width: 300px">
<el-input v-model="form.amount" placeholder="请输入金额" />
</el-form-item>
<el-form-item label="服务承诺" prop="servePromise" v-show="form.projectId == 0" >
<el-input style="width: 200px;" v-model="form.servePromise" placeholder="请输入服务承诺"/><span style="margin-left: 5px;"></span>
<el-form-item
label="服务承诺"
prop="servePromise"
v-show="form.projectId == 0"
>
<el-input
style="width: 200px"
v-model="form.servePromise"
placeholder="请输入服务承诺"
/><span style="margin-left: 5px"></span>
</el-form-item>
<el-form-item label="营养师" prop="nutritionistId">
<el-select v-model="form.nutritionistId" placeholder="请选择营养师" clearable size="small">
<el-option v-for="dict in nutritionistIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"/>
<el-select
v-model="form.nutritionistId"
placeholder="请选择营养师"
clearable
size="small"
>
<el-option
v-for="dict in nutritionistIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
<el-form-item label="服务时间" prop="serveTime">
@ -38,7 +61,11 @@
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
<el-input
v-model="form.remark"
type="textarea"
placeholder="请输入内容"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -48,20 +75,17 @@
</el-dialog>
</template>
<script>
import {addContract} from "@/api/custom/contract";
import {getOptions} from "@/api/custom/order";
import { addContract } from "@/api/custom/contract";
import { mapState } from "vuex";
export default {
name: "ContractAdd",
components: {
},
components: {},
props: {},
data() {
const checkServePromise = (rule, value, callback) => {
if (this.form.projectId == 0 && !value) {
return callback(new Error('请输入服务承诺'))
return callback(new Error("请输入服务承诺"));
}
callback();
};
@ -75,14 +99,14 @@ export default {
form: {},
// 表单校验
rules: {
projectId:[
{required: true, message: "请选择调理项目", trigger: "blur"}
projectId: [
{ required: true, message: "请选择调理项目", trigger: "blur" },
],
/*name: [
{required: true, message: "请输入客户姓名", trigger: "blur"}
],*/
amount: [
{required: true, message: "请输入签订金额", trigger: "blur"},
{ required: true, message: "请输入签订金额", trigger: "blur" },
{
required: true,
trigger: "blur",
@ -91,35 +115,31 @@ export default {
},
],
servePromise: [
{required: true, trigger: "blur", validator: checkServePromise}
{ required: true, trigger: "blur", validator: checkServePromise },
],
serveTime: [
{required: true, message: "请选择服务时间", trigger: "blur"}
{ required: true, message: "请选择服务时间", trigger: "blur" },
],
nutritionistId: [
{required: true, message: "请选择营养师", trigger: "blur"}
]
{ required: true, message: "请选择营养师", trigger: "blur" },
],
},
conditioningProjectIdOption:[],
serveTimeOptions:[],
nutritionistIdOptions:[]
conditioningProjectIdOption: [],
serveTimeOptions: [],
// nutritionistIdOptions: [],
};
},
computed: {
...mapState({
nutritionistIdOptions: (state) =>
state.global.nutritionistIdOptions.slice(1),
}),
},
created() {
getOptions().then(response => {
const options = response.data.reduce((opts, cur) => {
if (!opts[cur.postCode]) {
opts[cur.postCode] = [];
}
opts[cur.postCode].push({dictValue: cur.userId, dictLabel: cur.userName, remark: cur.remark})
return opts;
}, {})
this.nutritionistIdOptions = options['nutri'] || [];
})
this.getDicts("cus_serve_time").then(response => {
this.getDicts("cus_serve_time").then((response) => {
this.serveTimeOptions = response.data;
});
this.getDicts("conditioning_project").then(response => {
this.getDicts("conditioning_project").then((response) => {
this.conditioningProjectIdOption = response.data;
});
},
@ -127,29 +147,37 @@ export default {
showDialog(data, callback) {
this.callback = callback;
this.reset(data);
this.title = "新增"+`${data.customer}」客户合同`;
this.title = "新增" + `${data.customer}」客户合同`;
this.open = true;
},
// 表单重置
reset(obj) {
const defaultNutritionist = this.nutritionistIdOptions.find(opt => opt.dictValue === obj.nutritionistId);
const defaultProjectIdOption = this.conditioningProjectIdOption.find(opt => opt.remark === 'default');
const defaultNutritionist = this.nutritionistIdOptions.find(
(opt) => opt.dictValue === obj.nutritionistId
);
const defaultProjectIdOption = this.conditioningProjectIdOption.find(
(opt) => opt.remark === "default"
);
this.form = {
id: null,
customerId: obj.customerId,
projectId: defaultProjectIdOption ? parseInt(defaultProjectIdOption.dictValue) : null,
projectId: defaultProjectIdOption
? parseInt(defaultProjectIdOption.dictValue)
: null,
name: obj.customer,
phone: null,
serveTime: null,
amount: null,
path: null,
createBy: null,
nutritionistId: defaultNutritionist ? parseInt(defaultNutritionist.dictValue) : null,
nutritionistId: defaultNutritionist
? parseInt(defaultNutritionist.dictValue)
: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: null
remark: null,
};
this.resetForm("form");
},
@ -159,13 +187,16 @@ export default {
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs["form"].validate((valid) => {
if (valid) {
this.form.tutor = this.selectDictLabel(this.nutritionistIdOptions, this.form.nutritionistId)
if(this.form.projectId != 0){
this.form.tutor = this.selectDictLabel(
this.nutritionistIdOptions,
this.form.nutritionistId
);
if (this.form.projectId != 0) {
this.form.servePromise = null;
}
addContract(this.form).then(response => {
addContract(this.form).then((response) => {
if (response.code === 200) {
this.msgSuccess("新增成功");
this.open = false;
@ -174,7 +205,7 @@ export default {
});
}
});
}
}
},
},
};
</script>