From 8e963814d88c8af54d50d472a52e9385067988c3 Mon Sep 17 00:00:00 2001 From: xiezhijun <15270898033@163.com> Date: Fri, 13 Aug 2021 18:00:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E3=80=81=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E4=BB=A5=E5=8F=8A=E6=96=B0=E5=BB=BA=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E6=A1=A3=E6=A1=88=E6=97=B6=EF=BC=8C=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E8=90=A5=E5=85=BB=E5=B8=88=EF=BC=8C=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=80=89=E6=8B=A9=E5=8A=A9=E7=90=86=E5=92=8C=E5=94=AE?= =?UTF-8?q?=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stdiet-ui/src/components/OrderAdd/index.vue | 53 +++++++++---- stdiet-ui/src/components/OrderEdit/index.vue | 66 +++++++++++----- stdiet-ui/src/utils/orderUtils.js | 77 +++++++++++++++++++ stdiet-ui/src/views/custom/customer/index.vue | 56 ++++++++++---- 4 files changed, 203 insertions(+), 49 deletions(-) create mode 100644 stdiet-ui/src/utils/orderUtils.js 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 @@ </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: { // 监听收款账号的变化 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 @@ </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: { // 监听收款账号的变化 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 @@ /> </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>