mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
🔱: [client] sync upgrade with 5 commits [trident-sync]
build: publish success chore: chore: perf: 优化export,支持查询导出
This commit is contained in:
@@ -52,6 +52,11 @@ function install(app: any, options: any = {}) {
|
||||
}
|
||||
}
|
||||
},
|
||||
toolbar: {
|
||||
export: {
|
||||
fileType: "excel"
|
||||
}
|
||||
},
|
||||
rowHandle: {
|
||||
buttons: {
|
||||
view: { type: "link", text: null, icon: "ion:eye-outline" },
|
||||
|
||||
@@ -585,6 +585,12 @@ export const crudResources = [
|
||||
path: "/crud/feature/local-import",
|
||||
component: "/crud/feature/local-import/index.vue"
|
||||
},
|
||||
{
|
||||
title: "导出",
|
||||
name: "FeatureExport",
|
||||
path: "/crud/feature/export",
|
||||
component: "/crud/feature/export/index.vue"
|
||||
},
|
||||
{
|
||||
title: "自定义删除",
|
||||
name: "FeatureRemove",
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { requestForMock } from "/src/api/service";
|
||||
const request = requestForMock;
|
||||
const apiPrefix = "/mock/FeatureExport";
|
||||
export function GetList(query: any) {
|
||||
return request({
|
||||
url: apiPrefix + "/page",
|
||||
method: "get",
|
||||
data: query
|
||||
});
|
||||
}
|
||||
|
||||
export function AddObj(obj: any) {
|
||||
return request({
|
||||
url: apiPrefix + "/add",
|
||||
method: "post",
|
||||
data: obj
|
||||
});
|
||||
}
|
||||
|
||||
export function UpdateObj(obj: any) {
|
||||
return request({
|
||||
url: apiPrefix + "/update",
|
||||
method: "post",
|
||||
data: obj
|
||||
});
|
||||
}
|
||||
|
||||
export function DelObj(id: any) {
|
||||
return request({
|
||||
url: apiPrefix + "/delete",
|
||||
method: "post",
|
||||
params: { id }
|
||||
});
|
||||
}
|
||||
|
||||
export function GetObj(id: any) {
|
||||
return request({
|
||||
url: apiPrefix + "/info",
|
||||
method: "get",
|
||||
params: { id }
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
import * as api from "./api";
|
||||
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
||||
import { Modal } from "ant-design-vue";
|
||||
import dayjs from "dayjs";
|
||||
export default function ({ crudExpose, context }: 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
|
||||
},
|
||||
toolbar: {
|
||||
export: {
|
||||
columnBuilder: ({ col }) => {
|
||||
// https://docs.sheetjs.com/docs/csf/features/#row-and-column-properties
|
||||
if (col.key === "multi") {
|
||||
col.width = 40;
|
||||
} else {
|
||||
col.width = 20;
|
||||
}
|
||||
},
|
||||
dataFormatter: ({ row, originalRow, col }) => {
|
||||
//格式化日期
|
||||
if (col.key === "date" && originalRow.date) {
|
||||
row.date = dayjs(originalRow.date).format("YYYY-MM-DD HH:mm:ss");
|
||||
}
|
||||
},
|
||||
fileType: context.fileType, //导出类型为excel
|
||||
dataFrom: context.dataFrom, //search查询获取, local 当前页数据
|
||||
searchParams: {
|
||||
//查询条件
|
||||
page: {
|
||||
currentPage: 1,
|
||||
pageSize: 99999999
|
||||
}
|
||||
//以下不传,以当前查询条件为准
|
||||
// form: {},
|
||||
// sort: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
columns: {
|
||||
id: {
|
||||
title: "ID",
|
||||
key: "id",
|
||||
type: "number",
|
||||
column: {
|
||||
width: 50
|
||||
},
|
||||
form: {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
text: {
|
||||
title: "文本",
|
||||
search: { show: true },
|
||||
type: "text"
|
||||
},
|
||||
radio: {
|
||||
title: "状态",
|
||||
search: { show: true },
|
||||
type: "dict-radio",
|
||||
dict: dict({
|
||||
url: "/mock/dicts/OpenStatusEnum?single"
|
||||
})
|
||||
},
|
||||
multi: {
|
||||
title: "多选",
|
||||
search: { show: true },
|
||||
type: "dict-select",
|
||||
dict: dict({
|
||||
url: "/mock/dicts/OpenStatusEnum?single"
|
||||
}),
|
||||
form: {
|
||||
component: {
|
||||
mode: "multiple"
|
||||
}
|
||||
}
|
||||
},
|
||||
date: {
|
||||
title: "日期",
|
||||
search: { show: true },
|
||||
type: "datetime",
|
||||
valueBuilder({ row, value, key }) {
|
||||
if (value) {
|
||||
row[key] = dayjs(value);
|
||||
}
|
||||
},
|
||||
valueResolve({ form, value, key }) {
|
||||
if (value) {
|
||||
form[key] = dayjs(value).unix();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<fs-page>
|
||||
<fs-crud ref="crudRef" v-bind="crudBinding">
|
||||
<template #toolbar-left>
|
||||
<span class="ml-5">
|
||||
导出文件类型
|
||||
<a-select v-model:value="fileType">
|
||||
<a-select-option value="excel">Excel</a-select-option>
|
||||
<a-select-option value="csv">CSV</a-select-option>
|
||||
</a-select>
|
||||
</span>
|
||||
<span class="ml-5">
|
||||
数据来源
|
||||
<a-select v-model:value="dataFrom">
|
||||
<a-select-option value="search">查询</a-select-option>
|
||||
<a-select-option value="local">本页数据</a-select-option>
|
||||
</a-select>
|
||||
</span>
|
||||
</template>
|
||||
</fs-crud>
|
||||
</fs-page>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, onMounted, ref } from "vue";
|
||||
import { useFs } from "@fast-crud/fast-crud";
|
||||
import createCrudOptions from "./crud";
|
||||
|
||||
export default defineComponent({
|
||||
name: "FeatureExport",
|
||||
setup() {
|
||||
const fileType = ref("excel");
|
||||
const dataFrom = ref("search");
|
||||
const context = {
|
||||
fileType,
|
||||
dataFrom
|
||||
};
|
||||
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context });
|
||||
// 页面打开后获取列表数据
|
||||
onMounted(() => {
|
||||
crudExpose.doRefresh();
|
||||
});
|
||||
|
||||
return {
|
||||
crudBinding,
|
||||
crudRef,
|
||||
...context
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,31 @@
|
||||
import mockUtil from "/src/mock/base";
|
||||
const options: any = {
|
||||
name: "FeatureExport",
|
||||
idGenerator: 0
|
||||
};
|
||||
const list = [
|
||||
{
|
||||
text: "测试文本1",
|
||||
radio: "1",
|
||||
multi: ["1", "2"],
|
||||
date: 1111111222222
|
||||
},
|
||||
{
|
||||
text: "测试文本2",
|
||||
radio: "2",
|
||||
multi: ["0", "2"],
|
||||
date: 123123234433
|
||||
},
|
||||
{
|
||||
text: "测试文本3"
|
||||
},
|
||||
{
|
||||
text: "测试文本4"
|
||||
},
|
||||
{
|
||||
text: "测试文本5"
|
||||
}
|
||||
];
|
||||
options.list = list;
|
||||
const mock = mockUtil.buildMock(options);
|
||||
export default mock;
|
||||
Reference in New Issue
Block a user