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 <if test="reviewStatus != null and reviewStatus != ''"> - AND review_status = #{reviewStatus} + AND review_status = ${reviewStatus} </if> <if test="beginTime != null and beginTime != ''">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 @@ <div v-else> <span :style="{ color: '#8c8c8c' }">{{ con.title }}:</span> <el-image + v-if="data[con.value]" title="点击大图预览" fit="contain" style="width: auto; height: 80px" 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/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" /> <pie-chart @@ -65,13 +64,25 @@ export default { ["晚餐", data.calories5], ]; if (data.calories2) { - source.push(["早加餐", data.calories2]); + const tarIdx = source.findIndex((obj) => 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 @@ > 另存为模板 </el-button> + <el-button + size="mini" + type="primary" + style="margin-left: 12px" + icon="el-icon-download" + @click="handleOnExportImg" + v-loading="downloading" + :disabled="downloading" + > + 导出图片 + </el-button> </section> <section> <span class="font_size_style"> @@ -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"]), }, }; </script> -<style rel="stylesheet/scss" lang="scss" scope> +<style lang="scss" scoped> .recipes_header_com_wrapper { .header_btns { display: flex; @@ -219,5 +274,14 @@ export default { font-size: 12px; margin-right: 12px; } + + /deep/ .el-loading-spinner { + margin-top: -10px; + } + + /deep/.el-loading-spinner .circular { + width: 20px; + height: 20px; + } } </style> 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 @@ <VerifyView /> </div> </div> - <div class="content" v-loading="recipesDataLoading"> + <div class="content" v-loading="recipesDataLoading" id="center_content"> <RecipesView v-if="!!recipesData.length" :data="recipesData" 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] || "" 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..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,20 +63,17 @@ export default { data() { return { visible: false, + label: '', loading: false, 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 +97,7 @@ export default { } }, processShoppingCart(num, data = []) { + // console.log(data); this.shoppingCart = data.reduce((obj, cur, idx) => { 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"]), }, }; </script>