This commit is contained in:
xiezhijun 2021-03-26 19:04:57 +08:00
commit b1d2c60f4f
12 changed files with 205 additions and 103 deletions

View File

@ -33,7 +33,7 @@
FROM sys_order FROM sys_order
WHERE ${column} IS NOT NULL AND ${column} <> 0 AND del_flag = 0 WHERE ${column} IS NOT NULL AND ${column} <> 0 AND del_flag = 0
<if test="reviewStatus != null and reviewStatus != ''"> <if test="reviewStatus != null and reviewStatus != ''">
AND review_status = #{reviewStatus} AND review_status = ${reviewStatus}
</if> </if>
<if test="beginTime != null and beginTime != ''">AND date_format(order_time,'%y%m%d') &gt;= <if test="beginTime != null and beginTime != ''">AND date_format(order_time,'%y%m%d') &gt;=
date_format(${beginTime},'%y%m%d') date_format(${beginTime},'%y%m%d')

View File

@ -50,6 +50,7 @@
"element-ui": "2.13.2", "element-ui": "2.13.2",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"fuse.js": "3.4.4", "fuse.js": "3.4.4",
"html2canvas": "^1.0.0-rc.7",
"immer": "^8.0.1", "immer": "^8.0.1",
"js-beautify": "1.10.2", "js-beautify": "1.10.2",
"js-cookie": "2.2.0", "js-cookie": "2.2.0",

View File

@ -39,6 +39,7 @@
<div v-else> <div v-else>
<span :style="{ color: '#8c8c8c' }">{{ con.title }}:</span> <span :style="{ color: '#8c8c8c' }">{{ con.title }}:</span>
<el-image <el-image
v-if="data[con.value]"
title="点击大图预览" title="点击大图预览"
fit="contain" fit="contain"
style="width: auto; height: 80px" style="width: auto; height: 80px"

View File

@ -5,7 +5,8 @@ const oriState = {
cusUnitDict: {}, cusUnitDict: {},
cusWeightDict: {}, cusWeightDict: {},
menuTypeDict: {}, menuTypeDict: {},
idgTypeDict: {} idgTypeDict: {},
igdUnitDict: {}
}; };
const mutations = { const mutations = {
@ -55,6 +56,13 @@ const actions = {
}, {}); }, {});
commit("updateStateData", { idgTypeDict }); 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) { async fetchFullRecipes({ commit, dispatch }, payload) {
return new Promise((res, rej) => { return new Promise((res, rej) => {

View File

@ -164,7 +164,7 @@ export default {
: item[1]; : item[1];
return { return {
type: "text", type: "text",
top: idx * 20, top: idx * 24,
right: 10, right: 10,
style: { style: {
text: `${item[0]}${data.toFixed(1)}${ text: `${item[0]}${data.toFixed(1)}${

View File

@ -5,7 +5,6 @@
:data="nutritionSource" :data="nutritionSource"
type="nutrition" type="nutrition"
width="364px" width="364px"
:subTitle="subTitle" :subTitle="subTitle"
/> />
<pie-chart <pie-chart
@ -65,13 +64,25 @@ export default {
["晚餐", data.calories5], ["晚餐", data.calories5],
]; ];
if (data.calories2) { 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) { 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) { 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; return source;
}, },
@ -83,13 +94,25 @@ export default {
["晚餐", data.weight5], ["晚餐", data.weight5],
]; ];
if (data.weight2) { 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) { 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) { 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; return source;
}, },

View File

@ -275,6 +275,7 @@ import AddDishesDrawer from "./AddDishesDrawer";
import DishesSettingDialog from "./DishesSettingDialog"; import DishesSettingDialog from "./DishesSettingDialog";
import VueScrollTo from "vue-scrollto"; import VueScrollTo from "vue-scrollto";
import RemarkDialog from "./RemarkDialog"; import RemarkDialog from "./RemarkDialog";
import { processMenuData } from "./utils";
export default { export default {
name: "RecipesCom", name: "RecipesCom",
@ -318,86 +319,7 @@ export default {
if (!this.data.dishes) { if (!this.data.dishes) {
return []; return [];
} }
const mData = this.data.dishes const mData = processMenuData(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;
}, []);
// console.log(mData); // console.log(mData);
return mData; return mData;

View File

@ -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;
}, []);
}

View File

@ -19,6 +19,17 @@
> >
另存为模板 另存为模板
</el-button> </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>
<section> <section>
<span class="font_size_style"> <span class="font_size_style">
@ -96,6 +107,7 @@ const { mapActions, mapState, mapMutations } = createNamespacedHelpers(
"recipes" "recipes"
); );
import TemplateDialog from "@/components/TemplateDialog"; import TemplateDialog from "@/components/TemplateDialog";
import html2canvans from "html2canvas";
export default { export default {
name: "RecipesHeaderCom", name: "RecipesHeaderCom",
components: { components: {
@ -104,6 +116,7 @@ export default {
data() { data() {
return { return {
loading: false, loading: false,
downloading: false,
nFontSize: 0, nFontSize: 0,
fontSizeOpts: [ fontSizeOpts: [
{ value: 8, label: "8" }, { value: 8, label: "8" },
@ -117,7 +130,14 @@ export default {
}, },
updated() {}, updated() {},
computed: { computed: {
...mapState(["recipesId", "reviewStatus", "fontSize", "leftShow"]), ...mapState([
"recipesId",
"reviewStatus",
"fontSize",
"leftShow",
"healthyData",
"recipesData",
]),
}, },
watch: {}, watch: {},
methods: { methods: {
@ -193,12 +213,47 @@ export default {
return "info"; 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"]), ...mapActions(["saveRecipes", "updateReviewStatus"]),
...mapMutations(["updateStateData", "updateFontSize", "toggleLeftShow"]), ...mapMutations(["updateStateData", "updateFontSize", "toggleLeftShow"]),
}, },
}; };
</script> </script>
<style rel="stylesheet/scss" lang="scss" scope> <style lang="scss" scoped>
.recipes_header_com_wrapper { .recipes_header_com_wrapper {
.header_btns { .header_btns {
display: flex; display: flex;
@ -219,5 +274,14 @@ export default {
font-size: 12px; font-size: 12px;
margin-right: 12px; margin-right: 12px;
} }
/deep/ .el-loading-spinner {
margin-top: -10px;
}
/deep/.el-loading-spinner .circular {
width: 20px;
height: 20px;
}
} }
</style> </style>

View File

@ -8,7 +8,7 @@
<VerifyView /> <VerifyView />
</div> </div>
</div> </div>
<div class="content" v-loading="recipesDataLoading"> <div class="content" v-loading="recipesDataLoading" id="center_content">
<RecipesView <RecipesView
v-if="!!recipesData.length" v-if="!!recipesData.length"
:data="recipesData" :data="recipesData"

View File

@ -83,7 +83,11 @@ export default {
obj[cur.type] = []; obj[cur.type] = [];
} }
let tarMenu = cur; let tarMenu = cur;
if (!tarMenu.methods && tarMenu.igdList.length === 1) { if (
!tarMenu.methods &&
!tarMenu.remark &&
tarMenu.igdList.length === 1
) {
tarMenu = tarMenu.igdList[0]; tarMenu = tarMenu.igdList[0];
tarMenu.cusStr = `${this.cusWeightDict[tarMenu.cusWeight] || ""}${ tarMenu.cusStr = `${this.cusWeightDict[tarMenu.cusWeight] || ""}${
this.cusUnitDict[tarMenu.cusUnit] || "" this.cusUnitDict[tarMenu.cusUnit] || ""

View File

@ -63,20 +63,17 @@ export default {
data() { data() {
return { return {
visible: false, visible: false,
label: '',
loading: false, loading: false,
title: "", title: "",
logo: require("@/assets/logo/st_logo.png"), logo: require("@/assets/logo/st_logo.png"),
shoppingCart: {}, shoppingCart: {},
igdUnitDict: {
鸡蛋: "个",
牛奶: "盒",
},
}; };
}, },
methods: { methods: {
showDrawer(obj) { showDrawer(obj) {
const { recipesId, num, label, data } = obj; const { recipesId, num, label, data } = obj;
console.log(obj); // console.log(obj);
this.label = label; this.label = label;
// num < 0 // num < 0
this.title = `${ this.title = `${
@ -100,6 +97,7 @@ export default {
} }
}, },
processShoppingCart(num, data = []) { processShoppingCart(num, data = []) {
// console.log(data);
this.shoppingCart = data.reduce((obj, cur, idx) => { this.shoppingCart = data.reduce((obj, cur, idx) => {
if ( if (
num < 0 || // num < 0 || //
@ -115,14 +113,14 @@ export default {
const tarIObj = tarObj.find((zObj) => zObj.name === iObj.name); const tarIObj = tarObj.find((zObj) => zObj.name === iObj.name);
if (tarIObj) { if (tarIObj) {
tarIObj.weight += this.igdUnitDict[iObj.name] tarIObj.weight += this.igdUnitDict[iObj.name]
? iObj.cusWeight ? parseInt(iObj.cusWeight)
: iObj.weight; : iObj.weight;
} else { } else {
tarObj.push({ tarObj.push({
type: iObj.type, type: iObj.type,
name: iObj.name, name: iObj.name,
weight: this.igdUnitDict[iObj.name] weight: this.igdUnitDict[iObj.name]
? iObj.cusWeight ? parseInt(iObj.cusWeight)
: iObj.weight, : iObj.weight,
unit: this.igdUnitDict[iObj.name] || "g", unit: this.igdUnitDict[iObj.name] || "g",
}); });
@ -133,7 +131,7 @@ export default {
type: iObj.type, type: iObj.type,
name: iObj.name, name: iObj.name,
weight: this.igdUnitDict[iObj.name] weight: this.igdUnitDict[iObj.name]
? iObj.cusWeight ? parseInt(iObj.cusWeight)
: iObj.weight, : iObj.weight,
unit: this.igdUnitDict[iObj.name] || "g", unit: this.igdUnitDict[iObj.name] || "g",
}, },
@ -153,7 +151,7 @@ export default {
...mapActions(["fetchFullRecipes"]), ...mapActions(["fetchFullRecipes"]),
}, },
computed: { computed: {
...mapState(["recipes", "idgTypeDict"]), ...mapState(["recipes", "idgTypeDict", "igdUnitDict"]),
}, },
}; };
</script> </script>