commit
9397aa954b
@ -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;
|
||||||
|
@ -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;
|
||||||
|
}, []);
|
||||||
|
}
|
@ -229,7 +229,7 @@ export default {
|
|||||||
}
|
}
|
||||||
recipesDom.style.overflow = "visible";
|
recipesDom.style.overflow = "visible";
|
||||||
html2canvans(recipesDom, {
|
html2canvans(recipesDom, {
|
||||||
scale: 1.5,
|
scale: 2,
|
||||||
height: recipesDom.scrollHeight,
|
height: recipesDom.scrollHeight,
|
||||||
}).then((canvas) => {
|
}).then((canvas) => {
|
||||||
const { name } = this.healthyData;
|
const { name } = this.healthyData;
|
||||||
@ -244,6 +244,7 @@ export default {
|
|||||||
recipesDom.style.overflow = "auto";
|
recipesDom.style.overflow = "auto";
|
||||||
|
|
||||||
this.downloading = false;
|
this.downloading = false;
|
||||||
|
this.$message.success("食谱导出成功");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user