mirror of https://github.com/certd/certd
🔱: [client] sync upgrade with 5 commits [trident-sync]
build: publish success chore: chore: perf: 优化export,支持查询导出pull/14/head
parent
474fd77970
commit
b4c4dc2c2e
|
@ -3,6 +3,12 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.14.5](https://github.com/fast-crud/fast-crud/compare/v1.14.4...v1.14.5) (2023-07-04)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复search.value第一次查询无效的bug ([d9a907a](https://github.com/fast-crud/fast-crud/commit/d9a907a477bae66662a8a8720a24ab3506772d30))
|
||||
|
||||
## [1.14.4](https://github.com/fast-crud/fast-crud/compare/v1.14.3...v1.14.4) (2023-07-02)
|
||||
|
||||
**Note:** Version bump only for package @fast-crud/fs-admin-antdv
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@fast-crud/fs-admin-antdv",
|
||||
"version": "1.14.4",
|
||||
"version": "1.14.5",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
@ -26,10 +26,10 @@
|
|||
"@ant-design/icons-vue": "^6.1.0",
|
||||
"@aws-sdk/client-s3": "^3.292.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.292.0",
|
||||
"@fast-crud/fast-crud": "^1.14.4",
|
||||
"@fast-crud/fast-extends": "^1.14.4",
|
||||
"@fast-crud/ui-antdv": "^1.14.4",
|
||||
"@fast-crud/ui-interface": "^1.14.4",
|
||||
"@fast-crud/fast-crud": "^1.14.5",
|
||||
"@fast-crud/fast-extends": "^1.14.5",
|
||||
"@fast-crud/ui-antdv": "^1.14.5",
|
||||
"@fast-crud/ui-interface": "^1.14.5",
|
||||
"@iconify/iconify": "^3.1.0",
|
||||
"@iconify/json": "^2.2.35",
|
||||
"@purge-icons/generated": "^0.9.0",
|
||||
|
|
|
@ -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;
|
Loading…
Reference in New Issue