import {filterList} from "@/api/system/invWarehouse";


export default {
  name: 'deptSelect',
  props: { value: { required: true }, notCode: null,maintenance: null,disabled: false,
  },
  data() {
    return {
      val: '',
      list: [],
    }
  },
  watch: {
    val(newVal) {
      this.$emit('update:value', newVal);
    },
    value(newVal) {
      this.val = newVal
    },
  },
  created() {
    this.val = this.value
    this.getList()
  },
  methods: {
    getList() {
      let data =
        {enable: true,
        }
        if (this.maintenance != null) data.maintenance = true
      filterList(data).then(res => {
        if (res.code == 20000) {
          this.list = res.data.list || []
          if(this.notCode!=null) {
            let index = this.list.findIndex(i => i.code == this.notCode);
            if(index!=-1){
              this.list.splice(index,1)
            }
          }
        }
      })
    }
  }
}
