<template>
  <nm-combobox v-show="isShow" :value_="vmodel" v-model="vmodel" :isMultiple="isMultiple" :returnobject="returnObject" :dataSource="itemData" label="请选择清单明细"> </nm-combobox>
</template>

<script>
import { mixins } from 'xmanager-ui'

const unitapi = $api.materialApp.billOfMaterialsItem

export default {
  mixins: [mixins.formSave],
  props: {
    //条件
    bomNId: {
      type: String,
      default: '00000000-0000-0000-0000-000000000000'
    },
    returnObject: {
      type: Boolean,
      default: false
    },
    model: {
      type: String,
      default: ''
    },
    itemdisabled: {
      type: Boolean,
      default: false
    },
    // disabled: {
    //   type: Boolean,
    //   default: true
    // },
    isMultiple: {
      type: Boolean,
      default: true
    },
    unitDataRules: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      vmodel: this.model,
      // itemData: this.getData(),
      itemData: [],
      //显示
      isShow: false
    }
  },

  methods: {
    getData() {
      //this.bomNId
      console.log(this.bomNId)
      unitapi.select({ BillOfMaterials: this.bomNId }).then(data => {
        this.itemData = data
      })
    }
  },
  watch: {
    vmodel: function(val) {
      this.vmodel = val
      this.$emit('input', val)
    },
    bomNId: function(val) {
      if (val != null || val != '') {
        this.isShow = true
        unitapi.select({ BillOfMaterials: val }).then(data => {
          this.itemData = data
        })
        this.vmodel = []
      } else {
        this.itemData = []
        this.isShow = false
      }
    }
  }
}
</script>
