chris 3 years ago
parent
commit
6da0cf6b2b

+ 1 - 1
src/views/common/msg.vue

@@ -33,7 +33,7 @@
       listenWebsocket: function (data) {
         if (!data) return
         let json = parseJsonStr(data)
-        console.log('json = ' + JSON.stringify(json))
+        // console.log('json = ' + JSON.stringify(json))
         if (data.indexOf('{"approved') > -1) {
           readNotices(this, json['approved'])
           return

+ 104 - 0
src/views/modules/common/convert-component.vue

@@ -0,0 +1,104 @@
+<template>
+    <div>
+      <el-select
+        v-model="value"
+        ref="select"
+        placeholder="请选择"
+        clearable
+        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: 'convert-component',
+    props: {
+      convertId: {
+        type: String,
+        default: ''
+      }
+    },
+    model: {
+      prop: 'convertId',
+      event: 'convertSelected'
+    },
+    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 () {
+        this.$http({
+          url: this.$http.adornUrl(`/biz-service/conversion-ctl/list`),
+          method: 'get',
+          params: this.$http.adornParams({
+            'current': this.current,
+            'size': this.size,
+            'convertUnit': this.name
+          })
+        }).then(({data}) => {
+          if (data && data.code === '200') {
+            if (this.current > data.data.pages) {
+              return
+            }
+            data.data.records.forEach(item => {
+              this.options.push({
+                label: '1 ' + item.convertUnitBefore + ' —— ' + item.cnt + ' ' + item.convertUnit,
+                value: item.conversionId
+              })
+            })
+          } else {
+            this.options = []
+          }
+        })
+      },
+      handleClick () {
+        this.loadMore()
+      },
+      loadMore () {
+        this.current ++
+        this.getList()
+      },
+      onChange (item) {
+        if (item === 'undefined') {
+          this.value = null
+        }
+        this.$emit('convertSelected', item)
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>

+ 112 - 0
src/views/modules/common/material-component.vue

@@ -0,0 +1,112 @@
+<template>
+  <el-select
+    v-model="value"
+    ref="select"
+    placeholder="请选择"
+    clearable
+    filterable
+    remote
+    :remote-method="remoteMethod"
+    @change = "onChange"
+    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>
+  export default {
+    name: 'material-component',
+    props: {
+      materialId: {
+        type: String,
+        default: ''
+      },
+      material: {
+        type: Object,
+        default: () => {}
+      }
+    },
+    model: {
+      prop: 'material',
+      event: 'materialSelected'
+    },
+    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 () {
+        this.$http({
+          url: this.$http.adornUrl(`/biz-service/stock-mg-ctl/list`),
+          method: 'get',
+          params: this.$http.adornParams({
+            'current': this.current,
+            'size': this.size,
+            'materialName': this.name
+          })
+        }).then(({data}) => {
+          if (data && data.code === '200') {
+            if (this.current > data.data.pages) {
+              return
+            }
+            data.data.records.forEach(item => {
+              this.options.push({
+                label: item.materialName,
+                value: item.materialId,
+                materialId: item.materialId,
+                cateId: item.cateId,
+                categoryName: item.categoryName,
+                specifications: item.specifications,
+                unitName: item.unitName
+              })
+            })
+          } else {
+            this.options = []
+          }
+        })
+      },
+      handleClick () {
+        this.loadMore()
+      },
+      loadMore () {
+        this.current ++
+        this.getList()
+      },
+      onChange (item) {
+        if (item === 'undefined') {
+          this.value = null
+        }
+        this.$emit('materialSelected', this.options.find(item1 => item1.value === item))
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>

+ 104 - 0
src/views/modules/common/material-type-component.vue

@@ -0,0 +1,104 @@
+<template>
+    <div>
+      <el-select
+        v-model="value"
+        ref="select"
+        placeholder="请选择"
+        clearable
+        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: 'material-type-component',
+    props: {
+      typeId: {
+        type: String,
+        default: ''
+      }
+    },
+    model: {
+      prop: 'typeId',
+      event: 'typeSelected'
+    },
+    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 () {
+        this.$http({
+          url: this.$http.adornUrl(`/biz-service/wh-category/list`),
+          method: 'get',
+          params: this.$http.adornParams({
+            'current': this.current,
+            'size': this.size,
+            'materialName': this.name
+          })
+        }).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.id
+              })
+            })
+          } else {
+            this.options = []
+          }
+        })
+      },
+      handleClick () {
+        this.loadMore()
+      },
+      loadMore () {
+        this.current ++
+        this.getList()
+      },
+      onChange (item) {
+        if (item === 'undefined') {
+          this.value = null
+        }
+        this.$emit('typeSelected', item)
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>

+ 1 - 1
src/views/modules/common/user-component.vue

@@ -3,7 +3,7 @@
       <el-select
         v-model="value"
         ref="select"
-        placeholder="请输入姓名"
+        placeholder="请选择"
         clearable
         filterable
         remote

+ 1 - 1
src/views/modules/common/user-components.vue

@@ -3,7 +3,7 @@
       <el-select
         v-model="value"
         ref="select"
-        placeholder="请输入姓名"
+        placeholder="请选择"
         clearable
         filterable
         remote

+ 16 - 117
src/views/modules/warehouse/stock-order-inbound.vue

@@ -17,42 +17,20 @@
           <el-row class="my-row">
             <el-col :span="8">
               <el-form-item label="名称" prop="materialId" :rules="{required: false, message: '名称不能为空', trigger: 'blur'}">
-                <el-input v-if="display || item.buttonType === '1'" placeholder="请输入" v-model="item.materialName"
+                <el-input v-if="item.buttonType === '1'" placeholder="请输入" v-model="item.materialName"
                           :disabled="display" style="width: 200px; margin-right: 10px"/>
-                <el-select v-else v-model="item.materialId"
-                           remote
-                           filterable
-                           :remote-method="remoteMaterial"
-                           @change="onMaterialChanged(item)"
-                           placeholder="请选择"
-                           style="width: 200px">
-                  <el-option
-                    v-for="item in optionsMaterial"
-                    :key="item.code"
-                    :label="item.value"
-                    :value="item.code">
-                  </el-option>
-                </el-select>
-                <el-button v-show="!display && item.buttonType && item.buttonType === '1'" @click="changeButtonType(item, 0)" type="danger">选择</el-button>
-                <el-button v-show="!display && (!item.buttonType || item.buttonType === '0')" @click="changeButtonType(item, 1)" type="danger">输入</el-button>
+                <material-component v-else
+                                    v-model="dataList[index]"
+                                    :material-id="item.materialId">
+                </material-component>
+                <el-button v-show="item.buttonType && item.buttonType === '1'" @click="changeButtonType(item, 0)" type="danger">选择</el-button>
+                <el-button v-show="!item.buttonType || item.buttonType === '0'" @click="changeButtonType(item, 1)" type="danger">输入</el-button>
               </el-form-item>
             </el-col>
             <el-col :span="8" style="padding-left: 20px">
               <el-form-item label="类别" prop="materialTypeId" :rules="{required: false, message: '类别不能为空', trigger: 'blur'}">
-                <el-input v-if="display || !item.buttonType || item.buttonType === '0'" v-model="item.categoryName" :disabled="true" style="width: 200px"></el-input>
-                <el-select v-else v-model="item.materialTypeId"
-                           remote
-                           filterable
-                           :remote-method="remoteMaterialTypes"
-                           style="width: 200px"
-                           placeholder="请选择">
-                  <el-option
-                    v-for="item in optionsMaterialTypes"
-                    :key="item.code"
-                    :label="item.value"
-                    :value="item.code">
-                  </el-option>
-                </el-select>
+                <el-input v-if="!item.buttonType || item.buttonType === '0'" v-model="item.categoryName" :disabled="true" style="width: 200px"></el-input>
+                <material-type-component v-else v-model="item.materialTypeId" :type-id="item.materialTypeId"></material-type-component>
               </el-form-item>
             </el-col>
             <el-col :span="8" style="text-align: right;">
@@ -101,20 +79,7 @@
             </el-col>
             <el-col :span="8" style="padding-left: 20px">
               <el-form-item label="是否换算" prop="unitNeedChange">
-                <el-input v-if="display" v-model="item.conversionName" :disabled="true"></el-input>
-                <el-select v-else
-                           v-model="item.unitNeedChange"
-                           remote
-                           filterable
-                           :remote-method="remoteNeedChange"
-                           placeholder="请选择">
-                  <el-option
-                    v-for="item in optionsConversion"
-                    :key="item.code"
-                    :label="item.value"
-                    :value="item.code">
-                  </el-option>
-                </el-select>
+                <convert-component v-model="item.unitNeedChange" :convert-id="item.unitNeedChange"></convert-component>
               </el-form-item>
             </el-col>
           </el-row>
@@ -139,10 +104,13 @@
 <script>
   import UserComponent from '../common/user-component'
   import DictSelect from '../sys/dict-select'
-  import { getMaterialList, getConversionList, inboundBatch, getBoundDetails, getMaterialTypes } from '@/api/warehouse'
+  import { inboundBatch, getBoundDetails } from '@/api/warehouse'
+  import ConvertComponent from '../common/convert-component'
+  import MaterialComponent from '../common/material-component'
+  import MaterialTypeComponent from '../common/material-type-component'
   export default {
     name: 'stock-order-inbound',
-    components: {DictSelect, UserComponent},
+    components: {MaterialTypeComponent, MaterialComponent, ConvertComponent, DictSelect, UserComponent},
     data () {
       return {
         visible: false,
@@ -152,10 +120,7 @@
         dataList: [],
         dataRule: {
           userId: [{ required: true, message: '请选择入库申请人', trigger: 'blur' }]
-        },
-        optionsMaterial: [],
-        optionsConversion: [],
-        optionsMaterialTypes: []
+        }
       }
     },
     methods: {
@@ -267,72 +232,6 @@
       validateField (type) {
         this.$refs.dataForm.validateField(type)
       },
-      // 远程方法:货物种类
-      async remoteMaterialTypes (query) {
-        if (!query) return
-        const params = {
-          materialName: query.trimStart()
-        }
-        await getMaterialTypes(params).then(({data}) => {
-          if (data && data.code === '200') {
-            this.optionsMaterialTypes = []
-            data.data.records.forEach((item) => {
-              this.optionsMaterialTypes.push({
-                code: item.id,
-                value: item.name
-              })
-            })
-          }
-        })
-      },
-      // 远程方法:物料List
-      async remoteMaterial (query) {
-        if (!query) return
-        const params = {
-          materialName: query.trimStart()
-        }
-        await getMaterialList(params).then(({data}) => {
-          if (data && data.code === '200') {
-            this.optionsMaterial = []
-            data.data.records.forEach((item) => {
-              this.optionsMaterial.push({
-                code: item.materialId,
-                value: item.materialName,
-                cateId: item.cateId,
-                categoryName: item.categoryName,
-                specifications: item.specifications,
-                unitName: item.unitName
-              })
-            })
-          }
-        })
-      },
-      onMaterialChanged (item) {
-        let item2 = this.optionsMaterial.find((item1) => item1.code === item.materialId)
-        if (!item2) return
-        item.categoryName = item2.categoryName
-        item.cateId = item2.cateId
-        item.specifications = item2.specifications
-        item.unitName = item2.unitName
-      },
-      // 远程选择:是否需要换算
-      remoteNeedChange (query) {
-        if (!query) return
-        const params = {
-          convertUnit: query.trimStart()
-        }
-        getConversionList(params).then(({data}) => {
-          if (data && data.code === '200') {
-            this.optionsConversion = []
-            data.data.records.forEach((item) => {
-              this.optionsConversion.push({
-                code: item.conversionId,
-                value: '1 ' + item.convertUnitBefore + ' —— ' + item.cnt + ' ' + item.convertUnit
-              })
-            })
-          }
-        })
-      },
       // 切换按钮状态
       changeButtonType (item, type) {
         if (!item) return

+ 9 - 58
src/views/modules/warehouse/stock-order-outbound.vue

@@ -11,35 +11,16 @@
             <el-input v-model="dataForm.recordCode" :disabled="true" placeholder="编码系统自动生成"></el-input>
           </el-form-item>
         </el-col>
-<!--        <el-col :span="8" style="padding-left: 20px">-->
-<!--          <el-form-item label="领料人" prop="userId">-->
-<!--            <user-component v-model="dataForm.userId" @userSelected="userChanged"></user-component>-->
-<!--          </el-form-item>-->
-<!--        </el-col>-->
-<!--        <el-col :span="8" style="padding-left: 20px">-->
-<!--          <el-form-item label="领料人部门" prop="orgName">-->
-<!--            <el-input :disabled="true" v-model="dataForm.orgName" placeholder="自动匹配"></el-input>-->
-<!--          </el-form-item>-->
-<!--        </el-col>-->
       </el-row>
       <template v-for="(item, index) in dataList">
         <div :key="index" class="my-line">
           <el-row class="my-row">
             <el-col :span="8">
               <el-form-item label="名称" prop="materialName">
-                <el-select v-model="item.materialId"
-                           remote
-                           filterable
-                           :remote-method="remoteMaterial"
-                           @change="onMaterialChanged(item)"
-                           placeholder="请选择">
-                  <el-option
-                    v-for="item in optionsMaterial"
-                    :key="item.code"
-                    :label="item.value"
-                    :value="item.code">
-                  </el-option>
-                </el-select>
+                <material-component
+                                    v-model="dataList[index]"
+                                    :material-id="item.materialId">
+                </material-component>
               </el-form-item>
             </el-col>
             <el-col :span="8" style="padding-left: 20px">
@@ -96,19 +77,19 @@
 <script>
   import UserComponent from '../common/user-component'
   import DictSelect from '../sys/dict-select'
-  import { getMaterialList, outboundBatch } from '@/api/warehouse'
+  import { outboundBatch } from '@/api/warehouse'
   import {getUUID} from '../../../utils'
+  import MaterialComponent from '../common/material-component'
   export default {
     name: 'stock-order-inbound',
-    components: {DictSelect, UserComponent},
+    components: {MaterialComponent, DictSelect, UserComponent},
     data () {
       return {
         visible: false,
         dataForm: {},
         dataList: [],
         dataRule: {
-        },
-        optionsMaterial: []
+        }
       }
     },
     methods: {
@@ -158,6 +139,7 @@
                 applicant: this.dataForm.userId,
                 approver: item.approver,
                 batchNumber: item.batchNumber,
+                cateId: item.cateId,
                 cnt: item.cnt,
                 materialId: item.materialId,
                 materialName: item.materialName,
@@ -193,37 +175,6 @@
       },
       validateField (type) {
         this.$refs.dataForm.validateField(type)
-      },
-      // 远程方法:物料List
-      async remoteMaterial (query) {
-        if (!query) return
-        const params = {
-          materialName: query.trimStart()
-        }
-        await getMaterialList(params).then(({data}) => {
-          if (data && data.code === '200') {
-            this.optionsMaterial = []
-            data.data.records.forEach((item) => {
-              this.optionsMaterial.push({
-                code: item.materialId,
-                value: item.materialName,
-                cateId: item.cateId,
-                categoryName: item.categoryName,
-                specifications: item.specifications,
-                unitName: item.unitName
-              })
-            })
-          }
-        })
-      },
-      onMaterialChanged (item) {
-        if (!item.materialId) return
-        let item2 = this.optionsMaterial.find((item1) => item1.code === item.materialId)
-        if (!item2) return
-        item.categoryName = item2.categoryName
-        item.cateId = item2.cateId
-        item.specifications = item2.specifications
-        item.unitName = item2.unitName
       }
     }
   }