|
|
@@ -1,189 +1,185 @@
|
|
|
-<template>
|
|
|
- <div>
|
|
|
- <BasicTable @register="registerTable">
|
|
|
- <template #bodyCell="{ column, record }">
|
|
|
- <template v-if="column.key === 'action'">
|
|
|
- <TableAction
|
|
|
- :actions="[
|
|
|
- {
|
|
|
- auth: 'infra:storageconfig:query',
|
|
|
- icon: 'icon-eye|iconfont',
|
|
|
- tooltip: '查看',
|
|
|
- label: '查看',
|
|
|
- onClick: handleView.bind(null, record),
|
|
|
- },
|
|
|
- {
|
|
|
- auth: 'infra:storageconfig:edit',
|
|
|
- icon: 'icon-edit|iconfont',
|
|
|
- tooltip: '编辑',
|
|
|
- label: '编辑',
|
|
|
- onClick: handleEdit.bind(null, record),
|
|
|
- },
|
|
|
- {
|
|
|
- auth: 'infra:storageconfig:remove',
|
|
|
- icon: 'icon-delete|iconfont',
|
|
|
- tooltip: '删除',
|
|
|
- label: '删除',
|
|
|
- color: 'error',
|
|
|
- popConfirm: {
|
|
|
- title: '是否确认删除',
|
|
|
- placement: 'left',
|
|
|
- confirm: handleDelete.bind(null, record),
|
|
|
- },
|
|
|
- },
|
|
|
- ]"
|
|
|
- />
|
|
|
- </template>
|
|
|
- </template>
|
|
|
- <template #toolbar>
|
|
|
- <Button
|
|
|
- v-auth="['infra:storageconfig:add']"
|
|
|
- type="primary"
|
|
|
- @click="handleCreate"
|
|
|
- preIcon="icon-plus|iconfont"
|
|
|
- >
|
|
|
- 新增
|
|
|
- </Button>
|
|
|
- <Button
|
|
|
- v-auth="['infra:storageconfig:remove']"
|
|
|
- type="primary"
|
|
|
- danger
|
|
|
- @click="handleDelete(null)"
|
|
|
- preIcon="icon-delete|iconfont"
|
|
|
- >
|
|
|
- 批量删除
|
|
|
- </Button>
|
|
|
- </template>
|
|
|
- </BasicTable>
|
|
|
- <FormDrawer @register="registerDrawer" @success="handleSuccess" />
|
|
|
- <ViewDrawer @register="registerDrawerView" @success="handleSuccess" />
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-<script lang="ts" setup>
|
|
|
- import { onBeforeMount, ref } from 'vue';
|
|
|
- import { Button } from '/@/components/Button';
|
|
|
-
|
|
|
- import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
|
|
-
|
|
|
- // import { useModal } from '/@/components/Modal';
|
|
|
- import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
- import FormDrawer from './formDrawer.vue';
|
|
|
- import ViewDrawer from './viewDrawer.vue';
|
|
|
- import { columns, searchFormSchema } from './data';
|
|
|
-
|
|
|
- import {
|
|
|
- infraStorageconfigQueryPage,
|
|
|
- infraStorageconfigRemove,
|
|
|
- } from '/@/api/infra/infraStorageconfigApi';
|
|
|
- import { useDrawer } from '/@/components/Drawer';
|
|
|
-
|
|
|
- onBeforeMount(async () => {});
|
|
|
-
|
|
|
- const { createConfirm, createMessage } = useMessage();
|
|
|
- // const [registerModal, { openModal }] = useModal();
|
|
|
- const [registerDrawer, { openDrawer }] = useDrawer();
|
|
|
- const [registerDrawerView, { openDrawer: openDrawerView }] = useDrawer();
|
|
|
-
|
|
|
- const tableSort = ref([
|
|
|
- {
|
|
|
- field: 'create_time',
|
|
|
- direction: 'DESC',
|
|
|
- },
|
|
|
- ]) as any;
|
|
|
-
|
|
|
- const [registerTable, { reload, getSelectRowKeys }] = useTable({
|
|
|
- title: '文件存储配置 ',
|
|
|
- api: infraStorageconfigQueryPage,
|
|
|
- rowKey: 'id',
|
|
|
- columns,
|
|
|
- showIndexColumn: true,
|
|
|
- rowSelection: { type: 'checkbox' },
|
|
|
- formConfig: {
|
|
|
- labelWidth: 120,
|
|
|
- schemas: searchFormSchema,
|
|
|
- autoSubmitOnEnter: true,
|
|
|
- baseColProps: { xs: 24, sm: 12, md: 12, lg: 8 },
|
|
|
- resetButtonOptions: {
|
|
|
- preIcon: 'icon-delete|iconfont',
|
|
|
- },
|
|
|
- submitButtonOptions: {
|
|
|
- preIcon: 'icon-search|iconfont',
|
|
|
- },
|
|
|
- },
|
|
|
- useSearchForm: true,
|
|
|
- bordered: true,
|
|
|
- actionColumn: {
|
|
|
- width: 200,
|
|
|
- title: '操作',
|
|
|
- dataIndex: 'action',
|
|
|
- },
|
|
|
- beforeFetch: handleBeforeFetch,
|
|
|
- sortFn: handleSortFn,
|
|
|
- });
|
|
|
- // 详情按钮事件
|
|
|
- function handleView(record: Recordable) {
|
|
|
- console.log(record);
|
|
|
- openDrawerView(true, {
|
|
|
- record,
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 新增按钮事件
|
|
|
- function handleCreate() {
|
|
|
- openDrawer(true, {
|
|
|
- isUpdate: false,
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 编辑按钮事件
|
|
|
- function handleEdit(record: Recordable) {
|
|
|
- openDrawer(true, {
|
|
|
- record,
|
|
|
- isUpdate: true,
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 删除按钮事件
|
|
|
- async function handleDelete(record: Recordable) {
|
|
|
- if (record) {
|
|
|
- await infraStorageconfigRemove([record.id]);
|
|
|
- createMessage.success('删除成功!');
|
|
|
- await reload();
|
|
|
- } else {
|
|
|
- createConfirm({
|
|
|
- content: '你确定要删除?',
|
|
|
- iconType: 'warning',
|
|
|
- onOk: async () => {
|
|
|
- const keys = getSelectRowKeys();
|
|
|
- await infraStorageconfigRemove(keys);
|
|
|
- createMessage.success('删除成功!');
|
|
|
- await reload();
|
|
|
- },
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- // 表格点击字段排序
|
|
|
- function handleSortFn(sortInfo) {
|
|
|
- if (sortInfo?.order && sortInfo?.columnKey) {
|
|
|
- // 默认单列排序
|
|
|
- tableSort.value = [
|
|
|
- {
|
|
|
- field: sortInfo.columnKey,
|
|
|
- direction: sortInfo.order.replace(/(\w+)(end)/g, '$1').toUpperCase(),
|
|
|
- },
|
|
|
- ];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 表格请求之前,对参数进行处理, 添加默认 排序
|
|
|
- function handleBeforeFetch(params) {
|
|
|
- return { ...params, orders: tableSort.value };
|
|
|
- }
|
|
|
-
|
|
|
- // 弹窗回调事件
|
|
|
- async function handleSuccess({ isUpdate, values }) {
|
|
|
- console.log(isUpdate);
|
|
|
- console.log(values);
|
|
|
- await reload();
|
|
|
- }
|
|
|
-</script>
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <BasicTable @register="registerTable">
|
|
|
+ <template #bodyCell="{ column, record }">
|
|
|
+ <template v-if="column.key === 'size'"> {{ record.size }} kb </template>
|
|
|
+ <template v-if="column.key === 'action'">
|
|
|
+ <TableAction
|
|
|
+ :actions="[
|
|
|
+ {
|
|
|
+ auth: 'storage:record:query',
|
|
|
+ icon: 'icon-eye|iconfont',
|
|
|
+ tooltip: '查看',
|
|
|
+ label: '查看',
|
|
|
+ onClick: handleView.bind(null, record),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ auth: 'storage:record:edit',
|
|
|
+ icon: 'icon-edit|iconfont',
|
|
|
+ tooltip: '编辑',
|
|
|
+ label: '编辑',
|
|
|
+ onClick: handleEdit.bind(null, record),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ auth: 'storage:record:remove',
|
|
|
+ icon: 'icon-delete|iconfont',
|
|
|
+ tooltip: '删除',
|
|
|
+ label: '删除',
|
|
|
+ color: 'error',
|
|
|
+ popConfirm: {
|
|
|
+ title: '是否确认删除',
|
|
|
+ placement: 'left',
|
|
|
+ confirm: handleDelete.bind(null, record),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ]"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ <template #toolbar>
|
|
|
+ <Button
|
|
|
+ v-auth="['storage:record:add']"
|
|
|
+ type="primary"
|
|
|
+ @click="handleCreate"
|
|
|
+ preIcon="icon-plus|iconfont"
|
|
|
+ >
|
|
|
+ 新增
|
|
|
+ </Button>
|
|
|
+ <Button
|
|
|
+ v-auth="['storage:record:remove']"
|
|
|
+ type="primary"
|
|
|
+ danger
|
|
|
+ @click="handleDelete(null)"
|
|
|
+ preIcon="icon-delete|iconfont"
|
|
|
+ >
|
|
|
+ 批量删除
|
|
|
+ </Button>
|
|
|
+ </template>
|
|
|
+ </BasicTable>
|
|
|
+ <FormDrawer @register="registerDrawer" @success="handleSuccess" />
|
|
|
+ <ViewDrawer @register="registerDrawerView" @success="handleSuccess" />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script lang="ts" setup>
|
|
|
+ import { onBeforeMount, ref } from 'vue';
|
|
|
+ import { Button } from '/@/components/Button';
|
|
|
+ import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
|
|
+
|
|
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
+ import FormDrawer from './formDrawer.vue';
|
|
|
+ import ViewDrawer from './viewDrawer.vue';
|
|
|
+ import { columns, searchFormSchema } from './data';
|
|
|
+
|
|
|
+ import { storageRecordQueryPage, storageRecordRemove } from '/@/api/infra/storageRecordApi';
|
|
|
+ import { useDrawer } from '/@/components/Drawer';
|
|
|
+
|
|
|
+ onBeforeMount(async () => {});
|
|
|
+
|
|
|
+ const { createConfirm, createMessage } = useMessage();
|
|
|
+ // const [registerModal, { openModal }] = useModal();
|
|
|
+ const [registerDrawer, { openDrawer }] = useDrawer();
|
|
|
+ const [registerDrawerView, { openDrawer: openDrawerView }] = useDrawer();
|
|
|
+
|
|
|
+ const tableSort = ref([
|
|
|
+ {
|
|
|
+ field: 'create_time',
|
|
|
+ direction: 'DESC',
|
|
|
+ },
|
|
|
+ ]) as any;
|
|
|
+
|
|
|
+ const [registerTable, { reload, getSelectRowKeys }] = useTable({
|
|
|
+ title: ' ',
|
|
|
+ api: storageRecordQueryPage,
|
|
|
+ rowKey: 'id',
|
|
|
+ columns,
|
|
|
+ showIndexColumn: true,
|
|
|
+ rowSelection: { type: 'checkbox' },
|
|
|
+ formConfig: {
|
|
|
+ labelWidth: 120,
|
|
|
+ schemas: searchFormSchema,
|
|
|
+ autoSubmitOnEnter: true,
|
|
|
+ baseColProps: { xs: 24, sm: 12, md: 12, lg: 8 },
|
|
|
+ resetButtonOptions: {
|
|
|
+ preIcon: 'icon-delete|iconfont',
|
|
|
+ },
|
|
|
+ submitButtonOptions: {
|
|
|
+ preIcon: 'icon-search|iconfont',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ useSearchForm: true,
|
|
|
+ bordered: true,
|
|
|
+ actionColumn: {
|
|
|
+ width: 200,
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'action',
|
|
|
+ },
|
|
|
+ beforeFetch: handleBeforeFetch,
|
|
|
+ sortFn: handleSortFn,
|
|
|
+ });
|
|
|
+ // 详情按钮事件
|
|
|
+ function handleView(record: Recordable) {
|
|
|
+ console.log(record);
|
|
|
+ openDrawerView(true, {
|
|
|
+ record,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 新增按钮事件
|
|
|
+ function handleCreate() {
|
|
|
+ openDrawer(true, {
|
|
|
+ isUpdate: false,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 编辑按钮事件
|
|
|
+ function handleEdit(record: Recordable) {
|
|
|
+ openDrawer(true, {
|
|
|
+ record,
|
|
|
+ isUpdate: true,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除按钮事件
|
|
|
+ async function handleDelete(record: Recordable) {
|
|
|
+ if (record) {
|
|
|
+ await storageRecordRemove([record.id]);
|
|
|
+ createMessage.success('删除成功!');
|
|
|
+ await reload();
|
|
|
+ } else {
|
|
|
+ createConfirm({
|
|
|
+ content: '你确定要删除?',
|
|
|
+ iconType: 'warning',
|
|
|
+ onOk: async () => {
|
|
|
+ const keys = getSelectRowKeys();
|
|
|
+ await storageRecordRemove(keys);
|
|
|
+ createMessage.success('删除成功!');
|
|
|
+ await reload();
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 表格点击字段排序
|
|
|
+ function handleSortFn(sortInfo) {
|
|
|
+ if (sortInfo?.order && sortInfo?.columnKey) {
|
|
|
+ // 默认单列排序
|
|
|
+ tableSort.value = [
|
|
|
+ {
|
|
|
+ field: sortInfo.columnKey,
|
|
|
+ direction: sortInfo.order.replace(/(\w+)(end)/g, '$1').toUpperCase(),
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 表格请求之前,对参数进行处理, 添加默认 排序
|
|
|
+ function handleBeforeFetch(params) {
|
|
|
+ return { ...params, orders: tableSort.value };
|
|
|
+ }
|
|
|
+
|
|
|
+ // 弹窗回调事件
|
|
|
+ async function handleSuccess({ isUpdate, values }) {
|
|
|
+ console.log(isUpdate);
|
|
|
+ console.log(values);
|
|
|
+ await reload();
|
|
|
+ }
|
|
|
+</script>
|