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

View File

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

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-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 afterSaleIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
</el-col>
</el-col>
<el-col :span="12">
<el-form-item label="主营养师" prop="mainDietitian">
<el-select v-model="form.mainDietitian" placeholder="请选择">
<el-select v-model="form.mainDietitian" placeholder="请选择" @change="handleOnDietIdChange">
<el-option
v-for="dict in nutritionistIdOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
/>
</el-select>
</el-form-item>
@ -470,7 +459,19 @@
<el-form-item label="营养师助理" prop="assistantDietitian">
<el-select v-model="form.assistantDietitian" placeholder="请选择">
<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"
:label="dict.dictLabel"
:value="parseInt(dict.dictValue)"
@ -523,6 +524,7 @@ import RecipesPlanDrawer from "@/components/RecipesPlanDrawer";
import CustomerPunchLogDrawer from "@/components/PunchLog/CustomerPunchLog";
import { listPhysicalSigns } from "@/api/custom/physicalSigns";
import { mapGetters } from "vuex";
import * as orderUtils from "@/utils/orderUtils";
export default {
name: "Customer",
@ -616,6 +618,13 @@ export default {
},
//
physicalSignsList: [],
//
dietitianAfterAssistantOptions: [],
//
screenNutriAssisIdOptions: null,
//
screenAfterSaleIdOptions: null,
};
},
created() {
@ -636,6 +645,9 @@ export default {
this.accountIdOptions = response.data;
}
});
this.getDicts("dietitian_after_assistant").then((response) => {
this.dietitianAfterAssistantOptions = response.data;
});
this.getList();
listPhysicalSigns().then((response) => {
this.physicalSignsList = response.rows;
@ -759,6 +771,8 @@ export default {
updateBy: null,
delFlag: null,
};
this.screenNutriAssisIdOptions = this.nutriAssisIdOptions;
this.screenAfterSaleIdOptions = this.afterSaleIdOptions;
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>