Ver código fonte

客户组件

lilei 4 anos atrás
pai
commit
b0f97c3570

+ 66 - 0
src/views/common/custList.js

@@ -0,0 +1,66 @@
+import { custAllList } from '@/api/customer'
+const CustList = {
+  template: `
+        <a-select
+          :id="id"
+          placeholder="请选择客户"
+          allowClear
+          :value="defaultVal"
+          :showSearch="true"
+          @change="handleChange"
+          :filter-option="filterOption">
+          <a-select-option v-for="item in custAllList" :key="item.customerName" :value="item.customerName">{{ item.customerName }}</a-select-option>
+        </a-select>
+    `,
+  props: {
+    value: {
+      type: String,
+      defatut: ''
+    },
+    id: {
+      type: String,
+      default: ''
+    },
+  },
+  data() {
+    return {
+      defaultVal: this.value,
+      custAllList: []
+    };
+  },
+  watch: {
+    value(newValue, oldValue) {
+      console.log(newValue)
+      this.defaultVal = newValue
+    }
+  },
+  mounted() {
+    this.getCustAllList()
+  },
+  methods: {
+    filterOption (input, option) {
+      return (
+        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
+      )
+    },
+    handleChange(value) {
+      console.log(value)
+      this.defaultVal = value;
+      this.$emit('change', this.value);
+      this.$emit('input', value);
+    },
+    // 客户无分页列表数据
+    getCustAllList () {
+      const _this = this
+      custAllList().then(res => {
+        if (res.status == 200) {
+          _this.custAllList = res.data || []
+        } else {
+          _this.custAllList = []
+        }
+      })
+    },
+  },
+};
+
+export default CustList

+ 8 - 10
src/views/salesManagement/examineVerify/list.vue

@@ -18,15 +18,12 @@
           </a-col>
           <a-col :md="6" :sm="24">
             <a-form-item label="客户名称">
-              <a-select
-                placeholder="请选择"
-                allowClear
-                v-model="queryParam.name"
-                :showSearch="true"
-                option-filter-prop="children"
-                :filter-option="filterOption">
-                <a-select-option v-for="item in custData" :key="item.id" :value="item.id">{{ item.name }}</a-select-option>
-              </a-select>
+              <custList id="examineVerifyList-buyerName" v-model="queryParam.buyerName"></custList>
+            </a-form-item>
+          </a-col>
+          <a-col :md="6" :sm="24">
+            <a-form-item label="销售单号">
+              <a-input id="examineVerifyList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="24">
@@ -102,9 +99,10 @@
 
 <script>
 // import { customerBundleDelayList, customerBundleExportDelay } from '@/api/FinancialManagement'
+import custList from '@/views/common/custList.js'
 import { STable, VSelect } from '@/components'
 export default {
-  components: { STable, VSelect },
+  components: { STable, VSelect, custList },
   data () {
     return {
       advanced: false, // 高级搜索 展开/关闭

+ 3 - 30
src/views/salesManagement/salesQuery/list.vue

@@ -17,16 +17,7 @@
           </a-col>
           <a-col :md="6" :sm="24">
             <a-form-item label="客户名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
-              <a-select
-                id="salesManagementList-buyerName"
-                placeholder="请选择客户"
-                allowClear
-                v-model="queryParam.buyerName"
-                :showSearch="true"
-                option-filter-prop="children"
-                :filter-option="filterOption">
-                <a-select-option v-for="item in custAllList" :key="item.customerSn" :value="item.customerName">{{ item.customerName }}</a-select-option>
-              </a-select>
+              <custList id="salesManagementList-buyerName" v-model="queryParam.buyerName"></custList>
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="24">
@@ -184,12 +175,12 @@
 import moment from 'moment'
 import { STable, VSelect } from '@/components'
 import chooseCustomModal from './chooseCustomModal.vue'
-import { custAllList } from '@/api/customer'
+import custList from '@/views/common/custList.js'
 import { salesList, salesDel, salesWriteAudit, salesWriteStockOut, salesCount } from '@/api/sales'
 import { settleStyleQueryAll } from '@/api/settleStyle'
 export default {
   name: 'TableList',
-  components: { STable, VSelect, chooseCustomModal },
+  components: { STable, VSelect, chooseCustomModal, custList },
   data () {
     return {
       tableHeight: 0,
@@ -198,7 +189,6 @@ export default {
       dateFormat: 'YYYY-MM-DD',
       time: [], //  创建时间
       openModal: false, // 选择客户弹框是否显示
-      custAllList: [], //  客户 下拉数据
       settleStyleList: [], // 收款方式
       // 查询参数
       queryParam: {
@@ -356,17 +346,6 @@ export default {
         }
       })
     },
-    // 客户无分页列表数据
-    getCustAllList () {
-      const _this = this
-      custAllList().then(res => {
-        if (res.status == 200) {
-          _this.custAllList = res.data || []
-        } else {
-          _this.custAllList = []
-        }
-      })
-    },
     // 重置
     resetSearchForm () {
       this.queryParam.buyerName = undefined
@@ -379,11 +358,6 @@ export default {
       this.time = []
       this.$refs.table.refresh(true)
     },
-    filterOption (input, option) {
-      return (
-        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
-      )
-    },
     // 获取收款方式
     getSettleStyle () {
       settleStyleQueryAll().then(res => {
@@ -395,7 +369,6 @@ export default {
   },
   beforeRouteEnter (to, from, next) {
     next(vm => {
-      vm.getCustAllList()
       vm.getSettleStyle()
     })
   }