修复未生成食谱逻辑错误
This commit is contained in:
		
							
								
								
									
										62
									
								
								stdiet-ui/src/store/modules/global.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								stdiet-ui/src/store/modules/global.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,62 @@ | ||||
| import { getOptions } from "@/api/custom/order"; | ||||
|  | ||||
| const oriState = { | ||||
|   nutritionistIdOptions: [], | ||||
|   nutriAssisIdOptions: [], | ||||
|   preSaleIdOptions: [], | ||||
|   afterSaleIdOptions: [], | ||||
|   plannerIdOptions: [], | ||||
|   plannerAssisIdOptions: [], | ||||
|   operatorIdOptions: [], | ||||
|   operatorAssisIdOptions: [], | ||||
| }; | ||||
|  | ||||
| const mutations = { | ||||
|   save(state, payload) { | ||||
|     Object.keys(payload).forEach(key => { | ||||
|       state[key] = payload[key]; | ||||
|     }); | ||||
|   }, | ||||
|   clean(state) { | ||||
|     Object.keys(oriState).forEach(key => { | ||||
|       state[key] = oriState[key]; | ||||
|     }); | ||||
|   } | ||||
| }; | ||||
| const actions = { | ||||
|   async init({ commit }, payload) { | ||||
|     const { data: optionsData } = await getOptions(); | ||||
|     const options = optionsData.reduce((opts, cur) => { | ||||
|       if (!opts[cur.postCode]) { | ||||
|         opts[cur.postCode] = [ | ||||
|           // { dictValue: null, dictLabel: "全部", remark: null } | ||||
|         ]; | ||||
|       } | ||||
|       opts[cur.postCode].push({ | ||||
|         dictValue: cur.userId, | ||||
|         dictLabel: cur.userName, | ||||
|         remark: cur.remark | ||||
|       }); | ||||
|       return opts; | ||||
|     }, {}); | ||||
|     commit("save", { | ||||
|       nutritionistIdOptions: options["nutri"] || [], | ||||
|       nutriAssisIdOptions: options["nutri_assis"] || [], | ||||
|       preSaleIdOptions: options["pre_sale"] || [], | ||||
|       afterSaleIdOptions: options["after_sale"] || [], | ||||
|       plannerIdOptions: options["planner"] || [], | ||||
|       plannerAssisIdOptions: options["planner_assis"] || [], | ||||
|       operatorIdOptions: options["operator"] || [], | ||||
|       operatorAssisIdOptions: options["operator_assis"] || [] | ||||
|     }); | ||||
|   } | ||||
| }; | ||||
| const getters = {}; | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|   state: Object.assign({}, oriState), | ||||
|   mutations, | ||||
|   actions, | ||||
|   getters | ||||
| }; | ||||
| @@ -1,4 +1,3 @@ | ||||
| import { getOrder } from "@/api/custom/order"; | ||||
| import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer"; | ||||
| import { dealHealthy } from "@/utils/healthyData"; | ||||
| import { | ||||
| @@ -54,7 +53,7 @@ const mutations = { | ||||
|     // console.log(payload); | ||||
|     state.recipesData[payload.num].dishes = state.recipesData[ | ||||
|       payload.num | ||||
|     ].dishes.filter(obj => obj.id !== payload.dishesId); | ||||
|     ].dishes.filter(obj => obj.id !== payload.id); | ||||
|   }, | ||||
|   updateStateData(state, payload) { | ||||
|     Object.keys(payload).forEach(key => { | ||||
| @@ -92,7 +91,7 @@ const actions = { | ||||
|       commit("updateStateData", { dishesTypeOptions: response.data }); | ||||
|     }); | ||||
|  | ||||
|     // | ||||
|     // 健康数据 | ||||
|     if (payload.cusId) { | ||||
|       dispatch("getHealthyData", payload); | ||||
|     } | ||||
| @@ -104,7 +103,6 @@ const actions = { | ||||
|   }, | ||||
|   async getHealthyData({ commit }, payload) { | ||||
|     commit("updateStateData", { healthDataLoading: true }); | ||||
|     // 健康数据 | ||||
|     const healthyDataResult = await getCustomerPhysicalSignsByCusId( | ||||
|       payload.cusId | ||||
|     ); | ||||
| @@ -211,7 +209,9 @@ const actions = { | ||||
|     }; | ||||
|     const result = await addRecipesApi(params); | ||||
|     if (result.code === 200) { | ||||
|       dispatch("getRecipesInfo", { recipesId: result.data }); | ||||
|       const recipesId = result.data; | ||||
|       commit("updateStateData", { recipesId }); | ||||
|       dispatch("getRecipesInfo", { recipesId }); | ||||
|     } | ||||
|     // console.log(params); | ||||
|   }, | ||||
| @@ -238,10 +238,10 @@ const actions = { | ||||
|           payload.data.id = result.data; | ||||
|           commit("addRecipesDishes", payload); | ||||
|         } | ||||
|       } else { | ||||
|         commit("addRecipesDishes", payload); | ||||
|       } | ||||
|       // console.log(result); | ||||
|     } else { | ||||
|       commit("addRecipesDishes", payload); | ||||
|     } | ||||
|   }, | ||||
|   async updateDishes({ commit, state }, payload) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user