import { IPublicModelSettingField } from '@alilc/lowcode-types'; import { FieldsSelectSetter, RsArraySetter, RsObjectSetter, RsStringSetter, } from 'lowcode/_setters'; import { uuid } from 'lowcode/_utils'; import selectOptionsProp from '../select-options'; export default (componentType: string) => { return [ { name: 'typeOptions', title: { label: '选项类型', }, setter: { componentName: 'SelectSetter', initialValue: 'custom', props: { options: [ { title: '自定义', value: 'custom', }, { title: '远程数据', value: 'remote', }, ], }, }, propType: { type: 'oneOf', value: ['custom', 'remote'], }, }, { name: 'optionsUrl', title: { label: { type: 'i18n', zh_CN: '选项接口 URL', en_US: 'options url', }, tip: { type: 'i18n', zh_CN: '获取下拉框选项数据的接口url,url中 value 字段为组件的实际值,title 字段为组件显示的标签', en_US: 'Interface URL for obtaining dropdown menu option data, the value field in the URL is the actual value of the component, and the title field is the label displayed by the component', }, }, propType: 'string', setter: 'StringSetter', condition: (target: IPublicModelSettingField) => { return target.getProps().getPropValue('typeOptions') === 'remote'; }, }, { name: 'select_titleField', title: { label: { type: 'i18n', zh_CN: '显示字段', en_US: 'title field', }, tip: { type: 'i18n', zh_CN: '显示字段', en_US: 'title field', }, }, defaultValue: 'label', propType: 'string', setter: 'StringSetter', condition: (target: IPublicModelSettingField) => { return target.getProps().getPropValue('typeOptions') === 'remote'; }, }, { name: 'select_valueField', title: { label: { type: 'i18n', zh_CN: '取值字段', en_US: 'value field', }, tip: { type: 'i18n', zh_CN: '取值字段', en_US: 'value field', }, }, defaultValue: 'value', propType: 'string', setter: 'StringSetter', condition: (target: IPublicModelSettingField) => { return target.getProps().getPropValue('typeOptions') === 'remote'; }, }, { name: 'autoBackFill', title: { label: { type: 'i18n', zh_CN: '选中项反填', en_US: 'auto fill in', }, tip: { type: 'i18n', zh_CN: '获取下拉框选项数据的接口url,url中 value 字段为组件的实际值,title 字段为组件显示的标签', en_US: 'Interface URL for obtaining dropdown menu option data, the value field in the URL is the actual value of the component, and the title field is the label displayed by the component', }, }, condition: (target: IPublicModelSettingField) => { return target.getProps().getPropValue('typeOptions') === 'remote'; }, supportVariable: false, type: 'field', display: 'block', setter: { componentName: RsArraySetter, props: { itemSetter: { componentName: RsObjectSetter, props: { config: { items: [ { name: 'key', title: { label: '', }, setter: RsStringSetter, defaultValue: () => uuid(), condition: () => { return false; }, }, { name: 'optionsField', important: true, title: { label: { type: 'i18n', zh_CN: '选项字段', en_US: 'options field', }, tip: { type: 'i18n', zh_CN: '下拉框选中项的数据字段', en_US: 'The data field of the selected item in the drop-down box', }, }, propType: 'string', setter: 'StringSetter', }, { name: 'fillInField', important: true, title: { label: { type: 'i18n', zh_CN: '反填项', en_US: 'fill in field', }, tip: { type: 'i18n', zh_CN: '选择填入数据的字段。当前表格列或当前表单项', en_US: 'Select the fields to fill in the data. Current table column or current form item', }, }, setter: { componentName: FieldsSelectSetter, initialValue: '', props: { componentType, disableCurrentItem: true, }, }, }, ], }, }, }, }, }, }, { ...selectOptionsProp, condition: (target: IPublicModelSettingField) => { return target.getProps().getPropValue('typeOptions') === 'custom'; }, }, ]; };