amis-saas-7945 Merge remote-tracking branch 'origin/feat_input-city-improve' into amis-saas-7944

Change-Id: I3dad6252853fd654e9620c289efaad1896229602
This commit is contained in:
igrowp 2022-12-19 15:23:37 +08:00
commit 4070a89214

View File

@ -7,6 +7,7 @@ import {
SubRendererInfo, SubRendererInfo,
BaseEventContext BaseEventContext
} from 'amis-editor-core'; } from 'amis-editor-core';
import cloneDeep from 'lodash/cloneDeep';
import {formItemControl} from '../../component/BaseControl'; import {formItemControl} from '../../component/BaseControl';
import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core'; import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core';
@ -29,7 +30,10 @@ export class CityControlPlugin extends BasePlugin {
scaffold = { scaffold = {
type: 'input-city', type: 'input-city',
label: '城市选择', label: '城市选择',
name: 'city' name: 'city',
allowCity: true,
allowDistrict: true,
extractValue: true
}; };
previewSchema: any = { previewSchema: any = {
type: 'form', type: 'form',
@ -104,25 +108,64 @@ export class CityControlPlugin extends BasePlugin {
rendererWrapper: true, rendererWrapper: true,
mode: 'vertical' // 改成上下展示模式 mode: 'vertical' // 改成上下展示模式
}), }),
getSchemaTpl('switch', { {
name: 'allowDistrict', name: 'extractValue',
label: '允许选择区域', label: '值格式',
pipeIn: defaultValue(true) type: 'button-group-select',
}), size: 'sm',
options: [
{label: '行政编码', value: true},
{label: '对象结构', value: false}
]
},
getSchemaTpl('switch', { getSchemaTpl('switch', {
name: 'allowCity', name: 'allowCity',
label: '允许选择城市', label: '可选城市',
pipeIn: defaultValue(true) pipeIn: defaultValue(true),
onChange: (
value: string,
oldValue: string,
item: any,
form: any
) => {
if (!value) {
const schema = cloneDeep(form.data);
form.setValueByName('allowDistrict', undefined);
form.setValueByName('value', schema.extractValue ? '' : {});
}
}
}),
getSchemaTpl('switch', {
name: 'allowDistrict',
label: '可选区域',
visibleOn: 'data.allowCity',
pipeIn: defaultValue(true),
onChange: (
value: string,
oldValue: string,
item: any,
form: any
) => {
if (!value) {
const schema = cloneDeep(form.data);
form.setValueByName('value', schema.extractValue ? '' : {});
}
}
}), }),
getSchemaTpl('switch', { getSchemaTpl('switch', {
name: 'searchable', name: 'searchable',
label: '是否出搜索框', label: '可搜索',
pipeIn: defaultValue(false) pipeIn: defaultValue(false)
}), }),
getSchemaTpl('loadingConfig', {}, {context}) getSchemaTpl('loadingConfig', {}, {context}),
getSchemaTpl('labelRemark'),
getSchemaTpl('remark'),
getSchemaTpl('description'),
getSchemaTpl('autoFillApi')
] ]
}, },
getSchemaTpl('status', {isFormItem: true}), getSchemaTpl('status', {isFormItem: true}),