From b8fad6218f769b52967b58fc1fb6feb439d283d6 Mon Sep 17 00:00:00 2001
From: huangdeliang <huangdeliang@skieer.com>
Date: Wed, 3 Mar 2021 16:43:58 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9D=83=E9=99=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../PlanPauseDrawer/index.vue                 |   8 +-
 stdiet-ui/src/views/custom/dishes/index.vue   |  43 +-
 .../src/views/custom/ingredient/index.vue     | 495 +++++++++---------
 3 files changed, 283 insertions(+), 263 deletions(-)

diff --git a/stdiet-ui/src/components/RecipesPlanDrawer/PlanPauseDrawer/index.vue b/stdiet-ui/src/components/RecipesPlanDrawer/PlanPauseDrawer/index.vue
index bf19309b1..21f35b212 100644
--- a/stdiet-ui/src/components/RecipesPlanDrawer/PlanPauseDrawer/index.vue
+++ b/stdiet-ui/src/components/RecipesPlanDrawer/PlanPauseDrawer/index.vue
@@ -14,7 +14,7 @@
             icon="el-icon-plus"
             size="mini"
             @click="handleAdd"
-            v-hasPermi="['orderPause:pause:add']"
+            v-hasPermi="['recipes:pause:add']"
             >新增</el-button
           >
         </el-col>
@@ -24,7 +24,7 @@
             icon="el-icon-download"
             size="mini"
             @click="handleExport"
-            v-hasPermi="['orderPause:pause:export']"
+            v-hasPermi="['recipes:pause:export']"
             >导出</el-button
           >
         </el-col>
@@ -96,7 +96,7 @@
               type="text"
               icon="el-icon-edit"
               @click="handleUpdate(scope.row)"
-              v-hasPermi="['orderPause:pause:edit']"
+              v-hasPermi="['recipes:pause:edit']"
               >修改</el-button
             >
             <el-button
@@ -104,7 +104,7 @@
               type="text"
               icon="el-icon-delete"
               @click="handleDelete(scope.row)"
-              v-hasPermi="['orderPause:pause:remove']"
+              v-hasPermi="['recipes:pause:remove']"
               >删除</el-button
             >
           </template>
diff --git a/stdiet-ui/src/views/custom/dishes/index.vue b/stdiet-ui/src/views/custom/dishes/index.vue
index 2293142c8..d64acc459 100644
--- a/stdiet-ui/src/views/custom/dishes/index.vue
+++ b/stdiet-ui/src/views/custom/dishes/index.vue
@@ -247,17 +247,10 @@
                   :summary-method="getSummaries"
                   style="width: 100%"
                 >
-                  <el-table-column prop="name" label="食材"></el-table-column>
-                  <el-table-column label="通俗计量">
+                  <el-table-column prop="name" label="食材" align="center" />
+                  <el-table-column label="通俗计量" align="center">
                     <template slot-scope="scope">
                       <span class="cus-unit">
-                        <!-- <el-input-number
-                          v-model="scope.row.cusWeight"
-                          size="mini"
-                          controls-position="right"
-                          step="0.5"
-                          :min="0.5"
-                        /> -->
                         <el-select size="mini" v-model="scope.row.cusWeight">
                           <el-option
                             v-for="dict in cusWeightOptions"
@@ -277,7 +270,7 @@
                       </span>
                     </template>
                   </el-table-column>
-                  <el-table-column prop="weight" label="重量(g)">
+                  <el-table-column prop="weight" label="重量(g)" align="center">
                     <template slot-scope="scope">
                       <el-input-number
                         class="weight"
@@ -290,11 +283,31 @@
                       />
                     </template>
                   </el-table-column>
-                  <el-table-column prop="proteinRatio" label="蛋白质/100g">
-                  </el-table-column>
-                  <el-table-column prop="fatRatio" label="脂肪/100g">
-                  </el-table-column>
-                  <el-table-column prop="carbonRatio" label="碳水/100g">
+                  <el-table-column
+                    prop="proteinRatio"
+                    label="蛋白质/100g"
+                    align="center"
+                  />
+                  <el-table-column
+                    prop="fatRatio"
+                    label="脂肪/100g"
+                    align="center"
+                  />
+                  <el-table-column
+                    prop="carbonRatio"
+                    label="碳水/100g"
+                    align="center"
+                  />
+                  <el-table-column label="热量/100g" align="center">
+                    <template slot-scope="scope">
+                      {{
+                        `${(
+                          scope.row.proteinRatio * 4 +
+                          scope.row.fatRatio * 9 +
+                          scope.row.carbonRatio * 4
+                        ).toFixed(1)} kcal`
+                      }}
+                    </template>
                   </el-table-column>
                 </el-table>
               </el-form-item>
diff --git a/stdiet-ui/src/views/custom/ingredient/index.vue b/stdiet-ui/src/views/custom/ingredient/index.vue
index b44ef216f..61fbff02c 100644
--- a/stdiet-ui/src/views/custom/ingredient/index.vue
+++ b/stdiet-ui/src/views/custom/ingredient/index.vue
@@ -96,13 +96,11 @@
           icon="el-icon-search"
           size="mini"
           @click="handleQuery"
-        >搜索
-        </el-button
-        >
+          >搜索
+        </el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
-        >重置
-        </el-button
-        >
+          >重置
+        </el-button>
       </el-form-item>
     </el-form>
 
@@ -114,7 +112,7 @@
           size="mini"
           @click="handleAdd"
           v-hasPermi="['custom:ingredient:add']"
-        >新增
+          >新增
         </el-button>
       </el-col>
       <el-col :span="1.5">
@@ -124,7 +122,7 @@
           size="mini"
           @click="handleExport"
           v-hasPermi="['custom:ingredient:export']"
-        >导出
+          >导出
         </el-button>
       </el-col>
       <right-toolbar
@@ -179,6 +177,17 @@
         align="center"
         prop="carbonRatio"
       />
+      <el-table-column label="每百克热量(千卡)" align="center" width="120">
+        <template slot-scope="scope">
+          {{
+            (
+              scope.row.proteinRatio * 4 +
+              scope.row.fatRatio * 9 +
+              scope.row.carbonRatio * 4
+            ).toFixed(1)
+          }}
+        </template>
+      </el-table-column>
       <el-table-column
         label="地域"
         align="center"
@@ -192,15 +201,15 @@
         width="120"
       >
         <template slot-scope="scope">
-          <autohideinfo :data="string2Arr(scope.row.notRec)"/>
+          <autohideinfo :data="string2Arr(scope.row.notRec)" />
         </template>
       </el-table-column>
       <el-table-column label="推荐人群" align="center" prop="rec" width="120">
         <template slot-scope="scope">
-          <autohideinfo :data="string2Arr(scope.row.rec)"/>
+          <autohideinfo :data="string2Arr(scope.row.rec)" />
         </template>
       </el-table-column>
-      <el-table-column label="备注" align="center" prop="remark"/>
+      <el-table-column label="备注" align="center" prop="remark" />
       <el-table-column
         label="操作"
         align="center"
@@ -213,7 +222,7 @@
             icon="el-icon-edit"
             @click="handleUpdate(scope.row)"
             v-hasPermi="['custom:ingredient:edit']"
-          >修改
+            >修改
           </el-button>
           <el-button
             size="mini"
@@ -221,7 +230,7 @@
             icon="el-icon-delete"
             @click="handleDelete(scope.row)"
             v-hasPermi="['custom:ingredient:remove']"
-          >删除
+            >删除
           </el-button>
         </template>
       </el-table-column>
@@ -241,7 +250,7 @@
         <el-form ref="form" :model="form" :rules="rules" label-width="80px">
           <el-col :span="12">
             <el-form-item label="食材名称" prop="name" label-width="90px">
-              <el-input v-model="form.name" placeholder="请输入食材名称"/>
+              <el-input v-model="form.name" placeholder="请输入食材名称" />
             </el-form-item>
           </el-col>
           <el-col :span="12">
@@ -376,244 +385,242 @@
 </template>
 
 <script>
-  import {
-    addIngredient,
-    delIngredient,
-    exportIngredient,
-    getIngredient,
-    listIngredient,
-    updateIngredient,
-  } from "@/api/custom/ingredient";
+import {
+  addIngredient,
+  delIngredient,
+  exportIngredient,
+  getIngredient,
+  listIngredient,
+  updateIngredient,
+} from "@/api/custom/ingredient";
 
-  import AutoHideInfo from "@/components/AutoHideInfo";
+import AutoHideInfo from "@/components/AutoHideInfo";
 
-  import {listPhysicalSigns} from "@/api/custom/physicalSigns";
+import { listPhysicalSigns } from "@/api/custom/physicalSigns";
 
-  export default {
-    name: "Ingredient",
-    components: {
-      autohideinfo: AutoHideInfo,
+export default {
+  name: "Ingredient",
+  components: {
+    autohideinfo: AutoHideInfo,
+  },
+  data() {
+    return {
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 食材表格数据
+      ingredientList: [],
+      // 审核状态
+      reviewStatusOptions: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 食材类别字典
+      typeOptions: [],
+      // 地域字典
+      areaOptions: [],
+      //
+      physicalSignsOptions: [],
+      // 查询参数
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        name: null,
+        type: null,
+        area: null,
+        notRecIds: null,
+        recIds: null,
+        reviewStatus: null,
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {},
+    };
+  },
+  created() {
+    this.getList();
+    this.getDicts("cus_ing_type").then((response) => {
+      this.typeOptions = response.data;
+    });
+    this.getDicts("cus_area").then((response) => {
+      this.areaOptions = response.data;
+    });
+    this.getDicts("cus_review_status").then((response) => {
+      this.reviewStatusOptions = response.data;
+    });
+    listPhysicalSigns().then((response) => {
+      this.physicalSignsOptions = response.rows.map((obj) => ({
+        dictLabel: obj.name,
+        dictValue: obj.id,
+      }));
+    });
+  },
+  methods: {
+    /** 查询食材列表 */
+    getList() {
+      this.loading = true;
+      listIngredient(this.queryParams).then((response) => {
+        this.ingredientList = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
     },
-    data() {
-      return {
-        // 遮罩层
-        loading: true,
-        // 选中数组
-        ids: [],
-        // 非单个禁用
-        single: true,
-        // 非多个禁用
-        multiple: true,
-        // 显示搜索条件
-        showSearch: true,
-        // 总条数
-        total: 0,
-        // 食材表格数据
-        ingredientList: [],
-        // 审核状态
-        reviewStatusOptions: [],
-        // 弹出层标题
-        title: "",
-        // 是否显示弹出层
-        open: false,
-        // 食材类别字典
-        typeOptions: [],
-        // 地域字典
-        areaOptions: [],
-        //
-        physicalSignsOptions: [],
-        // 查询参数
-        queryParams: {
-          pageNum: 1,
-          pageSize: 10,
-          name: null,
-          type: null,
-          area: null,
-          notRecIds: null,
-          recIds: null,
-          reviewStatus: null,
-        },
-        // 表单参数
-        form: {},
-        // 表单校验
-        rules: {},
+    // 食材类别字典翻译
+    typeFormat(row, column) {
+      return this.selectDictLabel(this.typeOptions, row.type);
+    },
+    // 地域字典翻译
+    areaFormat(row, column) {
+      return this.selectDictLabel(this.areaOptions, row.area);
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        id: null,
+        name: null,
+        type: null,
+        proteinRatio: null,
+        fatRatio: null,
+        carbonRatio: null,
+        area: null,
+        notRecIds: [],
+        recIds: [],
+        remark: null,
+        createBy: null,
+        createTime: null,
+        updateBy: null,
+        updateTime: null,
       };
+      this.resetForm("form");
     },
-    created() {
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
       this.getList();
-      this.getDicts("cus_ing_type").then((response) => {
-        this.typeOptions = response.data;
-      });
-      this.getDicts("cus_area").then((response) => {
-        this.areaOptions = response.data;
-      });
-      this.getDicts("cus_review_status").then((response) => {
-        this.reviewStatusOptions = response.data;
-      });
-      listPhysicalSigns().then((response) => {
-        this.physicalSignsOptions = response.rows.map((obj) => ({
-          dictLabel: obj.name,
-          dictValue: obj.id,
-        }));
-      });
     },
-    methods: {
-      /** 查询食材列表 */
-      getList() {
-        this.loading = true;
-        listIngredient(this.queryParams).then((response) => {
-          this.ingredientList = response.rows;
-          this.total = response.total;
-          this.loading = false;
-        });
-      },
-      // 食材类别字典翻译
-      typeFormat(row, column) {
-        return this.selectDictLabel(this.typeOptions, row.type);
-      },
-      // 地域字典翻译
-      areaFormat(row, column) {
-        return this.selectDictLabel(this.areaOptions, row.area);
-      },
-      // 取消按钮
-      cancel() {
-        this.open = false;
-        this.reset();
-      },
-      // 表单重置
-      reset() {
-        this.form = {
-          id: null,
-          name: null,
-          type: null,
-          proteinRatio: null,
-          fatRatio: null,
-          carbonRatio: null,
-          area: null,
-          notRecIds: [],
-          recIds: [],
-          remark: null,
-          createBy: null,
-          createTime: null,
-          updateBy: null,
-          updateTime: null,
-        };
-        this.resetForm("form");
-      },
-      /** 搜索按钮操作 */
-      handleQuery() {
-        this.queryParams.pageNum = 1;
-        this.getList();
-      },
-      /** 重置按钮操作 */
-      resetQuery() {
-        this.resetForm("queryForm");
-        this.handleQuery();
-      },
-      // 多选框选中数据
-      handleSelectionChange(selection) {
-        this.ids = selection.map((item) => item.id);
-        this.single = selection.length !== 1;
-        this.multiple = !selection.length;
-      },
-      /** 新增按钮操作 */
-      handleAdd() {
-        this.reset();
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    // 多选框选中数据
+    handleSelectionChange(selection) {
+      this.ids = selection.map((item) => item.id);
+      this.single = selection.length !== 1;
+      this.multiple = !selection.length;
+    },
+    /** 新增按钮操作 */
+    handleAdd() {
+      this.reset();
+      this.open = true;
+      this.title = "添加食材";
+    },
+    /** 修改按钮操作 */
+    handleUpdate(row) {
+      this.reset();
+      const id = row.id || this.ids;
+      getIngredient(id).then((response) => {
+        this.form = response.data;
+        this.form.notRecIds = this.form.notRec
+          ? this.form.notRec
+              .split(",")
+              .map(
+                (label) =>
+                  this.physicalSignsOptions.find(
+                    (pObj) => pObj.dictLabel === label
+                  ).dictValue
+              )
+          : [];
+        this.form.recIds = this.form.rec
+          ? this.form.rec
+              .split(",")
+              .map(
+                (label) =>
+                  this.physicalSignsOptions.find(
+                    (pObj) => pObj.dictLabel === label
+                  ).dictValue
+              )
+          : [];
         this.open = true;
-        this.title = "添加食材";
-      },
-      /** 修改按钮操作 */
-      handleUpdate(row) {
-        this.reset();
-        const id = row.id || this.ids;
-        getIngredient(id).then((response) => {
-          this.form = response.data;
-          this.form.notRecIds = this.form.notRec
-            ? this.form.notRec
-              .split(",")
-              .map(
-                (label) =>
-                  this.physicalSignsOptions.find(
-                    (pObj) => pObj.dictLabel === label
-                  ).dictValue
-              )
-            : [];
-          this.form.recIds = this.form.rec
-            ? this.form.rec
-              .split(",")
-              .map(
-                (label) =>
-                  this.physicalSignsOptions.find(
-                    (pObj) => pObj.dictLabel === label
-                  ).dictValue
-              )
-            : [];
-          this.open = true;
-          this.title = "修改食材";
-        });
-      },
-      /** 提交按钮 */
-      submitForm() {
-        this.$refs["form"].validate((valid) => {
-          if (valid) {
-            if (this.form.id != null) {
-              updateIngredient(this.form).then((response) => {
-                if (response.code === 200) {
-                  this.msgSuccess("修改成功");
-                  this.open = false;
-                  this.getList();
-                }
-              });
-            } else {
-              addIngredient(this.form).then((response) => {
-                if (response.code === 200) {
-                  this.msgSuccess("新增成功");
-                  this.open = false;
-                  this.getList();
-                }
-              });
-            }
-          }
-        });
-      },
-      /** 删除按钮操作 */
-      handleDelete(row) {
-        const ids = row.id || this.ids;
-        this.$confirm('是否确认删除食材编号为"' + ids + '"的数据项?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning",
-        })
-          .then(function () {
-            return delIngredient(ids);
-          })
-          .then(() => {
-            this.getList();
-            this.msgSuccess("删除成功");
-          })
-          .catch(function () {
-          });
-      },
-      /** 导出按钮操作 */
-      handleExport() {
-        const queryParams = this.queryParams;
-        this.$confirm("是否确认导出所有食材数据项?", "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning",
-        })
-          .then(function () {
-            return exportIngredient(queryParams);
-          })
-          .then((response) => {
-            this.download(response.msg);
-          })
-          .catch(function () {
-          });
-      },
-      string2Arr(str) {
-        return str ? str.split(',') : []
-      }
+        this.title = "修改食材";
+      });
     },
-  };
+    /** 提交按钮 */
+    submitForm() {
+      this.$refs["form"].validate((valid) => {
+        if (valid) {
+          if (this.form.id != null) {
+            updateIngredient(this.form).then((response) => {
+              if (response.code === 200) {
+                this.msgSuccess("修改成功");
+                this.open = false;
+                this.getList();
+              }
+            });
+          } else {
+            addIngredient(this.form).then((response) => {
+              if (response.code === 200) {
+                this.msgSuccess("新增成功");
+                this.open = false;
+                this.getList();
+              }
+            });
+          }
+        }
+      });
+    },
+    /** 删除按钮操作 */
+    handleDelete(row) {
+      const ids = row.id || this.ids;
+      this.$confirm('是否确认删除食材编号为"' + ids + '"的数据项?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(function () {
+          return delIngredient(ids);
+        })
+        .then(() => {
+          this.getList();
+          this.msgSuccess("删除成功");
+        })
+        .catch(function () {});
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      const queryParams = this.queryParams;
+      this.$confirm("是否确认导出所有食材数据项?", "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(function () {
+          return exportIngredient(queryParams);
+        })
+        .then((response) => {
+          this.download(response.msg);
+        })
+        .catch(function () {});
+    },
+    string2Arr(str) {
+      return str ? str.split(",") : [];
+    },
+  },
+};
 </script>