From 86bb66a757127b1f34d46c83af76981462983016 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Fri, 26 Mar 2021 14:16:08 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A3=9F=E8=B0=B1?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E7=BB=9F=E8=AE=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/custom/SysCommisionMapper.xml | 2 +- stdiet-ui/src/store/modules/recipesShow.js | 10 +++++++++- .../PlanDrawer/ShoppingPlanDrawer/index.vue | 17 +++++++---------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysCommisionMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysCommisionMapper.xml index b4b9eebe8..69a9eda2b 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysCommisionMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysCommisionMapper.xml @@ -33,7 +33,7 @@ FROM sys_order WHERE ${column} IS NOT NULL AND ${column} <> 0 AND del_flag = 0 - AND review_status = #{reviewStatus} + AND review_status = ${reviewStatus} AND date_format(order_time,'%y%m%d') >= date_format(${beginTime},'%y%m%d') diff --git a/stdiet-ui/src/store/modules/recipesShow.js b/stdiet-ui/src/store/modules/recipesShow.js index e149dc2c2..f5365ea6b 100644 --- a/stdiet-ui/src/store/modules/recipesShow.js +++ b/stdiet-ui/src/store/modules/recipesShow.js @@ -5,7 +5,8 @@ const oriState = { cusUnitDict: {}, cusWeightDict: {}, menuTypeDict: {}, - idgTypeDict: {} + idgTypeDict: {}, + igdUnitDict: {} }; const mutations = { @@ -55,6 +56,13 @@ const actions = { }, {}); commit("updateStateData", { idgTypeDict }); }); + getDicts("sys_ingredient_unit").then(response => { + const igdUnitDict = response.data.reduce((obj, cur) => { + obj[cur.dictLabel] = cur.dictValue; + return obj; + }, {}); + commit("updateStateData", { igdUnitDict }); + }); }, async fetchFullRecipes({ commit, dispatch }, payload) { return new Promise((res, rej) => { diff --git a/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/ShoppingPlanDrawer/index.vue b/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/ShoppingPlanDrawer/index.vue index 83b27cf0f..f887bb45f 100644 --- a/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/ShoppingPlanDrawer/index.vue +++ b/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/ShoppingPlanDrawer/index.vue @@ -67,16 +67,12 @@ export default { title: "", logo: require("@/assets/logo/st_logo.png"), shoppingCart: {}, - igdUnitDict: { - 鸡蛋: "个", - 牛奶: "盒", - }, }; }, methods: { showDrawer(obj) { const { recipesId, num, label, data } = obj; - console.log(obj); + // console.log(obj); this.label = label; // num < 0 全部计算 this.title = `${ @@ -100,6 +96,7 @@ export default { } }, processShoppingCart(num, data = []) { + console.log(data); this.shoppingCart = data.reduce((obj, cur, idx) => { if ( num < 0 || // 全部计算 @@ -115,14 +112,14 @@ export default { const tarIObj = tarObj.find((zObj) => zObj.name === iObj.name); if (tarIObj) { tarIObj.weight += this.igdUnitDict[iObj.name] - ? iObj.cusWeight + ? parseInt(iObj.cusWeight) : iObj.weight; } else { tarObj.push({ type: iObj.type, name: iObj.name, weight: this.igdUnitDict[iObj.name] - ? iObj.cusWeight + ? parseInt(iObj.cusWeight) : iObj.weight, unit: this.igdUnitDict[iObj.name] || "g", }); @@ -133,7 +130,7 @@ export default { type: iObj.type, name: iObj.name, weight: this.igdUnitDict[iObj.name] - ? iObj.cusWeight + ? parseInt(iObj.cusWeight) : iObj.weight, unit: this.igdUnitDict[iObj.name] || "g", }, @@ -144,7 +141,7 @@ export default { } return obj; }, {}); - // console.log(this.shoppingCart); + console.log(this.shoppingCart); }, handleOnBackClick() { this.visible = false; @@ -153,7 +150,7 @@ export default { ...mapActions(["fetchFullRecipes"]), }, computed: { - ...mapState(["recipes", "idgTypeDict"]), + ...mapState(["recipes", "idgTypeDict", "igdUnitDict"]), }, }; From 6fe2d84e5e92d5fd2b95787dd8799fbd9ac76a12 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Fri, 26 Mar 2021 14:41:33 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/HealthyView/index.vue | 1 + .../DailyAnalyzeCom/PieChart/index.vue | 2 +- .../InfoView/DailyAnalyzeCom/index.vue | 37 +++++++++++++++---- .../PlanDrawer/ShoppingPlanDrawer/index.vue | 5 ++- 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/stdiet-ui/src/components/HealthyView/index.vue b/stdiet-ui/src/components/HealthyView/index.vue index 8d90762df..85cf0e5ce 100644 --- a/stdiet-ui/src/components/HealthyView/index.vue +++ b/stdiet-ui/src/components/HealthyView/index.vue @@ -39,6 +39,7 @@
{{ con.title }}: obj[0] === "早餐"); + source.splice(tarIdx > -1 ? tarIdx + 1 : source.length, 0, [ + "早加餐", + data.calories2, + ]); } if (data.calories4) { - source.push(["午加餐", data.calories4]); + const tarIdx = source.findIndex((obj) => obj[0] === "午餐"); + source.splice(tarIdx > -1 ? tarIdx + 1 : source.length, 0, [ + "午加餐", + data.calories4, + ]); } if (data.calories6) { - source.push(["晚加餐", data.calories6]); + const tarIdx = source.findIndex((obj) => obj[0] === "晚餐"); + source.splice(tarIdx > -1 ? tarIdx + 1 : source.length, 0, [ + "晚加餐", + data.calories6, + ]); } return source; }, @@ -83,13 +94,25 @@ export default { ["晚餐", data.weight5], ]; if (data.weight2) { - source.push(["早加餐", data.weight2]); + const tarIdx = source.findIndex((obj) => obj[0] === "早餐"); + source.splice(tarIdx > -1 ? tarIdx + 1 : source.length, 0, [ + "早加餐", + data.weight2, + ]); } if (data.weight4) { - source.push(["午加餐", data.weight4]); + const tarIdx = source.findIndex((obj) => obj[0] === "午餐"); + source.splice(tarIdx > -1 ? tarIdx + 1 : source.length, 0, [ + "午加餐", + data.weight4, + ]); } if (data.weight6) { - source.push(["晚加餐", data.weight6]); + const tarIdx = source.findIndex((obj) => obj[0] === "晚餐"); + source.splice(tarIdx > -1 ? tarIdx + 1 : source.length, 0, [ + "晚加餐", + data.weight6, + ]); } return source; }, diff --git a/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/ShoppingPlanDrawer/index.vue b/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/ShoppingPlanDrawer/index.vue index f887bb45f..66d252993 100644 --- a/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/ShoppingPlanDrawer/index.vue +++ b/stdiet-ui/src/views/custom/recipesShow/PlanDrawer/ShoppingPlanDrawer/index.vue @@ -63,6 +63,7 @@ export default { data() { return { visible: false, + label: '', loading: false, title: "", logo: require("@/assets/logo/st_logo.png"), @@ -96,7 +97,7 @@ export default { } }, processShoppingCart(num, data = []) { - console.log(data); + // console.log(data); this.shoppingCart = data.reduce((obj, cur, idx) => { if ( num < 0 || // 全部计算 @@ -141,7 +142,7 @@ export default { } return obj; }, {}); - console.log(this.shoppingCart); + // console.log(this.shoppingCart); }, handleOnBackClick() { this.visible = false; From 4ce5f3f7da3535e8d076f092b6a0c89b0b3f3fbb Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Fri, 26 Mar 2021 16:09:27 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E9=A3=9F=E8=B0=B1=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stdiet-ui/package.json | 1 + .../RecipesView/RecipesHeaderCom/index.vue | 67 ++++++++++++++++++- .../src/views/custom/recipesBuild/index.vue | 2 +- 3 files changed, 67 insertions(+), 3 deletions(-) diff --git a/stdiet-ui/package.json b/stdiet-ui/package.json index c60d94dd3..3d9272a77 100644 --- a/stdiet-ui/package.json +++ b/stdiet-ui/package.json @@ -50,6 +50,7 @@ "element-ui": "2.13.2", "file-saver": "^2.0.5", "fuse.js": "3.4.4", + "html2canvas": "^1.0.0-rc.7", "immer": "^8.0.1", "js-beautify": "1.10.2", "js-cookie": "2.2.0", diff --git a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesHeaderCom/index.vue b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesHeaderCom/index.vue index feed15795..5f5a599cf 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesHeaderCom/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesHeaderCom/index.vue @@ -19,6 +19,17 @@ > 另存为模板 + + 导出图片 +
@@ -96,6 +107,7 @@ const { mapActions, mapState, mapMutations } = createNamespacedHelpers( "recipes" ); import TemplateDialog from "@/components/TemplateDialog"; +import html2canvans from "html2canvas"; export default { name: "RecipesHeaderCom", components: { @@ -104,6 +116,7 @@ export default { data() { return { loading: false, + downloading: false, nFontSize: 0, fontSizeOpts: [ { value: 8, label: "8" }, @@ -117,7 +130,14 @@ export default { }, updated() {}, computed: { - ...mapState(["recipesId", "reviewStatus", "fontSize", "leftShow"]), + ...mapState([ + "recipesId", + "reviewStatus", + "fontSize", + "leftShow", + "healthyData", + "recipesData", + ]), }, watch: {}, methods: { @@ -193,12 +213,46 @@ export default { return "info"; } }, + handleOnExportImg() { + this.downloading = true; + this.$nextTick(() => { + const centerContentDom = document.getElementById("center_content"); + if (!centerContentDom) { + this.downloading = false; + return; + } + centerContentDom.style.overflow = "visible"; + const recipesDom = document.getElementById("recipes_content"); + if (!recipesDom) { + this.downloading = false; + return; + } + recipesDom.style.overflow = "visible"; + html2canvans(recipesDom, { + scale: 1.5, + height: recipesDom.scrollHeight, + }).then((canvas) => { + const { name } = this.healthyData; + const startNum = this.recipesData[0].numDay; + const endNum = this.recipesData[this.recipesData.length - 1].numDay; + const link = document.createElement("a"); + link.download = `${name}_第${startNum}至${endNum}天.jpeg`; + link.href = canvas.toDataURL(); + link.click(); + + centerContentDom.style.overflow = "auto"; + recipesDom.style.overflow = "auto"; + + this.downloading = false; + }); + }); + }, ...mapActions(["saveRecipes", "updateReviewStatus"]), ...mapMutations(["updateStateData", "updateFontSize", "toggleLeftShow"]), }, }; - diff --git a/stdiet-ui/src/views/custom/recipesBuild/index.vue b/stdiet-ui/src/views/custom/recipesBuild/index.vue index 81680c96e..b2e4ebeed 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/index.vue @@ -8,7 +8,7 @@
-
+
Date: Fri, 26 Mar 2021 16:55:55 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8C=E4=B8=80?= =?UTF-8?q?=E5=A4=A9=E5=90=8C=E4=B8=80=E9=A4=90=E5=88=AB=E8=8F=9C=E5=90=8D?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E5=90=88=E5=B9=B6=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RecipesView/RecipesCom/index.vue | 82 +------------------ .../RecipesView/RecipesCom/utils.js | 81 ++++++++++++++++++ .../RecipesView/RecipesHeaderCom/index.vue | 3 +- 3 files changed, 85 insertions(+), 81 deletions(-) create mode 100644 stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/utils.js diff --git a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/index.vue b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/index.vue index c32af5eb9..db4af82eb 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/index.vue @@ -275,6 +275,7 @@ import AddDishesDrawer from "./AddDishesDrawer"; import DishesSettingDialog from "./DishesSettingDialog"; import VueScrollTo from "vue-scrollto"; import RemarkDialog from "./RemarkDialog"; +import { processMenuData } from "./utils"; export default { name: "RecipesCom", @@ -318,86 +319,7 @@ export default { if (!this.data.dishes) { return []; } - const mData = this.data.dishes - .sort((a, b) => a.type - b.type) - .reduce((arr, cur, idx) => { - if (cur.dishesId > 0 && cur.type !== "0") { - cur.igdList.forEach((igd) => { - let lastTypeHit = false, - lastNameHit = false; - if (arr.length > 0) { - // 倒推,找到第一个出现的位置 - lastTypeHit = arr[arr.length - 1].type === cur.type; - if (lastTypeHit) { - let typePos = arr.length - 1; - for (let i = typePos; i >= 0; i--) { - if (arr[i].type !== cur.type) { - break; - } - typePos = i; - } - arr[typePos].typeSpan.rowspan += 1; - } - lastNameHit = - arr[arr.length - 1].name === cur.name && - arr[arr.length - 1].type === cur.type; - // arr[arr.length - 1].dishesId === cur.dishesId; - if (lastNameHit) { - let namePos = arr.length - 1; - for (let i = namePos; i >= 0; i--) { - if (arr[i].name !== cur.name) { - break; - } - namePos = i; - } - arr[namePos].nameSpan.rowspan += 1; - } - } - - // console.log(cur); - arr.push({ - id: cur.id, - dishesId: cur.dishesId, - menuId: cur.menuId, - name: cur.name, - type: cur.type, - isMain: cur.isMain, - methods: cur.methods, - remark: cur.remark, - igdId: igd.id, - igdType: igd.type, - igdName: igd.name, - proteinRatio: igd.proteinRatio, - fatRatio: igd.fatRatio, - carbonRatio: igd.carbonRatio, - rec: igd.rec, - notRec: igd.notRec, - weight: igd.weight, - cusWeight: igd.cusWeight, - cusUnit: igd.cusUnit, - typeSpan: lastTypeHit - ? { - rowspan: 0, - colspan: 0, - } - : { - rowspan: 1, - colspan: 1, - }, - nameSpan: lastNameHit - ? { - rowspan: 0, - colspan: 0, - } - : { - rowspan: 1, - colspan: 1, - }, - }); - }); - } - return arr; - }, []); + const mData = processMenuData(this.data.dishes); // console.log(mData); return mData; diff --git a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/utils.js b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/utils.js new file mode 100644 index 000000000..e9a834d81 --- /dev/null +++ b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesCom/utils.js @@ -0,0 +1,81 @@ +export function processMenuData(dishes) { + return dishes + .sort((a, b) => a.type - b.type) + .reduce((arr, cur) => { + if (cur.dishesId > 0 && cur.type !== "0") { + cur.igdList.forEach(igd => { + let lastTypeHit = false, + lastNameHit = false; + if (arr.length > 0) { + // 倒推,找到第一个出现的位置 + lastTypeHit = arr[arr.length - 1].type === cur.type; + if (lastTypeHit) { + let typePos = arr.length - 1; + for (let i = typePos; i >= 0; i--) { + if (arr[i].type !== cur.type) { + break; + } + typePos = i; + } + arr[typePos].typeSpan.rowspan += 1; + } + lastNameHit = + arr[arr.length - 1].dishesId === cur.dishesId && + arr[arr.length - 1].type === cur.type; + if (lastNameHit) { + let namePos = arr.length - 1; + for (let i = namePos; i >= 0; i--) { + if (arr[i].dishesId !== cur.dishesId) { + break; + } + namePos = i; + } + arr[namePos].nameSpan.rowspan += 1; + } + } + + // console.log(cur); + arr.push({ + id: cur.id, + dishesId: cur.dishesId, + menuId: cur.menuId, + name: cur.name, + type: cur.type, + isMain: cur.isMain, + methods: cur.methods, + remark: cur.remark, + igdId: igd.id, + igdType: igd.type, + igdName: igd.name, + proteinRatio: igd.proteinRatio, + fatRatio: igd.fatRatio, + carbonRatio: igd.carbonRatio, + rec: igd.rec, + notRec: igd.notRec, + weight: igd.weight, + cusWeight: igd.cusWeight, + cusUnit: igd.cusUnit, + typeSpan: lastTypeHit + ? { + rowspan: 0, + colspan: 0 + } + : { + rowspan: 1, + colspan: 1 + }, + nameSpan: lastNameHit + ? { + rowspan: 0, + colspan: 0 + } + : { + rowspan: 1, + colspan: 1 + } + }); + }); + } + return arr; + }, []); +} diff --git a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesHeaderCom/index.vue b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesHeaderCom/index.vue index 5f5a599cf..b9a91c467 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesHeaderCom/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesHeaderCom/index.vue @@ -229,7 +229,7 @@ export default { } recipesDom.style.overflow = "visible"; html2canvans(recipesDom, { - scale: 1.5, + scale: 2, height: recipesDom.scrollHeight, }).then((canvas) => { const { name } = this.healthyData; @@ -244,6 +244,7 @@ export default { recipesDom.style.overflow = "auto"; this.downloading = false; + this.$message.success("食谱导出成功"); }); }); }, From d75984ed3afefa072d99cb7d67e54e3c89f4b613 Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Fri, 26 Mar 2021 18:09:12 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A3=9F=E8=B0=B1?= =?UTF-8?q?=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recipesBuild/RecipesView/RecipesHeaderCom/index.vue | 2 +- stdiet-ui/src/views/custom/recipesShow/MenuDetail/index.vue | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesHeaderCom/index.vue b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesHeaderCom/index.vue index b9a91c467..46d51c089 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesHeaderCom/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/RecipesView/RecipesHeaderCom/index.vue @@ -229,7 +229,7 @@ export default { } recipesDom.style.overflow = "visible"; html2canvans(recipesDom, { - scale: 2, + scale: 1.5, height: recipesDom.scrollHeight, }).then((canvas) => { const { name } = this.healthyData; diff --git a/stdiet-ui/src/views/custom/recipesShow/MenuDetail/index.vue b/stdiet-ui/src/views/custom/recipesShow/MenuDetail/index.vue index 7d3f35f54..1103db21a 100644 --- a/stdiet-ui/src/views/custom/recipesShow/MenuDetail/index.vue +++ b/stdiet-ui/src/views/custom/recipesShow/MenuDetail/index.vue @@ -83,7 +83,11 @@ export default { obj[cur.type] = []; } let tarMenu = cur; - if (!tarMenu.methods && tarMenu.igdList.length === 1) { + if ( + !tarMenu.methods && + !tarMenu.remark && + tarMenu.igdList.length === 1 + ) { tarMenu = tarMenu.igdList[0]; tarMenu.cusStr = `${this.cusWeightDict[tarMenu.cusWeight] || ""}${ this.cusUnitDict[tarMenu.cusUnit] || ""