Kaynağa Gözat

库存:修改

chris 3 yıl önce
ebeveyn
işleme
fc7497a0e1

+ 113 - 0
src/views/modules/warehouse/shelve-select.vue

@@ -0,0 +1,113 @@
+<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-option v-if="options.length > 0" label="加载更多" style="font-style: italic; color: #8a979e" value="undefined" @click.native="handleClick()"></el-option>
+    </el-select>
+  </div>
+</template>
+
+<script>
+  export default {
+    name: 'shelve-select',
+    props: ['warehouseId', 'shelveId'],
+    model: {
+      prop: 'shelveId',
+      event: 'select'
+    },
+    data () {
+      return {
+        value: '',
+        current: 1,
+        size: 10,
+        // 货架名
+        name: '',
+        options: [],
+        loading: false,
+        noMore: false
+      }
+    },
+    mounted () {
+      this.init(this.warehouseId, this.shelveId)
+    },
+    watch: {
+      shelveId (newVal) {
+        this.init(this.warehouseId, newVal)
+      },
+      warehouseId (newVal) {
+        this.warehouseId = newVal
+      }
+    },
+    methods: {
+      async init (whId, shelveId) {
+        this.options = []
+        this.current = 1
+        this.getList(whId, shelveId)
+      },
+      remoteMethod (query) {
+        this.options = []
+        this.current = 1
+        this.name = query
+        this.getList(this.warehouseId, this.shelveId)
+      },
+      getList (whId, shelveId) {
+        this.$http({
+          url: this.$http.adornUrl(`/biz-service/stock-mg-ctl/listShelves`),
+          method: 'get',
+          params: this.$http.adornParams({
+            'current': this.current,
+            'size': this.size,
+            'name': this.name,
+            'warehouseId': whId
+          })
+        }).then(({data}) => {
+          if (data && data.code === '200') {
+            if (this.current > data.data.pages) {
+              return
+            }
+            data.data.records.forEach(item => {
+              this.options.push({
+                label: item.shelveNumber + '(' + item.name + ')',
+                value: item.shelveId
+              })
+            })
+            if (shelveId) {
+              this.value = shelveId
+            }
+          } else {
+            this.options = []
+          }
+        })
+      },
+      handleClick () {
+        this.loadMore()
+      },
+      loadMore () {
+        this.current ++
+        this.getList()
+      },
+      onChange (item) {
+        if (item === 'undefined') {
+          this.value = null
+        }
+        this.$emit('select', item)
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>

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

@@ -53,12 +53,12 @@
       <el-row class="my-row">
         <el-col :span="12">
           <el-form-item label="存放仓库" prop="warehouseId">
-            <warehouse-select v-model="dataForm.warehouseId"/>
+            <warehouse-select ref="warehouse" v-bind:warehouse-id="dataForm.warehouseId"/>
           </el-form-item>
         </el-col>
         <el-col :span="12">
           <el-form-item label="存放货架" prop="shelveId">
-            <el-input v-model="dataForm.shelveId" placeholder="请选择存放货架"></el-input>
+            <shelve-select ref="shelve" v-bind:warehouse-id="dataForm.warehouseId" v-bind:shelve-id="dataForm.shelveId"/>
           </el-form-item>
         </el-col>
       </el-row>
@@ -79,9 +79,10 @@
 
 <script>
   import WarehouseSelect from './warehouse-select'
+  import ShelveSelect from './shelve-select'
   export default {
     name: 'stock-add-or-update',
-    components: {WarehouseSelect},
+    components: {ShelveSelect, WarehouseSelect},
     data () {
       return {
         visible: false,
@@ -124,6 +125,7 @@
               this.dataForm.price = data.data.price
               this.dataForm.amount = data.data.amount
               this.dataForm.warehouseId = data.data.warehouseId
+              this.dataForm.shelveId = data.data.shelveId
               this.dataForm.shelveName = data.data.shelveName
               this.dataForm.notes = data.data.notes
             } else {

+ 4 - 12
src/views/modules/warehouse/warehouse-select.vue

@@ -22,12 +22,7 @@
 <script>
   export default {
     name: 'warehouse-select',
-    props: {
-      warehouseId: {
-        type: String,
-        default: ''
-      }
-    },
+    props: ['warehouseId'],
     model: {
       prop: 'warehouseId',
       event: 'select'
@@ -47,20 +42,17 @@
       this.init(this.warehouseId)
     },
     watch: {
-      warehouseId: {
-        handler (newVal) {
-          this.options = []
-          this.init(newVal)
-        }
+      warehouseId (newVal) {
+        this.init(newVal)
       }
     },
     methods: {
       async init (id) {
         this.current = 1
+        this.options = []
         this.getList(id)
       },
       remoteMethod (query) {
-        console.log('query = ' + query)
         this.options = []
         this.current = 1
         this.warehouseName = query