import {getLocalJoinByUser} from "@/api/basic/busType";


export default {
  name: "actionSelect",
  props: {value:"",invCode:{required:true},mainAction:null},
  data() {
    return {
      val: '',
      list:[],
    }
  },
  watch: {
    mainAction(){
      this.val = null
      this.getList()
    },
    invCode(){
      this.val = null
      this.getList()
    },
    val(newVal) {
      this.$emit('update:value', newVal);
    },
    value(newVal) {
      this.val = newVal
    },
  },
  created() {
    this.val=this.value
    this.getList()
  },
  methods: {
    getList(){
      if(!this.invCode){
        return
      }
      let query = {
        code: this.invCode,
        enable: true,
        mainAction: this.mainAction,
        vueType: "supInvoice",
      };
      getLocalJoinByUser(query)
        .then((response) => {
          this.list = response.data.list || [];
        })
        .catch(() => {
        });
    }
  }
}
