|
|
@@ -59,19 +59,63 @@
|
|
|
<span>{{ row.nutrientName }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="营养素计量单位" align="center" width="80px">
|
|
|
+ <el-table-column label="营养素计量单位" align="center" width="150px">
|
|
|
<template slot-scope="{row}">
|
|
|
- <span>{{ row.unit }}</span>
|
|
|
+ <template v-if="row.edit">
|
|
|
+ <el-autocomplete
|
|
|
+ class="inline-input"
|
|
|
+ v-model="row.unit"
|
|
|
+ :fetch-suggestions="queryUnits"
|
|
|
+ placeholder="单位关键词"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <span v-else>{{ row.unit }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="Nv_Spec" align="center" width="300px">
|
|
|
+ <el-table-column label="Nv_Spec" align="center" width="100px">
|
|
|
<template slot-scope="{row}">
|
|
|
- <span>{{ row.nvSpec + row.nvSpecUnit }}</span>
|
|
|
+ <template v-if="row.edit">
|
|
|
+ <el-input
|
|
|
+ v-model="row.nvSpec"
|
|
|
+ class="filter-item"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <span v-else>{{ row.nvSpec }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100px">
|
|
|
+ <el-table-column label="Nv_Spec单位" align="center" width="150px">
|
|
|
<template slot-scope="{row}">
|
|
|
- <el-button size="mini" type="danger" @click="removeNutrient(row)">
|
|
|
+ <template v-if="row.edit">
|
|
|
+ <el-autocomplete
|
|
|
+ class="inline-input"
|
|
|
+ v-model="row.nvSpecUnit"
|
|
|
+ :fetch-suggestions="queryUnits"
|
|
|
+ placeholder="单位关键词"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <span v-else>{{ row.nvSpecUnit }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="160px">
|
|
|
+ <template slot-scope="{row}">
|
|
|
+ <el-button
|
|
|
+ v-if="row.edit"
|
|
|
+ type="success"
|
|
|
+ size="mini"
|
|
|
+ @click="confirmEdit(row)"
|
|
|
+ >
|
|
|
+ 提交
|
|
|
+ </el-button>
|
|
|
+ <el-button v-else size="mini" type="primary" @click="row.edit=true">编辑</el-button>
|
|
|
+ <el-button
|
|
|
+ v-if="row.edit"
|
|
|
+ type="danger"
|
|
|
+ size="mini"
|
|
|
+ @click="fetchNutrients"
|
|
|
+ >
|
|
|
+ 取消
|
|
|
+ </el-button>
|
|
|
+ <el-button v-else size="mini" type="danger" @click="removeNutrient(row)">
|
|
|
删除
|
|
|
</el-button>
|
|
|
</template>
|
|
|
@@ -83,8 +127,8 @@
|
|
|
|
|
|
<script>
|
|
|
import { getList } from '@/api/nutrient'
|
|
|
-import { getList as getUnits, getBaseUnits } from '@/api/unit'
|
|
|
-import { getNutrients, addTemplateNutrient, removeNutrient } from '@/api/nutrientTemplate'
|
|
|
+import { getList as getUnits } from '@/api/unit'
|
|
|
+import { getNutrients, addTemplateNutrient, updateTemplateNutrient, removeNutrient } from '@/api/nutrientTemplate'
|
|
|
|
|
|
export default {
|
|
|
name: 'Detail',
|
|
|
@@ -131,6 +175,23 @@ export default {
|
|
|
this.$message.error('未选择营养素')
|
|
|
}
|
|
|
},
|
|
|
+ confirmEdit(row) {
|
|
|
+ updateTemplateNutrient(this.templateId, row.nutrientId, row).then(res => {
|
|
|
+ this.fetchNutrients()
|
|
|
+ this.$notify.success('提交成功')
|
|
|
+ }).catch(res => {
|
|
|
+ this.$message.error(res.data.message)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ cancelEdit(row) {
|
|
|
+ this.$set(row, 'edit', null)
|
|
|
+ console.log(row)
|
|
|
+ if (row.edit){
|
|
|
+ console.log('1111111')
|
|
|
+ } else {
|
|
|
+ console.log('2222222222')
|
|
|
+ }
|
|
|
+ },
|
|
|
queryNutrients(query) {
|
|
|
getList({ query }).then(res => {
|
|
|
this.nutrients = res.data.list
|