lilei 2 år sedan
förälder
incheckning
ba32d17eaa

+ 30 - 18
src/views/salesReturnManagement/billOfLading/logisticsCompany.js

@@ -1,19 +1,26 @@
 import { pickUpLogisticsList } from '@/api/pickUp'
 const LogisticsCompany = {
   template: `
-       <a-input-group compact :id="id">
-        <a-input style="width: 70%" allowClear @change="handleChange" :placeholder="placeholder" :value="defaultVal"/>
-        <a-select
-          style="width: 30%"
-          @change="changeSel"
-          placeholder="选择物流公司"
+      <a-select
+          allowClear
+          :size="size"
+          mode="combobox"
+          :value="defaultVal"
+          show-search
+          :placeholder="placeholder"
           option-filter-prop="children"
-          :filter-option="filterOption">
+          style="width: 100%"
+          :filter-option="filterOption"
+          :dropdownMatchSelectWidth="false"
+          @change="onChange"
+          @blur="onBlur"
+          @focus="open=true"
+          :open="open"
+        >
           <a-select-option v-for="item in list" :key="item.id" :value="item.logisticsCompany">
-          {{ item.logisticsCompany }}
+            {{ item.logisticsCompany }}
           </a-select-option>
         </a-select>
-      </a-input-group>
     `,
   props: {
     value: {
@@ -28,11 +35,16 @@ const LogisticsCompany = {
       type: String,
       default: '请输入物流公司'
     },
+    size: {
+      type: String,
+      default: 'default'
+    }
   },
   data() {
     return {
       defaultVal: this.value,
-      list: []
+      list: [],
+      open: false,
     };
   },
   mounted() {
@@ -49,16 +61,16 @@ const LogisticsCompany = {
         option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
       )
     },
-    changeSel(value){
+    onChange(value) {
+      console.log('onChange', value);
       this.defaultVal = value;
-      this.$emit('change', value);
-      this.$emit('input', value);
+      this.open = false;
+      this.$emit('change', value||'');
+      this.$emit('input', value||'');
     },
-    handleChange(e) {
-      const value = e.target.value
-      this.defaultVal = value;
-      this.$emit('change', value);
-      this.$emit('input', value);
+    onBlur(value){
+      this.open = false;
+      this.$emit('blur', value);
     },
     getList () {
       pickUpLogisticsList({}).then(res => {

+ 31 - 19
src/views/salesReturnManagement/billOfLading/logisticsPoint.js

@@ -1,19 +1,26 @@
 import { pickUpPointList } from '@/api/pickUp'
 const LogisticsPoint = {
   template: `
-      <a-input-group compact :id="id">
-        <a-input style="width: 70%" allowClear @change="handleChange" :placeholder="placeholder" :value="defaultVal"/>
-        <a-select
-          style="width: 30%"
-          @change="changeSel"
-          placeholder="选择物流点"
+      <a-select
+          allowClear
+          :size="size"
+          mode="combobox"
+          :value="defaultVal"
+          show-search
+          :placeholder="placeholder"
           option-filter-prop="children"
-          :filter-option="filterOption">
+          style="width: 100%"
+          :filter-option="filterOption"
+          :dropdownMatchSelectWidth="false"
+          @change="onChange"
+          @blur="onBlur"
+          @focus="open=true"
+          :open="open"
+        >
           <a-select-option v-for="item in list" :key="item" :value="item">
-          {{ item }}
+            {{ item }}
           </a-select-option>
         </a-select>
-      </a-input-group>
     `,
   props: {
     value: {
@@ -31,12 +38,17 @@ const LogisticsPoint = {
     defLoad:{
       type: Boolean,
       default: true
+    },
+    size: {
+      type: String,
+      default: 'default'
     }
   },
   data() {
     return {
       defaultVal: this.value,
-      list: []
+      list: [],
+      open: false,
     };
   },
   mounted() {
@@ -55,16 +67,16 @@ const LogisticsPoint = {
         option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
       )
     },
-    changeSel(value) {
-      this.defaultVal = value;
-      this.$emit('change', value);
-      this.$emit('input', value);
+    onChange(value) {
+      console.log('onChange', value);
+      this.defaultVal = value||'';
+      this.open = false;
+      this.$emit('change', value||'');
+      this.$emit('input', value||'');
     },
-    handleChange(e) {
-      const value = e.target.value
-      this.defaultVal = value;
-      this.$emit('change', value);
-      this.$emit('input', value);
+    onBlur(value){
+      this.open = false;
+      this.$emit('blur', value);
     },
     getList (data) {
       if(!data){