mirror of
https://github.com/certd/certd.git
synced 2026-05-16 13:17:29 +08:00
6ec697b010
refactor: 1.11.0 refactor: 1.11.0 refactor: 1.11.0 refactor: 1.11.0 refactor: ts化 refactor: ts化 feat: 全面TS化 perf: 全面ts化 refactor: 继续优化ts perf: ts定义优化 fix: 修复wangeditor无法上传视频的bug
117 lines
3.0 KiB
TypeScript
117 lines
3.0 KiB
TypeScript
import * as api from "./api";
|
|
import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
|
import { message } from "ant-design-vue";
|
|
|
|
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
|
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
|
return await api.GetList(query);
|
|
};
|
|
const editRequest = async ({ form, row }: EditReq) => {
|
|
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
|
|
},
|
|
form: {
|
|
//配置表单label的宽度
|
|
labelCol: { span: 6 }
|
|
},
|
|
columns: {
|
|
id: {
|
|
title: "ID",
|
|
key: "id",
|
|
type: "number",
|
|
column: {
|
|
width: 50
|
|
},
|
|
form: {
|
|
show: false
|
|
}
|
|
},
|
|
button: {
|
|
title: "按钮",
|
|
search: { show: true },
|
|
type: "button",
|
|
column: {
|
|
component: {
|
|
show: compute(({ value }) => {
|
|
//当value为null时,不显示
|
|
return value != null;
|
|
}),
|
|
on: {
|
|
// 注意:必须要on前缀
|
|
onClick({ row }) {
|
|
message.success("按钮点击:" + row.button);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
url: {
|
|
title: "url",
|
|
search: { show: true },
|
|
type: "text",
|
|
column: {
|
|
show: false
|
|
}
|
|
},
|
|
link: {
|
|
title: "链接",
|
|
search: { show: true },
|
|
type: "link",
|
|
column: {
|
|
component: {
|
|
on: {
|
|
// 注意:必须要on前缀
|
|
onClick({ row }) {
|
|
if (row.url) {
|
|
window.open(row.url);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
form: {
|
|
title: "按钮文字"
|
|
}
|
|
},
|
|
link2: {
|
|
title: "手写link配置",
|
|
search: { show: true },
|
|
type: "text", //form组件用input
|
|
column: {
|
|
component: {
|
|
name: "fs-button", //列展示组件为button
|
|
vModel: "text", // 将row.link2的值赋值给text属性
|
|
type: "link", // 按钮展示为链接样式
|
|
on: {
|
|
//注册点击事件
|
|
// 注意:必须要on前缀
|
|
onClick({ row }) {
|
|
if (row.url) {
|
|
window.open(row.url);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|