<template>
  <!-- <nm-combobox :value_="vmodel" v-model="vmodel" :isMultiple="isMultiple" :dataSource="unitData" label="请选择单位"> </nm-combobox> -->
  <nm-combobox :value_="vmodel" v-model="v_model" :returnobject="returnObject" :isMultiple="isMultiple" :dataSource="unitData" label="请选择单位"> </nm-combobox>
</template>

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

const unitapi = $api.materialApp.material

export default {
  mixins: [mixins.formSave],
  props: {
    returnObject: {
      type: Boolean,
      default: false
    },
    model: {
      type: [String, Object],
      default: ''
    },
    itemdisabled: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    },
    isMultiple: {
      type: Boolean,
      default: false
    },
    unitDataRules: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      vmodel: this.model,
      v_model: this.model,
      unitData: []
    }
  },

  methods: {
    // query() {
    //   return new Promise(resolve => {
    //     this.$nextTick(() => {
    //       unitapi.getUnit().then(data => {
    //         this.unitData = data
    //         resolve(this.unitData)
    //       })
    //     })
    //   })
    // },
    getData() {
      unitapi.getUnit().then(data => {
        this.unitData = data
      })
    }
  },
  created() {
    unitapi.getUnit().then(data => {
      this.unitData = data
    })
  },
  watch: {
    v_model: function(val) {
      this.vmodel = val
      this.v_model = val
      // console.log(this.model, '子传父')
      this.$emit('input', val)
    },
    model: function(val) {
      this.v_model = val
      this.vmodel = val
      // console.log(this.model, '子传孙')
    }
  }
}
</script>
