12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <template>
- <div>
- <Select
- v-if="!value.id"
- :value="value[data.keyword]"
- :placeholder="data.props.placeholder"
- :filterable="data.props.filterable || false"
- :clearable="data.props.clearable || false"
- :multiple="data.props.multiple || false"
- :not-found-text="option[data.keyword].loading || '无匹配数据'"
- transfer
- @on-change="onChange"
- @on-open-change="onOpenChange">
- <Option
- v-for="(item, index) in option[data.keyword].list"
- :key="index"
- :value="item.value">{{item.label}}</Option>
- </Select>
- <error :text="error[data.keyword]" />
- </div>
- </template>
- <script>
- import allActions from '@/actions'
- export default {
- props: ['data', 'value', 'option', 'error'],
- data () {
- return {
- attribute_category_id: '',
- attribute_item: [],
- }
- },
- methods: {
- onChange (e) {
- this.getAttributeList(e)
- },
- onOpenChange (open) {
- if (!open) return
- const currentOption = this.option[this.data.keyword]
- this.$hub.$emit(this.data.hub, {
- type: 'option',
- payload: {
- type: currentOption.type || 'sync',
- keyword: currentOption.keyword || this.data.keyword,
- },
- })
- },
- async getAttributeList (v) {
- const res = await allActions.getAttributesDetail({ attribute_category_id: v })
- const patternData = []
- const parameterData = []
- res.forEach(i => {
- if (!i.attribute_type) {
- i.list = i.input_list.split(',')
- i.selected = []
- patternData.push(i)
- } else {
- i.list = i.input_list.split(',')
- i.text = ''
- i.selected = ''
- parameterData.push(i)
- }
- })
- this.$hub.$emit(this.data.hub, {
- type: 'value',
- payload: Object.assign(this.value, {
- attribute_category_id: v,
- patternData,
- parameterData,
- }),
- })
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- </style>
|