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/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/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 }}: { + 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/recipesBuild/InfoView/DailyAnalyzeCom/PieChart/index.vue b/stdiet-ui/src/views/custom/recipesBuild/InfoView/DailyAnalyzeCom/PieChart/index.vue index 10de59f15..2b717d20f 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/InfoView/DailyAnalyzeCom/PieChart/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/InfoView/DailyAnalyzeCom/PieChart/index.vue @@ -164,7 +164,7 @@ export default { : item[1]; return { type: "text", - top: idx * 20, + top: idx * 24, right: 10, style: { text: `${item[0]}:${data.toFixed(1)}${ diff --git a/stdiet-ui/src/views/custom/recipesBuild/InfoView/DailyAnalyzeCom/index.vue b/stdiet-ui/src/views/custom/recipesBuild/InfoView/DailyAnalyzeCom/index.vue index 7945362bf..69206c729 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/InfoView/DailyAnalyzeCom/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/InfoView/DailyAnalyzeCom/index.vue @@ -5,7 +5,6 @@ :data="nutritionSource" type="nutrition" width="364px" - :subTitle="subTitle" /> 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/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 feed15795..46d51c089 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,47 @@ 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; + this.$message.success("食谱导出成功"); + }); + }); + }, ...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 @@
-
+
{ if ( num < 0 || // 全部计算 @@ -115,14 +113,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 +131,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", }, @@ -153,7 +151,7 @@ export default { ...mapActions(["fetchFullRecipes"]), }, computed: { - ...mapState(["recipes", "idgTypeDict"]), + ...mapState(["recipes", "idgTypeDict", "igdUnitDict"]), }, };