chris 3 роки тому
батько
коміт
76ae57b29e

+ 104 - 0
src/views/modules/common/cus-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: 'cus-component',
+    props: {
+      cusId: {
+        type: String,
+        default: ''
+      }
+    },
+    model: {
+      prop: 'cusId',
+      event: 'cusSelected'
+    },
+    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/cusCustomer/list`),
+          method: 'get',
+          params: this.$http.adornParams({
+            'current': this.current,
+            'size': this.size,
+            'customerName': 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.customerName,
+                value: item.customerId
+              })
+            })
+          } else {
+            this.options = []
+          }
+        })
+      },
+      handleClick () {
+        this.loadMore()
+      },
+      loadMore () {
+        this.current ++
+        this.getList()
+      },
+      onChange (item) {
+        if (item === 'undefined') {
+          this.value = null
+        }
+        this.$emit('cusSelected', item)
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>

+ 3 - 43
src/views/modules/order/order-add-or-update.vue

@@ -38,21 +38,7 @@
           </el-col>
           <el-col :span="8" style="padding-left: 20px">
             <el-form-item label="客户名称" prop="customerId">
-              <el-input v-if="display" v-model="dataForm.customerName" disabled></el-input>
-              <el-select v-else
-                v-model="dataForm.customerId"
-                :disabled="display"
-                filterable
-                remote
-                :remote-method="remoteCusList"
-                placeholder="请选择">
-                <el-option
-                  v-for="item in optionsCus"
-                  :key="item.code"
-                  :label="item.value"
-                  :value="item.code">
-                </el-option>
-              </el-select>
+              <cus-component v-model="dataForm.customerId" :cus-id="dataForm.customerId"></cus-component>
             </el-form-item>
           </el-col>
         </el-row>
@@ -174,15 +160,15 @@
 <script>
   import templateChose from '../product/template-chose'
   import { getOrderDetail } from '@/api/sale'
-  import { getCusList } from '@/api/cus'
   import UserComponent from '../common/user-component'
   import {toNumber, toPercent} from '@/utils/common'
   import UploadComponent from '../common/upload-component'
   import { dealStepData, dealStepLogs } from '@/api/util'
+  import CusComponent from '../common/cus-component'
 
   export default {
     name: 'order-add-or-update',
-    components: {UploadComponent, UserComponent, templateChose},
+    components: {CusComponent, UploadComponent, UserComponent, templateChose},
     computed: {
       orgId: {
         get () { return this.$store.state.user.orgId }
@@ -193,7 +179,6 @@
         productListVisible: false,
         visible: false,
         display: false,
-        optionsCus: [],
         fileList: [],
         dataList: [],
         id: 0,
@@ -253,37 +238,12 @@
                 })
               })
             }
-            // 编辑
-            if (!display) {
-              this.optionsCus.push({
-                code: data.data.customerId,
-                value: data.data.customerName
-              })
-            }
           }
         })
       },
       uploadSuccess (fileList) {
         this.fileList = fileList
       },
-      // 产品来源(客户)列表
-      async remoteCusList (query) {
-        if (!query) {
-          query = ''
-        }
-        await getCusList({'customerName': query}).then(({data}) => {
-          if (data && data.code === '200') {
-            this.optionsCus = []
-            data.data.records.forEach((item) => {
-              this.optionsCus.push({
-                code: item.customerId,
-                value: item.customerName
-              })
-            })
-          }
-        }
-        )
-      },
       // 添加组合产品
       addProduct () {
         this.productListVisible = true

+ 5 - 32
src/views/modules/order/order.vue

@@ -3,19 +3,7 @@
   <div class="order">
     <el-form :inline="true" :model="dataForm" @keyup.enter.native="queryData()">
       <el-form-item label="客户名称">
-        <el-select
-                   v-model="dataForm.customerId"
-                   remote
-                   filterable
-                   :remote-method="remoteCustomer"
-                   placeholder="请选择">
-          <el-option
-            v-for="item in optionsCustomer"
-            :key="item.code"
-            :label="item.value"
-            :value="item.code">
-          </el-option>
-        </el-select>
+        <cus-component v-model="dataForm.customerId" :cus-id="dataForm.customerId"></cus-component>
       </el-form-item>
       <el-form-item label="合同编码">
         <el-input v-model="dataForm.cusOrderCode" placeholder="合同编码" clearable></el-input>
@@ -141,11 +129,13 @@
   import AddOrUpdate from './order-add-or-update'
   import Detail from './order-detail'
   import { getOrderList } from '@/api/sale'
-  import { getCusList } from '@/api/cus'
+  import CusComponent from '../common/cus-component'
   export default {
     name: 'order',
     components: {
-      AddOrUpdate, Detail
+      CusComponent,
+      AddOrUpdate,
+      Detail
     },
     created () {
       this.optionsState = this.$store.state.common.approveStates
@@ -209,23 +199,6 @@
       selectionChangeHandle (val) {
         this.dataListSelections = val
       },
-      // 远程方法:获取客户列表
-      async remoteCustomer (query) {
-        if (!query) {
-          query = ''
-        }
-        await getCusList({'customerName': query}).then(({data}) => {
-          if (data && data.code === '200') {
-            this.optionsCustomer = []
-            data.data.records.forEach((item) => {
-              this.optionsCustomer.push({
-                code: item.customerId,
-                value: item.customerName
-              })
-            })
-          }
-        })
-      },
       // 新增 / 修改
       addOrUpdateHandle (id, disable) {
         this.addOrUpdateVisible = true

+ 4 - 64
src/views/modules/sale/purchase-add-or-update.vue

@@ -58,30 +58,6 @@
               </el-select>
             </el-form-item>
           </el-col>
-          <el-col :span="8" style="padding-left: 20px">
-            <el-form-item label="申请人" prop="applierId">
-              <el-input v-if="display" v-model="dataForm.applierName" disabled></el-input>
-              <el-select v-else
-                v-model="dataForm.applierId"
-                remote
-                filterable
-                :remote-method="remoteApplier"
-                @change="onApplierChanged"
-                placeholder="请选择">
-                <el-option
-                  v-for="item in optionsApplier"
-                  :key="item.code"
-                  :label="item.value"
-                  :value="item.code">
-                </el-option>
-              </el-select>
-            </el-form-item>
-          </el-col>
-          <el-col :span="8" style="padding-left: 20px">
-            <el-form-item label="申请部门" prop="deptName">
-              <el-input v-model="dataForm.deptName" disabled></el-input>
-            </el-form-item>
-          </el-col>
         </el-row>
         <el-row class="my-row">
           <el-form-item label="备注" prop="notes">
@@ -197,11 +173,13 @@
   import Add from './add-material'
   import { getDictList } from '@/api/dict'
   import { getPurchaseDetail } from '@/api/sale'
-  import { getUserList } from '@/api/user'
+  import { getUserInfo } from '@/api/user'
   import { dealStepData, dealStepLogs } from '@/api/util'
+  import UserComponent from '../common/user-component'
   export default {
     name: 'purchase-add-or-update',
     components: {
+      UserComponent,
       Add
     },
     data () {
@@ -212,7 +190,6 @@
         id: 0,
         dataForm: {},
         optionsType: [],
-        optionsApplier: [],
         materialDetails: [],
         addMaterialVisible: false,
         totalAmount: 0,
@@ -260,16 +237,6 @@
               this.materialDetails = data.data.details
               this.calTotal()
             }
-            // 获取申请人
-            if (data.data.applierId) {
-              this.optionsApplier = []
-              this.optionsApplier.push({
-                code: data.data.applierId,
-                value: data.data.applierName,
-                orgId: data.data.orgId,
-                orgName: data.data.deptName
-              })
-            }
           }
         })
       },
@@ -285,7 +252,7 @@
             this.$http({
               url: !this.id ? this.$http.adornUrl(`/biz-service/purchase/save`) : this.$http.adornUrl(`/biz-service/purchase/update`),
               method: 'post',
-              data: this.$http.adornData(this.dataForm)
+              data: this.$http.adornData({...this.dataForm, applierId: this.$store.state.user.id, orgId: this.$store.state.user.orgId})
             }).then(({data}) => {
               if (data && data.code === '200') {
                 this.$message({
@@ -304,26 +271,6 @@
           }
         })
       },
-      // 获取申请人
-      async remoteApplier (query) {
-        if (!query) return
-        const params = {
-          name: query.trimStart()
-        }
-        await getUserList(params).then(({data}) => {
-          if (data && data.code === '200') {
-            this.optionsApplier = []
-            data.data.records.forEach((item) => {
-              this.optionsApplier.push({
-                code: item.userId,
-                value: item.name + '  (用户名: ' + item.username + ')',
-                orgId: item.orgId,
-                orgName: item.orgName
-              })
-            })
-          }
-        })
-      },
       addMaterial () {
         this.addMaterialVisible = true
         this.$nextTick(() => {
@@ -365,13 +312,6 @@
         let str = (Number(row.taxRate * 100)).toFixed(0)
         str += '%'
         return str
-      },
-      onApplierChanged (val) {
-        if (!val) return
-        let item1 = this.optionsApplier.find((item) => item.code === val)
-        if (!item1) return
-        this.dataForm.deptName = item1.orgName
-        this.dataForm.orgId = item1.orgId
       }
     }
   }