!347 新增、编辑订单以及新建客户档案时,下拉选择营养师,自动选择助理和售后

Merge pull request !347 from 德仔/xzj
This commit is contained in:
德仔 2021-08-13 10:57:37 +00:00 committed by Gitee
commit 63acde300c
4 changed files with 203 additions and 49 deletions

View File

@ -161,19 +161,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8" v-show="orderModuleshow.afterSaleShow">
<el-form-item label="售后" prop="afterSaleId">
<el-select v-model="form.afterSaleId" placeholder="请选择" filterable
clearable>
<el-option
v-for="dict in afterSaleIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8" v-show="orderModuleshow.nutritionistShow"> <el-col :span="8" v-show="orderModuleshow.nutritionistShow">
<el-form-item label="主营养师" prop="nutritionistIdList"> <el-form-item label="主营养师" prop="nutritionistIdList">
<el-select <el-select
@ -181,6 +169,7 @@
multiple multiple
filterable filterable
placeholder="请选择" placeholder="请选择"
@change="handleOnDietIdChange"
> >
<el-option <el-option
v-for="dict in nutritionistIdOptions" v-for="dict in nutritionistIdOptions"
@ -208,7 +197,20 @@
<el-select v-model="form.nutriAssisId" placeholder="请选择" filterable <el-select v-model="form.nutriAssisId" placeholder="请选择" filterable
clearable> clearable>
<el-option <el-option
v-for="dict in nutriAssisIdOptions" v-for="dict in (screenNutriAssisIdOptions || nutriAssisIdOptions)"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8" v-show="orderModuleshow.afterSaleShow">
<el-form-item label="售后" prop="afterSaleId">
<el-select v-model="form.afterSaleId" placeholder="请选择" filterable
clearable>
<el-option
v-for="dict in (screenAfterSaleIdOptions || afterSaleIdOptions)"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictLabel" :label="dict.dictLabel"
:value="parseInt(dict.dictValue)" :value="parseInt(dict.dictValue)"
@ -343,6 +345,7 @@
import { addOrder, updateOrder } from "@/api/custom/order"; import { addOrder, updateOrder } from "@/api/custom/order";
import dayjs from "dayjs"; import dayjs from "dayjs";
import * as orderTypeData from "@/utils/orderType"; import * as orderTypeData from "@/utils/orderType";
import * as orderUtils from "@/utils/orderUtils";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
export default { export default {
@ -478,6 +481,12 @@ export default {
reviewStatusOptions: [], reviewStatusOptions: [],
//() //()
orderDropdownCorrespondingOptions: [], orderDropdownCorrespondingOptions: [],
//
dietitianAfterAssistantOptions: [],
//
screenNutriAssisIdOptions: null,
//
screenAfterSaleIdOptions: null,
// //
orderTypeOptions: orderTypeData["orderTypeArray"], orderTypeOptions: orderTypeData["orderTypeArray"],
secondAfterSaleFlagShow: false, secondAfterSaleFlagShow: false,
@ -516,6 +525,9 @@ export default {
this.getDicts("order_dropdown_corresponding").then((response) => { this.getDicts("order_dropdown_corresponding").then((response) => {
this.orderDropdownCorrespondingOptions = response.data; this.orderDropdownCorrespondingOptions = response.data;
}); });
this.getDicts("dietitian_after_assistant").then((response) => {
this.dietitianAfterAssistantOptions = response.data;
});
// //
/*this.getDicts("order_type").then((response) => { /*this.getDicts("order_type").then((response) => {
// //
@ -793,6 +805,8 @@ export default {
accountId, accountId,
...obj, ...obj,
}; };
this.screenNutriAssisIdOptions = this.nutriAssisIdOptions;
this.screenAfterSaleIdOptions = this.afterSaleIdOptions;
this.resetForm("form"); this.resetForm("form");
}, },
handleOnClosed() { handleOnClosed() {
@ -835,6 +849,17 @@ export default {
handleOnChanelIdChange(val) { handleOnChanelIdChange(val) {
this.initPlanningAndOperation(); this.initPlanningAndOperation();
}, },
//
handleOnDietIdChange(val) {
let assistantAfterArray = orderUtils.getAfterSaleAndAssistantByDietId(this.dietitianAfterAssistantOptions, (val && val.length != null) ? val[val.length-1] : 0);
this.form = {
...this.form,
nutriAssisId: assistantAfterArray ? orderUtils.getRandomValueByArray(assistantAfterArray[0]) : 0,
afterSaleId: assistantAfterArray ? orderUtils.getRandomValueByArray(assistantAfterArray[1]) : 0,
};
this.screenNutriAssisIdOptions = orderUtils.getAfterSaleOrAssistantByIds(this.nutriAssisIdOptions, assistantAfterArray[0]);
this.screenAfterSaleIdOptions = orderUtils.getAfterSaleOrAssistantByIds(this.afterSaleIdOptions, assistantAfterArray[1]);
},
}, },
watch: { watch: {
// //

View File

@ -25,7 +25,7 @@
</el-col> </el-col>
<el-col :span="8" v-show="orderModuleshow.payTypeShow"> <el-col :span="8" v-show="orderModuleshow.payTypeShow">
<el-form-item label="收款方式" prop="payTypeId"> <el-form-item label="收款方式" prop="payTypeId">
<el-select v-model="form.payTypeId" placeholder="请选择"> <el-select v-model="form.payTypeId" filterable clearable placeholder="请选择">
<el-option <el-option
v-for="dict in payTypeIdOptions" v-for="dict in payTypeIdOptions"
:key="dict.dictValue" :key="dict.dictValue"
@ -40,6 +40,7 @@
<el-select <el-select
v-model="form.accountId" v-model="form.accountId"
placeholder="请选择" placeholder="请选择"
filterable clearable
@change="handleOnChannelIdChange" @change="handleOnChannelIdChange"
> >
<el-option <el-option
@ -80,6 +81,7 @@
<el-select <el-select
v-model="form.conditioningProjectId" v-model="form.conditioningProjectId"
placeholder="请选择" placeholder="请选择"
filterable clearable
> >
<el-option <el-option
v-for="dict in conditioningProjectIdOption" v-for="dict in conditioningProjectIdOption"
@ -92,7 +94,7 @@
</el-col> </el-col>
<el-col :span="8" v-show="orderModuleshow.preSaleShow"> <el-col :span="8" v-show="orderModuleshow.preSaleShow">
<el-form-item label="售前" prop="preSaleId"> <el-form-item label="售前" prop="preSaleId">
<el-select v-model="form.preSaleId" placeholder="请选择"> <el-select v-model="form.preSaleId" filterable clearable placeholder="请选择">
<el-option <el-option
v-for="dict in preSaleIdOptions" v-for="dict in preSaleIdOptions"
:key="dict.dictValue" :key="dict.dictValue"
@ -138,21 +140,9 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8" v-show="orderModuleshow.afterSaleShow">
<el-form-item label="售后" prop="afterSaleId">
<el-select v-model="form.afterSaleId" placeholder="请选择">
<el-option
v-for="dict in afterSaleIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8" v-show="orderModuleshow.nutritionistShow"> <el-col :span="8" v-show="orderModuleshow.nutritionistShow">
<el-form-item label="主营养师" prop="nutritionistId"> <el-form-item label="主营养师" prop="nutritionistId">
<el-select v-model="form.nutritionistId" placeholder="请选择"> <el-select v-model="form.nutritionistId" filterable clearable placeholder="请选择" @change="handleOnDietIdChange">
<el-option <el-option
v-for="dict in nutritionistIdOptions" v-for="dict in nutritionistIdOptions"
:key="dict.dictValue" :key="dict.dictValue"
@ -164,9 +154,21 @@
</el-col> </el-col>
<el-col :span="8" v-show="orderModuleshow.nutriAssisShow"> <el-col :span="8" v-show="orderModuleshow.nutriAssisShow">
<el-form-item label="助理营养师" prop="nutriAssisId"> <el-form-item label="助理营养师" prop="nutriAssisId">
<el-select v-model="form.nutriAssisId" placeholder="请选择"> <el-select v-model="form.nutriAssisId" filterable clearable placeholder="请选择">
<el-option <el-option
v-for="dict in nutriAssisIdOptions" v-for="dict in (screenNutriAssisIdOptions || nutriAssisIdOptions)"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8" v-show="orderModuleshow.afterSaleShow">
<el-form-item label="售后" prop="afterSaleId">
<el-select v-model="form.afterSaleId" filterable clearable placeholder="请选择">
<el-option
v-for="dict in (screenAfterSaleIdOptions || afterSaleIdOptions)"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictLabel" :label="dict.dictLabel"
:value="parseInt(dict.dictValue)" :value="parseInt(dict.dictValue)"
@ -288,7 +290,7 @@ import { addOrder, updateOrder } from "@/api/custom/order";
import dayjs from "dayjs"; import dayjs from "dayjs";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import * as orderTypeData from "@/utils/orderType"; import * as orderTypeData from "@/utils/orderType";
import * as orderUtils from "@/utils/orderUtils";
export default { export default {
name: "OrderEdit", name: "OrderEdit",
props: { props: {
@ -417,7 +419,12 @@ export default {
reviewStatusOptions: [], reviewStatusOptions: [],
//() //()
orderDropdownCorrespondingOptions: [], orderDropdownCorrespondingOptions: [],
//
dietitianAfterAssistantOptions: [],
//
screenNutriAssisIdOptions: null,
//
screenAfterSaleIdOptions: null,
// //
orderModuleshow: Object.assign({}, orderTypeData.orderModuleshow) orderModuleshow: Object.assign({}, orderTypeData.orderModuleshow)
}; };
@ -449,6 +456,9 @@ export default {
this.getDicts("order_dropdown_corresponding").then((response) => { this.getDicts("order_dropdown_corresponding").then((response) => {
this.orderDropdownCorrespondingOptions = response.data; this.orderDropdownCorrespondingOptions = response.data;
}); });
this.getDicts("dietitian_after_assistant").then((response) => {
this.dietitianAfterAssistantOptions = response.data;
});
}, },
computed: { computed: {
...mapGetters([ ...mapGetters([
@ -609,7 +619,10 @@ export default {
let resultArray = orderTypeData.dealOrderModuleshowByOrderType(orderTypeList, this.orderModuleshow, this.form); let resultArray = orderTypeData.dealOrderModuleshowByOrderType(orderTypeList, this.orderModuleshow, this.form);
this.orderModuleshow = resultArray[0]; this.orderModuleshow = resultArray[0];
this.screenNutriAssisIdOptions = this.nutriAssisIdOptions;
this.screenAfterSaleIdOptions = this.afterSaleIdOptions;
console.log("重置操作");
}, },
handleOnClosed() { handleOnClosed() {
this.reset(); this.reset();
@ -649,6 +662,19 @@ export default {
console.log(val); console.log(val);
this.initPlanningAndOperation(); this.initPlanningAndOperation();
}, },
//
handleOnDietIdChange(val) {
console.log(val);
let assistantAfterArray = orderUtils.getAfterSaleAndAssistantByDietId(this.dietitianAfterAssistantOptions, val);
console.log(assistantAfterArray);
this.form = {
...this.form,
nutriAssisId: assistantAfterArray ? orderUtils.getRandomValueByArray(assistantAfterArray[0]) : 0,
afterSaleId: assistantAfterArray ? orderUtils.getRandomValueByArray(assistantAfterArray[1]) : 0,
};
this.screenNutriAssisIdOptions = orderUtils.getAfterSaleOrAssistantByIds(this.nutriAssisIdOptions, assistantAfterArray[0]);
this.screenAfterSaleIdOptions = orderUtils.getAfterSaleOrAssistantByIds(this.afterSaleIdOptions, assistantAfterArray[1]);
},
}, },
watch: { watch: {
// //

View File

@ -0,0 +1,77 @@
/**
* 根据营养师ID获取对应售后助理
* @param {*} options 营养师助理售后对应关系字典表查询
* @param {*} dietId 营养师ID
* @return 数组 [助理数组, 售后数组]
*/
export function getAfterSaleAndAssistantByDietId(options, dietId){
if(options == undefined || options == null || options.length == 0 || dietId == undefined || dietId == null || dietId == 0){
return [[0], [0]];
}
let dietOperationValue = options.find(
(opt) => parseInt(opt.dictValue) === dietId
);
let afterSaleAndAssistant = dietOperationValue ? dietOperationValue.dictLabel.split("|") : ['0','0'];
let resultArray = [];
afterSaleAndAssistant.forEach((item, index) => {
resultArray.push(item ? (item.split(",").map((str) => parseInt(str))) : [0]);
});
return resultArray;
}
/**
* 根据字典ID数组筛选字典下拉列表
* @param {*} options 原有下拉列表
* @param {*} idArray 字典值数组
* @returns
*/
export function getAfterSaleOrAssistantByIds(options, idArray){
if(options == undefined || options == null || options.length == 0 || idArray == undefined || idArray == null || idArray.length == 0
|| (idArray.length == 1 && idArray[0] == 0)){
return options;
}
let selectOptions = [{ dictValue: 0, dictLabel: "无", remark: null }];
options.forEach(item => {
if(idArray.indexOf(item.dictValue) != -1 && item.dictValue != 0){
selectOptions.push(item);
}
});
return selectOptions;
}
/**
* 随机获取数组一个元素
* @param {*} array
* @returns
*/
export function getRandomValueByArray(array){
if(array && array != null && array.length > 0){
if(array.length == 1){
return array[0];
}else{
return array[getRandomNumber(0, array.length-1)];
}
}
return 0;
}
/**
* 生成从minNum到maxNum的随机数
* @param {*} minNum
* @param {*} maxNum
* @returns
*/
export function getRandomNumber(minNum,maxNum){
switch(arguments.length){
case 1:
return parseInt(Math.random()*minNum+1,10);
break;
case 2:
return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10);
break;
default:
return 0;
break;
}
}

View File

@ -441,27 +441,16 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-form-item label="售后" prop="afterDietitian">
<el-select v-model="form.afterDietitian" placeholder="请选择">
<el-option
v-for="dict in afterSaleIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="主营养师" prop="mainDietitian"> <el-form-item label="主营养师" prop="mainDietitian">
<el-select v-model="form.mainDietitian" placeholder="请选择"> <el-select v-model="form.mainDietitian" placeholder="请选择" @change="handleOnDietIdChange">
<el-option <el-option
v-for="dict in nutritionistIdOptions" v-for="dict in nutritionistIdOptions"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictLabel" :label="dict.dictLabel"
:value="parseInt(dict.dictValue)" :value="parseInt(dict.dictValue)"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -470,7 +459,19 @@
<el-form-item label="营养师助理" prop="assistantDietitian"> <el-form-item label="营养师助理" prop="assistantDietitian">
<el-select v-model="form.assistantDietitian" placeholder="请选择"> <el-select v-model="form.assistantDietitian" placeholder="请选择">
<el-option <el-option
v-for="dict in nutriAssisIdOptions" v-for="dict in (screenNutriAssisIdOptions || nutriAssisIdOptions)"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="售后" prop="afterDietitian">
<el-select v-model="form.afterDietitian" placeholder="请选择">
<el-option
v-for="dict in (screenAfterSaleIdOptions || afterSaleIdOptions)"
:key="dict.dictValue" :key="dict.dictValue"
:label="dict.dictLabel" :label="dict.dictLabel"
:value="parseInt(dict.dictValue)" :value="parseInt(dict.dictValue)"
@ -523,6 +524,7 @@ import RecipesPlanDrawer from "@/components/RecipesPlanDrawer";
import CustomerPunchLogDrawer from "@/components/PunchLog/CustomerPunchLog"; import CustomerPunchLogDrawer from "@/components/PunchLog/CustomerPunchLog";
import { listPhysicalSigns } from "@/api/custom/physicalSigns"; import { listPhysicalSigns } from "@/api/custom/physicalSigns";
import { mapGetters } from "vuex"; import { mapGetters } from "vuex";
import * as orderUtils from "@/utils/orderUtils";
export default { export default {
name: "Customer", name: "Customer",
@ -616,6 +618,13 @@ export default {
}, },
// //
physicalSignsList: [], physicalSignsList: [],
//
dietitianAfterAssistantOptions: [],
//
screenNutriAssisIdOptions: null,
//
screenAfterSaleIdOptions: null,
}; };
}, },
created() { created() {
@ -636,6 +645,9 @@ export default {
this.accountIdOptions = response.data; this.accountIdOptions = response.data;
} }
}); });
this.getDicts("dietitian_after_assistant").then((response) => {
this.dietitianAfterAssistantOptions = response.data;
});
this.getList(); this.getList();
listPhysicalSigns().then((response) => { listPhysicalSigns().then((response) => {
this.physicalSignsList = response.rows; this.physicalSignsList = response.rows;
@ -759,6 +771,8 @@ export default {
updateBy: null, updateBy: null,
delFlag: null, delFlag: null,
}; };
this.screenNutriAssisIdOptions = this.nutriAssisIdOptions;
this.screenAfterSaleIdOptions = this.afterSaleIdOptions;
this.resetForm("form"); this.resetForm("form");
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@ -922,6 +936,18 @@ export default {
} }
}); });
}, },
//
handleOnDietIdChange(val) {
let assistantAfterArray = orderUtils.getAfterSaleAndAssistantByDietId(this.dietitianAfterAssistantOptions, val);
this.form = {
...this.form,
assistantDietitian: assistantAfterArray ? orderUtils.getRandomValueByArray(assistantAfterArray[0]) : 0,
afterDietitian: assistantAfterArray ? orderUtils.getRandomValueByArray(assistantAfterArray[1]) : 0,
};
this.screenNutriAssisIdOptions = orderUtils.getAfterSaleOrAssistantByIds(this.nutriAssisIdOptions, assistantAfterArray[0]);
this.screenAfterSaleIdOptions = orderUtils.getAfterSaleOrAssistantByIds(this.afterSaleIdOptions, assistantAfterArray[1]);
}
}, },
}; };
</script> </script>