lilei 2 yıl önce
ebeveyn
işleme
da8a6b31e4

+ 3 - 3
src/views/basicData/transferTypeManagement/editModal.vue

@@ -20,7 +20,7 @@
           :wrapper-col="formItemLayout.wrapperCol"
         >
           <a-form-model-item label="调拨类别" prop="allocateCategory">
-            <allocateType id="transferTypeManagementEdit-allocateCategory" @change="changeCategory" :level="2" v-model="form.allocateCategory" placeholder="请选择调拨类别"></allocateType>
+            <AllocateTypeByLevel id="transferTypeManagementEdit-allocateCategory" @change="changeCategory" :level="2" v-model="form.allocateCategory" placeholder="请选择调拨类别"></AllocateTypeByLevel>
           </a-form-model-item>
           <a-form-model-item label="调拨类型名称" prop="name">
             <a-input
@@ -45,11 +45,11 @@
 import { commonMixin } from '@/utils/mixin'
 import { VSelect } from '@/components'
 import { allocateTypeSave } from '@/api/allocateType'
-import allocateType from '@/views/common/allocateType'
+import AllocateTypeByLevel from '@/views/common/allocateTypeByLevel.js'
 export default {
   name: 'TransferTypeManagementEditModal',
   mixins: [commonMixin],
-  components: { VSelect, allocateType },
+  components: { VSelect, AllocateTypeByLevel },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,

+ 72 - 0
src/views/common/allocateTypeByLevel.js

@@ -0,0 +1,72 @@
+import { queryListByTreeLevel } from '@/api/allocateType'
+const AllocateTypeByLevel = {
+  template: `
+      <a-select
+        :placeholder="placeholder"
+        :id="id"
+        allowClear
+        :value="defaultVal"
+        :showSearch="true"
+        @change="handleChange"
+        option-filter-prop="children"
+        :filter-option="filterOption">
+        <a-select-option v-for="item in list" :key="item.allocateTypeSn" :value="item.allocateTypeSn">{{ item.name }}</a-select-option>
+      </a-select>
+    `,
+  props: {
+    value: {
+      type: [String,Number],
+      defatut: ''
+    },
+    id: {
+      type: String,
+      default: ''
+    },
+    level: {
+      type: [String,Number],
+      default: '3'
+    },
+    placeholder:{
+      type: String,
+      default: '请选择'
+    }
+  },
+  data() {
+    return {
+      defaultVal: this.value,
+      list: []
+    };
+  },
+  mounted() {
+    this.getProductBrand()
+  },
+  watch: {
+    value(newValue, oldValue) {
+      this.defaultVal = newValue
+    }
+  },
+  methods: {
+    filterOption (input, option) {
+      return (
+        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
+      )
+    },
+    handleChange(value) {
+      this.defaultVal = value;
+      this.$emit('input', value);
+      this.$emit('change', value);
+    },
+    //  调拨类型
+    getProductBrand () {
+      queryListByTreeLevel({"treeLevel":this.level}).then(res => {
+        if (res.status == 200) {
+          this.list = res.data
+        } else {
+          this.list = []
+        }
+      })
+    },
+  },
+};
+
+export default AllocateTypeByLevel