增加主食按钮
This commit is contained in:
		@@ -32,8 +32,18 @@ public class SysDishes extends BaseEntity
 | 
			
		||||
    @Excel(name = "做法")
 | 
			
		||||
    private String methods;
 | 
			
		||||
 | 
			
		||||
    private Integer isMain;
 | 
			
		||||
 | 
			
		||||
    private String reviewStatus;
 | 
			
		||||
 | 
			
		||||
    public Integer getIsMain() {
 | 
			
		||||
        return isMain;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setIsMain(Integer isMain) {
 | 
			
		||||
        this.isMain = isMain;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setReviewStatus(String reviewStatus) {
 | 
			
		||||
        this.reviewStatus = reviewStatus;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@
 | 
			
		||||
        <result property="id"    column="id"    />
 | 
			
		||||
        <result property="name"    column="name"    />
 | 
			
		||||
        <result property="type"    column="type"    />
 | 
			
		||||
        <result property="isMain"    column="is_main"    />
 | 
			
		||||
        <result property="methods"    column="methods"    />
 | 
			
		||||
        <result property="reviewStatus" column="review_status" />
 | 
			
		||||
        <result property="createBy"    column="create_by"    />
 | 
			
		||||
@@ -32,7 +33,7 @@
 | 
			
		||||
    </resultMap>
 | 
			
		||||
 | 
			
		||||
    <sql id="selectSysDishesVo">
 | 
			
		||||
        select id, name, type, methods, create_by, create_time, update_by, update_time, review_status from sys_dishes
 | 
			
		||||
        select id, name, type, is_main, methods, create_by, create_time, update_by, update_time, review_status from sys_dishes
 | 
			
		||||
    </sql>
 | 
			
		||||
 | 
			
		||||
    <select id="selectSysDishesList" parameterType="SysDishes" resultMap="SysDishesResult">
 | 
			
		||||
@@ -41,6 +42,7 @@
 | 
			
		||||
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
 | 
			
		||||
            <if test="type != null  and type != ''"> and FIND_IN_SET(#{type}, type)</if>
 | 
			
		||||
            <if test="reviewStatus != null  and type != ''"> and review_status = #{reviewStatus}</if>
 | 
			
		||||
            <if test="isMain != null  and type != ''"> and is_main = #{isMain}</if>
 | 
			
		||||
        </where>
 | 
			
		||||
    </select>
 | 
			
		||||
 | 
			
		||||
@@ -86,6 +88,7 @@
 | 
			
		||||
        <trim prefix="(" suffix=")" suffixOverrides=",">
 | 
			
		||||
            <if test="name != null">name,</if>
 | 
			
		||||
            <if test="type != null">type,</if>
 | 
			
		||||
            <if test="isMain != null">is_main,</if>
 | 
			
		||||
            <if test="methods != null">methods,</if>
 | 
			
		||||
            <if test="createBy != null">create_by,</if>
 | 
			
		||||
            <if test="reviewStatus != null">review_status</if>
 | 
			
		||||
@@ -96,6 +99,7 @@
 | 
			
		||||
        <trim prefix="values (" suffix=")" suffixOverrides=",">
 | 
			
		||||
            <if test="name != null">#{name},</if>
 | 
			
		||||
            <if test="type != null">#{type},</if>
 | 
			
		||||
            <if test="isMain != null">#{isMain},</if>
 | 
			
		||||
            <if test="methods != null">#{methods},</if>
 | 
			
		||||
            <if test="createBy != null">#{createBy},</if>
 | 
			
		||||
            <if test="reviewStatus != null">#{reviewStatus}</if>
 | 
			
		||||
@@ -110,6 +114,7 @@
 | 
			
		||||
        <trim prefix="SET" suffixOverrides=",">
 | 
			
		||||
            <if test="name != null">name = #{name},</if>
 | 
			
		||||
            <if test="type != null">type = #{type},</if>
 | 
			
		||||
            <if test="isMain != null">is_main = #{isMain},</if>
 | 
			
		||||
            <if test="methods != null">methods = #{methods},</if>
 | 
			
		||||
            <if test="createBy != null">create_by = #{createBy},</if>
 | 
			
		||||
            <if test="reviewStatus != null">review_status = #{reviewStatus},</if>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								stdiet-ui/src/assets/icons/svg/contract.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								stdiet-ui/src/assets/icons/svg/contract.svg
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
		 After Width: | Height: | Size: 92 KiB  | 
							
								
								
									
										2
									
								
								stdiet-ui/src/assets/icons/svg/dishes-menu.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								stdiet-ui/src/assets/icons/svg/dishes-menu.svg
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
		 After Width: | Height: | Size: 93 KiB  | 
							
								
								
									
										2
									
								
								stdiet-ui/src/assets/icons/svg/dishes.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								stdiet-ui/src/assets/icons/svg/dishes.svg
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
		 After Width: | Height: | Size: 91 KiB  | 
							
								
								
									
										2
									
								
								stdiet-ui/src/assets/icons/svg/ingredient.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								stdiet-ui/src/assets/icons/svg/ingredient.svg
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
		 After Width: | Height: | Size: 94 KiB  | 
							
								
								
									
										2
									
								
								stdiet-ui/src/assets/icons/svg/order-list.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								stdiet-ui/src/assets/icons/svg/order-list.svg
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
		 After Width: | Height: | Size: 92 KiB  | 
@@ -1,6 +1,12 @@
 | 
			
		||||
<template>
 | 
			
		||||
  <div class="app-container">
 | 
			
		||||
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
 | 
			
		||||
    <el-form
 | 
			
		||||
      :model="queryParams"
 | 
			
		||||
      ref="queryForm"
 | 
			
		||||
      :inline="true"
 | 
			
		||||
      v-show="showSearch"
 | 
			
		||||
      label-width="68px"
 | 
			
		||||
    >
 | 
			
		||||
      <el-form-item label="菜品名称" prop="name">
 | 
			
		||||
        <el-input
 | 
			
		||||
          v-model="queryParams.name"
 | 
			
		||||
@@ -11,7 +17,12 @@
 | 
			
		||||
        />
 | 
			
		||||
      </el-form-item>
 | 
			
		||||
      <el-form-item label="菜品类型" prop="type">
 | 
			
		||||
        <el-select v-model="queryParams.type" placeholder="请选择菜品类型" clearable size="small">
 | 
			
		||||
        <el-select
 | 
			
		||||
          v-model="queryParams.type"
 | 
			
		||||
          placeholder="请选择菜品类型"
 | 
			
		||||
          clearable
 | 
			
		||||
          size="small"
 | 
			
		||||
        >
 | 
			
		||||
          <el-option
 | 
			
		||||
            v-for="dict in typeOptions"
 | 
			
		||||
            :key="dict.dictValue"
 | 
			
		||||
@@ -35,8 +46,16 @@
 | 
			
		||||
        </el-select>
 | 
			
		||||
      </el-form-item>
 | 
			
		||||
      <el-form-item>
 | 
			
		||||
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
 | 
			
		||||
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
 | 
			
		||||
        <el-button
 | 
			
		||||
          type="cyan"
 | 
			
		||||
          icon="el-icon-search"
 | 
			
		||||
          size="mini"
 | 
			
		||||
          @click="handleQuery"
 | 
			
		||||
          >搜索</el-button
 | 
			
		||||
        >
 | 
			
		||||
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
 | 
			
		||||
          >重置</el-button
 | 
			
		||||
        >
 | 
			
		||||
      </el-form-item>
 | 
			
		||||
    </el-form>
 | 
			
		||||
 | 
			
		||||
@@ -61,9 +80,16 @@
 | 
			
		||||
          >导出
 | 
			
		||||
        </el-button>
 | 
			
		||||
      </el-col>
 | 
			
		||||
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
 | 
			
		||||
      <right-toolbar
 | 
			
		||||
        :showSearch.sync="showSearch"
 | 
			
		||||
        @queryTable="getList"
 | 
			
		||||
      ></right-toolbar>
 | 
			
		||||
    </el-row>
 | 
			
		||||
    <el-table v-loading="loading" :data="dishesList" @selection-change="handleSelectionChange">
 | 
			
		||||
    <el-table
 | 
			
		||||
      v-loading="loading"
 | 
			
		||||
      :data="dishesList"
 | 
			
		||||
      @selection-change="handleSelectionChange"
 | 
			
		||||
    >
 | 
			
		||||
      <el-table-column label="审核状态" align="center" width="80">
 | 
			
		||||
        <template slot-scope="scope">
 | 
			
		||||
          <el-tag
 | 
			
		||||
@@ -82,8 +108,7 @@
 | 
			
		||||
      </el-table-column>
 | 
			
		||||
      <el-table-column label="包含食材" align="center">
 | 
			
		||||
        <template slot-scope="scope">
 | 
			
		||||
          <div v-for="igd in scope.row.igdList"
 | 
			
		||||
               :key="igd.id">
 | 
			
		||||
          <div v-for="igd in scope.row.igdList" :key="igd.id">
 | 
			
		||||
            {{ igd.name }}
 | 
			
		||||
          </div>
 | 
			
		||||
        </template>
 | 
			
		||||
@@ -99,7 +124,11 @@
 | 
			
		||||
        </template>
 | 
			
		||||
      </el-table-column>
 | 
			
		||||
      <el-table-column label="做法" align="center" prop="methods" />
 | 
			
		||||
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
 | 
			
		||||
      <el-table-column
 | 
			
		||||
        label="操作"
 | 
			
		||||
        align="center"
 | 
			
		||||
        class-name="small-padding fixed-width"
 | 
			
		||||
      >
 | 
			
		||||
        <template slot-scope="scope">
 | 
			
		||||
          <el-button
 | 
			
		||||
            size="mini"
 | 
			
		||||
@@ -132,12 +161,20 @@
 | 
			
		||||
    <!-- 添加或修改菜品对话框 -->
 | 
			
		||||
    <el-drawer :title="title" :visible.sync="open" size="50%">
 | 
			
		||||
      <div class="drawer_content">
 | 
			
		||||
        <el-row class="content_detail">
 | 
			
		||||
          <el-form ref="form" :model="form" :rules="rules" label-width="80px">
 | 
			
		||||
            <el-col span="24">
 | 
			
		||||
              <el-form-item label="菜品名称" prop="name">
 | 
			
		||||
                <el-input v-model="form.name" placeholder="请输入菜品名称" />
 | 
			
		||||
              </el-form-item>
 | 
			
		||||
            </el-col>
 | 
			
		||||
            <el-col span="12">
 | 
			
		||||
              <el-form-item label="菜品类型" prop="type">
 | 
			
		||||
            <el-select v-model="form.type" placeholder="请选择菜品类型" multiple>
 | 
			
		||||
                <el-select
 | 
			
		||||
                  v-model="form.type"
 | 
			
		||||
                  placeholder="请选择菜品类型"
 | 
			
		||||
                  multiple
 | 
			
		||||
                >
 | 
			
		||||
                  <el-option
 | 
			
		||||
                    v-for="dict in typeOptions"
 | 
			
		||||
                    :key="dict.dictValue"
 | 
			
		||||
@@ -146,6 +183,16 @@
 | 
			
		||||
                  ></el-option>
 | 
			
		||||
                </el-select>
 | 
			
		||||
              </el-form-item>
 | 
			
		||||
            </el-col>
 | 
			
		||||
            <el-col span="12">
 | 
			
		||||
              <el-form-item label="是否主食" prop="type">
 | 
			
		||||
                <el-radio-group v-model="form.isMain">
 | 
			
		||||
                  <el-radio :label="0">是</el-radio>
 | 
			
		||||
                  <el-radio :label="1">否</el-radio>
 | 
			
		||||
                </el-radio-group>
 | 
			
		||||
              </el-form-item>
 | 
			
		||||
            </el-col>
 | 
			
		||||
            <el-col span="24">
 | 
			
		||||
              <el-form-item label="食材" prop="ingIds">
 | 
			
		||||
                <el-transfer
 | 
			
		||||
                  style="text-align: left; display: inline-block"
 | 
			
		||||
@@ -167,16 +214,24 @@
 | 
			
		||||
                    size="small"
 | 
			
		||||
                    filterable
 | 
			
		||||
                    v-model="ingType"
 | 
			
		||||
                @change="handleOnTypeChange">
 | 
			
		||||
                    @change="handleOnTypeChange"
 | 
			
		||||
                  >
 | 
			
		||||
                    <el-option
 | 
			
		||||
                      v-for="dict in ingTypeOptions"
 | 
			
		||||
                      :key="dict.dictValue"
 | 
			
		||||
                      :label="dict.dictLabel"
 | 
			
		||||
                  :value="dict.dictValue"/>
 | 
			
		||||
                      :value="dict.dictValue"
 | 
			
		||||
                    />
 | 
			
		||||
                  </el-select>
 | 
			
		||||
              <div class="transfer-footer" slot="right-footer" size="small"/>
 | 
			
		||||
                  <div
 | 
			
		||||
                    class="transfer-footer"
 | 
			
		||||
                    slot="right-footer"
 | 
			
		||||
                    size="small"
 | 
			
		||||
                  />
 | 
			
		||||
                </el-transfer>
 | 
			
		||||
              </el-form-item>
 | 
			
		||||
            </el-col>
 | 
			
		||||
            <el-col span="24">
 | 
			
		||||
              <el-form-item label="分量" prop="weight">
 | 
			
		||||
                <el-table
 | 
			
		||||
                  :data="selTableData"
 | 
			
		||||
@@ -184,11 +239,9 @@
 | 
			
		||||
                  show-summary
 | 
			
		||||
                  size="mini"
 | 
			
		||||
                  :summary-method="getSummaries"
 | 
			
		||||
              style="width: 100%">
 | 
			
		||||
              <el-table-column
 | 
			
		||||
                prop="name"
 | 
			
		||||
                label="食材">
 | 
			
		||||
              </el-table-column>
 | 
			
		||||
                  style="width: 100%"
 | 
			
		||||
                >
 | 
			
		||||
                  <el-table-column prop="name" label="食材"> </el-table-column>
 | 
			
		||||
                  <el-table-column label="通俗计量">
 | 
			
		||||
                    <template slot-scope="scope">
 | 
			
		||||
                      <span class="cus-unit">
 | 
			
		||||
@@ -197,11 +250,9 @@
 | 
			
		||||
                          size="small"
 | 
			
		||||
                          controls-position="right"
 | 
			
		||||
                          step="0.5"
 | 
			
		||||
                    :min="0.5"/>
 | 
			
		||||
                  <el-select
 | 
			
		||||
                    size="small"
 | 
			
		||||
                    v-model="scope.row.cusUnit"
 | 
			
		||||
                  >
 | 
			
		||||
                          :min="0.5"
 | 
			
		||||
                        />
 | 
			
		||||
                        <el-select size="small" v-model="scope.row.cusUnit">
 | 
			
		||||
                          <el-option
 | 
			
		||||
                            v-for="dict in cusUnitOptions"
 | 
			
		||||
                            :key="dict.dictValue"
 | 
			
		||||
@@ -212,9 +263,7 @@
 | 
			
		||||
                      </span>
 | 
			
		||||
                    </template>
 | 
			
		||||
                  </el-table-column>
 | 
			
		||||
              <el-table-column
 | 
			
		||||
                prop="weight"
 | 
			
		||||
                label="重量(g)">
 | 
			
		||||
                  <el-table-column prop="weight" label="重量(g)">
 | 
			
		||||
                    <template slot-scope="scope">
 | 
			
		||||
                      <el-input-number
 | 
			
		||||
                        class="weight"
 | 
			
		||||
@@ -223,45 +272,46 @@
 | 
			
		||||
                        controls-position="right"
 | 
			
		||||
                        @change="handleInputChange"
 | 
			
		||||
                        :min="0"
 | 
			
		||||
                    step="50"/>
 | 
			
		||||
                        step="50"
 | 
			
		||||
                      />
 | 
			
		||||
                    </template>
 | 
			
		||||
                  </el-table-column>
 | 
			
		||||
              <el-table-column
 | 
			
		||||
                prop="proteinRatio"
 | 
			
		||||
                label="P/100g">
 | 
			
		||||
                  <el-table-column prop="proteinRatio" label="P/100g">
 | 
			
		||||
                  </el-table-column>
 | 
			
		||||
              <el-table-column
 | 
			
		||||
                prop="fatRatio"
 | 
			
		||||
                label="F/100g">
 | 
			
		||||
                  <el-table-column prop="fatRatio" label="F/100g">
 | 
			
		||||
                  </el-table-column>
 | 
			
		||||
              <el-table-column
 | 
			
		||||
                prop="carbonRatio"
 | 
			
		||||
                label="C/100g">
 | 
			
		||||
                  <el-table-column prop="carbonRatio" label="C/100g">
 | 
			
		||||
                  </el-table-column>
 | 
			
		||||
              <el-table-column
 | 
			
		||||
                prop="remark"
 | 
			
		||||
                label="备注">
 | 
			
		||||
                  <el-table-column prop="remark" label="备注">
 | 
			
		||||
                  </el-table-column>
 | 
			
		||||
                </el-table>
 | 
			
		||||
              </el-form-item>
 | 
			
		||||
            </el-col>
 | 
			
		||||
            <el-col span="24">
 | 
			
		||||
              <el-form-item label="推荐人群">
 | 
			
		||||
                <el-tag
 | 
			
		||||
                  style="margin-right: 4px"
 | 
			
		||||
                  v-for="rec in selRec"
 | 
			
		||||
                  :key="rec"
 | 
			
		||||
              type="success">
 | 
			
		||||
                  type="success"
 | 
			
		||||
                >
 | 
			
		||||
                  {{ rec }}
 | 
			
		||||
                </el-tag>
 | 
			
		||||
              </el-form-item>
 | 
			
		||||
            </el-col>
 | 
			
		||||
            <el-col span="24">
 | 
			
		||||
              <el-form-item label="忌口人群">
 | 
			
		||||
                <el-tag
 | 
			
		||||
                  style="margin-right: 4px"
 | 
			
		||||
                  v-for="notRec in selNotRec"
 | 
			
		||||
                  :key="notRec"
 | 
			
		||||
              type="danger">
 | 
			
		||||
                  type="danger"
 | 
			
		||||
                >
 | 
			
		||||
                  {{ notRec }}
 | 
			
		||||
                </el-tag>
 | 
			
		||||
              </el-form-item>
 | 
			
		||||
            </el-col>
 | 
			
		||||
            <el-col span="24">
 | 
			
		||||
              <el-form-item label="审核状态" prop="reviewStatus">
 | 
			
		||||
                <el-select
 | 
			
		||||
                  v-model="form.reviewStatus"
 | 
			
		||||
@@ -276,10 +326,19 @@
 | 
			
		||||
                  />
 | 
			
		||||
                </el-select>
 | 
			
		||||
              </el-form-item>
 | 
			
		||||
            </el-col>
 | 
			
		||||
            <el-col span="24">
 | 
			
		||||
              <el-form-item label="做法" prop="methods">
 | 
			
		||||
            <el-input v-model="form.methods" type="textarea" placeholder="请输入内容" rows="4"/>
 | 
			
		||||
                <el-input
 | 
			
		||||
                  v-model="form.methods"
 | 
			
		||||
                  type="textarea"
 | 
			
		||||
                  placeholder="请输入内容"
 | 
			
		||||
                  rows="4"
 | 
			
		||||
                />
 | 
			
		||||
              </el-form-item>
 | 
			
		||||
            </el-col>
 | 
			
		||||
          </el-form>
 | 
			
		||||
        </el-row>
 | 
			
		||||
        <div slot="footer" class="dialog-footer">
 | 
			
		||||
          <el-button type="primary" @click="submitForm">确 定</el-button>
 | 
			
		||||
          <el-button @click="cancel">取 消</el-button>
 | 
			
		||||
@@ -290,7 +349,14 @@
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
  import {addDishes, delDishes, exportDishes, getDishes, listDishes, updateDishes} from "@/api/custom/dishes";
 | 
			
		||||
import {
 | 
			
		||||
  addDishes,
 | 
			
		||||
  delDishes,
 | 
			
		||||
  exportDishes,
 | 
			
		||||
  getDishes,
 | 
			
		||||
  listDishes,
 | 
			
		||||
  updateDishes,
 | 
			
		||||
} from "@/api/custom/dishes";
 | 
			
		||||
import { listAllIngredient } from "@/api/custom/ingredient";
 | 
			
		||||
import AutoHideInfo from "@/components/AutoHideInfo";
 | 
			
		||||
 | 
			
		||||
@@ -321,7 +387,7 @@
 | 
			
		||||
      title: "",
 | 
			
		||||
      // 是否显示弹出层
 | 
			
		||||
      open: false,
 | 
			
		||||
        ingType: '1',
 | 
			
		||||
      ingType: "1",
 | 
			
		||||
      // 食材类别字典
 | 
			
		||||
      ingTypeOptions: [],
 | 
			
		||||
      // 远程数据缓存,预防新增的食材找不到
 | 
			
		||||
@@ -352,18 +418,18 @@
 | 
			
		||||
      // 表单参数
 | 
			
		||||
      form: {},
 | 
			
		||||
      // 表单校验
 | 
			
		||||
        rules: {}
 | 
			
		||||
      rules: {},
 | 
			
		||||
    };
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
    this.getList();
 | 
			
		||||
      this.getDicts("cus_dishes_type").then(response => {
 | 
			
		||||
    this.getDicts("cus_dishes_type").then((response) => {
 | 
			
		||||
      this.typeOptions = response.data;
 | 
			
		||||
    });
 | 
			
		||||
      this.getDicts("cus_ing_type").then(response => {
 | 
			
		||||
    this.getDicts("cus_ing_type").then((response) => {
 | 
			
		||||
      this.ingTypeOptions = response.data;
 | 
			
		||||
    });
 | 
			
		||||
      this.getDicts("cus_cus_unit").then(response => {
 | 
			
		||||
    this.getDicts("cus_cus_unit").then((response) => {
 | 
			
		||||
      this.cusUnitOptions = response.data;
 | 
			
		||||
    });
 | 
			
		||||
    this.getDicts("cus_review_status").then((response) => {
 | 
			
		||||
@@ -374,39 +440,44 @@
 | 
			
		||||
    /** 查询菜品列表 */
 | 
			
		||||
    getList() {
 | 
			
		||||
      this.loading = true;
 | 
			
		||||
        listDishes(this.queryParams).then(response => {
 | 
			
		||||
          this.dishesList = response.rows.map(d => {
 | 
			
		||||
            const recTags = [], notRecTags = [];
 | 
			
		||||
            d.igdList.forEach(igd => {
 | 
			
		||||
      listDishes(this.queryParams).then((response) => {
 | 
			
		||||
        this.dishesList = response.rows.map((d) => {
 | 
			
		||||
          const recTags = [],
 | 
			
		||||
            notRecTags = [];
 | 
			
		||||
          d.igdList.forEach((igd) => {
 | 
			
		||||
            if (igd.rec) {
 | 
			
		||||
                igd.rec.split(',').forEach(rec => {
 | 
			
		||||
              igd.rec.split(",").forEach((rec) => {
 | 
			
		||||
                if (!recTags.includes(rec)) {
 | 
			
		||||
                    recTags.push(rec)
 | 
			
		||||
                  recTags.push(rec);
 | 
			
		||||
                }
 | 
			
		||||
                })
 | 
			
		||||
              });
 | 
			
		||||
            }
 | 
			
		||||
            if (igd.notRec) {
 | 
			
		||||
                igd.notRec.split(',').forEach(notRec => {
 | 
			
		||||
              igd.notRec.split(",").forEach((notRec) => {
 | 
			
		||||
                if (!notRecTags.includes(notRec)) {
 | 
			
		||||
                    notRecTags.push(notRec)
 | 
			
		||||
                  notRecTags.push(notRec);
 | 
			
		||||
                }
 | 
			
		||||
                })
 | 
			
		||||
              });
 | 
			
		||||
            }
 | 
			
		||||
            })
 | 
			
		||||
          });
 | 
			
		||||
          return {
 | 
			
		||||
            ...d,
 | 
			
		||||
            recTags,
 | 
			
		||||
              notRecTags
 | 
			
		||||
            }
 | 
			
		||||
            notRecTags,
 | 
			
		||||
          };
 | 
			
		||||
        });
 | 
			
		||||
          console.log(this.dishesList)
 | 
			
		||||
        console.log(this.dishesList);
 | 
			
		||||
        this.total = response.total;
 | 
			
		||||
        this.loading = false;
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    // 菜品类型字典翻译
 | 
			
		||||
    typeFormat(row, column) {
 | 
			
		||||
        return !row.type ? '' : row.type.split(',').map(type => this.selectDictLabel(this.typeOptions, type));
 | 
			
		||||
      return !row.type
 | 
			
		||||
        ? ""
 | 
			
		||||
        : row.type
 | 
			
		||||
            .split(",")
 | 
			
		||||
            .map((type) => this.selectDictLabel(this.typeOptions, type));
 | 
			
		||||
    },
 | 
			
		||||
    cusUnitFormat(row, column) {
 | 
			
		||||
      return this.selectDictLabel(this.cusUnitOptions, row.type);
 | 
			
		||||
@@ -431,7 +502,8 @@
 | 
			
		||||
        createTime: null,
 | 
			
		||||
        updateBy: null,
 | 
			
		||||
        updateTime: null,
 | 
			
		||||
          igdList: []
 | 
			
		||||
        igdList: [],
 | 
			
		||||
        isMain: 0
 | 
			
		||||
      };
 | 
			
		||||
      this.selIngIds = [];
 | 
			
		||||
      this.selIngList = [];
 | 
			
		||||
@@ -439,7 +511,7 @@
 | 
			
		||||
      this.oriDataList = [];
 | 
			
		||||
      this.selRec = [];
 | 
			
		||||
      this.selNotRec = [];
 | 
			
		||||
        this.ingType = '1';
 | 
			
		||||
      this.ingType = "1";
 | 
			
		||||
      this.resetForm("form");
 | 
			
		||||
    },
 | 
			
		||||
    /** 搜索按钮操作 */
 | 
			
		||||
@@ -454,53 +526,53 @@
 | 
			
		||||
    },
 | 
			
		||||
    // 多选框选中数据
 | 
			
		||||
    handleSelectionChange(selection) {
 | 
			
		||||
        this.ids = selection.map(item => item.id)
 | 
			
		||||
        this.single = selection.length !== 1
 | 
			
		||||
        this.multiple = !selection.length
 | 
			
		||||
      this.ids = selection.map((item) => item.id);
 | 
			
		||||
      this.single = selection.length !== 1;
 | 
			
		||||
      this.multiple = !selection.length;
 | 
			
		||||
    },
 | 
			
		||||
    /** 新增按钮操作 */
 | 
			
		||||
    handleAdd() {
 | 
			
		||||
      this.reset();
 | 
			
		||||
        listAllIngredient({type: this.ingType}).then(response => {
 | 
			
		||||
      listAllIngredient({ type: this.ingType }).then((response) => {
 | 
			
		||||
        this.open = true;
 | 
			
		||||
        this.title = "添加菜品";
 | 
			
		||||
        this.oriDataList = response.rows;
 | 
			
		||||
          this.ingDataList = this.oriDataList.map(obj => ({
 | 
			
		||||
        this.ingDataList = this.oriDataList.map((obj) => ({
 | 
			
		||||
          key: obj.id,
 | 
			
		||||
            label: obj.name
 | 
			
		||||
          }))
 | 
			
		||||
        })
 | 
			
		||||
          label: obj.name,
 | 
			
		||||
        }));
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    /** 修改按钮操作 */
 | 
			
		||||
    handleUpdate(row) {
 | 
			
		||||
      this.reset();
 | 
			
		||||
        const id = row.id || this.ids
 | 
			
		||||
        getDishes(id).then(response => {
 | 
			
		||||
      const id = row.id || this.ids;
 | 
			
		||||
      getDishes(id).then((response) => {
 | 
			
		||||
        this.form = response.data;
 | 
			
		||||
          this.form.type = this.form.type ? this.form.type.split(',') : null;
 | 
			
		||||
          this.form.igdList.forEach(obj => {
 | 
			
		||||
        this.form.type = this.form.type ? this.form.type.split(",") : null;
 | 
			
		||||
        this.form.igdList.forEach((obj) => {
 | 
			
		||||
          this.selIngIds.push(obj.id);
 | 
			
		||||
          this.selIngList.push({
 | 
			
		||||
            key: obj.id,
 | 
			
		||||
              label: obj.name
 | 
			
		||||
            label: obj.name,
 | 
			
		||||
          });
 | 
			
		||||
            this.selTableData.push(obj)
 | 
			
		||||
          this.selTableData.push(obj);
 | 
			
		||||
          if (obj.rec) {
 | 
			
		||||
              obj.rec.split(',').forEach(rec => {
 | 
			
		||||
            obj.rec.split(",").forEach((rec) => {
 | 
			
		||||
              if (!this.selRec.includes(rec)) {
 | 
			
		||||
                  this.selRec.push(rec)
 | 
			
		||||
                this.selRec.push(rec);
 | 
			
		||||
              }
 | 
			
		||||
              })
 | 
			
		||||
            });
 | 
			
		||||
          }
 | 
			
		||||
          if (obj.notRec) {
 | 
			
		||||
              obj.notRec.split(',').forEach(notRec => {
 | 
			
		||||
            obj.notRec.split(",").forEach((notRec) => {
 | 
			
		||||
              if (!this.selNotRec.includes(notRec)) {
 | 
			
		||||
                  this.selNotRec.push(notRec)
 | 
			
		||||
                this.selNotRec.push(notRec);
 | 
			
		||||
              }
 | 
			
		||||
              })
 | 
			
		||||
            });
 | 
			
		||||
          }
 | 
			
		||||
          })
 | 
			
		||||
          listAllIngredient({type: this.ingType}).then(res => {
 | 
			
		||||
        });
 | 
			
		||||
        listAllIngredient({ type: this.ingType }).then((res) => {
 | 
			
		||||
          this.open = true;
 | 
			
		||||
          this.title = "修改菜品";
 | 
			
		||||
          this.oriDataList = res.rows;
 | 
			
		||||
@@ -508,22 +580,22 @@
 | 
			
		||||
            if (!arr.some(({ key }) => key === cur.id)) {
 | 
			
		||||
              arr.push({
 | 
			
		||||
                key: cur.id,
 | 
			
		||||
                  label: cur.name
 | 
			
		||||
                label: cur.name,
 | 
			
		||||
              });
 | 
			
		||||
            }
 | 
			
		||||
            return arr;
 | 
			
		||||
          }, this.selIngList.slice());
 | 
			
		||||
          })
 | 
			
		||||
        });
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    /** 提交按钮 */
 | 
			
		||||
    submitForm() {
 | 
			
		||||
        this.$refs["form"].validate(valid => {
 | 
			
		||||
      this.$refs["form"].validate((valid) => {
 | 
			
		||||
        if (valid) {
 | 
			
		||||
          this.form.igdList = this.selTableData;
 | 
			
		||||
            this.form.type = this.form.type.join(',');
 | 
			
		||||
          this.form.type = this.form.type.join(",");
 | 
			
		||||
          if (this.form.id != null) {
 | 
			
		||||
              updateDishes(this.form).then(response => {
 | 
			
		||||
            updateDishes(this.form).then((response) => {
 | 
			
		||||
              if (response.code === 200) {
 | 
			
		||||
                this.msgSuccess("修改成功");
 | 
			
		||||
                this.open = false;
 | 
			
		||||
@@ -531,7 +603,7 @@
 | 
			
		||||
              }
 | 
			
		||||
            });
 | 
			
		||||
          } else {
 | 
			
		||||
              addDishes(this.form).then(response => {
 | 
			
		||||
            addDishes(this.form).then((response) => {
 | 
			
		||||
              if (response.code === 200) {
 | 
			
		||||
                this.msgSuccess("新增成功");
 | 
			
		||||
                this.open = false;
 | 
			
		||||
@@ -548,87 +620,97 @@
 | 
			
		||||
      this.$confirm('是否确认删除菜品编号为"' + ids + '"的数据项?', "警告", {
 | 
			
		||||
        confirmButtonText: "确定",
 | 
			
		||||
        cancelButtonText: "取消",
 | 
			
		||||
          type: "warning"
 | 
			
		||||
        }).then(function () {
 | 
			
		||||
        type: "warning",
 | 
			
		||||
      })
 | 
			
		||||
        .then(function () {
 | 
			
		||||
          return delDishes(ids);
 | 
			
		||||
        }).then(() => {
 | 
			
		||||
        })
 | 
			
		||||
        .then(() => {
 | 
			
		||||
          this.getList();
 | 
			
		||||
          this.msgSuccess("删除成功");
 | 
			
		||||
        }).catch(function () {
 | 
			
		||||
        });
 | 
			
		||||
        })
 | 
			
		||||
        .catch(function () {});
 | 
			
		||||
    },
 | 
			
		||||
    /** 导出按钮操作 */
 | 
			
		||||
    handleExport() {
 | 
			
		||||
      const queryParams = this.queryParams;
 | 
			
		||||
        this.$confirm('是否确认导出所有菜品数据项?', "警告", {
 | 
			
		||||
      this.$confirm("是否确认导出所有菜品数据项?", "警告", {
 | 
			
		||||
        confirmButtonText: "确定",
 | 
			
		||||
        cancelButtonText: "取消",
 | 
			
		||||
          type: "warning"
 | 
			
		||||
        }).then(function () {
 | 
			
		||||
        type: "warning",
 | 
			
		||||
      })
 | 
			
		||||
        .then(function () {
 | 
			
		||||
          return exportDishes(queryParams);
 | 
			
		||||
        }).then(response => {
 | 
			
		||||
        })
 | 
			
		||||
        .then((response) => {
 | 
			
		||||
          this.download(response.msg);
 | 
			
		||||
        }).catch(function () {
 | 
			
		||||
        });
 | 
			
		||||
        })
 | 
			
		||||
        .catch(function () {});
 | 
			
		||||
    },
 | 
			
		||||
    handleChange(value, direction, movedKeys) {
 | 
			
		||||
      // console.log({oriIgdList: this.oriDataList, selIgdList: this.form.igdList});
 | 
			
		||||
      const newTableData = [];
 | 
			
		||||
      this.selRec = [];
 | 
			
		||||
      this.selNotRec = [];
 | 
			
		||||
        this.selIngList = value.map(id => {
 | 
			
		||||
      this.selIngList = value.map((id) => {
 | 
			
		||||
        // 搜索table中的数据
 | 
			
		||||
          let tmpTableObj = this.selTableData.find(obj => obj.id === id);
 | 
			
		||||
        let tmpTableObj = this.selTableData.find((obj) => obj.id === id);
 | 
			
		||||
        if (tmpTableObj) {
 | 
			
		||||
          newTableData.push(tmpTableObj);
 | 
			
		||||
        } else {
 | 
			
		||||
          // 搜索请求的缓存数据
 | 
			
		||||
            tmpTableObj = this.oriDataList.find(obj => obj.id === id);
 | 
			
		||||
          tmpTableObj = this.oriDataList.find((obj) => obj.id === id);
 | 
			
		||||
          if (tmpTableObj) {
 | 
			
		||||
              newTableData.push({...tmpTableObj, weight: 100, cusWeight: 1, cusUnit: 1})
 | 
			
		||||
            newTableData.push({
 | 
			
		||||
              ...tmpTableObj,
 | 
			
		||||
              weight: 100,
 | 
			
		||||
              cusWeight: 1,
 | 
			
		||||
              cusUnit: 1,
 | 
			
		||||
            });
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        if (tmpTableObj) {
 | 
			
		||||
          if (tmpTableObj.rec) {
 | 
			
		||||
              tmpTableObj.rec.split(',').forEach(rec => {
 | 
			
		||||
            tmpTableObj.rec.split(",").forEach((rec) => {
 | 
			
		||||
              if (!this.selRec.includes(rec)) {
 | 
			
		||||
                  this.selRec.push(rec)
 | 
			
		||||
                this.selRec.push(rec);
 | 
			
		||||
              }
 | 
			
		||||
              })
 | 
			
		||||
            });
 | 
			
		||||
          }
 | 
			
		||||
          if (tmpTableObj.notRec) {
 | 
			
		||||
              tmpTableObj.notRec.split(',').forEach(notRec => {
 | 
			
		||||
            tmpTableObj.notRec.split(",").forEach((notRec) => {
 | 
			
		||||
              if (!this.selNotRec.includes(notRec)) {
 | 
			
		||||
                  this.selNotRec.push(notRec)
 | 
			
		||||
                this.selNotRec.push(notRec);
 | 
			
		||||
              }
 | 
			
		||||
              })
 | 
			
		||||
            });
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
        const tarObj = this.ingDataList.find(({ key }) => key === id);
 | 
			
		||||
          return tarObj
 | 
			
		||||
        return tarObj;
 | 
			
		||||
      });
 | 
			
		||||
      this.selTableData = newTableData;
 | 
			
		||||
    },
 | 
			
		||||
    handleOnTypeChange(value) {
 | 
			
		||||
        listAllIngredient({type: value}).then(res => {
 | 
			
		||||
      listAllIngredient({ type: value }).then((res) => {
 | 
			
		||||
        this.oriDataList = res.rows;
 | 
			
		||||
        this.ingDataList = this.oriDataList.reduce((arr, cur) => {
 | 
			
		||||
          if (!arr.some(({ key }) => key === cur.id)) {
 | 
			
		||||
            arr.push({
 | 
			
		||||
              key: cur.id,
 | 
			
		||||
                label: cur.name
 | 
			
		||||
              label: cur.name,
 | 
			
		||||
            });
 | 
			
		||||
          }
 | 
			
		||||
          return arr;
 | 
			
		||||
        }, this.selIngList.slice());
 | 
			
		||||
        })
 | 
			
		||||
      });
 | 
			
		||||
    },
 | 
			
		||||
    handleInputChange(val) {
 | 
			
		||||
        console.log({val, table: this.selTableData})
 | 
			
		||||
      console.log({ val, table: this.selTableData });
 | 
			
		||||
    },
 | 
			
		||||
    getSummaries(param) {
 | 
			
		||||
      const { columns, data } = param;
 | 
			
		||||
        return columns.reduce((arr, cur, idx) => {
 | 
			
		||||
      return columns.reduce(
 | 
			
		||||
        (arr, cur, idx) => {
 | 
			
		||||
          if (idx > 1) {
 | 
			
		||||
            if (idx === 6) {
 | 
			
		||||
              // 备注
 | 
			
		||||
@@ -638,13 +720,17 @@
 | 
			
		||||
              if (idx === 2) {
 | 
			
		||||
                return acc + parseFloat(dAcc.weight);
 | 
			
		||||
              }
 | 
			
		||||
              return parseFloat((acc + dAcc[cur.property] * dAcc.weight / 100).toFixed(1));
 | 
			
		||||
              return parseFloat(
 | 
			
		||||
                (acc + (dAcc[cur.property] * dAcc.weight) / 100).toFixed(1)
 | 
			
		||||
              );
 | 
			
		||||
            }, 0);
 | 
			
		||||
          }
 | 
			
		||||
          return arr;
 | 
			
		||||
        }, ['合计'])
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
        },
 | 
			
		||||
        ["合计"]
 | 
			
		||||
      );
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
@@ -677,7 +763,7 @@
 | 
			
		||||
  padding: 0;
 | 
			
		||||
  border-radius: 0;
 | 
			
		||||
  border: unset;
 | 
			
		||||
    border-bottom: 1px solid #DCDFE6;
 | 
			
		||||
  border-bottom: 1px solid #dcdfe6;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.cus-unit .el-select .el-input__suffix {
 | 
			
		||||
@@ -690,7 +776,7 @@
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.weight {
 | 
			
		||||
    width: 70px
 | 
			
		||||
  width: 70px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.weight .el-input .el-input__inner {
 | 
			
		||||
@@ -703,14 +789,13 @@
 | 
			
		||||
  flex-direction: column;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
  .drawer_content .el-form {
 | 
			
		||||
    /*height: calc(100% - 45px);*/
 | 
			
		||||
.drawer_content .content_detail {
 | 
			
		||||
  flex: 1 1 0;
 | 
			
		||||
  padding: 12px;
 | 
			
		||||
  overflow: auto;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
  .drawer_content > div {
 | 
			
		||||
.drawer_content .dialog-footer {
 | 
			
		||||
  flex: 0 0 45px;
 | 
			
		||||
  display: inline-flex;
 | 
			
		||||
  align-items: center;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user