mirror of
https://github.com/certd/certd.git
synced 2026-05-16 13:17:29 +08:00
ad360e81cb
perf: 优化antdv4 示例授权页面tree的样式 build: publish success chore: 1 chore: 1 chore: 1 fix: getFileName支持item参数 https://github.com/fast-crud/fast-crud/issues/385 fix: fs-form独立使用支持插槽 https://github.com/fast-crud/fast-crud/issues/389 fix: 修复三级以上路由页面无法缓存的问题 https://github.com/fast-crud/fast-crud/issues/394 perf: form.wrapper.buttons支持compute动态计算 feat: 表单支持变更关闭前提醒保存,form.wrapper支持beforeClose事件 fix: 修复图片裁剪按钮上下和左右相反的bug https://github.com/fast-crud/fast-crud/issues/402 perf: alioss getAuthorization接口支持后台返回key https://github.com/fast-crud/fast-crud/issues/405 perf: alioss getAuthorization接口支持后台返回key https://github.com/fast-crud/fast-crud/issues/405 perf: fs-dict-tree支持插槽 https://github.com/fast-crud/fast-crud/issues/407 perf: 单选、多选、select、tree-select、table-select 都提供selected-change事件,可以获取选中的dict选项 feat: table-select 支持查看模式 https://github.com/fast-crud/fast-crud/issues/413 perf: 优化fs-admin可以在手机上操作 chore: pnpm workspace问题优化 docs: 1 chore: antdv4 支持主题色选择 ...
147 lines
4.1 KiB
TypeScript
147 lines
4.1 KiB
TypeScript
import * as api from "./api";
|
|
import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes, utils } from "@fast-crud/fast-crud";
|
|
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
|
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
|
return await api.GetList(query);
|
|
};
|
|
const editRequest = async ({ form, row }: EditReq) => {
|
|
if (form.id == null) {
|
|
form.id = row.id;
|
|
}
|
|
return await api.UpdateObj(form);
|
|
};
|
|
const delRequest = async ({ row }: DelReq) => {
|
|
return await api.DelObj(row.id);
|
|
};
|
|
|
|
const addRequest = async ({ form }: AddReq) => {
|
|
return await api.AddObj(form);
|
|
};
|
|
|
|
return {
|
|
crudOptions: {
|
|
request: {
|
|
pageRequest,
|
|
addRequest,
|
|
editRequest,
|
|
delRequest
|
|
},
|
|
//将 addRow 按钮启用
|
|
actionbar: { buttons: { add: { show: false }, addRow: { show: true } } },
|
|
table: {
|
|
editable: {
|
|
enabled: true,
|
|
mode: "row",
|
|
exclusive: true, //排他式激活
|
|
exclusiveEffect: "save" //排他式激活时,其他行的编辑状态的处理方式
|
|
}
|
|
},
|
|
columns: {
|
|
id: {
|
|
title: "ID",
|
|
type: "number",
|
|
form: {
|
|
show: false
|
|
},
|
|
column: { width: 80, align: "center" }
|
|
},
|
|
disable: {
|
|
title: "禁止编辑",
|
|
type: "text",
|
|
column: {
|
|
editable: {
|
|
disabled: true //也可以配置为方法,根据条件禁用或启用编辑
|
|
// disabled: ({ column, index, row }) => {
|
|
// return index % 2 === 0;
|
|
// }
|
|
}
|
|
}
|
|
},
|
|
radio: {
|
|
title: "状态",
|
|
search: { show: true },
|
|
type: "dict-radio",
|
|
dict: dict({
|
|
url: "/mock/dicts/OpenStatusEnum?single"
|
|
}),
|
|
column: {
|
|
width: 300
|
|
},
|
|
form: {
|
|
rules: {
|
|
async asyncValidator(context) {
|
|
utils.logger.info("context", context);
|
|
return true;
|
|
},
|
|
message: "远程校验测试"
|
|
}
|
|
}
|
|
},
|
|
target: {
|
|
title: "根据状态动态显隐",
|
|
search: { show: true },
|
|
type: "text",
|
|
form: {
|
|
conditionalRender: {
|
|
match: ({ form }) => {
|
|
return form.radio === "2";
|
|
},
|
|
render: ({ form }) => {
|
|
return <div>已停止</div>;
|
|
}
|
|
},
|
|
show: compute(({ form }) => {
|
|
return form.radio !== "0";
|
|
})
|
|
}
|
|
},
|
|
"user.name": {
|
|
title: "姓名",
|
|
type: "text",
|
|
form: {
|
|
key: ["user", "name"],
|
|
rules: [
|
|
{ required: true, message: "请输入姓名" },
|
|
{
|
|
type: "string",
|
|
min: 2,
|
|
max: 10,
|
|
message: "长度在 2 到 10 个字符"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
address: {
|
|
title: "地址",
|
|
children: {
|
|
province: {
|
|
title: "省份",
|
|
search: { show: true },
|
|
type: "text",
|
|
form: {
|
|
rules: [{ required: true, message: "请输入省份" }]
|
|
}
|
|
},
|
|
city: {
|
|
title: "城市",
|
|
search: { show: true },
|
|
type: "dict-select",
|
|
dict: dict({
|
|
value: "id",
|
|
label: "text",
|
|
data: [
|
|
{ id: "sz", text: "深圳", color: "success" },
|
|
{ id: "gz", text: "广州", color: "primary" },
|
|
{ id: "bj", text: "北京" },
|
|
{ id: "wh", text: "武汉" },
|
|
{ id: "sh", text: "上海" }
|
|
]
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|