Files
certd/packages/ui/certd-client/src/views/crud/feature/search/crud.jsx
T
2023-01-29 15:26:45 +08:00

92 lines
2.2 KiB
React

import * as api from "./api";
import { dict } from "@fast-crud/fast-crud";
import { ref } from "vue";
export default function ({ expose }) {
const pageRequest = async (query) => {
return await api.GetList(query);
};
const editRequest = async ({ form, row }) => {
form.id = row.id;
return await api.UpdateObj(form);
};
const delRequest = async ({ row }) => {
return await api.DelObj(row.id);
};
const addRequest = async ({ form }) => {
return await api.AddObj(form);
};
return {
crudOptions: {
request: {
pageRequest,
addRequest,
editRequest,
delRequest
},
table: {
// 表头过滤改变事件
onFilterChange(e) {
console.log("onFilterChange", e);
}
},
search: {
initialForm: {
radio: "0"
},
buttons: {
custom: {
text: "自定义",
show: true,
order: 3,
icon: {
icon: "ant-design:search",
style: {
"font-size": "16px"
}
},
click() {
console.log("点击了自定义按钮");
}
}
}
},
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"
}),
column: {
filters: [
{ text: "开", value: "1" },
{ text: "关", value: "0" },
{ text: "停", value: "2" }
],
// specify the condition of filtering result
// here is that finding the name started with `value`
onFilter: (value, record) => {
return record.radio === value;
},
sorter: (a, b) => a.radio - b.radio,
sortDirections: ["descend"]
}
}
}
}
};
}