|
|
@ -8,25 +8,25 @@ |
|
|
<!-- 处置方式:business_czfs --> |
|
|
<!-- 处置方式:business_czfs --> |
|
|
<template> |
|
|
<template> |
|
|
<div> |
|
|
<div> |
|
|
<el-select :style="showMax?'width:100%':''" v-model="selected" :placeholder="$t('form.placeholderSelect')" :disabled="readonly" :multiple="multiple" @change="handleChange" :filterable="filterable"> |
|
|
|
|
|
<el-option v-for="item in list" :key="item.dictCode" :label="item.dictLabel" :value="item.dictLabel" /> |
|
|
|
|
|
|
|
|
<el-select :style="showMax ? 'width:100%' : ''" v-model="selected" :placeholder="$t('form.placeholderSelect')" |
|
|
|
|
|
:disabled="readonly" :multiple="multiple" @change="handleChange" :filterable="filterable"> |
|
|
|
|
|
<el-option v-for="item in list" :key="item.dictCode" :label="item.dictLabel" :value="item.dictLabel" /> |
|
|
</el-select> |
|
|
</el-select> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import { listData } from "@/api/system/dict/data" |
|
|
import { listData } from "@/api/system/dict/data" |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
name: "BusinessSelect", |
|
|
name: "BusinessSelect", |
|
|
components: {}, |
|
|
components: {}, |
|
|
props: { |
|
|
props: { |
|
|
dictType: { |
|
|
dictType: { |
|
|
type: [Number, String , Array], |
|
|
|
|
|
|
|
|
type: [Number, String, Array], |
|
|
default: '' |
|
|
default: '' |
|
|
}, |
|
|
}, |
|
|
value: { |
|
|
value: { |
|
|
type: [Number, String , Array], |
|
|
|
|
|
|
|
|
type: [Number, String, Array], |
|
|
default: '', |
|
|
default: '', |
|
|
}, |
|
|
}, |
|
|
readonly: { |
|
|
readonly: { |
|
|
@ -54,18 +54,18 @@ export default { |
|
|
value: { |
|
|
value: { |
|
|
immediate: true, |
|
|
immediate: true, |
|
|
handler(v) { |
|
|
handler(v) { |
|
|
if(!this.multiple){ |
|
|
|
|
|
|
|
|
if (!this.multiple) { |
|
|
this.selected = v ? v : '' |
|
|
this.selected = v ? v : '' |
|
|
}else{ |
|
|
|
|
|
if(v){ |
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
if (v) { |
|
|
//默认传的,分割的字符串,有传数组再改造 |
|
|
//默认传的,分割的字符串,有传数组再改造 |
|
|
let arr = v.split(',') |
|
|
let arr = v.split(',') |
|
|
let s = [] |
|
|
let s = [] |
|
|
_.forEach(arr,a=>{ |
|
|
|
|
|
|
|
|
_.forEach(arr, a => { |
|
|
s.push(a) |
|
|
s.push(a) |
|
|
}) |
|
|
}) |
|
|
this.selected = s |
|
|
this.selected = s |
|
|
}else{ |
|
|
|
|
|
|
|
|
} else { |
|
|
this.selected = [] |
|
|
this.selected = [] |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@ -90,23 +90,45 @@ export default { |
|
|
methods: { |
|
|
methods: { |
|
|
getList() { |
|
|
getList() { |
|
|
this.list = [] |
|
|
this.list = [] |
|
|
listData(this.queryParams).then(response => { |
|
|
|
|
|
this.list = response.rows |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
if (this.dictType === 'business_ccwz') { |
|
|
|
|
|
listData(this.queryParams).then(response => { |
|
|
|
|
|
this.list = response.rows |
|
|
|
|
|
this.list.forEach(item => { |
|
|
|
|
|
item.dictLabel = item.bh |
|
|
|
|
|
item.dictCode = item.id |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
listData(this.queryParams).then(response => { |
|
|
|
|
|
this.list = response.rows |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
handleChange(val) { |
|
|
handleChange(val) { |
|
|
this.$emit('input', this.multiple ? (val && val.length>0 ? val.join(','): ''):(val || '')) |
|
|
|
|
|
//默认传的,分割的字符串,有传数组再改造 |
|
|
|
|
|
let _index = _.findIndex(this.list, function (a) { |
|
|
|
|
|
return a.dictLabel == val |
|
|
|
|
|
}) |
|
|
|
|
|
console.log(_index) |
|
|
|
|
|
if (_index > -1) { |
|
|
|
|
|
this.$emit('change', this.list[_index]) |
|
|
|
|
|
|
|
|
console.log(val) |
|
|
|
|
|
if (this.dictType === 'business_ccwz') { |
|
|
|
|
|
this.$emit('input', this.multiple ? (val && val.length > 0 ? val.join(',') : '') : (val || '')) |
|
|
|
|
|
//默认传的,分割的字符串,有传数组再改造 |
|
|
|
|
|
let _index = _.findIndex(this.list, function (a) { |
|
|
|
|
|
return a.dictLabel == val |
|
|
|
|
|
}) |
|
|
|
|
|
if (_index > -1) { |
|
|
|
|
|
this.$emit('change', this.list[_index]) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.$emit('change', null) |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
this.$emit('change', null) |
|
|
|
|
|
|
|
|
this.$emit('input', this.multiple ? (val && val.length > 0 ? val.join(',') : '') : (val || '')) |
|
|
|
|
|
//默认传的,分割的字符串,有传数组再改造 |
|
|
|
|
|
let _index = _.findIndex(this.list, function (a) { |
|
|
|
|
|
return a.dictLabel == val |
|
|
|
|
|
}) |
|
|
|
|
|
if (_index > -1) { |
|
|
|
|
|
this.$emit('change', this.list[_index]) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.$emit('change', null) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|