diff --git a/stdiet-ui/src/components/OrderAdd/index.vue b/stdiet-ui/src/components/OrderAdd/index.vue index a34839e6f..4eb4379c5 100644 --- a/stdiet-ui/src/components/OrderAdd/index.vue +++ b/stdiet-ui/src/components/OrderAdd/index.vue @@ -161,19 +161,7 @@ - - - - - - - + + + + + + + + { 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: { // 监听收款账号的变化 diff --git a/stdiet-ui/src/components/OrderEdit/index.vue b/stdiet-ui/src/components/OrderEdit/index.vue index 342e070c9..178e6ab2a 100644 --- a/stdiet-ui/src/components/OrderEdit/index.vue +++ b/stdiet-ui/src/components/OrderEdit/index.vue @@ -25,7 +25,7 @@ - + - + - - - - - - - - + - + + + + + + + + { 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: { // 监听收款账号的变化 diff --git a/stdiet-ui/src/utils/orderUtils.js b/stdiet-ui/src/utils/orderUtils.js new file mode 100644 index 000000000..39cf87c31 --- /dev/null +++ b/stdiet-ui/src/utils/orderUtils.js @@ -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; + } +} \ No newline at end of file diff --git a/stdiet-ui/src/views/custom/customer/index.vue b/stdiet-ui/src/views/custom/customer/index.vue index e41791e88..008cbea68 100644 --- a/stdiet-ui/src/views/custom/customer/index.vue +++ b/stdiet-ui/src/views/custom/customer/index.vue @@ -441,27 +441,16 @@ /> - - - - - - - - + - + @@ -470,7 +459,19 @@ + + + + + + + { + 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]); + } + }, };