From 180f994141d0b428746a26bc6ae4668a363adbba Mon Sep 17 00:00:00 2001 From: huangdeliang Date: Sat, 20 Mar 2021 19:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=A1=E9=AA=8C=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stdiet-ui/public/index.html | 365 +++++++++--------- stdiet-ui/src/store/modules/recipes.js | 84 ++-- .../recipesBuild/InfoView/PieChart/index.vue | 210 ++++++---- .../VerifyView/IngredientSearchCom/index.vue | 147 +++++++ .../VerifyView/PhysicalSignCom/index.vue | 132 +++++++ .../custom/recipesBuild/VerifyView/index.vue | 136 ++----- 6 files changed, 703 insertions(+), 371 deletions(-) create mode 100644 stdiet-ui/src/views/custom/recipesBuild/VerifyView/IngredientSearchCom/index.vue create mode 100644 stdiet-ui/src/views/custom/recipesBuild/VerifyView/PhysicalSignCom/index.vue diff --git a/stdiet-ui/public/index.html b/stdiet-ui/public/index.html index 34b70ae6f..40cf9db93 100644 --- a/stdiet-ui/public/index.html +++ b/stdiet-ui/public/index.html @@ -1,208 +1,211 @@ - - - - - - + + + + + + <%= webpackConfig.name %> - + .no-js h1 { + color: #222222; + } + + #loader-wrapper .load_title { + font-family: "Open Sans"; + color: #fff; + font-size: 19px; + width: 100%; + text-align: center; + z-index: 9999999999999; + position: absolute; + top: 60%; + opacity: 1; + line-height: 30px; + } + + #loader-wrapper .load_title span { + font-weight: normal; + font-style: italic; + font-size: 13px; + color: #fff; + opacity: 0.5; + } +
-
-
-
-
-
正在加载系统资源,请耐心等待
-
-
+
+
+
+
+
正在加载系统资源,请耐心等待
+
+ diff --git a/stdiet-ui/src/store/modules/recipes.js b/stdiet-ui/src/store/modules/recipes.js index c5dc6652a..3f3d903d7 100644 --- a/stdiet-ui/src/store/modules/recipes.js +++ b/stdiet-ui/src/store/modules/recipes.js @@ -522,6 +522,8 @@ const getters = { (igd.weight / 100) * igd.proteinRatio * 4 + (igd.weight / 100) * igd.fatRatio * 9 + (igd.weight / 100) * igd.carbonRatio * 4; + obj[`weight${cur.type}`] += igd.weight; + obj.totalWeight += igd.weight; }); return obj; }, @@ -533,66 +535,96 @@ const getters = { pHeat: 0, fHeat: 0, cHeat: 0, + // totalHeat: 0, heat1: 0, heat2: 0, heat3: 0, heat4: 0, heat5: 0, - heat6: 0 + heat6: 0, + // + totalWeight: 0, + weight1: 0, + weight2: 0, + weight3: 0, + weight4: 0, + weight5: 0, + weight6: 0 } ) ); console.log(nutriData); return nutriData; }, - verifyNotRecData: state => - state.recipesData.reduce((arr, cur, dayIdx) => { + verifyNotRecData: state => { + const data = state.recipesData.reduce((arr, cur, dayIdx) => { cur.dishes.forEach(dObj => { dObj.igdList.forEach(iObj => { (iObj.notRec || "").split(",").forEach(nRec => { if (nRec) { - let tarObj = arr.find(obj => obj.name === nRec); + const tarObj = arr.find(obj => obj.name === nRec); if (tarObj) { - tarObj.data.push({ - igdId: iObj.id, - num: dayIdx, - dishesId: dObj.dishesId, - id: dObj.id - }); + if (!tarObj.igdIds.includes(iObj.id)) { + tarObj.igdIds.push(iObj.id); + } + const tarIgdObj = tarObj.data.find(obj => obj.id === iObj.id); + if (tarIgdObj) { + if (!tarIgdObj.data.some(obj => obj.day === cur.numDay)) { + tarIgdObj.data.push({ num: dayIdx, day: cur.numDay }); + } + } else { + tarObj.data.push({ + name: iObj.name, + id: iObj.id, + data: [{ num: dayIdx, day: cur.numDay }] + }); + } } else { - tarObj = { + arr.push({ name: nRec, + igdIds: [iObj.id], data: [ { - igdId: iObj.id, - num: dayIdx, - dishesId: dObj.dishesId, - id: dObj.id + name: iObj.name, + id: iObj.id, + data: [{ num: dayIdx, day: cur.numDay }] } ] - }; - arr.push(tarObj); + }); } } }); }); }); return arr; - }, []), - igdTypeDetial: state => - state.recipesData.reduce((obj, cur) => { + }, []); + // console.log(data); + return data; + }, + igdTypeData: state => { + const data = state.recipesData.reduce((arr, cur, idx) => { cur.dishes.forEach(dObj => { dObj.igdList.forEach(iObj => { - if (!obj[iObj.type]) { - obj[iObj.type] = [{ name: iObj.name, id: iObj.id }]; - } else if (!obj[iObj.type].some(tObj => tObj.id === iObj.id)) { - obj[iObj.type].push({ name: iObj.name, id: iObj.id }); + let tarObj = arr.find(obj => obj.id === iObj.id); + if (!tarObj) { + tarObj = { + name: iObj.name, + id: iObj.id, + data: [{ num: idx, day: cur.numDay }] + }; + arr.push(tarObj); + } else if (!tarObj.data.some(obj => obj.day === cur.numDay)) { + tarObj.data.push({ num: idx, day: cur.numDay }); } }); }); - return obj; - }, {}), + return arr; + }, []); + + // console.log(data); + return data; + }, cusUnitDict: state => state.cusUnitOptions.reduce((obj, cur) => { obj[cur.dictValue] = cur.dictLabel; diff --git a/stdiet-ui/src/views/custom/recipesBuild/InfoView/PieChart/index.vue b/stdiet-ui/src/views/custom/recipesBuild/InfoView/PieChart/index.vue index 3e4eda1bc..32c634733 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/InfoView/PieChart/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/InfoView/PieChart/index.vue @@ -20,6 +20,16 @@ @click="handleOnViewChange(1)" /> + + +
") - : [ + : this.view === 1 + ? [ `${marker} ${name}`, `热量:${data[`heat${dim}`].toFixed(1)}千卡`, `供能比:${percent}%`, + ].join("
") + : [ + `${marker} ${name}`, + `质量:${data[`weight${dim}`].toFixed(1)}克`, + `占比:${percent}%`, ].join("
"); }, }, - graphic: - this.view === 1 - ? [ - { - type: "group", - top: 60, - left: 10, - silent: true, - children: [ - { + graphic: !this.view + ? [] + : [ + { + type: "group", + top: 60, + left: 10, + silent: true, + children: [ + { + type: "text", + style: { + text: this.curTotalText, + fill: "#606266", + }, + }, + { + type: "text", + top: 18, + left: 8, + style: { + text: `${ + data[`${this.curTotalName}`] + ? data[`${this.curTotalName}`].toFixed(1) + : 0 + } ${this.curUnit}`, + font: '14px "Microsoft YaHei", sans-serif', + }, + }, + ], + }, + { + type: "group", + top: 36, + right: 10, + silent: true, + children: Object.keys(this.curNameDict).reduce((arr, cur) => { + const tarData = data[this.getDataName(cur)]; + if (tarData) { + arr.push({ type: "text", + top: arr.length * 20, + right: 10, style: { - text: "总热量约", + text: `${this.curNameDict[cur]}:${tarData.toFixed(1)}`, fill: "#606266", }, - }, - { - type: "text", - top: 18, - left: 8, - style: { - text: `${ - data.totalHeat ? data.totalHeat.toFixed(1) : 0 - }千卡`, - font: '14px "Microsoft YaHei", sans-serif', - }, - }, - ], - }, - { - type: "group", - top: 36, - right: 10, - silent: true, - children: Object.keys(this.menuDict).reduce((arr, cur) => { - const tarData = data[`heat${cur}`]; - if (tarData) { - arr.push({ - type: "text", - top: arr.length * 20, - right: 10, - style: { - text: `${this.menuDict[cur]}:${tarData.toFixed(1)}`, - fill: "#606266", - }, - }); - } - return arr; - }, []), - }, - ] - : [], + }); + } + return arr; + }, []), + }, + ], series: [ { name: data.name, type: "pie", radius: [0, !this.view ? 40 : 60], center: ["50%", "55%"], - data: (!this.view - ? Object.keys(this.nameDict) - : Object.keys(this.menuDict) - ).reduce((arr, dim) => { + data: Object.keys(this.curNameDict).reduce((arr, dim) => { if (!this.view || data[`heat${dim}`]) { arr.push({ dim, - value: !this.view ? data[`${dim}Heat`] : data[`heat${dim}`], - name: (!this.view ? this.nameDict : this.menuDict)[dim], + value: data[this.getDataName(dim)], + name: this.curNameDict[dim], oriData: data, }); } diff --git a/stdiet-ui/src/views/custom/recipesBuild/VerifyView/IngredientSearchCom/index.vue b/stdiet-ui/src/views/custom/recipesBuild/VerifyView/IngredientSearchCom/index.vue new file mode 100644 index 000000000..4308ad74b --- /dev/null +++ b/stdiet-ui/src/views/custom/recipesBuild/VerifyView/IngredientSearchCom/index.vue @@ -0,0 +1,147 @@ + + + diff --git a/stdiet-ui/src/views/custom/recipesBuild/VerifyView/PhysicalSignCom/index.vue b/stdiet-ui/src/views/custom/recipesBuild/VerifyView/PhysicalSignCom/index.vue new file mode 100644 index 000000000..e0767867c --- /dev/null +++ b/stdiet-ui/src/views/custom/recipesBuild/VerifyView/PhysicalSignCom/index.vue @@ -0,0 +1,132 @@ + + + diff --git a/stdiet-ui/src/views/custom/recipesBuild/VerifyView/index.vue b/stdiet-ui/src/views/custom/recipesBuild/VerifyView/index.vue index bb423afbc..aab65ef1f 100644 --- a/stdiet-ui/src/views/custom/recipesBuild/VerifyView/index.vue +++ b/stdiet-ui/src/views/custom/recipesBuild/VerifyView/index.vue @@ -1,33 +1,29 @@ @@ -99,33 +75,5 @@ export default { .verify_view_wrapper { height: calc(100vh - 32px); overflow: auto; - .content { - margin: 8px 0; - .item { - font-size: 14px; - margin: 4px; - border-radius: 8px; - cursor: pointer; - display: inline-block; - color: #262626; - border: 1px solid #8c8c8c; - padding: 3px 8px; - word-break: normal; - transition: all 0.3s; - - &:hover { - color: white; - background: #d96969; - border-color: #d96969; - } - } - - .selected_item { - color: white; - background: #d96969; - border-color: #d96969; - font-weight: bold; - } - } }