chris 3 жил өмнө
parent
commit
2c8853bc7c

+ 91 - 0
src/views/modules/sys/dict-select.vue

@@ -0,0 +1,91 @@
+<template>
+  <div>
+    <el-select
+      v-model="value"
+      ref="select"
+      placeholder="请选择"
+      filterable
+      remote
+      :remote-method="remoteMethod"
+      @change = "onChange">
+      <el-option
+        v-for="item in options"
+        :key="item.value"
+        :label="item.label"
+        :value="item.value">
+      </el-option>
+    </el-select>
+  </div>
+</template>
+
+<script>
+  export default {
+    name: 'dict-select',
+    props: ['dictId', 'dictType'],
+    model: {
+      prop: 'dictId',
+      event: 'select'
+    },
+    watch: {
+      dictId (newVal) {
+        this.init(newVal, this.dictType)
+      }
+    },
+    data () {
+      return {
+        value: '',
+        name: '',
+        options: [],
+        loading: false
+      }
+    },
+    mounted () {
+      this.init(this.dictId, this.dictType)
+    },
+    methods: {
+      async init (dictId, dictType) {
+        this.options = []
+        this.current = 1
+        this.getList(dictId, dictType)
+      },
+      remoteMethod (query) {
+        this.options = []
+        this.name = query
+        this.getList(this.dictId, this.dictType)
+      },
+      getList (dictId, dictType) {
+        this.$http({
+          url: this.$http.adornUrl(`/user-service/dict/queryByType`),
+          method: 'get',
+          params: this.$http.adornParams({
+            'type': dictType
+          })
+        }).then(({data}) => {
+          if (data && data.code === '200') {
+            data.data.forEach(item => {
+              this.options.push({
+                label: item.value,
+                value: item.id
+              })
+            })
+            if (dictId) {
+              this.value = dictId
+            }
+          } else {
+            this.options = []
+          }
+        })
+      },
+      onChange (item) {
+        if (item === 'undefined') {
+          this.value = null
+        }
+        this.$emit('select', item)
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>

+ 7 - 3
src/views/modules/warehouse/stock-add-or-update.vue

@@ -15,7 +15,7 @@
         </el-col>
         <el-col :span="12">
           <el-form-item label="类别" prop="materialTypeId">
-            <el-input v-model="dataForm.materialTypeId" placeholder="物品(零件)类别"></el-input>
+            <dict-select v-model:dict-id="dataForm.cateId" v-bind:dict-type="dictType"/>
           </el-form-item>
         </el-col>
       </el-row>
@@ -80,17 +80,20 @@
 <script>
   import WarehouseSelect from './warehouse-select'
   import ShelveSelect from './shelve-select'
+  import DictSelect from '../sys/dict-select'
   export default {
     name: 'stock-add-or-update',
-    components: {ShelveSelect, WarehouseSelect},
+    components: {DictSelect, ShelveSelect, WarehouseSelect},
     data () {
       return {
         visible: false,
+        dictType: 'material_type',
         dataForm: {
           materialId: 0,
           materialCode: '',
           materialName: '',
           materialTypeId: '',
+          cateId: '',
           specifications: '',
           unitName: '',
           cnt: '',
@@ -128,6 +131,7 @@
               this.dataForm.shelveId = data.data.shelveId
               this.dataForm.shelveName = data.data.shelveName
               this.dataForm.notes = data.data.notes
+              this.dataForm.cateId = data.data.cateId
             } else {
               this.$message.error(data.msg)
             }
@@ -147,7 +151,7 @@
                 'materialId': this.dataForm.materialId,
                 'materialName': this.dataForm.materialName,
                 'amount': this.dataForm.amount,
-                'cateId': this.dataForm.materialTypeId,
+                'cateId': this.dataForm.cateId,
                 'materialTypeId': this.dataForm.materialTypeId,
                 'cnt': this.dataForm.cnt,
                 'materialCode': this.dataForm.materialCode,

+ 1 - 1
src/views/modules/warehouse/stock-details.vue

@@ -7,7 +7,7 @@
         <DescriptionList title="" col="6" :content="dataForm">
           <Description term="编码">{{dataForm.materialName}}</Description>
           <Description term="名称">{{dataForm.materialName}}</Description>
-          <Description term="类别">{{dataForm.materialTypeId}}</Description>
+          <Description term="类别">{{dataForm.categoryName}}</Description>
         </DescriptionList>
         <DescriptionList title="" col="6" :content="dataForm">
           <Description term="规格">{{dataForm.specifications}}</Description>