mirror of
https://github.com/certd/certd.git
synced 2026-04-14 12:30:54 +08:00
71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import * as api from "./api";
|
|
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
|
import { ref } from "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) => {
|
|
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);
|
|
};
|
|
|
|
const selectedRowKeys = ref([]);
|
|
|
|
const onSelectChange = (changed: any) => {
|
|
console.log("selection", changed);
|
|
selectedRowKeys.value = changed;
|
|
};
|
|
return {
|
|
selectedRowKeys, //返回给index.vue去使用
|
|
crudOptions: {
|
|
table: {
|
|
rowKey: "id",
|
|
rowSelection: {
|
|
selectedRowKeys: selectedRowKeys,
|
|
onChange: onSelectChange,
|
|
getCheckboxProps: (record: any) => ({
|
|
disabled: record.id === 1 // 此处演示第一行禁用
|
|
})
|
|
}
|
|
},
|
|
request: {
|
|
pageRequest,
|
|
addRequest,
|
|
editRequest,
|
|
delRequest
|
|
},
|
|
columns: {
|
|
id: {
|
|
title: "ID",
|
|
key: "id",
|
|
type: "number",
|
|
column: {
|
|
width: 50
|
|
},
|
|
form: {
|
|
show: false
|
|
}
|
|
},
|
|
radio: {
|
|
title: "状态",
|
|
search: { show: true },
|
|
type: "dict-radio",
|
|
dict: dict({
|
|
url: "/mock/dicts/OpenStatusEnum?single"
|
|
})
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|