|
|
@@ -157,65 +157,65 @@
|
|
|
<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"
|
|
|
+ url="/api/volume-units"
|
|
|
placeholder="体积单位"
|
|
|
:value.sync="dlg.form.data.densityVolumeUnitId"
|
|
|
:label.sync="dlg.form.data.densityVolumeUnit"
|
|
|
width="130px;margin-left:1px;"
|
|
|
/>
|
|
|
+ <span style="color:red;font-size:14px;font-weight:700;"> = </span>
|
|
|
+ <el-input v-model="dlg.form.data.densityAmt" placeholder="质量" style="width:60px;" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/mass-units"
|
|
|
+ placeholder="质量单位"
|
|
|
+ :value.sync="dlg.form.data.densityUnitId"
|
|
|
+ :label.sync="dlg.form.data.densityUnit"
|
|
|
+ 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;" />
|
|
|
+ <el-input v-model="dlg.form.data.bulkDensityVolumeAmt" placeholder="体积" style="width:60px;" />
|
|
|
<DataSelect
|
|
|
- url="/api/units"
|
|
|
- placeholder="堆密度单位"
|
|
|
- :value.sync="dlg.form.data.bulkDensityUnitId"
|
|
|
- :label.sync="dlg.form.data.bulkDensityUnit"
|
|
|
+ url="/api/volume-units"
|
|
|
+ placeholder="体积单位"
|
|
|
+ :value.sync="dlg.form.data.bulkDensityVolumeUnitId"
|
|
|
+ :label.sync="dlg.form.data.bulkDensityVolumeUnit"
|
|
|
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;" />
|
|
|
+ <el-input v-model="dlg.form.data.bulkDensityAmt" placeholder="堆密度" style="width:60px;" />
|
|
|
<DataSelect
|
|
|
url="/api/units"
|
|
|
- placeholder="体积单位"
|
|
|
- :value.sync="dlg.form.data.bulkDensityVolumeUnitId"
|
|
|
- :label.sync="dlg.form.data.bulkDensityVolumeUnit"
|
|
|
+ placeholder="堆密度单位"
|
|
|
+ :value.sync="dlg.form.data.bulkDensityUnitId"
|
|
|
+ :label.sync="dlg.form.data.bulkDensityUnit"
|
|
|
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"
|
|
|
+ url="/api/volume-units"
|
|
|
placeholder="体积单位"
|
|
|
:value.sync="dlg.form.data.calcDensityVolumeUnitId"
|
|
|
:label.sync="dlg.form.data.calcDensityVolumeUnit"
|
|
|
width="130px;margin-left:1px;"
|
|
|
/>
|
|
|
+ <span style="color:red;font-size:14px;font-weight:700;"> = </span>
|
|
|
+ <el-input v-model="dlg.form.data.calcDensityAmt" placeholder="质量" style="width:60px;" />
|
|
|
+ <DataSelect
|
|
|
+ url="/api/mass-units"
|
|
|
+ placeholder="质量单位"
|
|
|
+ :value.sync="dlg.form.data.calcDensityUnitId"
|
|
|
+ :label.sync="dlg.form.data.calcDensityUnit"
|
|
|
+ width="130px;margin-left:1px;"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
@@ -385,6 +385,9 @@
|
|
|
</el-table>
|
|
|
</el-tab-pane>
|
|
|
<el-tab-pane label="CF" name="cf">
|
|
|
+ <el-tag v-if="dlg.form.data.calcDensityAmt>0&&dlg.form.data.calcDensityVolumeAmt>0" style="margin-bottom:5px;">
|
|
|
+ {{ dlg.form.data.calcDensityAmt }}{{ dlg.form.data.calcDensityUnit }}={{ dlg.form.data.calcDensityVolumeAmt }}{{ dlg.form.data.calcDensityVolumeUnit }}
|
|
|
+ </el-tag>
|
|
|
<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="源单位">
|
|
|
@@ -399,9 +402,21 @@
|
|
|
</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>
|
|
|
+ <span v-if="row.edit">
|
|
|
+ <span v-if="row._edit">
|
|
|
+ 1 {{ row.fromUnit }} *
|
|
|
+ <el-input v-model="row.cf" style="width:100px;margin-right:10px;" />
|
|
|
+ =1 {{ row.toUnit }}
|
|
|
+ <i class="el-icon-check" style="cursor:pointer;color:green;font-size:15px;" @click="saveCf(row)" />
|
|
|
+ </span>
|
|
|
+ <span v-else>
|
|
|
+ 1 {{ row.fromUnit }} * {{ row.cf }} = 1 {{ row.toUnit }}
|
|
|
+ <i class="el-icon-edit" style="cursor:pointer;color:blue;font-size:15px;" @click="row._edit=true" />
|
|
|
+ </span>
|
|
|
+ </span>
|
|
|
+ <span v-else>
|
|
|
+ 1 {{ row.fromUnit }} * {{ row.cf }} = 1 {{ row.toUnit }}
|
|
|
+ </span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
@@ -476,6 +491,9 @@ export default {
|
|
|
v._nutrientUnitOptions = []
|
|
|
})
|
|
|
row.cfs = row.cfs || []
|
|
|
+ row.cfs && row.cfs.forEach(v => {
|
|
|
+ v._edit = false
|
|
|
+ })
|
|
|
return row
|
|
|
},
|
|
|
query: {
|
|
|
@@ -532,6 +550,9 @@ export default {
|
|
|
v._edit = true
|
|
|
v._nutrientUnitOptions = []
|
|
|
})
|
|
|
+ detail.cfs && detail.cfs.forEach(v => {
|
|
|
+ v._edit = false
|
|
|
+ })
|
|
|
this.dlg.form.data = detail
|
|
|
this.modifierUnitChange()
|
|
|
})
|
|
|
@@ -547,21 +568,30 @@ export default {
|
|
|
this.M.edit({ form: 'form', title: 'name', row: row })
|
|
|
this.loadDetail(row.id)
|
|
|
},
|
|
|
+ // 自定义单位判断
|
|
|
+ isCustomUnit(id, name) {
|
|
|
+ return !!name && name.trim().length > 0 && (!id || id == 'CUSTOM_UNIT' || id.length == 0 || id == name)
|
|
|
+ },
|
|
|
// 规格单位列表生成
|
|
|
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 unitId = modifier.unitId || ''
|
|
|
+ const unitName = modifier.unitName || ''
|
|
|
+ if (this.isCustomUnit(unitId, unitName)) {
|
|
|
const name = modifier.name || ''
|
|
|
- modifier.key = (unitName == name ? unitName : `${unitName}${name}`)
|
|
|
- modifierUnitOptions.push({
|
|
|
- label: modifier.key,
|
|
|
- value: modifier.key
|
|
|
- })
|
|
|
- modifierUnitInclude[modifier.key] = true
|
|
|
- }
|
|
|
+ if (!!(modifier.unitName) && modifier.unitName.trim().length > 0) {
|
|
|
+ modifier.key = (unitName == name ? unitName : `${unitName}${name}`)
|
|
|
+ modifierUnitOptions.push({
|
|
|
+ label: modifier.key,
|
|
|
+ value: modifier.key
|
|
|
+ })
|
|
|
+ modifierUnitInclude[modifier.key] = true
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ modifier.key = unitName
|
|
|
+ }
|
|
|
})
|
|
|
this.dlg.form.data.modifiers.forEach(modifier => {
|
|
|
if (!!(modifier.toModifierName) && !modifierUnitInclude[modifier.toModifierName]) {
|
|
|
@@ -625,12 +655,18 @@ export default {
|
|
|
// 刷新 CF
|
|
|
refreshCf() {
|
|
|
fGet(`/api/foods/${this.dlg.form.data.id}/cfs`).then(res => {
|
|
|
- this.dlg.form.data.cfs = res || []
|
|
|
+ this.dlg.form.data.cfs = res.map(v => {
|
|
|
+ v._edit = false
|
|
|
+ return v
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
// 保存 CF
|
|
|
saveCf(cf) {
|
|
|
- fPost(`/api/foods/${this.dlg.form.data.id}/cfs`, cf)
|
|
|
+ fPost(`/api/foods/${this.dlg.form.data.id}/cfs`, cf).then(res => {
|
|
|
+ this.refreshCf()
|
|
|
+ })
|
|
|
+ cf._edit = false
|
|
|
},
|
|
|
// 仅保存
|
|
|
onlySave() {
|