From 907db1d3c9667ca1c5af1ffaea4d12b3bc89b49a Mon Sep 17 00:00:00 2001 From: juetan Date: Thu, 12 Oct 2023 22:10:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/form/form-node.tsx | 2 +- src/components/table/use-interface.ts | 16 ++++++- src/components/table/use-table.tsx | 17 ++++++- src/pages/post/category/index.vue | 16 +++---- src/pages/post/media/components/use-modal.ts | 4 -- src/pages/post/media/index.vue | 50 +++++++++++++++++--- src/styles/css-arco.less | 1 + src/types/auto-component.d.ts | 24 ++++++++++ src/types/vite-env.d.ts | 5 ++ src/utils/delConfirm.ts | 3 +- 10 files changed, 113 insertions(+), 25 deletions(-) delete mode 100644 src/pages/post/media/components/use-modal.ts diff --git a/src/components/form/form-node.tsx b/src/components/form/form-node.tsx index 24e6413..46774a4 100644 --- a/src/components/form/form-node.tsx +++ b/src/components/form/form-node.tsx @@ -58,7 +58,7 @@ export const nodeMap = { nodeProps: { placeholder: "请输入", allowClear: true, - } as InstanceType["$props"], + } as InstanceType["$props"] & InstanceType["$props"], }, /** * 文本域 diff --git a/src/components/table/use-interface.ts b/src/components/table/use-interface.ts index 414a9bf..a8df104 100644 --- a/src/components/table/use-interface.ts +++ b/src/components/table/use-interface.ts @@ -1,8 +1,8 @@ import { Doption, Link, TableColumnData, TableData } from "@arco-design/web-vue"; +import { RenderFunction } from "vue"; import { FormModalProps, FormProps } from "../form"; import { IFormItem } from "../form/form-item"; import { TableProps } from "./table"; -import { RenderFunction } from "vue"; interface UseColumnRenderOptions { /** @@ -102,12 +102,20 @@ type ExtendedFormItem = Partial & { extend?: string; }; +type SearchFormItem = ExtendedFormItem & { + enableLoad?: boolean; +}; + type Search = Partial< Omit & { /** * 表单项 */ - items?: ExtendedFormItem[]; + items?: SearchFormItem[]; + /** + * bu + */ + button?: boolean } >; @@ -147,4 +155,8 @@ export interface UseTableOptions extends Omit UseTableOptions)) continue; } } - searchItems.push(merge({}, item)); + const search = !item.enableLoad ? undefined : () => getTable().reloadData() + searchItems.push( + merge( + { + nodeProps: { + onSearch: search, + onPressEnter: search + }, + }, + item + ) + ); + } + if (options.search.button !== false) { + searchItems.push(config.searchItemSubmit); } - searchItems.push(config.searchItemSubmit); options.search.items = searchItems; } diff --git a/src/pages/post/category/index.vue b/src/pages/post/category/index.vue index b7db5cb..7342a9a 100644 --- a/src/pages/post/category/index.vue +++ b/src/pages/post/category/index.vue @@ -1,8 +1,6 @@ @@ -45,8 +43,8 @@ const table = useTable({ width: 120, buttons: [ { - type: 'modify', - text: '修改' + type: "modify", + text: "修改", }, { type: "delete", @@ -59,15 +57,17 @@ const table = useTable({ }, ], search: { + button: false, items: [ { field: "nickname", label: "登陆账号", - type: "input", + type: "search", required: false, + enableLoad: true, nodeProps: { - placeholder: "名称关键字", - }, + placeholder: "分类名称", + } as any, itemProps: { hideLabel: true, }, diff --git a/src/pages/post/media/components/use-modal.ts b/src/pages/post/media/components/use-modal.ts deleted file mode 100644 index 75d227a..0000000 --- a/src/pages/post/media/components/use-modal.ts +++ /dev/null @@ -1,4 +0,0 @@ - -export const useModal = (modal: any) => { - -} \ No newline at end of file diff --git a/src/pages/post/media/index.vue b/src/pages/post/media/index.vue index 6851beb..f5c34fe 100644 --- a/src/pages/post/media/index.vue +++ b/src/pages/post/media/index.vue @@ -19,9 +19,10 @@ -
  • +
  • 日常素材 @@ -57,6 +58,23 @@ import { api } from "@/api"; import { Table, useTable } from "@/components"; import { dayjs } from "@/libs/dayjs"; +import numeral from 'numeral'; + +const getIcon = (mimetype: string) => { + if (mimetype.startsWith("image")) { + return "icon-file-iimage"; + } + if (mimetype.startsWith("video")) { + return "icon-file-ivideo"; + } + if (mimetype.startsWith("text")) { + return "icon-file-itxt"; + } + if (mimetype.startsWith("audio")) { + return "icon-file-iaudio"; + } + return "icon-file-iunknown"; +}; const table = useTable({ data: async (model, paging) => { @@ -66,14 +84,23 @@ const table = useTable({ { title: "文件名称", dataIndex: "name", - width: 260, + render: ({ record }) => { + return ( +
    + + {record.name} +
    + ); + }, }, { - title: "操作描述", + title: "大小", dataIndex: "description", + width: 120, + render: ({ record }) => numeral(record.size).format('0 b') }, { - title: "登陆时间", + title: "上传时间", dataIndex: "createdAt", width: 200, render: ({ record }) => dayjs(record.createdAt).format(), @@ -85,6 +112,7 @@ const table = useTable({ buttons: [ { type: "modify", + text: '修改' }, { type: "delete", @@ -97,11 +125,19 @@ const table = useTable({ }, ], search: { + button: false, items: [ { field: "name", label: "文件名称", - type: "input", + type: "search", + enableLoad: true, + itemProps: { + hideLabel: true, + }, + nodeProps: { + placeholder: '素材名称...' + } as any }, ], }, diff --git a/src/styles/css-arco.less b/src/styles/css-arco.less index 6bc69f4..338bf63 100644 --- a/src/styles/css-arco.less +++ b/src/styles/css-arco.less @@ -3,6 +3,7 @@ @arcoblue-6: #08f; body { + --border-radius-small: 4px; li.arco-dropdown-option { line-height: 28px; width: calc(100% - 8px); diff --git a/src/types/auto-component.d.ts b/src/types/auto-component.d.ts index 6563669..461209e 100644 --- a/src/types/auto-component.d.ts +++ b/src/types/auto-component.d.ts @@ -7,34 +7,58 @@ export {} declare module '@vue/runtime-core' { export interface GlobalComponents { + AAlert: typeof import('@arco-design/web-vue')['Alert'] AAutoComplete: typeof import('@arco-design/web-vue')['AutoComplete'] + AAvatar: typeof import('@arco-design/web-vue')['Avatar'] + ABreadcrumb: typeof import('@arco-design/web-vue')['Breadcrumb'] + ABreadcrumbItem: typeof import('@arco-design/web-vue')['BreadcrumbItem'] AButton: typeof import('@arco-design/web-vue')['Button'] + ACard: typeof import('@arco-design/web-vue')['Card'] ACheckbox: typeof import('@arco-design/web-vue')['Checkbox'] + ACheckboxGroup: typeof import('@arco-design/web-vue')['CheckboxGroup'] AConfigProvider: typeof import('@arco-design/web-vue')['ConfigProvider'] + ADatePicker: typeof import('@arco-design/web-vue')['DatePicker'] ADivider: typeof import('@arco-design/web-vue')['Divider'] ADoption: typeof import('@arco-design/web-vue')['Doption'] + ADrawer: typeof import('@arco-design/web-vue')['Drawer'] + ADropdown: typeof import('@arco-design/web-vue')['Dropdown'] ADropdownButton: typeof import('@arco-design/web-vue')['DropdownButton'] AEmpty: typeof import('@arco-design/web-vue')['Empty'] AForm: typeof import('@arco-design/web-vue')['Form'] AFormItem: typeof import('@arco-design/web-vue')['FormItem'] + AImage: typeof import('@arco-design/web-vue')['Image'] AInput: typeof import('@arco-design/web-vue')['Input'] AInputNumber: typeof import('@arco-design/web-vue')['InputNumber'] AInputPassword: typeof import('@arco-design/web-vue')['InputPassword'] AInputSearch: typeof import('@arco-design/web-vue')['InputSearch'] + ALayout: typeof import('@arco-design/web-vue')['Layout'] + ALayoutContent: typeof import('@arco-design/web-vue')['LayoutContent'] + ALayoutHeader: typeof import('@arco-design/web-vue')['LayoutHeader'] + ALayoutSider: typeof import('@arco-design/web-vue')['LayoutSider'] ALink: typeof import('@arco-design/web-vue')['Link'] + AList: typeof import('@arco-design/web-vue')['List'] + AListItem: typeof import('@arco-design/web-vue')['ListItem'] + AListItemMeta: typeof import('@arco-design/web-vue')['ListItemMeta'] AMenu: typeof import('@arco-design/web-vue')['Menu'] AMenuItem: typeof import('@arco-design/web-vue')['MenuItem'] + AMenuItemGroup: typeof import('@arco-design/web-vue')['MenuItemGroup'] AModal: typeof import('@arco-design/web-vue')['Modal'] APagination: typeof import('@arco-design/web-vue')['Pagination'] APopover: typeof import('@arco-design/web-vue')['Popover'] ARadio: typeof import('@arco-design/web-vue')['Radio'] ARadioGroup: typeof import('@arco-design/web-vue')['RadioGroup'] + AScrollbar: typeof import('@arco-design/web-vue')['Scrollbar'] ASelect: typeof import('@arco-design/web-vue')['Select'] ASpace: typeof import('@arco-design/web-vue')['Space'] ASpin: typeof import('@arco-design/web-vue')['Spin'] + ASwitch: typeof import('@arco-design/web-vue')['Switch'] + ATabPane: typeof import('@arco-design/web-vue')['TabPane'] + ATabs: typeof import('@arco-design/web-vue')['Tabs'] ATag: typeof import('@arco-design/web-vue')['Tag'] ATextarea: typeof import('@arco-design/web-vue')['Textarea'] ATooltip: typeof import('@arco-design/web-vue')['Tooltip'] + ATree: typeof import('@arco-design/web-vue')['Tree'] + AUpload: typeof import('@arco-design/web-vue')['Upload'] BaseOption: typeof import('./../components/editor/components/BaseOption.vue')['default'] Block: typeof import('./../components/editor/panel-main/components/block.vue')['default'] BreadCrumb: typeof import('./../components/breadcrumb/bread-crumb.vue')['default'] diff --git a/src/types/vite-env.d.ts b/src/types/vite-env.d.ts index 49bdadc..ac9107e 100644 --- a/src/types/vite-env.d.ts +++ b/src/types/vite-env.d.ts @@ -5,4 +5,9 @@ declare module "*.vue" { import type { DefineComponent } from "vue"; const component: DefineComponent<{}, {}, any>; export default component; +} + +declare module 'numeral' { + const numeral: any + export default numeral; } \ No newline at end of file diff --git a/src/utils/delConfirm.ts b/src/utils/delConfirm.ts index df962a6..cad8a2c 100644 --- a/src/utils/delConfirm.ts +++ b/src/utils/delConfirm.ts @@ -7,7 +7,7 @@ const delOptions = { title: "提示", titleAlign: "start", width: 432, - content: "确定删除该数据吗?注意:该操作不可恢复!", + content: "危险操作!确定删除该数据吗?", maskClosable: false, closable: false, okText: "确定", @@ -27,3 +27,4 @@ const delConfirm = (config: DelOptions = {}) => { }; export { delConfirm }; +