Browse Source

营养素相关增加信息来源

wangyang 5 năm trước cách đây
mục cha
commit
c20e973add
2 tập tin đã thay đổi với 60 bổ sung4 xóa
  1. 39 2
      src/views/food/nutrient.vue
  2. 21 2
      src/views/nutrientTemplate/detail.vue

+ 39 - 2
src/views/food/nutrient.vue

@@ -40,6 +40,12 @@
         :fetch-suggestions="queryUnits"
         placeholder="单位关键词"
       />
+      信息来源:
+      <el-autocomplete
+        v-model="params.source"
+        :fetch-suggestions="querySources"
+        placeholder="请输入信息来源"
+      />
       <el-button
         class="filter-item"
         style="margin-left: 10px;"
@@ -56,7 +62,7 @@
       border
       fit
       highlight-current-row
-      style="width: 60%;margin-top: 10px"
+      style="width: 100%;margin-top: 10px"
     >
       <el-table-column type="index" label="序号" align="center" width="60px" />
       <el-table-column label="营养素名称" align="center">
@@ -96,6 +102,26 @@
           <span v-else>{{ row.nvSpecUnit }}</span>
         </template>
       </el-table-column>
+      <el-table-column label="信息来源" align="center" width="200">
+        <template slot-scope="{row}">
+          <template v-if="row.edit">
+            <el-autocomplete
+              v-model="row.source"
+              :fetch-suggestions="querySources"
+              placeholder="请输入信息来源"
+            />
+          </template>
+          <span v-else>{{ row.source }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="信息来源备注" align="center" width="200">
+        <template slot-scope="{row}">
+          <template v-if="row.edit">
+            <el-input type="text" :rows="2" v-model="row.sourceNote" />
+          </template>
+          <span v-else>{{ row.sourceNote }}</span>
+        </template>
+      </el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="320" fixed="right">
         <template slot-scope="{row}">
           <template v-if="row.edit">
@@ -156,7 +182,8 @@ export default {
       nutrients: [],
       params: {},
       loading: false,
-      unitLoading: false
+      unitLoading: false,
+      sources: [{ value: "营养标签" }, { value: "食品官方资料" }, { value: "计算值" }]
     }
   },
   methods: {
@@ -223,6 +250,16 @@ export default {
       }).catch(res => {
         this.$message.error(res.data.message)
       })
+    },
+    querySources(query, cb) {
+      let sources = this.sources
+      let results = query ? sources.filter(this.sourcesFilter(query)) : sources;
+      cb(results)
+    },
+    sourcesFilter(query) {
+      return (restaurant) => {
+        return (restaurant.value.toLowerCase().indexOf(query.toLowerCase()) === 0);
+      };
     }
   }
 }

+ 21 - 2
src/views/nutrientTemplate/detail.vue

@@ -35,6 +35,12 @@
         :fetch-suggestions="queryUnits"
         placeholder="单位关键词"
       />
+      信息来源:
+      <el-autocomplete
+        v-model="params.source"
+        :fetch-suggestions="querySources"
+        placeholder="请输入信息来源"
+      />
       <el-button
         class="filter-item"
         style="margin-left: 10px;"
@@ -51,7 +57,7 @@
         border
         fit
         highlight-current-row
-        style="width: 60%;margin-top: 10px"
+        style="width: 100%;margin-top: 10px"
       >
         <el-table-column type="index" label="序号" align="center" width="60px" />
         <el-table-column label="营养素名称" align="center">
@@ -96,6 +102,8 @@
             <span v-else>{{ row.nvSpecUnit }}</span>
           </template>
         </el-table-column>
+
+
         <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="320px">
           <template slot-scope="{row}">
             <template v-if="row.edit">
@@ -152,7 +160,8 @@ export default {
       nutrients: [],
       params: {},
       loading: false,
-      unitLoading: false
+      unitLoading: false,
+      sources: [{ value: "营养标签" }, { value: "食品官方资料" }, { value: "计算值" }]
     }
   },
   created() {
@@ -241,6 +250,16 @@ export default {
         this.fetchNutrients()
         this.$message.error(res.data.message)
       })
+    },
+    querySources(query, cb) {
+      let sources = this.sources
+      let results = query ? sources.filter(this.sourcesFilter(query)) : sources;
+      cb(results)
+    },
+    sourcesFilter(query) {
+      return (restaurant) => {
+        return (restaurant.value.toLowerCase().indexOf(query.toLowerCase()) === 0);
+      };
     }
   }
 }