const schema = { title: "用户", type: "object", properties: { userName: { title: "用户名", type: "string", readOnly: true, showForList: true, rules: [ { required: true, }, { max: 64, }, { min: 4, }, ], }, password: { title: "密码", type: "string", readOnly: true, input: "password", rules: [ { required: true, }, { min: 6, }, ], }, name: { title: "姓名", type: "string", showForList: true, rules: [ { required: true, }, { pattern: "^[\u4e00-\u9fa5]+$", message: "%s必须是正确的格式" }, ], }, phoneNumber: { title: "电话", type: "string", showForList: true, rules: [ { required: true, }, { pattern: "^\\d{11}$", message: "%s必须是正确的格式" }, ], }, email: { title: "邮箱", type: "string", showForList: true, rules: [ { required: true }, { pattern: "^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+.[a-zA-Z0-9_-]+$", message: "%s必须是正确的格式" }, ], }, // roleNames: { // title: "角色", // type: "array", // input: "select", // multiple: true, // url: "identity/roles/all", // value: "name", // label: "name", // items: { // type: "string", // }, // }, }, }; const baseUrl = "base/user"; const queryUrl = `${baseUrl}`; const detailsUrl = `${baseUrl}/%s`; const createUrl = `${baseUrl}`; const updateUrl = `${baseUrl}/%s`; const deleteUrl = "identity/users/%s"; const queryMethod = "GET"; const detailsMethod = "GET"; const createMethod = "POST"; const updateMethod = "PUT"; const deleteMethod = "DELETE"; export default function () { return { query: { url: queryUrl, method: queryMethod, schema: { title: "用户", type: "object", properties: { filter: { title: "用户名", type: "string", }, skipCount: { hidden: true, default: 0, }, maxResultCount: { hidden: true, default: 10, }, }, }, }, table: { schema: schema, selectable: (o) => o.name !== "admin", }, edit: { detailsUrl, createUrl, updateUrl, deleteUrl, detailsMethod, createMethod, updateMethod, deleteMethod, schema: schema, }, }; }