tachybase_todo/packages/plugins/@nocobase/plugin-mock-collections/src/server/field-interfaces/chinaRegion.ts
chenos 3b5b732a1a
feat: plugin-mock-collections (#2988)
* feat: plugin-mock-collections

* fix: mock bug

* feat: field interfaces

* fix: field interface

* fix: formula

* fix: file collection

* fix: map

* refactor: change api path from :create to :mock

* fix: avoid test failed

* chore: remove useless code

* fix: mock records

* fix: association

* feat: custom data

* fix: mockAttachment

* fix: count

---------

Co-authored-by: Rain <958414905@qq.com>
2023-11-10 11:32:03 +08:00

33 lines
963 B
TypeScript

import { uid } from '@nocobase/utils';
export const chinaRegion = {
options: (options) => ({
type: 'belongsToMany',
target: 'chinaRegions',
targetKey: 'code',
sortBy: 'level',
through: options.through || `t_${uid()}`,
foreignKey: options.foreignKey || `f_${uid()}`,
otherKey: options.otherKey || `f_${uid()}`,
sourceKey: options.sourceKey || 'id',
// name,
uiSchema: {
type: 'array',
// title,
'x-component': 'Cascader',
'x-component-props': {
useDataSource: '{{ useChinaRegionDataSource }}',
useLoadData: '{{ useChinaRegionLoadData }}',
changeOnSelectLast: options?.uiSchema?.['x-component-props']?.changeOnSelectLast || false,
labelInValue: true,
maxLevel: options?.uiSchema?.['x-component-props']?.maxLevel || 3,
fieldNames: {
label: 'name',
value: 'code',
children: 'children',
},
},
},
}),
};