瀏覽代碼

Fix: 盘点相关问题

liqianyi 3 年之前
父節點
當前提交
7fb919fc03

+ 1 - 1
src/components/work-flow/home.vue

@@ -175,7 +175,7 @@ export default {
     }
   },
   mounted () {
-    console.log('mounted')
+    // console.log('mounted')
     this.jsPlumb = jsPlumb.getInstance()
     this.initNodeTypeObj()
     this.initNode()

+ 114 - 0
src/views/modules/common/shelve-component.vue

@@ -0,0 +1,114 @@
+<template>
+  <el-select
+    v-model="value"
+    ref="select"
+    placeholder="请选择"
+    clearable
+    filterable
+    remote
+    :remote-method="remoteMethod"
+    @change = "onChange"
+    @focus="cancelReadOnly"
+    @hook:mounted="cancelReadOnly"
+    @visible-change="cancelReadOnly"
+    style="width: 200px">
+    <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>
+</template>
+
+<script>
+import {getShelveList} from '@/api/warehouse'
+export default {
+  name: 'shelve-component',
+  props: {
+    shelveId: {
+      type: String,
+      default: ''
+    },
+    shelve: {
+      type: Object,
+      default: () => {}
+    }
+  },
+  model: {
+    prop: 'shelveId',
+    event: 'shelveSelected'
+  },
+  data () {
+    return {
+      value: '',
+      current: 1,
+      size: 10,
+      name: '',
+      options: [],
+      loading: false,
+      noMore: false
+    }
+  },
+  mounted () {
+    this.init()
+  },
+  methods: {
+    async init (warehouseId) {
+      this.getList(warehouseId)
+    },
+    remoteMethod (query) {
+      this.options = []
+      this.current = 1
+      this.name = query
+      this.getList()
+    },
+    getList (warehouseId) {
+      getShelveList({ 'name': this.name, 'warehouseId': warehouseId, 'current': this.current, 'size': this.size }).then(({data}) => {
+        if (data && data.code === '200') {
+          if (this.current > data.data.pages) {
+            return
+          }
+          data.data.records.forEach(item => {
+            this.options.push({
+              label: item.name,
+              value: item.shelveId
+            })
+          })
+        } else {
+          this.options = []
+        }
+      })
+    },
+    handleClick () {
+      this.loadMore()
+    },
+    loadMore () {
+      this.current ++
+      this.getList()
+    },
+    onChange (item) {
+      if (item === 'undefined') {
+        this.value = null
+      }
+      this.$emit('shelveSelected', item)
+    },
+    cancelReadOnly (onOff) {
+      this.$nextTick(() => {
+        if (!onOff) {
+          const input = this.$refs.select.$el.querySelector('.el-input__inner')
+          const timer = setTimeout(() => {
+            input.removeAttribute('readonly')
+            clearTimeout(timer)
+          }, 200)
+        }
+      })
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>

+ 114 - 0
src/views/modules/common/warehouse-component.vue

@@ -0,0 +1,114 @@
+<template>
+  <el-select
+    v-model="value"
+    ref="select"
+    placeholder="请选择"
+    clearable
+    filterable
+    remote
+    :remote-method="remoteMethod"
+    @change = "onChange"
+    @focus="cancelReadOnly"
+    @hook:mounted="cancelReadOnly"
+    @visible-change="cancelReadOnly"
+    style="width: 200px">
+    <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>
+</template>
+
+<script>
+import {getWarehouseList} from '@/api/warehouse'
+export default {
+  name: 'warehouse-component',
+  props: {
+    warehouseId: {
+      type: String,
+      default: ''
+    },
+    warehouse: {
+      type: Object,
+      default: () => {}
+    }
+  },
+  model: {
+    prop: 'warehouseId',
+    event: 'warehouseSelected'
+  },
+  data () {
+    return {
+      value: '',
+      current: 1,
+      size: 10,
+      name: '',
+      options: [],
+      loading: false,
+      noMore: false
+    }
+  },
+  mounted () {
+    this.init()
+  },
+  methods: {
+    async init () {
+      this.getList()
+    },
+    remoteMethod (query) {
+      this.options = []
+      this.current = 1
+      this.name = query
+      this.getList()
+    },
+    getList () {
+      getWarehouseList({ 'warehouseName': this.name, 'current': this.current, 'size': this.size }).then(({data}) => {
+        if (data && data.code === '200') {
+          if (this.current > data.data.pages) {
+            return
+          }
+          data.data.records.forEach(item => {
+            this.options.push({
+              label: item.warehouseName,
+              value: item.warehouseId
+            })
+          })
+        } else {
+          this.options = []
+        }
+      })
+    },
+    handleClick () {
+      this.loadMore()
+    },
+    loadMore () {
+      this.current ++
+      this.getList()
+    },
+    onChange (item) {
+      if (item === 'undefined') {
+        this.value = null
+      }
+      this.$emit('warehouseSelected', item)
+    },
+    cancelReadOnly (onOff) {
+      this.$nextTick(() => {
+        if (!onOff) {
+          const input = this.$refs.select.$el.querySelector('.el-input__inner')
+          const timer = setTimeout(() => {
+            input.removeAttribute('readonly')
+            clearTimeout(timer)
+          }, 200)
+        }
+      })
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>

+ 15 - 2
src/views/modules/msg-center/approve-add-or-update.vue

@@ -21,6 +21,9 @@
     <div v-show="businessType === 'pro_technology_flow'">
       <craft-detail ref="craftDetail" @approveFinished="approveFinished" @onChose="onChose"/>
     </div>
+    <div v-show="businessType === 'wh_inventory_record_flow'">
+      <inventory-detail ref="inventoryDetail" @approveFinished="approveFinished" @onChose="onChose"/>
+    </div>
   </div>
 </template>
 
@@ -32,10 +35,18 @@
   import templateOutDetail from '../warehouse/template-delivery-detail'
   import productDetail from '../tech/product-detail'
   import craftDetail from '../tech/crafts-detail'
-  export default {
+  import InventoryDetail from '../warehouse/inventory-detail'
+export default {
     name: 'approve-add-or-update',
     components: {
-      stockOrderDetail, contractDetail, orderDetail, purchaseDetail, templateOutDetail, productDetail, craftDetail
+      InventoryDetail,
+      stockOrderDetail,
+      contractDetail,
+      orderDetail,
+      purchaseDetail,
+      templateOutDetail,
+      productDetail,
+      craftDetail
     },
     data () {
       return {
@@ -66,6 +77,8 @@
           this.display ? this.$refs.productDetail.init(this.businessId) : this.$refs.productDetail.init(this.businessId, businessType)
         } else if (this.businessType === 'pro_technology_flow') {
           this.display ? this.$refs.craftDetail.init(this.businessId) : this.$refs.craftDetail.init(this.businessId, businessType)
+        } else if (this.businessType === 'wh_inventory_record_flow') {
+          this.display ? this.$refs.inventoryDetail.init(this.businessId) : this.$refs.inventoryDetail.init(this.businessId, businessType)
         } else {
           this.$message.error('流程类别不支持,请联系管理员!')
         }

+ 16 - 30
src/views/modules/warehouse/inventory-begin.vue

@@ -32,34 +32,10 @@
       <el-row>
         <el-form :inline="true" :model="dataForm1" @keyup.enter.native="queryData()">
           <el-form-item label="仓库名称" prop="warehouseId">
-            <el-select
-              v-model="dataForm1.warehouseId"
-              filterable
-              remote
-              :remote-method="remoteWarehouse"
-              placeholder="请选择">
-              <el-option
-                v-for="item in optionsWh"
-                :key="item.code"
-                :label="item.value"
-                :value="item.code">
-              </el-option>
-            </el-select>
+            <warehouse-component v-model="dataForm1.warehouseId" :warehouse-id="dataForm1.warehouseId" @warehouseSelected="warehouseChanged"/>
           </el-form-item>
           <el-form-item label="货架名称" prop="shelveId">
-            <el-select
-              v-model="dataForm1.shelveId"
-              filterable
-              remote
-              :remote-method="remoteShelve"
-              placeholder="请选择">
-              <el-option
-                v-for="item in optionsShelve"
-                :key="item.code"
-                :label="item.value"
-                :value="item.code">
-              </el-option>
-            </el-select>
+            <shelve-component ref="shelveCom" v-model="dataForm1.shelveId" :warehouse-id="dataForm1.warehouseId" :shelve-id="dataForm1.shelveId"/>
           </el-form-item>
           <el-form-item>
             <el-button @click="queryData()">查询</el-button>
@@ -115,7 +91,7 @@
           header-align="center"
           align="center"
           min-width="160"
-          label="请选择数量">
+          label="盘点的数量">
           <template slot-scope="scope">
             <el-input-number v-model="scope.row.inventoryCnt" :disabled="display" :step="1" :min="1" style="width: 140px;"/>
           </template>
@@ -138,12 +114,12 @@
           fixed="right"
           header-align="center"
           align="center"
-          width="150"
+          width="100"
           label="操作"
           v-if="!display">
           <template slot-scope="scope">
-            <el-button v-if="isAuth('wh:inventory:complete')" type="text" size="small" @click="finish(scope.row)">完成</el-button>
-            <el-button v-if="isAuth('wh:inventory:start')" type="text" size="small" @click="begin(scope.row)">开始盘点</el-button>
+            <el-button v-if="isAuth('wh:inventory:start') && Number(scope.row.materialState) === 0" type="text" size="small" @click="begin(scope.row)">开始盘点</el-button>
+            <el-button v-if="isAuth('wh:inventory:complete')  && Number(scope.row.materialState) === 1" type="text" size="small" @click="finish(scope.row)">完成</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -157,14 +133,20 @@
         layout="total, sizes, prev, pager, next, jumper">
       </el-pagination>
     </el-form>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="onChose">返回</el-button>
+    </span>
   </div>
   <!-- </el-dialog> -->
 </template>
 
 <script>
   import {getInventoryDetail, getWarehouseList, getShelveList, beginInventory, finishInventory} from '@/api/warehouse'
+  import WarehouseComponent from '../common/warehouse-component'
+  import ShelveComponent from '../common/shelve-component'
   export default {
     name: 'inventory-begin',
+    components: {ShelveComponent, WarehouseComponent},
     data () {
       return {
         visible: false,
@@ -394,6 +376,10 @@
             return this.optionsState[i].value
           }
         }
+      },
+      warehouseChanged (item) {
+        this.dataForm1.warehouseId = item
+        this.$refs.shelveCom.init(item)
       }
     }
   }

+ 27 - 97
src/views/modules/warehouse/inventory-detail.vue

@@ -8,8 +8,8 @@
     <div class="my-title">查看</div>
     <div style="margin-left: 20px;margin-right: 20px">
       <!-- 工作流 -->
-      <div v-show="dataForm.workFlowBusinessExt">
-        <el-steps :active="dataForm.workFlowBusinessExt&&dataForm.workFlowBusinessExt.workFlowProcessStepList?dataForm.workFlowBusinessExt.workFlowProcessStepList.length + 2:0" align-center style="margin-bottom: 20px">
+      <div v-show="flowVisible">
+        <el-steps :active="flowVisible?dataList[0].workFlowBusinessExt.workFlowProcessStepList.length:0" align-center style="margin-bottom: 20px">
           <template v-for="(item, i) in stepList">
             <el-step :icon="item.icon" :title="item.title" :description="item.description"></el-step>
           </template>
@@ -37,34 +37,10 @@
       <el-row style="margin-top: 20px">
         <el-form :inline="true" :model="dataForm1" @keyup.enter.native="queryData()">
           <el-form-item label="仓库名称" prop="warehouseId">
-            <el-select
-              v-model="dataForm1.warehouseId"
-              filterable
-              remote
-              :remote-method="remoteWarehouse"
-              placeholder="请选择">
-              <el-option
-                v-for="item in optionsWh"
-                :key="item.code"
-                :label="item.value"
-                :value="item.code">
-              </el-option>
-            </el-select>
+            <warehouse-component v-model="dataForm1.warehouseId" :warehouse-id="dataForm1.warehouseId" @warehouseSelected="warehouseChanged"/>
           </el-form-item>
           <el-form-item label="货架名称" prop="shelveId">
-            <el-select
-              v-model="dataForm1.shelveId"
-              filterable
-              remote
-              :remote-method="remoteShelve"
-              placeholder="请选择">
-              <el-option
-                v-for="item in optionsShelve"
-                :key="item.code"
-                :label="item.value"
-                :value="item.code">
-              </el-option>
-            </el-select>
+            <shelve-component ref="shelveCom" v-model="dataForm1.shelveId" :warehouse-id="dataForm1.warehouseId" :shelve-id="dataForm1.shelveId"/>
           </el-form-item>
           <el-form-item>
             <el-button @click="queryData()">查询</el-button>
@@ -159,22 +135,23 @@
   import uploadComponent from '../common/upload-component'
   import { dealStepData, dealStepLogs } from '@/api/util'
   import ApproveComponent from '../common/approve-component'
-  import {getInventoryDetail, getWarehouseList, getShelveList} from '@/api/warehouse'
+  import {getInventoryDetail} from '@/api/warehouse'
+  import WarehouseComponent from '../common/warehouse-component'
+  import ShelveComponent from '../common/shelve-component'
   export default {
     name: 'inventory-detail',
     components: {
-      EDesc, EDescItem, uploadComponent, ApproveComponent
+      EDesc, EDescItem, uploadComponent, ApproveComponent, ShelveComponent, WarehouseComponent
     },
     data () {
       return {
         visible: false,
+        flowVisible: false,
         isFlow: false,
         id: 0,
         dataForm: {},
         dataForm1: {},
         dataList: [],
-        optionsWh: [],
-        optionsShelve: [],
         fileList: [],
         fileList1: [],
         stepList: [],
@@ -221,20 +198,19 @@
         this.dataForm = {}
         this.fileList = []
         this.fileList1 = []
-        this.stepList = []
-        this.logList = []
         this.dataForm1 = {}
-        this.getDetails(businessType)
         // 获取详情
-        this.queryData()
+        this.queryData(businessType)
       },
       // 查询
-      queryData () {
+      queryData (businessType) {
         this.pageIndex = 1
-        this.getDataList()
+        this.stepList = []
+        this.logList = []
+        this.getDataList(businessType)
       },
       // 获取数据列表
-      getDataList () {
+      getDataList (businessType) {
         this.dataListLoading = true
         let params = {
           'current': this.pageIndex,
@@ -253,6 +229,14 @@
               this.dataForm.checkerName = item.checkerName
               this.dataForm.dcheckerName = item.dcheckerName
               this.dataForm.notes = item.notes
+              // 流程图展示
+              if (item.workFlowBusinessExt) {
+                this.flowVisible = true
+                dealStepData(this.dataList[0].workFlowBusinessExt.workFlowProcessStepList, this.stepList)
+                dealStepLogs(this.dataList[0].workFlowBusinessExt.processLogList, this.logList)
+              }
+              // 初始化审批Form
+              this.showApproveForm(businessType, this.id)
             }
           } else {
             this.dataList = []
@@ -276,64 +260,6 @@
       selectionChangeHandle (val) {
         this.dataListSelections = val
       },
-      // 仓库列表
-      async remoteWarehouse (query) {
-        let warehouseName = query || null
-        await getWarehouseList({'warehouseName': warehouseName}).then(({data}) => {
-          if (data && data.code === '200') {
-            this.dataForm1 = {}
-            this.optionsWh = []
-            data.data.records.forEach((item) => {
-              this.optionsWh.push({
-                code: item.warehouseId,
-                value: item.warehouseName
-              })
-            })
-          }
-        })
-      },
-      // 货架列表
-      async remoteShelve (query) {
-        let name = query || null
-        let warehouseId = this.dataForm1.warehouseId || null
-        await getShelveList({'name': name, 'warehouseId': warehouseId}).then(({data}) => {
-          if (data && data.code === '200') {
-            this.optionsShelve = []
-            data.data.records.forEach((item) => {
-              this.optionsShelve.push({
-                code: item.shelveId,
-                value: item.name
-              })
-            })
-          }
-        })
-      },
-      getDetails (businessType) {
-        getInventoryDetail(this.id).then(({data}) => {
-          if (data && data.code === '200') {
-            this.dataList = data.data.records
-            this.totalPage = Number(data.data.total)
-            if (this.dataList.length > 0) {
-              let item = this.dataList[0]
-              this.dataForm.inventoryCode = item.inventoryCode
-              this.dataForm.checkerName = item.checkerName
-              this.dataForm.dcheckerName = item.dcheckerName
-              this.dataForm.notes = item.notes
-            }
-            // 流程图展示
-            if (data.data.workFlowBusinessExt) {
-              dealStepData(data.data.workFlowBusinessExt.workFlowProcessStepList, this.stepList)
-              dealStepLogs(data.data.workFlowBusinessExt.processLogList, this.logList)
-            }
-            // 初始化审批Form
-            this.showApproveForm(businessType, this.id)
-          } else {
-            this.dataList = []
-            this.totalPage = 0
-          }
-          this.dataListLoading = false
-        })
-      },
       // 初始化审批Form
       showApproveForm (businessType, businessId) {
         if (this.isFlow) {
@@ -362,6 +288,10 @@
       approveFinished () {
         this.visible = false
         this.$emit('approveFinished')
+      },
+      warehouseChanged (item) {
+        this.dataForm1.warehouseId = item
+        this.$refs.shelveCom.init(item)
       }
     }
   }

+ 3 - 3
src/views/modules/warehouse/inventory.vue

@@ -83,11 +83,11 @@
           fixed="right"
           header-align="center"
           align="center"
-          width="150"
+          width="100"
           label="操作">
           <template slot-scope="scope">
-            <el-button v-if="isAuth('wh:inventory:info') && scope.row.state === '1'" type="text" size="small" @click="detailHandle(scope.row.inventoryId)">查看</el-button>
-            <el-button v-if="isAuth('wh:inventory:start') && scope.row.state === '0'" type="text" size="small" @click="addOrUpdateHandle(scope.row.inventoryId, false)">开始盘点</el-button>
+            <el-button v-if="isAuth('wh:inventory:info') && Number(scope.row.state) === 1" type="text" size="small" @click="detailHandle(scope.row.inventoryId)">查看</el-button>
+            <el-button v-if="isAuth('wh:inventory:start') && Number(scope.row.state) === 0" type="text" size="small" @click="addOrUpdateHandle(scope.row.inventoryId, false)">盘点</el-button>
           </template>
         </el-table-column>
       </el-table>