|
|
|
@ -1,6 +1,6 @@ |
|
|
|
<!-- 选择部门 --> |
|
|
|
<template> |
|
|
|
<treeselect v-model="selected" :options="list" :show-count="true" :disabled="readonly" :placeholder="$t('form.placeholderSelect')" @input="handleChange" /> |
|
|
|
<treeselect v-model="selected" :options="list" :show-count="true" :disabled="readonly" :multiple="multiple" :placeholder="$t('form.placeholderSelect')" @input="handleChange" /> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
@ -19,12 +19,31 @@ export default { |
|
|
|
type: Boolean, |
|
|
|
default: false |
|
|
|
}, |
|
|
|
multiple: { |
|
|
|
type: Boolean, |
|
|
|
default: false |
|
|
|
}, |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
value: { |
|
|
|
immediate: true, |
|
|
|
handler(v) { |
|
|
|
this.selected = v ? parseInt(v) : null |
|
|
|
if (!this.multiple) { |
|
|
|
this.selected = v ? parseInt(v) : null |
|
|
|
} else { |
|
|
|
if (v) { |
|
|
|
//默认传的,分割的字符串,有传数组再改造 |
|
|
|
debugger |
|
|
|
let arr = (v+'').split(',') |
|
|
|
let s = [] |
|
|
|
_.forEach(arr, a => { |
|
|
|
s.push(parseInt(a)) |
|
|
|
}) |
|
|
|
this.selected = s |
|
|
|
} else { |
|
|
|
this.selected = [] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
@ -57,8 +76,8 @@ export default { |
|
|
|
}) |
|
|
|
}, |
|
|
|
handleChange(val) { |
|
|
|
this.$emit('input', val || '') |
|
|
|
this.$emit('change', val || '') |
|
|
|
this.$emit('input', this.multiple ? (val && val.length > 0 ? val.join(',') : '') : (val || '')) |
|
|
|
this.$emit('change', this.multiple ? (val && val.length > 0 ? val.join(',') : '') : (val || '')) |
|
|
|
}, |
|
|
|
} |
|
|
|
}; |
|
|
|
|