From aa555d98c2d35104774f2c5b62d795701badc1b0 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Wed, 10 Mar 2021 17:35:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A1=E5=88=92=E5=BC=80?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/custom/SysWapController.java | 13 ++ .../custom/domain/SysRecipesPlanListInfo.java | 2 + .../mapper/custom/SysRecipesPlanMapper.xml | 1 + stdiet-ui/src/api/custom/recipesShow.js | 11 +- stdiet-ui/src/store/modules/recipesShow.js | 104 ++++++++- .../custom/recipesShow/MenuDetail/index.vue | 36 +-- .../PlanDrawer/PlanTimeDialog/index.vue | 17 +- .../PlanDrawer/ShoppingPlanDrawer/index.vue | 220 ++++++++++++++++++ .../custom/recipesShow/PlanDrawer/index.vue | 25 +- .../src/views/custom/recipesShow/index.vue | 5 + 10 files changed, 394 insertions(+), 40 deletions(-) create mode 100644 stdiet-ui/src/views/custom/recipesShow/PlanDrawer/ShoppingPlanDrawer/index.vue diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java index bb4236852..02f239ff9 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysWapController.java @@ -36,6 +36,7 @@ public class SysWapController extends BaseController { /** * 获取用户信息 + * * @param outId * @return */ @@ -46,6 +47,7 @@ public class SysWapController extends BaseController { /** * 获取某天食谱菜品 + * * @param id * @return */ @@ -56,6 +58,7 @@ public class SysWapController extends BaseController { /** * 系统字典 + * * @param dictType * @return */ @@ -63,4 +66,14 @@ public class SysWapController extends BaseController { public AjaxResult sysDict(@PathVariable String dictType) { return AjaxResult.success(iSysDictTypeService.selectDictDataByType(dictType)); } + + /** + * 获取完整食谱 + * @param id + * @return + */ + @GetMapping(value = "recipes/{id}") + public AjaxResult recipesDetail(@PathVariable Long id) { + return AjaxResult.success(iSysRecipesService.selectSysRecipesByRecipesId(id)); + } } diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanListInfo.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanListInfo.java index f82fd751b..926e9925c 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanListInfo.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysRecipesPlanListInfo.java @@ -11,6 +11,8 @@ public class SysRecipesPlanListInfo { private Long id; + private Long recipesId; + @JsonFormat(pattern = "yyyy-MM-dd") private Date startDate; diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml index 4c2d153a3..4ce1ed6ab 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysRecipesPlanMapper.xml @@ -234,6 +234,7 @@ + diff --git a/stdiet-ui/src/api/custom/recipesShow.js b/stdiet-ui/src/api/custom/recipesShow.js index 5f72315c6..70a9de050 100644 --- a/stdiet-ui/src/api/custom/recipesShow.js +++ b/stdiet-ui/src/api/custom/recipesShow.js @@ -1,6 +1,5 @@ import request from "@/utils/request"; - export function getRecipesPlans(id) { return request({ url: "/wap/recipes/plans/" + id, @@ -40,3 +39,13 @@ export function getDicts(id) { } }); } + +export function getRecipesFullInfo(id) { + return request({ + url: "/wap/recipes/" + id, + method: "get", + headers: { + isToken: false + } + }); +} diff --git a/stdiet-ui/src/store/modules/recipesShow.js b/stdiet-ui/src/store/modules/recipesShow.js index 84a1d3529..e149dc2c2 100644 --- a/stdiet-ui/src/store/modules/recipesShow.js +++ b/stdiet-ui/src/store/modules/recipesShow.js @@ -1,9 +1,18 @@ +import { getRecipesFullInfo, getDicts } from "@/api/custom/recipesShow"; + const oriState = { recipes: {}, - shoppingCart: {} + cusUnitDict: {}, + cusWeightDict: {}, + menuTypeDict: {}, + idgTypeDict: {} }; const mutations = { + setRecipesData(state, payload) { + // console.log(payload); + state.recipes[payload.recipesId] = payload.data; + }, updateStateData(state, payload) { Object.keys(payload).forEach(key => { state[key] = payload[key]; @@ -17,8 +26,97 @@ const mutations = { }; const actions = { - async fetchFullRecipes({commit, dispatch},payload ) { - + async init({ commit, dispatch }, payload) { + getDicts("cus_cus_unit").then(response => { + const cusUnitDict = response.data.reduce((obj, cur) => { + obj[cur.dictValue] = cur.dictLabel; + return obj; + }, {}); + commit("updateStateData", { cusUnitDict }); + }); + getDicts("cus_cus_weight").then(response => { + const cusWeightDict = response.data.reduce((obj, cur) => { + obj[cur.dictValue] = cur.dictLabel; + return obj; + }, {}); + commit("updateStateData", { cusWeightDict }); + }); + getDicts("cus_dishes_type").then(response => { + const menuTypeDict = response.data.reduce((obj, cur) => { + obj[cur.dictValue] = cur.dictLabel; + return obj; + }, {}); + commit("updateStateData", { menuTypeDict }); + }); + getDicts("cus_ing_type").then(response => { + const idgTypeDict = response.data.reduce((obj, cur) => { + obj[cur.dictValue] = cur.dictLabel; + return obj; + }, {}); + commit("updateStateData", { idgTypeDict }); + }); + }, + async fetchFullRecipes({ commit, dispatch }, payload) { + return new Promise((res, rej) => { + getRecipesFullInfo(payload.recipesId).then(response => { + if (response.code === 200) { + commit("setRecipesData", { + recipesId: payload.recipesId, + data: response.data.reduce((outArr, dayData, idx) => { + outArr.push({ + id: dayData.id, + numDay: dayData.numDay, + dishes: dayData.dishes.reduce((arr, cur) => { + if ( + cur.dishesId > -1 && + cur.name && + cur.igdList.length > 0 && + cur.type !== "0" + ) { + arr.push({ + id: cur.id, + dishesId: cur.dishesId, + name: cur.name, + menuId: cur.menuId, + methods: cur.methods, + remark: cur.remark, + type: cur.type, + isMain: cur.isMain, + igdList: cur.igdList.reduce((igdArr, igdData) => { + if (igdData.id > 0) { + const tarDetail = cur.detail.find( + obj => obj.id === igdData.id + ); + if (tarDetail) { + igdArr.push({ + id: igdData.id, + name: igdData.name, + carbonRatio: igdData.carbonRatio, + fatRatio: igdData.fatRatio, + proteinRatio: igdData.proteinRatio, + cusUnit: tarDetail.cus_unit, + cusWeight: tarDetail.cus_weight, + weight: parseFloat(tarDetail.weight), + notRec: igdData.notRec, + rec: igdData.rec, + type: igdData.type + }); + } + } + return igdArr; + }, []) + }); + } + return arr; + }, []) + }); + return outArr; + }, []) + }); + } + res(); + }); + }); } }; diff --git a/stdiet-ui/src/views/custom/recipesShow/MenuDetail/index.vue b/stdiet-ui/src/views/custom/recipesShow/MenuDetail/index.vue index 3743ef03e..ee45c848f 100644 --- a/stdiet-ui/src/views/custom/recipesShow/MenuDetail/index.vue +++ b/stdiet-ui/src/views/custom/recipesShow/MenuDetail/index.vue @@ -34,9 +34,15 @@ + diff --git a/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/index.vue b/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/index.vue index 13833aaaf..0cf280e99 100644 --- a/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/index.vue +++ b/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/index.vue @@ -21,7 +21,6 @@
{{ plan.label }} @@ -42,11 +41,15 @@
+ + +