function crudCommonOptions() { return { affixHeader: false, stopAutoRefreshWhenModalIsOpen: true, resizable: false, syncLocation: false, silentPolling: true, } } function readOnlyDialogOptions() { return { actions: [], showCloseButton: false, closeOnEsc: true, closeOnOutside: true, disabled: true, } } function paginationCommonOptions(perPage = true, maxButtons = 5) { let option = { type: 'pagination', layout: [ 'pager' ], maxButtons: maxButtons, showPageInput: false, perPageAvailable: [10, 15, 20, 50, 100, 200], } if (perPage) { option.layout.push('perPage') } return option } function paginationTemplate(perPage = 20, maxButtons = 5) { return { perPage: perPage, headerToolbar: [ "reload", paginationCommonOptions(true, maxButtons), ], footerToolbar: [ "statistics", paginationCommonOptions(true, maxButtons), ], } } function mappingField(field, mapping) { let mapData = { '*': `\${${field}}`, } mapping.forEach(item => { mapData[item['value']] = `${item['label']}` }) return { type: 'mapping', value: `\${${field}}`, map: mapData, } } function mappingItem(label, value, color = 'bg-info') { return { label: label, value: value, color: color, } } const userRoleMapping = [ mappingItem('数据提供方', 'PROVIDER', 'bg-blue-500'), mappingItem('数据使用方', 'CUSTOMER', 'bg-purple-500'), mappingItem('审核监管方', 'CHECKER', 'bg-cyan-500'), mappingItem('系统管理员', 'ADMINISTRATOR', 'bg-green-500'), ] const userStateMapping = [ mappingItem('审查中', 'CHECKING', 'bg-warning'), mappingItem('正常', 'NORMAL', 'bg-success'), mappingItem('禁用', 'DISABLED', 'bg-danger'), ] function userAddDialog() { return { actionType: 'dialog', dialog: { title: '新用户注册', actions: [ { type: 'reset', label: '清空', }, { type: 'submit', label: '注册', level: 'primary', } ], body: { type: 'form', api: '${base}/user/register', mode: 'horizontal', canAccessSuperData: false, horizontal: { left: 2, }, body: [ { type: 'input-email', name: 'username', label: '邮箱', placeholder: '请输入邮箱', required: true, clearable: true, clearValueOnEmpty: true, validateApi: '${base}/user/exists_username/${username}' }, { type: 'input-password', name: 'password', label: '密码', placeholder: '请输入密码', required: true, clearable: true, clearValueOnEmpty: true, validations: { matchRegexp: /^(?=.*\d)(?!.*(\d)\1{2})(?!.*(012|123|234|345|456|567|678|789|987|876|765|654|543|432|321|210))(?=.*[a-zA-Z])(?=.*[^\da-zA-Z\s]).{8,16}$/ }, validationErrors: { matchRegexp: '密码至少包含字母、数字、特殊字符,8-16位,并且不能连续出现3个大小连续或相同的数字', } }, { type: 'input-password', name: 'confirm-password', label: '确认密码', placeholder: '请再次输入密码', required: true, clearable: true, validations: { equalsField: 'password' }, validationErrors: { equalsField: '两次输入密码不一致', } }, { type: 'radios', name: 'role', label: '角色', required: true, selectFirst: true, options: [ {label: '数据提供方', value: 'PROVIDER'}, {label: '数据使用方', value: 'CUSTOMER'}, {label: '审查监管方', value: 'CHECKER'}, ] }, ] } } } }