wangyang 5 years ago
parent
commit
78d7102547

+ 16 - 2
src/router/config.js

@@ -40,11 +40,25 @@ export const asyncRouterMap = [
         hidden: true
       },
       {
-        path: ':id/addNutrient',
+        path: ':id/nutrient',
         name: '营养素关联',
-        component: () => import('@/views/food/addNutrient'),
+        component: () => import('@/views/food/nutrient'),
         meta: { title: '营养素关联', icon: 'dashboard' },
         hidden: true
+      },
+      {
+        path: ':id/unit',
+        name: '单位管理',
+        component: () => import('@/views/food/unit'),
+        meta: { title: '单位管理' },
+        hidden: true
+      },
+      {
+        path: ':id/modifier',
+        name: '规格管理',
+        component: () => import('@/views/food/modifier'),
+        meta: { title: '规格管理' },
+        hidden: true
       }
     ]
   },

+ 10 - 1
src/views/food/components/FoodDetail.vue

@@ -168,6 +168,12 @@ export default {
   methods: {
     fetchData(id) {
       getDetail(id).then(res => {
+        if (res.data.nvSpecUnit) {
+          this.units.push({ id: res.data.nvSpecUnit, name: res.data.nvSpecUnitName })
+        }
+        if (res.data.inInitUnit && res.data.nvSpecUnitName !== res.data.inInitUnitName) {
+          this.units.push({ id: res.data.inInitUnit, name: res.data.inInitUnitName })
+        }
         this.postForm = res.data
       })
     },
@@ -240,8 +246,11 @@ export default {
     queryUnits(query) {
       getUnits({ query }).then(res => {
         this.units = res.data.list
+        // console.log(this.units)
+        // for (let i=0; i < res.data.list.length; i++){
+        //   this.units.add({ id: res.data.list[i].id, name: res.data.list[i].name })
+        // }
       }).catch(() => {
-        this.units = []
       })
     },
     queryTemplates(query) {

+ 17 - 5
src/views/food/index.vue

@@ -44,7 +44,7 @@
           <span>{{ row.name }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="描述" align="center">
+      <el-table-column label="描述" align="center" width="200">
         <template slot-scope="{row}">
           <span>{{ row.description }}</span>
         </template>
@@ -94,14 +94,20 @@
           <span>{{ row.updateTime }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+      <el-table-column label="操作" align="center" class-name="small-padding" width="500">
         <template slot-scope="{row,$index}">
           <el-button type="primary" size="mini" @click="handleUpdate(row)">
             更新
           </el-button>
-          <el-button type="primary" size="mini" @click="addNutrient(row)">
+          <el-button type="primary" size="mini" @click="manageNutrients(row)">
             营养素关联
           </el-button>
+          <el-button type="primary" size="mini" @click="manageUnits(row)">
+            单位管理
+          </el-button>
+          <el-button type="primary" size="mini" @click="manageModifiers(row)">
+            规格管理
+          </el-button>
           <el-button size="mini" type="danger" @click="handleDelete(row, $index)">
             删除
           </el-button>
@@ -162,8 +168,14 @@ export default {
     handleUpdate(row) {
       this.$router.push({ path: '/food/edit/' + row.id })
     },
-    addNutrient(row) {
-      this.$router.push( { path: `/food/${row.id}/addNutrient` })
+    manageNutrients(row) {
+      this.$router.push( { path: `/food/${row.id}/nutrient` })
+    },
+    manageUnits(row) {
+      this.$router.push({ path: `/food/${row.id}/unit` })
+    },
+    manageModifiers(row) {
+      this.$router.push({ path: `/food/${row.id}/modifier` })
     },
     handleDelete(row, index) {
       remove(row.id).then(res => {

+ 13 - 0
src/views/food/modifier.vue

@@ -0,0 +1,13 @@
+<template>
+
+</template>
+
+<script>
+  export default {
+    name: 'FoodModifier'
+  }
+</script>
+
+<style scoped>
+
+</style>

+ 0 - 0
src/views/food/addNutrient.vue → src/views/food/nutrient.vue


+ 13 - 0
src/views/food/unit.vue

@@ -0,0 +1,13 @@
+<template>
+
+</template>
+
+<script>
+  export default {
+    name: 'FoodUnit'
+  }
+</script>
+
+<style scoped>
+
+</style>