|
|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div class="app-container">
|
|
|
<div class="filter-container">
|
|
|
- <el-select v-model="list.main.query.baseUnit" class="filter-item" size="mini" placeholder="食物类型" style="width:150px;margin-right:5px;" clearable>
|
|
|
+ <!-- <el-select v-model="list.main.query.baseUnit" class="filter-item" size="mini" placeholder="食物类型" style="width:150px;margin-right:5px;" clearable>
|
|
|
<el-option label="是" :value="true" />
|
|
|
<el-option label="否" :value="false" />
|
|
|
</el-select>
|
|
|
@@ -14,7 +14,7 @@
|
|
|
<el-select v-model="list.main.query.baseUnit" class="filter-item" size="mini" placeholder="状态" style="width:150px;margin-right:5px;" clearable>
|
|
|
<el-option label="是" :value="true" />
|
|
|
<el-option label="否" :value="false" />
|
|
|
- </el-select>
|
|
|
+ </el-select> -->
|
|
|
<el-button class="filter-item" size="mini" type="primary" @click="M.list()">查询</el-button>
|
|
|
<el-button class="filter-item" size="mini" @click="() => {M.reset({ data: { page: 1, limit: list.main.query.limit } })}">重置</el-button>
|
|
|
|
|
|
@@ -23,11 +23,11 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<el-table v-loading="list.main.loading" :data="list.main.list" border fit highlight-current-row style="width:100%" :max-height="maxHeight">
|
|
|
- <el-table-column width="50" header-align="center" label="权重">
|
|
|
+ <!-- <el-table-column width="50" header-align="center" label="权重">
|
|
|
<template slot-scope="{row}">
|
|
|
<span>{{ row.sortOrder }}</span>
|
|
|
</template>
|
|
|
- </el-table-column>
|
|
|
+ </el-table-column> -->
|
|
|
<el-table-column width="70" align="center" label="图片">
|
|
|
<template slot-scope="{row}">
|
|
|
<el-image v-if="row.mainImage" style="width:50px;height:50px;" :src="row.mainImage" fit="contain" />
|
|
|
@@ -35,7 +35,7 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column min-width="150" header-align="center" label="名称">
|
|
|
<template slot-scope="{row}">
|
|
|
- <el-tag size="mini" effect="plain">类型</el-tag><span>{{ row.name }}</span>
|
|
|
+ <el-tag v-if="!!row.typeName" size="mini" effect="plain">{{ row.typeName }}</el-tag><span>{{ row.name }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column min-width="180" header-align="center" label="英文名称">
|
|
|
@@ -95,39 +95,133 @@
|
|
|
</el-table>
|
|
|
<pagination v-show="list.main.total>0" :total="list.main.total" :page.sync="list.main.query.page" :limit.sync="list.main.query.limit" @pagination="M.list()" />
|
|
|
|
|
|
- <el-dialog :title="dlg.form.title" :visible.sync="dlg.form.visible" width="80%" top="3vh">
|
|
|
+ <el-dialog :title="dlg.form.title" :visible.sync="dlg.form.visible" width="95%" top="3vh">
|
|
|
<el-form ref="form" :rules="dlg.form.rules" :model="dlg.form.data" size="mini" label-position="right" label-width="100px">
|
|
|
- <el-tabs v-model="dlg.form.infoTab">
|
|
|
+ <el-tabs v-model="dlg.form.infoTab" @tab-click="foodInfoTabClick">
|
|
|
<el-tab-pane label="食物基本信息" name="base">
|
|
|
- <el-form-item label="主/辅材" prop="category">
|
|
|
- <el-input v-model="dlg.form.data.category" placeholder="请输入单位类别" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="食物类别" prop="name">
|
|
|
- <el-input v-model="dlg.form.data.name" placeholder="请输入单位名称,不能重复" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="名称" prop="name">
|
|
|
- <el-input v-model="dlg.form.data.name" placeholder="请输入单位名称,不能重复" />
|
|
|
- </el-form-item>
|
|
|
+ <el-row :gutter="10">
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="名称" prop="name">
|
|
|
+ <el-input v-model="dlg.form.data.name" placeholder="请输入食物名称,不能重复" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="主/辅料" prop="type">
|
|
|
+ <el-select v-model="dlg.form.data.type" class="filter-item" size="mini" placeholder="请选择主/辅料" style="width:100%;">
|
|
|
+ <el-option label="主料" value="MAIN" />
|
|
|
+ <el-option label="辅料" value="SUB" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="食物形态">
|
|
|
+ <el-select v-model="dlg.form.data.som" class="filter-item" size="mini" placeholder="请选择食物形态" style="width:70%;">
|
|
|
+ <el-option label="固态" value="SOLID" />
|
|
|
+ <el-option label="液态" value="LIQUID" />
|
|
|
+ </el-select>
|
|
|
+ <el-checkbox v-model="dlg.form.data.isGranular" style="float:right;">颗粒状</el-checkbox>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="食物类别">
|
|
|
+ <el-input v-model="dlg.form.data.categoryId" placeholder="请选择食物类别" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="10">
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="可食部">
|
|
|
+ <el-input v-model="dlg.form.data.ep" :min="0" :max="100" placeholder="可食部(0~100%)">
|
|
|
+ <span slot="append">%</span>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="[计算]可食部">
|
|
|
+ <el-input v-model="dlg.form.data.calcEp" :min="0" :max="100" placeholder="计算用可食部(0~100%)">
|
|
|
+ <span slot="append">%</span>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="GI">
|
|
|
+ <el-input v-model="dlg.form.data.gi" placeholder="请输入GI" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="GL">
|
|
|
+ <el-input v-model="dlg.form.data.gl" placeholder="请输入GL" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row :gutter="10">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="密度">
|
|
|
+ <el-input v-model="dlg.form.data.densityAmt" placeholder="密度" style="width:60px;" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="密度单位"
|
|
|
+ :value.sync="dlg.form.data.densityUnitId"
|
|
|
+ :label.sync="dlg.form.data.densityUnit"
|
|
|
+ width="130px;margin-left:1px;"
|
|
|
+ />
|
|
|
+ <span style="color:red;font-size:14px;font-weight:700;"> = </span>
|
|
|
+ <el-input v-model="dlg.form.data.densityVolumeAmt" placeholder="体积" style="width:60px;" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="体积单位"
|
|
|
+ :value.sync="dlg.form.data.densityVolumeUnitId"
|
|
|
+ :label.sync="dlg.form.data.densityVolumeUnit"
|
|
|
+ width="130px;margin-left:1px;"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="堆密度">
|
|
|
+ <el-input v-model="dlg.form.data.bulkDensityAmt" placeholder="堆密度" style="width:60px;" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="堆密度单位"
|
|
|
+ :value.sync="dlg.form.data.bulkDensityUnitId"
|
|
|
+ :label.sync="dlg.form.data.bulkDensityUnit"
|
|
|
+ width="130px;margin-left:1px;"
|
|
|
+ />
|
|
|
+ <span style="color:red;font-size:14px;font-weight:700;"> = </span>
|
|
|
+ <el-input v-model="dlg.form.data.bulkDensityVolumeAmt" placeholder="体积" style="width:60px;" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="体积单位"
|
|
|
+ :value.sync="dlg.form.data.bulkDensityVolumeUnitId"
|
|
|
+ :label.sync="dlg.form.data.bulkDensityVolumeUnit"
|
|
|
+ width="130px;margin-left:1px;"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="[计算]密度">
|
|
|
+ <el-input v-model="dlg.form.data.calcDensityAmt" placeholder="密度" style="width:60px;" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="密度单位"
|
|
|
+ :value.sync="dlg.form.data.calcDensityUnitId"
|
|
|
+ :label.sync="dlg.form.data.calcDensityUnit"
|
|
|
+ width="130px;margin-left:1px;"
|
|
|
+ />
|
|
|
+ <span style="color:red;font-size:14px;font-weight:700;"> = </span>
|
|
|
+ <el-input v-model="dlg.form.data.calcDensityVolumeAmt" placeholder="体积" style="width:60px;" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="体积单位"
|
|
|
+ :value.sync="dlg.form.data.calcDensityVolumeUnitId"
|
|
|
+ :label.sync="dlg.form.data.calcDensityVolumeUnit"
|
|
|
+ width="130px;margin-left:1px;"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
<el-form-item label="描述">
|
|
|
<el-input v-model="dlg.form.data.code" type="textarea" rows="3" placeholder="请输入单位编码,可为空,但不能重复" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item v-if="!dlg.form.data.baseUnit" label="可食部" required>
|
|
|
- <el-input v-model="dlg.form.data.ratio" placeholder="百分比">
|
|
|
- <span slot="append">%</span>
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="GI">
|
|
|
- <el-input v-model="dlg.form.data.name" placeholder="请输入单位名称,不能重复" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="GL">
|
|
|
- <el-input v-model="dlg.form.data.name" placeholder="请输入单位名称,不能重复" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="密度">
|
|
|
- <el-input v-model="dlg.form.data.name" placeholder="请输入单位名称,不能重复" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="堆密度">
|
|
|
- <el-input v-model="dlg.form.data.name" placeholder="请输入单位名称,不能重复" />
|
|
|
- </el-form-item>
|
|
|
<el-form-item label="食物图">
|
|
|
</el-form-item>
|
|
|
<el-form-item label="营养素图">
|
|
|
@@ -137,60 +231,200 @@
|
|
|
</el-tab-pane>
|
|
|
<el-tab-pane label="规格" name="modifier">
|
|
|
<div style="margin-bottom:5px;">
|
|
|
- <el-button size="mini" type="primary" plain>添加</el-button>
|
|
|
+ <el-button size="mini" type="primary" plain @click="addModifier(dlg.form.data)">添加</el-button>
|
|
|
</div>
|
|
|
- <el-table :data="tempList" :show-header="true" border fit highlight-current-row style="width:100%">
|
|
|
+ <el-table :data="dlg.form.data.modifiers" :show-header="false" border fit highlight-current-row style="width:100%">
|
|
|
<el-table-column type="index" width="50" align="center" />
|
|
|
- <el-table-column label="包装名称" width="70" align="center">
|
|
|
- <el-input size="mini" />
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="包装单位" width="70" align="center">
|
|
|
- <el-select size="mini" style="width:100%;">
|
|
|
- </el-select>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="CNVR" width="70" align="center">
|
|
|
- <el-input size="mini" />
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="规格转换" width="180" align="center">
|
|
|
- <el-input size="mini">
|
|
|
- <span slot="prepend">1随身包装=</span>
|
|
|
- </el-input>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="净含量" width="70" align="center">
|
|
|
- <el-input size="mini" />
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="状态" width="70" align="center">
|
|
|
- <el-input size="mini" />
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="卡尺" width="70" align="center">
|
|
|
- <el-input size="mini" />
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="规格图片" width="70" align="center">
|
|
|
+ <el-table-column>
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span v-if="row._edit">
|
|
|
+ <el-input v-model="row.name" placeholder="规格名称" style="width:130px;margin-right:5px;" @change="modifierUnitChange" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="规格单位"
|
|
|
+ :value.sync="row.unitId"
|
|
|
+ :label.sync="row.unitName"
|
|
|
+ width="100px"
|
|
|
+ :allowCreate="true"
|
|
|
+ @select="modifierUnitChange"
|
|
|
+ />
|
|
|
+ [
|
|
|
+ <span style="color:blue;font-size:13px;"> 规格转换: </span>
|
|
|
+ <el-input v-model="row.toModifierInput" placeholder="数量" style="width:60px;" />
|
|
|
+ <span>{{ row.key || '' }}</span>
|
|
|
+ <span style="color:red;font-size:14px;font-weight:700;"> = </span>
|
|
|
+ <el-input v-model="row.toModifierAmt" placeholder="数量" style="width:60px;margin-right:10px;" />
|
|
|
+ <el-select v-model="row.toModifierName" placeholder="规格单位" style="width:120px" clearable>
|
|
|
+ <el-option v-for="opt in dlg.form.modifierUnitOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
|
|
|
+ </el-select>
|
|
|
+ ]
|
|
|
+ [
|
|
|
+ <span style="color:blue;font-size:13px;"> 标准单位转换: </span>
|
|
|
+ <el-input v-model="row.stdMeasureInput" placeholder="数量" style="width:60px;" />
|
|
|
+ <span>{{ row.key || '' }}</span>
|
|
|
+ <span style="color:red;font-size:14px;font-weight:700;"> = </span>
|
|
|
+ <el-input v-model="row.stdMeasureAmt" placeholder="数量" style="width:60px;margin-right:10px;" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="标准单位"
|
|
|
+ :value.sync="row.stdMeasureUnitId"
|
|
|
+ :label.sync="row.stdMeasureUnit"
|
|
|
+ width="90px"
|
|
|
+ />
|
|
|
+ ]
|
|
|
+ [
|
|
|
+ <span style="color:blue;font-size:13px;"> 推荐量: </span>
|
|
|
+ <el-input v-model="row.inInit" placeholder="数量" style="width:60px;" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="推荐量单位"
|
|
|
+ :value.sync="row.inInitUnitId"
|
|
|
+ :label.sync="row.inInitUnit"
|
|
|
+ :initOptions="dlg.form.modifierUnitOptions"
|
|
|
+ width="90px"
|
|
|
+ />
|
|
|
+ ]
|
|
|
+ </span>
|
|
|
+ <span v-else>
|
|
|
+ -
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column width="70" align="center">
|
|
|
+ <el-table-column width="90" align="center">
|
|
|
+ <template slot-scope="{$index}">
|
|
|
+ <i class="el-icon-delete" style="cursor:pointer;color:#999999;margin-right:5px;" @click="fn.remove(dlg.form.data.modifiers, $index)"></i>
|
|
|
+
|
|
|
+ <i class="el-icon-top" style="cursor:pointer;color:#999999;margin-right:5px;" @click="fn.moveUp(dlg.form.data.modifiers, $index)"></i>
|
|
|
+
|
|
|
+ <i class="el-icon-bottom" style="cursor:pointer;color:#999999;" @click="fn.moveDown(dlg.form.data.modifiers, $index)"></i>
|
|
|
+ </template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</el-tab-pane>
|
|
|
<el-tab-pane label="营养素" name="nutrient">
|
|
|
- <el-table :data="tempList" :show-header="false" border fit highlight-current-row style="width:100%">
|
|
|
+ <div style="margin-bottom:5px;">
|
|
|
+ <el-button size="mini" type="primary" plain @click="addNutrient(dlg.form.data)">添加</el-button>
|
|
|
+ </div>
|
|
|
+ <el-table :data="dlg.form.data.nutrients" :show-header="false" border fit highlight-current-row style="width:100%">
|
|
|
<el-table-column type="index" width="50" align="center" />
|
|
|
<el-table-column>
|
|
|
<template slot-scope="{row}">
|
|
|
- 名称选择<br>
|
|
|
- 计量方式<br>
|
|
|
- 计量单位<br>
|
|
|
- 转换关系<br>
|
|
|
- NVR(%)<br>
|
|
|
- nv_spec<br>
|
|
|
- nv_spec_unit<br>
|
|
|
- 来源
|
|
|
+ <span v-if="row._edit">
|
|
|
+ <DataSelect
|
|
|
+ url="/api/nutrients"
|
|
|
+ placeholder="请选择营养素"
|
|
|
+ width="130px;margin-right:5px;"
|
|
|
+ :value.sync="row.nutrientId"
|
|
|
+ :label.sync="row.nutrientName"
|
|
|
+ @select="(nutrient) => nutrientSelect(nutrient, row)"
|
|
|
+ />
|
|
|
+ <el-select v-model="row.nvMeasureMode" size="mini" placeholder="计量" style="width:80px;margin-right:5px;">
|
|
|
+ <el-option label="值" value="VALUE" />
|
|
|
+ <el-option label="范围" value="RANGE" />
|
|
|
+ <el-option label="误差" value="ADJUST" />
|
|
|
+ </el-select>
|
|
|
+ <span style="color:red;font-size:15px;font-weight:700;">(</span>
|
|
|
+ <span v-if="row.nvMeasureMode=='VALUE'">
|
|
|
+ <el-input v-model="row.nv" placeholder="取值" style="width:70px;margin-right:10px;" />
|
|
|
+ </span>
|
|
|
+ <span v-else-if="row.nvMeasureMode=='RANGE'">
|
|
|
+ <el-input v-model="row.nvMin" placeholder="最小值" style="width:70px;margin-right:10px;" />
|
|
|
+ -
|
|
|
+ <el-input v-model="row.nvMax" placeholder="最大值" style="width:70px;margin-right:10px;" />
|
|
|
+ </span>
|
|
|
+ <span v-else-if="row.nvMeasureMode=='ADJUST'">
|
|
|
+ <el-input v-model="row.nv" placeholder="取值" style="width:70px;margin-right:10px;" />
|
|
|
+ <el-input v-model="row.nv_adjust" placeholder="误差" style="width:80px;margin-right:10px;">
|
|
|
+ <span slot="prepend">±</span>
|
|
|
+ </el-input>
|
|
|
+ </span>
|
|
|
+ <el-select v-model="row.nvUnitId" placeholder="营养素单位" style="width:100px" clearable>
|
|
|
+ <el-option v-if="!!row.nvUnitId && row._nutrientUnitOptions && !row._nutrientUnitOptions.find(v => v.value == row.nvUnitId)" :key="row.nvUnitId" :label="row.nvUnit" :value="row.nvUnitId" />
|
|
|
+ <el-option v-for="opt in row._nutrientUnitOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
|
|
|
+ </el-select>
|
|
|
+ <!-- <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="营养素单位"
|
|
|
+ :value.sync="row.nvUnitId"
|
|
|
+ :label.sync="row.nvUnitName"
|
|
|
+ :clearable="true"
|
|
|
+ width="100px"
|
|
|
+ /> -->
|
|
|
+ <span style="color:red;font-weight:700;"> / </span>
|
|
|
+ <el-input v-model="row.nvSpec" placeholder="nv_spec" style="width:70px;margin-right:10px;" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="nv_spec单位"
|
|
|
+ :value.sync="row.nvSpecUnitId"
|
|
|
+ :label.sync="row.nvSpecUnit"
|
|
|
+ width="110px"
|
|
|
+ :allowCreate="true"
|
|
|
+ :initOptions="dlg.form.modifierUnitOptions"
|
|
|
+ />
|
|
|
+ <span style="color:red;font-size:15px;font-weight:700;">)</span>
|
|
|
+ <!-- [
|
|
|
+ <span style="color:green;font-weight:700;">1</span> <span style="color:red">{{ row.nvSpecUnit }}</span>
|
|
|
+ *
|
|
|
+ <el-input v-model="row.cfNvUnitToBaseUnit" style="width:80px;margin-right:5px;" />
|
|
|
+ = * 1 {{ row.nutrient && row.nutrient.baseUnitName || '基础单位' }}
|
|
|
+ ] -->
|
|
|
+ </span>
|
|
|
+ <span v-else>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column width="90" align="center">
|
|
|
+ <template slot-scope="{$index}">
|
|
|
+ <i class="el-icon-delete" style="cursor:pointer;color:#999999;margin-right:5px;" @click="fn.remove(dlg.form.data.nutrients, $index)"></i>
|
|
|
+
|
|
|
+ <i class="el-icon-top" style="cursor:pointer;color:#999999;margin-right:5px;" @click="fn.moveUp(dlg.form.data.nutrients, $index)"></i>
|
|
|
+
|
|
|
+ <i class="el-icon-bottom" style="cursor:pointer;color:#999999;" @click="fn.moveDown(dlg.form.data.nutrients, $index)"></i>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</el-tab-pane>
|
|
|
<el-tab-pane label="CF" name="cf">
|
|
|
+ <el-table :data="dlg.form.data.cfs" border fit highlight-current-row style="width:100%">
|
|
|
+ <el-table-column type="index" width="50" align="center" />
|
|
|
+ <el-table-column min-width="180" header-align="center" label="源单位">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.fromUnit }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column min-width="180" header-align="center" label="转换后单位">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>{{ row.toUnit }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column min-width="210" header-align="center" label="转换关系">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <span>1 {{ row.fromUnit }} *
|
|
|
+ <el-input v-model="row.cf" style="width:100px;margin-right:10px;" @blur="saveCf(row)" />
|
|
|
+ =1 {{ row.toUnit }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
</el-tab-pane>
|
|
|
<el-tab-pane label="营养素含量计算" name="calc">
|
|
|
+ <div>
|
|
|
+ <el-input v-model="calc.req.amt" placeholder="摄入量" style="width:100px;margin-right:10px;" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/units"
|
|
|
+ placeholder="摄入量单位"
|
|
|
+ :value.sync="calc.req.unitId"
|
|
|
+ :label.sync="calc.req.unitName"
|
|
|
+ :initOptions="dlg.form.modifierUnitOptions"
|
|
|
+ width="110px"
|
|
|
+ />
|
|
|
+ <el-button :loading="calc.loading" size="mini" type="success" style="margin-left:15px;" @click="calcNvIn">计算</el-button>
|
|
|
+ <span>
|
|
|
+ {{ calc.rsp.amt }}{{ calc.rsp.unitName }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <div style="margin-top:5px;">
|
|
|
+ <p v-for="nv in calc.rsp.nvList" :key="nv.name">{{ nv.name }} 摄入:{{ nv.nvIn }}{{ nv.nvUnit }}, ({{ nv.nv }}{{ nv.nvUnit }}/{{ nv.nvSpec }}{{ nv.nvSpecUnit }})</p>
|
|
|
+ </div>
|
|
|
</el-tab-pane>
|
|
|
</el-tabs>
|
|
|
</el-form>
|
|
|
@@ -198,8 +432,11 @@
|
|
|
<el-button size="mini" @click="dlg.form.visible = false">
|
|
|
取消
|
|
|
</el-button>
|
|
|
+ <el-button :loading="dlg.form.saveLoading" size="mini" type="primary" @click="onlySave">
|
|
|
+ 仅保存
|
|
|
+ </el-button>
|
|
|
<el-button :loading="dlg.form.saveLoading" size="mini" type="primary" @click="M.save()">
|
|
|
- 确认
|
|
|
+ 保存并退出
|
|
|
</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
@@ -208,24 +445,37 @@
|
|
|
|
|
|
<script>
|
|
|
import Pagination from '@/components/Pagination'
|
|
|
-import { fGet, fPost } from '@/api/rest'
|
|
|
+import { fGet, fPost, fSave } from '@/api/rest'
|
|
|
import { M } from '@/api/op'
|
|
|
+import DataSelect from '@/views/components/DataSelect/index'
|
|
|
+import fn from '@/api/fn'
|
|
|
|
|
|
export default {
|
|
|
- components: { Pagination },
|
|
|
+ components: { Pagination, DataSelect },
|
|
|
data() {
|
|
|
return {
|
|
|
M: new M(this),
|
|
|
+ fn,
|
|
|
URI: '/api/foods',
|
|
|
maxHeight: 600,
|
|
|
baseUnitOptions: [],
|
|
|
- tempList: [{},{}],
|
|
|
+ tempList: [{
|
|
|
+ _edit: true
|
|
|
+ },{}],
|
|
|
list: {
|
|
|
main: {
|
|
|
loading: true,
|
|
|
total: 0,
|
|
|
list: [],
|
|
|
render(row) {
|
|
|
+ row.modifiers = row.modifiers || []
|
|
|
+ row.nutrients = row.nutrients || []
|
|
|
+ row.modifiers && row.modifiers.forEach(v => v._edit = true)
|
|
|
+ row.nutrients && row.nutrients.forEach(v => {
|
|
|
+ v._edit = true
|
|
|
+ v._nutrientUnitOptions = []
|
|
|
+ })
|
|
|
+ row.cfs = row.cfs || []
|
|
|
return row
|
|
|
},
|
|
|
query: {
|
|
|
@@ -234,15 +484,32 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ calc: {
|
|
|
+ loading: false,
|
|
|
+ req: {
|
|
|
+ amt: undefined,
|
|
|
+ unitId: undefined,
|
|
|
+ unitName: undefined
|
|
|
+ },
|
|
|
+ rsp: {
|
|
|
+ amt: undefined,
|
|
|
+ unitName: undefined,
|
|
|
+ nvList: []
|
|
|
+ }
|
|
|
+ },
|
|
|
dlg: {
|
|
|
form: {
|
|
|
- infoTab: 'modifier',
|
|
|
+ infoTab: 'base',
|
|
|
visible: false,
|
|
|
title: '',
|
|
|
- data: {},
|
|
|
+ data: {
|
|
|
+ modifiers: [],
|
|
|
+ nutrients: []
|
|
|
+ },
|
|
|
saveLoading: false,
|
|
|
+ modifierUnitOptions: [],
|
|
|
rules: {
|
|
|
- category: [{ required: true, message: '类别不能为空', trigger: 'blur' }],
|
|
|
+ // type: [{ required: true, message: '请选择主/辅料', trigger: 'blur' }],
|
|
|
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }]
|
|
|
}
|
|
|
}
|
|
|
@@ -252,34 +519,128 @@ export default {
|
|
|
created() {
|
|
|
this.maxHeight = document.documentElement.clientHeight - 135
|
|
|
this.M.list()
|
|
|
- this.dlg.form.visible = true
|
|
|
},
|
|
|
methods: {
|
|
|
- loadBaseUnit() {
|
|
|
- fGet(this.URI, { baseUnit: true, size: 10000 }).then(res => {
|
|
|
- this.baseUnitOptions = res.data.map(v => {
|
|
|
- return {
|
|
|
- label: v.name,
|
|
|
- value: v.id
|
|
|
- }
|
|
|
+ // 加载详细信息
|
|
|
+ loadDetail(id) {
|
|
|
+ fGet(`${this.URI}/${id}`).then(res => {
|
|
|
+ const detail = {
|
|
|
+ ...res
|
|
|
+ }
|
|
|
+ detail.modifiers && detail.modifiers.forEach(v => v._edit = true)
|
|
|
+ detail.nutrients && detail.nutrients.forEach(v => {
|
|
|
+ v._edit = true
|
|
|
+ v._nutrientUnitOptions = []
|
|
|
})
|
|
|
+ this.dlg.form.data = detail
|
|
|
+ this.modifierUnitChange()
|
|
|
})
|
|
|
},
|
|
|
+ // 新增
|
|
|
create() {
|
|
|
+ this.dlg.form.modifierUnitOptions = []
|
|
|
this.M.create({ form: 'form', title: '新增', data: {} })
|
|
|
},
|
|
|
+ // 编辑
|
|
|
edit(row) {
|
|
|
+ this.dlg.form.modifierUnitOptions = []
|
|
|
this.M.edit({ form: 'form', title: 'name', row: row })
|
|
|
+ this.loadDetail(row.id)
|
|
|
},
|
|
|
- baseUnitChange() {
|
|
|
- if (!!this.dlg.form.data.baseUnitId) {
|
|
|
- const baseUnit = this.baseUnitOptions.find(v => v.value == this.dlg.form.data.baseUnitId)
|
|
|
- if (!!baseUnit) {
|
|
|
- this.dlg.form.data.baseUnitName = baseUnit.label
|
|
|
+ // 规格单位列表生成
|
|
|
+ modifierUnitChange() {
|
|
|
+ const modifierUnitOptions = []
|
|
|
+ const modifierUnitInclude = {}
|
|
|
+ this.dlg.form.data.modifiers.forEach(modifier => {
|
|
|
+ if (!!(modifier.unitName) && modifier.unitName.trim().length > 0) {
|
|
|
+ const unitName = modifier.unitName || ''
|
|
|
+ const name = modifier.name || ''
|
|
|
+ modifier.key = (unitName == name ? unitName : `${unitName}${name}`)
|
|
|
+ modifierUnitOptions.push({
|
|
|
+ label: modifier.key,
|
|
|
+ value: modifier.key
|
|
|
+ })
|
|
|
+ modifierUnitInclude[modifier.key] = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.dlg.form.data.modifiers.forEach(modifier => {
|
|
|
+ if (!!(modifier.toModifierName) && !modifierUnitInclude[modifier.toModifierName]) {
|
|
|
+ modifier.toModifierId = undefined
|
|
|
+ modifier.toModifierName = undefined
|
|
|
}
|
|
|
- } else {
|
|
|
- this.dlg.form.data.baseUnitName = undefined
|
|
|
+ })
|
|
|
+ this.dlg.form.modifierUnitOptions = modifierUnitOptions
|
|
|
+ },
|
|
|
+ // 添加规格
|
|
|
+ addModifier(row) {
|
|
|
+ row.modifiers.push({
|
|
|
+ _edit: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 删除规格
|
|
|
+ removeModifier(row, index) {
|
|
|
+ row.modifiers.splice(index, 1)
|
|
|
+ },
|
|
|
+ // 添加营养素
|
|
|
+ addNutrient(row) {
|
|
|
+ row.nutrients.push({
|
|
|
+ _edit: true,
|
|
|
+ _nutrientUnitOptions: []
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 删除营养素
|
|
|
+ removeNutrient(row, index) {
|
|
|
+ row.nutrients.splice(index, 1)
|
|
|
+ },
|
|
|
+ // 营养素选择
|
|
|
+ nutrientSelect(nutrient, row) {
|
|
|
+ row._nutrientUnitOptions = []
|
|
|
+ if (nutrient._data && nutrient._data.unitName) {
|
|
|
+ row._nutrientUnitOptions.push({
|
|
|
+ value: nutrient._data.unitId == 'CUSTOM_UNIT' ? nutrient._data.unitName : nutrient._data.unitId,
|
|
|
+ label: nutrient._data.unitName
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (nutrient._data && nutrient._data.optionUnits) {
|
|
|
+ nutrient._data.optionUnits.forEach(optionUnit => {
|
|
|
+ row._nutrientUnitOptions.push({
|
|
|
+ value: optionUnit.unitId == 'CUSTOM_UNIT' ? optionUnit.name : optionUnit.unitId,
|
|
|
+ label: optionUnit.name
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
+ },
|
|
|
+ // 食物信息标签切换
|
|
|
+ foodInfoTabClick(tab) {
|
|
|
+ },
|
|
|
+ // 计算营养素摄入量
|
|
|
+ calcNvIn() {
|
|
|
+ this.calc.loading = true
|
|
|
+ fPost(`/api/foods/${this.dlg.form.data.id}`, this.calc.req).then(res => {
|
|
|
+ this.calc.rsp = res
|
|
|
+ }).finally(() => {
|
|
|
+ this.calc.loading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 刷新 CF
|
|
|
+ refreshCf() {
|
|
|
+ fGet(`/api/foods/${this.dlg.form.data.id}/cfs`).then(res => {
|
|
|
+ this.dlg.form.data.cfs = res || []
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 保存 CF
|
|
|
+ saveCf(cf) {
|
|
|
+ fPost(`/api/foods/${this.dlg.form.data.id}/cfs`, cf)
|
|
|
+ },
|
|
|
+ // 仅保存
|
|
|
+ onlySave() {
|
|
|
+ this.dlg.form.saveLoading = true
|
|
|
+ fSave(this.URI, this.dlg.form.data).then(res => {
|
|
|
+ this.$message.success('保存成功')
|
|
|
+ this.refreshCf()
|
|
|
+ }).finally(() => {
|
|
|
+ this.dlg.form.saveLoading = false
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|