|
|
@@ -254,7 +254,7 @@
|
|
|
<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-select v-model="row.toModifierName" class="filter-item" 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>
|
|
|
]
|
|
|
@@ -295,6 +295,7 @@
|
|
|
<span v-else>
|
|
|
-
|
|
|
</span>
|
|
|
+
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column width="90" align="center">
|
|
|
@@ -310,7 +311,14 @@
|
|
|
</el-tab-pane>
|
|
|
<el-tab-pane label="营养素" name="nutrient">
|
|
|
<div style="margin-bottom:5px;">
|
|
|
- <el-button size="mini" type="primary" plain @click="addNutrient(dlg.form.data)">添加</el-button>
|
|
|
+ <span>
|
|
|
+ <el-button size="mini" type="primary" plain @click="addNutrient(dlg.form.data)">添加</el-button>
|
|
|
+ </span>
|
|
|
+ <el-select v-model="dlg.form.selectedNutrientTemplate" style="margin-left: 10%; display: float" @input.native="getNutrienttemplateList($event)" filterable placeholder="请输入检索词">
|
|
|
+ <el-option v-for="opt in dlg.form.nutrientTemplateOptions" :key="opt.id" :label="opt.value" :value="opt.name" />
|
|
|
+ </el-select>
|
|
|
+ <el-button v-model="dlg.form.nutrientTemplateTable" size="mini" type="primary" plain @click="importNutrientTemplate()">导入营养素模版</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" />
|
|
|
@@ -348,15 +356,8 @@
|
|
|
<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-option v-for="opt in dlg.form.data.nutrients" :key="opt.nvUnitId" :label="opt.nvUnit" :value="opt.nvUnitId" />
|
|
|
</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
|
|
|
@@ -611,7 +612,7 @@ export default {
|
|
|
// 添加规格
|
|
|
addModifier(row) {
|
|
|
row.modifiers.push({
|
|
|
- _edit: true
|
|
|
+ _edit: true,
|
|
|
})
|
|
|
},
|
|
|
// 删除规格
|
|
|
@@ -629,6 +630,74 @@ export default {
|
|
|
removeNutrient(row, index) {
|
|
|
row.nutrients.splice(index, 1)
|
|
|
},
|
|
|
+ // 导入营养素模版
|
|
|
+ importNutrientTemplate() {
|
|
|
+ console.log(this.dlg.form.selectedNutrientTemplate)
|
|
|
+
|
|
|
+ if (this.dlg.form.selectedNutrientTemplate == undefined) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.dlg.form.nutrientTemplateOptions.forEach(opt => {
|
|
|
+ if (opt.name == this.dlg.form.selectedNutrientTemplate) {
|
|
|
+ this.dlg.form.selectedNutrientTemplateId = opt.id
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ fGet(`/api/nutrient-templates/${this.dlg.form.selectedNutrientTemplateId}/nutrients`, {}).then(res => {
|
|
|
+ console.log(res)
|
|
|
+
|
|
|
+ if (res == undefined) {return}
|
|
|
+
|
|
|
+ let existed = false
|
|
|
+ // 渲染营养素
|
|
|
+ res.forEach(nv => {
|
|
|
+ // 筛选营养素
|
|
|
+ this.dlg.form.data.nutrients.forEach(existNv => {
|
|
|
+ console.log(nv.nutrientId)
|
|
|
+ console.log(existNv)
|
|
|
+ if (nv.nutrientId == existNv.nutrientId) {
|
|
|
+ existed = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (! existed) {
|
|
|
+ this.dlg.form.data.nutrients.push({
|
|
|
+ _edit: true,
|
|
|
+ _nutrientUnitOptions: [],
|
|
|
+ nutrientId: nv.nutrientId,
|
|
|
+ nutrientName: nv.nutrientName,
|
|
|
+ nvUnit: nv.unit,
|
|
|
+ nvSpec: nv.nvSpec,
|
|
|
+ nvSpecUnit: nv.nvSpecUnit,
|
|
|
+ nvSpecUnitId: nv.nvSpecUnitId,
|
|
|
+ nvUnitId: nv.unitId
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ console.log(this.dlg.form.data.nutrients)
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ // 导入营养素
|
|
|
+ importNutrientFromTemplate(row) {
|
|
|
+ row.nutrients.push({
|
|
|
+ _edit: true,
|
|
|
+ _nutrientUnitOptions: []
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getNutrienttemplateList(e) {
|
|
|
+ console.log(1)
|
|
|
+ fGet(`/api/nutrient-templates`, {keyword: e.target.value}).then(res => {
|
|
|
+ console.log(2)
|
|
|
+ this.dlg.form.nutrientTemplateOptions = res
|
|
|
+ console.log(res)
|
|
|
+
|
|
|
+ })
|
|
|
+ this.$forceUpdate()
|
|
|
+ },
|
|
|
// 营养素选择
|
|
|
nutrientSelect(nutrient, row) {
|
|
|
row._nutrientUnitOptions = []
|