浏览代码

调整营养素模板相关页面功能

wangyang 5 年之前
父节点
当前提交
98823a16a3
共有 4 个文件被更改,包括 241 次插入227 次删除
  1. 17 13
      src/views/nutrient/index.vue
  2. 106 95
      src/views/nutrientTemplate/detail.vue
  3. 103 106
      src/views/nutrientTemplate/index.vue
  4. 15 13
      src/views/unit/index.vue

+ 17 - 13
src/views/nutrient/index.vue

@@ -16,24 +16,25 @@
         style="margin: 0 10px 20px 0; float: right;"
         type="success"
         icon="el-icon-circle-plus-outline"
-        @click="handleCreateOrUpdate('create')">
+        @click="handleCreateOrUpdate('create')"
+      >
         新建
       </el-button>
     </div>
 
     <el-table
+      ref="table"
       :key="tableKey"
       v-loading="listLoading"
       :data="list"
       border
       fit
       highlight-current-row
-      ref="table"
     >
       <el-table-column type="index" label="序号" align="center" width="60" />
       <el-table-column label="图片" align="center" width="180">
         <template slot-scope="{row}">
-          <el-image style="width: 150px; height: 180px" :src="row.coverPic" fit="contain" v-if="row.coverPic" />
+          <el-image v-if="row.coverPic" style="width: 150px; height: 180px" :src="row.coverPic" fit="contain" />
         </template>
       </el-table-column>
       <el-table-column label="自定义ID" align="center" width="100">
@@ -142,7 +143,7 @@
           <el-radio v-model="params.recommendType" :label="1">范围</el-radio>
           <el-radio v-model="params.recommendType" :label="2">无</el-radio>
         </el-form-item>
-        <el-form-item label="推荐量单位" prop="recommendUnit" v-if="params.recommendType!==2">
+        <el-form-item v-if="params.recommendType!==2" label="推荐量单位" prop="recommendUnit">
           <el-select
             v-model="params.recommendUnit"
             filterable
@@ -150,17 +151,18 @@
             reserve-keyword
             placeholder="请选择推荐量单位"
             :remote-method="queryUnits"
-            :loading="loading">
+            :loading="loading"
+          >
             <el-option v-for="item in units" :key="item.id" :label="item.name" :value="item.name" />
           </el-select>
         </el-form-item>
-        <el-form-item label="每日推荐摄入量" v-if="params.recommendType===0" prop="recommend">
+        <el-form-item v-if="params.recommendType===0" prop="recommend" label="每日推荐摄入量">
           <el-input v-model="params.recommend" placeholder="每日推荐摄入量" />
         </el-form-item>
-        <el-form-item label="每日推荐摄入量范围-开始值" v-if="params.recommendType===1" prop="recommendBegin">
+        <el-form-item v-if="params.recommendType===1" prop="recommendBegin" label="每日推荐摄入量范围-开始值">
           <el-input v-model="params.recommendBegin" placeholder="每日推荐摄入量范围-开始值" />
         </el-form-item>
-        <el-form-item label="每日推荐摄入量范围-截止值" v-if="params.recommendType===1" prop="recommendEnd">
+        <el-form-item v-if="params.recommendType===1" prop="recommendEnd" label="每日推荐摄入量范围-截止值">
           <el-input v-model="params.recommendEnd" placeholder="每日推荐摄入量范围-截止值" />
         </el-form-item>
         <el-form-item label="上级营养素" prop="parentId">
@@ -171,12 +173,13 @@
             reserve-keyword
             placeholder="请选择上级营养素"
             :remote-method="queryNutrients"
-            :loading="loading">
+            :loading="loading"
+          >
             <el-option v-for="item in parentNutrients" :key="item.id" :label="item.name" :value="item.id" />
           </el-select>
         </el-form-item>
         <el-form-item label="营养素图片" prop="coverPic">
-          <single-image :value="params.coverPic" :show-preview="true" @success="updateFile" style="width: 100%" />
+          <single-image :value="params.coverPic" :show-preview="true" style="width: 100%" @success="updateFile" />
         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
@@ -197,7 +200,7 @@ import SingleImage from '@/components/Upload/SingleImage'
 import { getList, update, remove, create, updateSortOrder } from '@/api/nutrient'
 import { getList as getUnits } from '@/api/unit'
 
-const recommendTypes = { 0: '值', 1: '范围', 2: '无'}
+const recommendTypes = { 0: '值', 1: '范围', 2: '无' }
 
 export default {
   name: 'NutrientList',
@@ -245,6 +248,7 @@ export default {
         this.listLoading = false
       }).catch(() => {
         this.$message.error('获取数据失败')
+        this.listLoading = false
       })
     },
     handleCreateOrUpdate(dialogStatus, row) {
@@ -266,7 +270,7 @@ export default {
       })
     },
     createOrUpdateData() {
-      let resultPromise = this.dialogStatus === 'create' ? create(this.params) : update(this.params.id, this.params)
+      const resultPromise = this.dialogStatus === 'create' ? create(this.params) : update(this.params.id, this.params)
       resultPromise.then(res => {
         this.$message.success('提交成功')
         this.fetchData()
@@ -301,7 +305,7 @@ export default {
     },
     updateSort(row, type) {
       updateSortOrder(row.id, { type }).then(res => {
-        this.$message.success("提交成功")
+        this.$message.success('提交成功')
         this.fetchData()
       }).catch(res => {
         this.$message.error(res.data.message)

+ 106 - 95
src/views/nutrientTemplate/detail.vue

@@ -3,6 +3,7 @@
     <div class="filter-container">
       营养素:
       <el-select
+        ref="nutrientSelect"
         v-model="params.nutrientId"
         filterable
         remote
@@ -11,39 +12,49 @@
         placeholder="请输入营养素关键词"
         :remote-method="queryNutrients"
         :loading="loading"
-        ref="nutrientSelect"
       >
-        <el-option
-          v-for="item in nutrients"
-          :key="item.id"
-          :label="item.name"
-          :value="item.id">
-        </el-option>
+        <el-option v-for="item in nutrients" :key="item.id" :label="item.name" :value="item.id" />
       </el-select>
-      营养素计量:
+      营养素计量单位:
+      <el-select
+        v-model="params.unit"
+        style="width: 120px;margin-left: 10px;"
+        class="filter-item"
+        filterable
+        remote
+        reserve-keyword
+        placeholder="单位关键词"
+        :loading="unitLoading"
+        :remote-method="queryUnits"
+      >
+        <el-option v-for="item in units" :key="`nutrient${item.id}`" :label="item.name" :value="item.name" />
+      </el-select>
+      Nv_Spec计量:
       <el-input
-        v-model="params.quantity"
+        v-model="params.nvSpec"
         style="width: 80px;"
         class="filter-item"
       />
+      Nv_Spec计量单位:
       <el-select
-        v-model="params.unit"
-        style="width: 300px;margin-left: 10px;"
+        v-model="params.nvSpecUnit"
+        style="width: 120px;margin-left: 10px;"
         class="filter-item"
         filterable
         remote
         reserve-keyword
-        placeholder="请输入单位关键词"
+        placeholder="单位关键词"
         :loading="unitLoading"
         :remote-method="queryUnits"
       >
-        <el-option v-for="item in units" :key="`nutrient${item.id}`" :label="item.name" :value="item.id" />
+        <el-option v-for="item in units" :key="`nutrient${item.id}`" :label="item.name" :value="item.name" />
       </el-select>
       <el-button
         class="filter-item"
         style="margin-left: 10px;"
         type="primary"
-        @click="addNutrient">
+        @click="addNutrient"
+      >
         添加
       </el-button>
 
@@ -62,18 +73,18 @@
             <span>{{ row.nutrientName }}</span>
           </template>
         </el-table-column>
-        <el-table-column label="营养素计量" align="center" width="80px">
+        <el-table-column label="营养素计量单位" align="center" width="80px">
           <template slot-scope="{row}">
-            <span>{{ row.quantity }}</span>
+            <span>{{ row.unit }}</span>
           </template>
         </el-table-column>
-        <el-table-column label="单位" align="center" width="300px">
+        <el-table-column label="Nv_Spec" align="center" width="300px">
           <template slot-scope="{row}">
-            <span>{{ row.unitName }}</span>
+            <span>{{ row.nvSpec + row.nvSpecUnit }}</span>
           </template>
         </el-table-column>
         <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100px">
-          <template slot-scope="{row,$index}">
+          <template slot-scope="{row}">
             <el-button size="mini" type="danger" @click="removeNutrient(row)">
               删除
             </el-button>
@@ -85,90 +96,90 @@
 </template>
 
 <script>
-  import { getList } from '@/api/nutrient'
-  import { getList as getUnits } from '@/api/unit'
-  import { getNutrients, addTemplateNutrient, removeNutrient } from '@/api/nutrientTemplate'
+import { getList } from '@/api/nutrient'
+import { getList as getUnits } from '@/api/unit'
+import { getNutrients, addTemplateNutrient, removeNutrient } from '@/api/nutrientTemplate'
 
-  export default {
-    name: 'Detail',
-    components: {},
-    created() {
-      this.templateId = this.$route.params.id
-      if (!this.templateId) {
-        this.$message.error("未获取到模板")
-        this.$router.push({ path: '/nutrient-template' })
-      }
-      this.fetchNutrients()
-      this.$nextTick(() => {
-        this.$refs['nutrientSelect'].focus()
-      })
-    },
-    data() {
-      return {
-        templateId: '',
-        tableKey: 0,
-        listLoading: false,
-        list: [],
-        units: [],
-        nutrients: [],
-        params: {},
-        loading: false,
-        unitLoading: false
-      }
-    },
-    methods: {
-      addNutrient() {
-        if (this.params.nutrientId) {
-          addTemplateNutrient(this.templateId, this.params).then(res => {
-            this.fetchNutrients()
-            this.$message.success("添加成功")
-            this.params = {}
-            this.$nextTick(() => {
-              this.$refs['nutrientSelect'].focus()
-            })
-          }).catch(res => {
-            this.$message.error(res.data.message)
-          })
-        } else {
-          this.$message.error("未选择营养素")
-        }
-      },
-      queryNutrients(query) {
-        getList({ query }).then(res => {
-          this.nutrients = res.data.list
-        }).catch(() => {
-          this.nutrients = []
-        })
-      },
-      queryUnits(query) {
-        getUnits({ query }).then(res => {
-          this.units = res.data.list
-        }).catch(() => {
-          this.units = []
-        })
-      },
-      fetchNutrients() {
-        this.listLoading = true
-        getNutrients(this.templateId).then(res => {
-          this.list = res.data
-          this.listLoading = false
-        }).catch(() => {
-          this.$message.error("获取数据失败")
-          this.listLoading = false
-          this.$router.push({ path: '/nutrient-template' })
-        })
-      },
-      removeNutrient(row) {
-        removeNutrient(this.templateId, row.nutrientId).then(res => {
+export default {
+  name: 'Detail',
+  components: {},
+  data() {
+    return {
+      templateId: '',
+      tableKey: 0,
+      listLoading: false,
+      list: [],
+      units: [],
+      nutrients: [],
+      params: {},
+      loading: false,
+      unitLoading: false
+    }
+  },
+  created() {
+    this.templateId = this.$route.params.id
+    if (!this.templateId) {
+      this.$message.error('获取数据失败')
+      this.$router.push({ path: '/nutrient-template' })
+    }
+    this.fetchNutrients()
+    this.$nextTick(() => {
+      this.$refs['nutrientSelect'].focus()
+    })
+  },
+  methods: {
+    addNutrient() {
+      if (this.params.nutrientId) {
+        addTemplateNutrient(this.templateId, this.params).then(res => {
           this.fetchNutrients()
-          this.$message.success("提交成功")
+          this.$message.success('添加成功')
+          this.params = {}
+          this.$nextTick(() => {
+            this.$refs['nutrientSelect'].focus()
+          })
         }).catch(res => {
-          this.fetchNutrients()
           this.$message.error(res.data.message)
         })
+      } else {
+        this.$message.error('未选择营养素')
       }
+    },
+    queryNutrients(query) {
+      getList({ query }).then(res => {
+        this.nutrients = res.data.list
+      }).catch(() => {
+        this.nutrients = []
+      })
+    },
+    queryUnits(query) {
+      getUnits({ query }).then(res => {
+        this.units = res.data.list
+      }).catch(() => {
+        this.units = []
+      })
+    },
+    fetchNutrients() {
+      this.listLoading = true
+      getNutrients(this.templateId).then(res => {
+        this.list = res.data
+        this.listLoading = false
+      }).catch(() => {
+        this.$message.error('获取数据失败')
+        this.listLoading = false
+        this.$router.push({ path: '/nutrient-template' })
+      })
+    },
+    removeNutrient(row) {
+      removeNutrient(this.templateId, row.nutrientId).then(res => {
+        this.fetchNutrients()
+        this.$message.success('提交成功')
+      }).catch(res => {
+        this.fetchNutrients()
+        this.$message.error(res.data.message)
+      })
     }
   }
+}
 </script>
 
 <style scoped>

+ 103 - 106
src/views/nutrientTemplate/index.vue

@@ -16,19 +16,20 @@
         style="margin: 0 10px 20px 0; float: right;"
         type="success"
         icon="el-icon-circle-plus-outline"
-        @click="handleCreateOrUpdate('create')">
+        @click="handleCreateOrUpdate('create')"
+      >
         新建
       </el-button>
     </div>
 
     <el-table
+      ref="table"
       :key="tableKey"
       v-loading="listLoading"
       :data="list"
       border
       fit
       highlight-current-row
-      ref="table"
     >
       <el-table-column type="index" label="序号" align="center" width="60" />
       <el-table-column label="名称" align="center" width="150">
@@ -57,33 +58,42 @@
         </template>
       </el-table-column>
       <el-table-column label="操作" align="center">
-        <template slot-scope="{row,$index}">
-          <el-button type="primary" size="mini" @click="handleCreateOrUpdate('update', row)" :disabled="!canUpdate(row.userId)">
+        <template slot-scope="{row}">
+          <el-button type="primary" size="mini" :disabled="!canUpdate(row.userId)" @click="handleCreateOrUpdate('update', row)">
             更新
           </el-button>
-          <el-button type="primary" size="mini" @click="manageNutrients(row)" :disabled="!canUpdate(row.userId)">
+          <el-button type="primary" size="mini" :disabled="!canUpdate(row.userId)" @click="manageNutrients(row)">
             管理营养素
           </el-button>
-          <el-button type="primary" size="mini" @click="updateSort(row, 0)" :disabled="!canUpdate(row.userId)">
+          <el-button type="primary" size="mini" :disabled="!canUpdate(row.userId)" @click="updateSort(row, 0)">
             上移
           </el-button>
-          <el-button type="primary" size="mini" @click="updateSort(row, 1)" :disabled="!canUpdate(row.userId)">
+          <el-button type="primary" size="mini" :disabled="!canUpdate(row.userId)" @click="updateSort(row, 1)">
             下移
           </el-button>
-          <el-button type="primary" size="mini" @click="updateSort(row, 2)" :disabled="!canUpdate(row.userId)">
+          <el-button type="primary" size="mini" :disabled="!canUpdate(row.userId)" @click="updateSort(row, 2)">
             置顶
           </el-button>
-          <el-button size="mini" type="danger" @click="handleDelete(row, $index)" :disabled="!canUpdate(row.userId)">
+          <el-button type="primary" size="mini" :disabled="!canUpdate(row.userId)" @click="updateSort(row, 3)">
+            置底
+          </el-button>
+          <el-button size="mini" type="danger" :disabled="!canUpdate(row.userId)" @click="handleDelete(row)">
             删除
           </el-button>
         </template>
       </el-table-column>
     </el-table>
 
-    <pagination v-show="total>0" :total="total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize" @pagination="fetchData" />
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page.sync="listQuery.pageNum"
+      :limit.sync="listQuery.pageSize"
+      @pagination="fetchData"
+    />
 
     <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
-      <el-form ref="dataForm" :rules="rules" :model="params" label-position="left" label-width="200px" style="width: 400px; margin-left:50px;">
+      <el-form ref="dataForm" :rules="rules" :model="params" label-position="left" label-width="80px" style="width: 400px; margin-left:50px;">
         <el-form-item label="名称" prop="name">
           <el-input v-model="params.name" placeholder="请输入名称" />
         </el-form-item>
@@ -95,7 +105,7 @@
         <el-button @click="dialogFormVisible = false">
           取消
         </el-button>
-        <el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">
+        <el-button type="primary" @click="createOrUpdateData">
           提交
         </el-button>
       </div>
@@ -104,105 +114,92 @@
 </template>
 
 <script>
-  import store from '@/store'
-  import Pagination from '@/components/Pagination'
-  import { getNutrientTemplates, createTemplate, updateSort, updateTemplate, removeTemplate } from '@/api/nutrientTemplate'
-  import {create} from "@/api/nutrient";
+import store from '@/store'
+import Pagination from '@/components/Pagination'
+import { getNutrientTemplates, createTemplate, updateSort, updateTemplate, removeTemplate } from '@/api/nutrientTemplate'
 
-  export default {
-    name: 'NutrientTemplateList',
-    components: { Pagination },
-    created() {
-      this.fetchData()
-    },
-    data() {
-      return {
-        tableKey: 0,
-        listQuery: {
-          query: '',
-          pageNum: 1,
-          pageSize: 20
-        },
-        listLoading: false,
-        list: [],
-        total: 0,
-        textMap: {
-          update: '更新',
-          create: '新建'
-        },
-        dialogStatus: '',
-        dialogFormVisible: false,
-        rules: {},
-        params: {}
-      }
-    },
-    methods: {
-      fetchData() {
-        this.listLoading = true
-        getNutrientTemplates(this.listQuery).then(res => {
-          this.list = res.data.list
-          this.total = res.data.count
-          this.listLoading = false
-        }).catch(res => {
-          this.$message.error("获取数据失败")
-          this.listLoading = false
-        })
-      },
-      handleCreateOrUpdate(type, row) {
-        this.dialogStatus = type
-        this.params = type === 'create' ? {} : row
-        this.dialogFormVisible = true
-      },
-      updateSort(row, type) {
-        updateSort(row.id, { type }).then(res => {
-          this.fetchData()
-          this.$message.success("提交成功")
-        }).catch(res => {
-          this.fetchData()
-          this.$message.error(res.data.message)
-        })
-      },
-      handleDelete(row, index) {
-        removeTemplate(row.id).then(res => {
-          this.fetchData()
-          this.$message.success("提交成功")
-        }).catch(res => {
-          this.fetchData()
-          this.$message.error(res.data.message)
-        })
+export default {
+  name: 'NutrientTemplateList',
+  components: { Pagination },
+  data() {
+    return {
+      tableKey: 0,
+      listQuery: {
+        query: '',
+        pageNum: 1,
+        pageSize: 20
       },
-      createData() {
-        if (this.params) {
-          createTemplate(this.params).then(res => {
-            this.$notify({ title: '成功', message: '提交成功', type: 'success', duration: 2000 })
-            this.fetchData()
-            this.dialogFormVisible = false
-          }).catch(error => {
-            this.$notify({ title: '失败', message: error.response.data.message, type: 'error', duration: 2000 })
-            this.fetchData()
-          })
-        }
+      listLoading: false,
+      list: [],
+      total: 0,
+      textMap: {
+        update: '更新',
+        create: '新建'
       },
-      updateData() {
-        if (this.params) {
-          updateTemplate(this.params.id, this.params).then(res => {
-            this.$notify({ title: '成功', message: '提交成功', type: 'success', duration: 2000 })
-            this.fetchData()
-            this.dialogFormVisible = false
-          }).catch(error => {
-            this.$notify({ title: '失败', message: error.response.data.message, type: 'error', duration: 2000 })
-            this.fetchData()
-          })
-        }
-      },
-      canUpdate(userId) {
-        return store.getters.isAdmin || store.getters.userId === userId
-      },
-      manageNutrients(row) {
-        this.$router.push({ path: `nutrient-template/${row.id}/detail` })
-      }
+      dialogStatus: '',
+      dialogFormVisible: false,
+      rules: {},
+      params: {}
+    }
+  },
+  created() {
+    this.fetchData()
+  },
+  methods: {
+    fetchData() {
+      this.listLoading = true
+      getNutrientTemplates(this.listQuery).then(res => {
+        this.list = res.data.list
+        this.total = res.data.count
+        this.listLoading = false
+      }).catch(res => {
+        this.$message.error('获取数据失败')
+        this.listLoading = false
+      })
+    },
+    handleCreateOrUpdate(type, row) {
+      this.dialogStatus = type
+      this.params = type === 'create' ? {} : Object.assign(row, {})
+      this.dialogFormVisible = true
+    },
+    updateSort(row, type) {
+      updateSort(row.id, { type }).then(res => {
+        this.fetchData()
+        this.$message.success('提交成功')
+      }).catch(res => {
+        this.fetchData()
+        this.$message.error(res.data.message)
+      })
+    },
+    handleDelete(row) {
+      removeTemplate(row.id).then(res => {
+        this.fetchData()
+        this.$message.success('提交成功')
+      }).catch(res => {
+        this.fetchData()
+        this.$message.error(res.data.message)
+      })
+    },
+    createOrUpdateData() {
+      const resultPromise = this.dialogStatus === 'create' ? createTemplate(this.params) : updateTemplate(this.params.id,
+        this.params)
+      resultPromise.then(res => {
+        this.$message.success('提交成功')
+        this.fetchData()
+        this.dialogFormVisible = false
+      }).catch(res => {
+        this.$message.error(res.data.message)
+        this.fetchData()
+      })
+    },
+    canUpdate(userId) {
+      return store.getters.isAdmin || store.getters.userId === userId
+    },
+    manageNutrients(row) {
+      this.$router.push({ path: `nutrient-template/${row.id}/detail` })
     }
   }
+}
 </script>
 
 <style scoped>

+ 15 - 13
src/views/unit/index.vue

@@ -15,7 +15,8 @@
       style="margin: 0 10px 20px 0; float: right;"
       type="success"
       icon="el-icon-circle-plus-outline"
-      @click="handleCreateOrUpdate('CREATE')">
+      @click="handleCreateOrUpdate('CREATE')"
+    >
       新建
     </el-button>
 
@@ -77,7 +78,7 @@
         </template>
       </el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="400">
-        <template slot-scope="{row,$index}">
+        <template slot-scope="{row}">
           <el-button type="primary" size="mini" @click="handleCreateOrUpdate('UPDATE', row)">
             更新
           </el-button>
@@ -117,12 +118,12 @@
           <el-radio v-model="params.isBaseUnit" :label="true" :disabled="dialogStatus === 'UPDATE'">是</el-radio>
           <el-radio v-model="params.isBaseUnit" :label="false" :disabled="dialogStatus === 'UPDATE'">否</el-radio>
         </el-form-item>
-        <el-form-item label="基础单位" prop="code" v-if="!params.isBaseUnit">
+        <el-form-item v-if="!params.isBaseUnit" label="基础单位" prop="code">
           <el-select v-model="params.baseUnit" :disabled="dialogStatus === 'UPDATE'">
             <el-option v-for="item in baseUnits" :key="item.id" :value="item.id" :label="item.name" />
           </el-select>
         </el-form-item>
-        <el-form-item label="转换关系(1 * unit = ratio * baseUnit)" prop="ratio" v-if="!params.isBaseUnit">
+        <el-form-item v-if="!params.isBaseUnit" label="转换关系(1 * unit = ratio * baseUnit)" prop="ratio">
           <el-input v-model="params.ratio" placeholder="请输入转换关系" :disabled="dialogStatus === 'UPDATE'" />
         </el-form-item>
         <el-form-item label="最小刻度" prop="minScale">
@@ -155,9 +156,6 @@ import Pagination from '@/components/Pagination'
 export default {
   name: 'UnitList',
   components: { Pagination },
-  created() {
-    this.fetchData()
-  },
   filters: {
     booleanFilter(value) {
       return value ? '是' : '否'
@@ -183,6 +181,9 @@ export default {
       baseUnits: []
     }
   },
+  created() {
+    this.fetchData()
+  },
   methods: {
     fetchData() {
       this.listLoading = true
@@ -191,11 +192,12 @@ export default {
         this.total = res.data.count
         this.listLoading = false
       }).catch(res => {
-        this.$message("获取数据失败")
+        this.$message('获取数据失败')
+        this.listLoading = false
       })
     },
     handleCreateOrUpdate(dialogStatus, row) {
-      if (this.baseUnits <= 0){
+      if (this.baseUnits <= 0) {
         this.fetchBaseUnits()
       }
       this.dialogStatus = dialogStatus
@@ -205,7 +207,7 @@ export default {
     updateSort(row, type) {
       updateSortOrder(row.id, { type }).then(res => {
         this.fetchData()
-        this.$message.success("提交成功")
+        this.$message.success('提交成功')
       }).catch(res => {
         this.fetchData()
         this.$message.error(res.data.message)
@@ -217,11 +219,11 @@ export default {
       })
     },
     createOrUpdateData() {
-      let resultPromise = this.dialogStatus === 'CREATE' ? createUnit(this.params) :
-        updateUnit(this.params.id, this.params)
+      const resultPromise = this.dialogStatus === 'CREATE' ? createUnit(this.params) : updateUnit(this.params.id,
+        this.params)
       resultPromise.then(res => {
         this.fetchData()
-        this.$message.success("提交成功")
+        this.$message.success('提交成功')
         this.dialogFormVisible = false
       }).catch(res => {
         this.fetchData()