fan vor 2 Jahren
Ursprung
Commit
9e1c1f0859

+ 96 - 0
src/api/sys/sysConstantConfigApi.ts

@@ -0,0 +1,96 @@
+import { defHttp } from '/@/utils/http/axios';
+import { setParams } from '/@/utils/index';
+
+enum Api {
+  sysConstantConfigQueryPage = '/sys/constant/config/query/page',
+  sysConstantConfigDetail = '/sys/constant/config/detail',
+  sysConstantConfigAdd = '/sys/constant/config/add',
+  sysConstantConfigEdit = '/sys/constant/config/edit',
+  sysConstantConfigRemove = '/sys/constant/config/removeByIds',
+}
+
+/**
+ *
+ * @author zsl
+ * @date  2023/05/18 16:13
+ * @description: 根据条件查询常量配置列表,权限 - constant:config:query
+ * @method: POST
+ * @param:
+ *       {String}  name  like   常量名称
+ *       {String}  code  eq   常量编码
+ * @return:
+ *       {String}  name  常量名称
+ *       {Integer}  type  常量类型
+ *       {String}  remark  备注
+ *       {String}  code  常量编码
+ *       {String}  cateid  目录id
+ */
+
+export const sysConstantConfigQueryPage = (params?: object) => {
+  return defHttp.post({ url: Api.sysConstantConfigQueryPage, params: setParams(params) });
+};
+/**
+ *
+ * @author zsl
+ * @date  2023/05/18 16:13
+ * @description: 根据id查询常量配置详细信息,权限 - constant:config:query
+ * @method: GET
+ * @param:  id 常量配置主键id
+ * @return:
+ *       {String}  name  常量名称
+ *       {Integer}  type  常量类型
+ *       {String}  remark  备注
+ *       {String}  code  常量编码
+ *       {String}  cateid  目录id
+ */
+export const sysConstantConfigDetail = (id: string) => {
+  return defHttp.get({ url: Api.sysConstantConfigDetail + '/' + id });
+};
+
+/**
+ *
+ * @author zsl
+ * @date  2023/05/18 16:13
+ * @description: 添加常量配置,权限 - constant:config:add
+ * @method: POST
+ * @param:
+ *       {String}  name  常量名称
+ *       {Integer}  type  常量类型
+ *       {String}  remark  备注
+ *       {String}  code  常量编码
+ *       {String}  cateid  目录id
+ * @return:
+ *       0 添加失败
+ *       1 添加成功
+ */
+export const sysConstantConfigAdd = (params?: object) => {
+  return defHttp.post({ url: Api.sysConstantConfigAdd, params: params });
+};
+
+/**
+ *
+ * @author zsl
+ * @date  2023/05/18 16:13
+ * @description: 通过主键id编辑常量配置,权限 - constant:config:edit
+ * @method: POST
+ * @param:
+ *       {String}  name  常量名称
+ *       {Integer}  type  常量类型
+ *       {String}  remark  备注
+ *       {String}  code  常量编码
+ *       {String}  cateid  目录id
+ * @return:
+ *       0 编辑失败
+ *       1 编辑成功
+ */
+export const sysConstantConfigEdit = (params?: object) => {
+  return defHttp.post({ url: Api.sysConstantConfigEdit, params: params });
+};
+
+/**
+ * @description: 删除,权限 - constant:config:remove
+ * @method: POST
+ */
+export const sysConstantConfigRemove = (params: Array<string | number>) => {
+  return defHttp.post({ url: Api.sysConstantConfigRemove, params: params });
+};

+ 108 - 0
src/api/sys/sysConstantMenuApi.ts

@@ -0,0 +1,108 @@
+import { defHttp } from '/@/utils/http/axios';
+import { setParams } from '/@/utils/index';
+
+enum Api {
+  sysConstantQueryPage = '/sys/constant/constantmenu/query/page',
+  sysConstantDetail = '/sys/constant/constantmenu/detail',
+  sysConstantAdd = '/sys/constant/constantmenu/add',
+  sysConstantEdit = '/sys/constant/constantmenu/edit',
+  sysConstantRemove = '/sys/constant/constantmenu/removeByIds',
+}
+
+/**
+ *
+ * @author zsl
+ * @date  2023/05/18 15:54
+ * @description: 根据条件查询常量菜单列表,权限 - constant:constant:query
+ * @method: POST
+ * @param:
+ *       {String}  code  like   目录编码
+ *       {Boolean}  disable  eq   是否可用
+ * @return:
+ *       {String}  type  目录类型
+ *       {String}  code  目录编码
+ *       {String}  name  菜单名称
+ *       {String}  parentId  上级菜单
+ *       {Integer}  sort  排序
+ *       {String}  remarks  备注
+ *       {Boolean}  disable  是否可用
+ *       {String}  remark  备注
+ */
+
+export const sysConstantQueryPage = (params?: object) => {
+  return defHttp.post({ url: Api.sysConstantQueryPage, params: setParams(params) });
+};
+/**
+ *
+ * @author zsl
+ * @date  2023/05/18 15:54
+ * @description: 根据id查询常量菜单详细信息,权限 - constant:constant:query
+ * @method: GET
+ * @param:  id 常量菜单主键id
+ * @return:
+ *       {String}  type  目录类型
+ *       {String}  code  目录编码
+ *       {String}  name  菜单名称
+ *       {String}  parentId  上级菜单
+ *       {Integer}  sort  排序
+ *       {String}  remarks  备注
+ *       {Boolean}  disable  是否可用
+ *       {String}  remark  备注
+ */
+export const sysConstantDetail = (id: string) => {
+  return defHttp.get({ url: Api.sysConstantDetail + '/' + id });
+};
+
+/**
+ *
+ * @author zsl
+ * @date  2023/05/18 15:54
+ * @description: 添加常量菜单,权限 - constant:constant:add
+ * @method: POST
+ * @param:
+ *       {String}  type  目录类型
+ *       {String}  code  目录编码
+ *       {String}  name  菜单名称
+ *       {String}  parentId  上级菜单
+ *       {Integer}  sort  排序
+ *       {String}  remarks  备注
+ *       {Boolean}  disable  是否可用
+ *       {String}  remark  备注
+ * @return:
+ *       0 添加失败
+ *       1 添加成功
+ */
+export const sysConstantAdd = (params?: object) => {
+  return defHttp.post({ url: Api.sysConstantAdd, params: params });
+};
+
+/**
+ *
+ * @author zsl
+ * @date  2023/05/18 15:54
+ * @description: 通过主键id编辑常量菜单,权限 - constant:constant:edit
+ * @method: POST
+ * @param:
+ *       {String}  type  目录类型
+ *       {String}  code  目录编码
+ *       {String}  name  菜单名称
+ *       {String}  parentId  上级菜单
+ *       {Integer}  sort  排序
+ *       {String}  remarks  备注
+ *       {Boolean}  disable  是否可用
+ *       {String}  remark  备注
+ * @return:
+ *       0 编辑失败
+ *       1 编辑成功
+ */
+export const sysConstantEdit = (params?: object) => {
+  return defHttp.post({ url: Api.sysConstantEdit, params: params });
+};
+
+/**
+ * @description: 删除,权限 - constant:constant:remove
+ * @method: POST
+ */
+export const sysConstantRemove = (params: Array<string | number>) => {
+  return defHttp.post({ url: Api.sysConstantRemove, params: params });
+};

+ 128 - 0
src/views/sys/sysConstant/config/data.ts

@@ -0,0 +1,128 @@
+import { DescItem } from '/@/components/Description';
+import { BasicColumn, FormSchema } from '/@/components/Table';
+
+export const columns: BasicColumn[] = [
+  {
+    title: '常量名称',
+    dataIndex: 'name',
+  },
+  {
+    title: '常量类型',
+    dataIndex: 'type',
+  },
+  {
+    title: '备注',
+    dataIndex: 'remark',
+  },
+  {
+    title: '常量编码',
+    dataIndex: 'code',
+  },
+  {
+    title: '目录id',
+    dataIndex: 'cateid',
+  },
+];
+
+// 表单列定义
+export const searchFormSchema: FormSchema[] = [
+  {
+    label: '常量名称',
+    field: 'name',
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入常量名称',
+    },
+  },
+  {
+    label: '常量编码',
+    field: 'code',
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入常量编码',
+    },
+  },
+];
+// 表单新增编辑
+export const dataFormSchema: FormSchema[] = [
+  {
+    label: '常量名称',
+    field: 'name',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入常量名称',
+    },
+  },
+  {
+    label: '常量类型',
+    field: 'type',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入常量类型',
+    },
+  },
+  {
+    label: '备注',
+    field: 'remark',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入备注',
+    },
+  },
+  {
+    label: '常量编码',
+    field: 'code',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入常量编码',
+    },
+  },
+  {
+    label: '目录id',
+    field: 'cateid',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入目录id',
+    },
+  },
+];
+// 表单详情查看
+export const viewSchema: DescItem[] = [
+  {
+    label: 'id',
+    field: 'id',
+  },
+  {
+    label: '常量名称',
+    field: 'name',
+  },
+  {
+    label: '常量类型',
+    field: 'type',
+  },
+  {
+    label: '备注',
+    field: 'remark',
+  },
+  {
+    label: '常量编码',
+    field: 'code',
+  },
+  {
+    label: '目录id',
+    field: 'cateid',
+  },
+  {
+    label: '记录创建时间',
+    field: 'createTime',
+  },
+  {
+    label: '记录更新时间',
+    field: 'updateTime',
+  },
+];

+ 75 - 0
src/views/sys/sysConstant/config/formDrawer.vue

@@ -0,0 +1,75 @@
+<template>
+  <BasicDrawer
+    v-bind="$attrs"
+    destroyOnClose
+    @register="registerDrawer"
+    :title="getTitle"
+    :width="width"
+    @ok="handleSubmit"
+    :showFooter="true"
+  >
+    <BasicForm @register="registerForm" layout="vertical" />
+  </BasicDrawer>
+</template>
+<script lang="ts" setup>
+  import { ref, computed, unref } from 'vue';
+  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
+  import { BasicForm, useForm } from '/@/components/Form';
+  import { useMessage } from '/@/hooks/web/useMessage';
+  import { dataFormSchema } from './data';
+
+  import {
+    sysConstantConfigAdd,
+    sysConstantConfigEdit,
+    sysConstantConfigDetail,
+  } from '/@/api/sys/sysConstantConfigApi';
+
+  const emit = defineEmits(['success', 'register']);
+
+  const getTitle = computed(() => (!unref(isUpdate) ? '新增常量配置' : '编辑常量配置'));
+  const width = '45%';
+  const isUpdate = ref(false);
+  const rowId = ref();
+
+  const { createMessage } = useMessage();
+  const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
+    labelWidth: 100,
+    schemas: dataFormSchema,
+    showActionButtonGroup: false,
+    actionColOptions: {
+      span: 23,
+    },
+  });
+  const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async data => {
+    await resetFields();
+    setDrawerProps({ confirmLoading: false });
+    isUpdate.value = !!data?.isUpdate;
+
+    if (unref(isUpdate)) {
+      const resData = await sysConstantConfigDetail(data.record.id);
+      rowId.value = resData.id;
+      await setFieldsValue({
+        ...resData,
+      });
+    }
+  });
+
+  // 提交按钮事件
+  async function handleSubmit() {
+    try {
+      const values = await validate();
+      setDrawerProps({ confirmLoading: true });
+      !unref(isUpdate)
+        ? await sysConstantConfigAdd({ ...values })
+        : await sysConstantConfigEdit({ ...values, id: rowId.value });
+      !unref(isUpdate) ? createMessage.success('新增成功!') : createMessage.success('编辑成功!');
+      closeDrawer();
+      emit('success', {
+        isUpdate: unref(isUpdate),
+        values: { ...values, id: rowId.value },
+      });
+    } finally {
+      setDrawerProps({ confirmLoading: false });
+    }
+  }
+</script>

+ 189 - 0
src/views/sys/sysConstant/config/index.vue

@@ -0,0 +1,189 @@
+<template>
+  <div>
+    <BasicTable @register="registerTable">
+      <template #bodyCell="{ column, record }">
+        <template v-if="column.key === 'action'">
+          <TableAction
+            :actions="[
+              {
+                auth: 'constant:config:query',
+                icon: 'icon-eye|iconfont',
+                tooltip: '查看',
+                label: '查看',
+                onClick: handleView.bind(null, record),
+              },
+              {
+                auth: 'constant:config:edit',
+                icon: 'icon-edit|iconfont',
+                tooltip: '编辑',
+                label: '编辑',
+                onClick: handleEdit.bind(null, record),
+              },
+              {
+                auth: 'constant:config: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="['constant:config:add']"
+          type="primary"
+          @click="handleCreate"
+          preIcon="icon-plus|iconfont"
+        >
+          新增
+        </Button>
+        <Button
+          v-auth="['constant:config: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 {
+    sysConstantConfigQueryPage,
+    sysConstantConfigRemove,
+  } from '/@/api/sys/sysConstantConfigApi';
+  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: sysConstantConfigQueryPage,
+    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 sysConstantConfigRemove([record.id]);
+      createMessage.success('删除成功!');
+      await reload();
+    } else {
+      createConfirm({
+        content: '你确定要删除?',
+        iconType: 'warning',
+        onOk: async () => {
+          const keys = getSelectRowKeys();
+          await sysConstantConfigRemove(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>

+ 40 - 0
src/views/sys/sysConstant/config/viewDrawer.vue

@@ -0,0 +1,40 @@
+<template>
+  <BasicDrawer
+    v-bind="$attrs"
+    destroyOnClose
+    @register="registerDrawer"
+    :title="getTitle"
+    :width="width"
+  >
+    <Description @register="registerDesc" :data="descData" />
+  </BasicDrawer>
+</template>
+<script lang="ts" setup>
+  import { onBeforeMount, ref } from 'vue'; // onBeforeMount,
+  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
+  import { Description, useDescription } from '/@/components/Description';
+  import { viewSchema } from './data';
+
+  import { sysConstantConfigDetail } from '/@/api/sys/sysConstantConfigApi';
+
+  const descData = ref({});
+  const getTitle = '查看常量配置';
+  const width = '45%';
+
+  onBeforeMount(async () => {});
+  const [registerDrawer] = useDrawerInner(async data => {
+    console.log('::::::::::', data.record);
+    const resData = await sysConstantConfigDetail(data.record.id);
+    descData.value = {
+      ...resData,
+    };
+  });
+  const [registerDesc] = useDescription({
+    schema: viewSchema,
+    column: 2,
+    size: 'middle',
+    labelStyle: {
+      width: '120px',
+    },
+  });
+</script>

+ 185 - 0
src/views/sys/sysConstant/menu/data.ts

@@ -0,0 +1,185 @@
+import { listDictModel } from '/@/api/common';
+import { DescItem } from '/@/components/Description';
+import { BasicColumn, FormSchema } from '/@/components/Table';
+
+export const columns: BasicColumn[] = [
+  {
+    title: '目录类型',
+    dataIndex: 'type',
+  },
+  {
+    title: '目录编码',
+    dataIndex: 'code',
+  },
+  {
+    title: '菜单名称',
+    dataIndex: 'name',
+  },
+  {
+    title: '上级菜单',
+    dataIndex: 'parentId',
+  },
+  {
+    title: '排序',
+    dataIndex: 'sort',
+  },
+  {
+    title: '备注',
+    dataIndex: 'remarks',
+  },
+  {
+    title: '是否可用',
+    dataIndex: 'disable',
+  },
+  {
+    title: '备注',
+    dataIndex: 'remark',
+  },
+];
+
+// 表单列定义
+export const searchFormSchema: FormSchema[] = [
+  {
+    label: '目录编码',
+    field: 'code',
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入目录编码',
+    },
+  },
+  {
+    label: '是否可用',
+    field: 'disable',
+    component: 'ApiRadioGroup',
+    componentProps: {
+      api: listDictModel,
+      params: {
+        dictCode: 'sys_disable_type',
+      },
+    },
+  },
+];
+// 表单新增编辑
+export const dataFormSchema: FormSchema[] = [
+  {
+    label: '目录类型',
+    field: 'type',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入目录类型',
+    },
+  },
+  {
+    label: '目录编码',
+    field: 'code',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入目录编码',
+    },
+  },
+  {
+    label: '菜单名称',
+    field: 'name',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入菜单名称',
+    },
+  },
+  {
+    label: '上级菜单',
+    field: 'parentId',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入上级菜单',
+    },
+  },
+  {
+    label: '排序',
+    field: 'sort',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入排序',
+    },
+  },
+  {
+    label: '备注',
+    field: 'remarks',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入备注',
+    },
+  },
+  {
+    label: '是否可用',
+    field: 'disable',
+    component: 'ApiRadioGroup',
+    componentProps: {
+      api: listDictModel,
+      params: {
+        dictCode: 'sys_disable_type',
+      },
+    },
+  },
+  {
+    label: '备注',
+    field: 'remark',
+    required: true,
+    component: 'Input',
+    componentProps: {
+      placeholder: '请输入备注',
+    },
+  },
+];
+// 表单详情查看
+export const viewSchema: DescItem[] = [
+  {
+    label: '主键',
+    field: 'id',
+  },
+  {
+    label: '目录类型',
+    field: 'type',
+  },
+  {
+    label: '目录编码',
+    field: 'code',
+  },
+  {
+    label: '菜单名称',
+    field: 'name',
+  },
+  {
+    label: '上级菜单',
+    field: 'parentId',
+  },
+  {
+    label: '排序',
+    field: 'sort',
+  },
+  {
+    label: '备注',
+    field: 'remarks',
+  },
+  {
+    label: '创建时间',
+    field: 'createTime',
+  },
+  {
+    label: '更新时间',
+    field: 'updateTime',
+  },
+  {
+    label: '是否可用',
+    field: 'disable',
+  },
+  {
+    label: '备注',
+    field: 'remark',
+  },
+];

+ 75 - 0
src/views/sys/sysConstant/menu/formDrawer.vue

@@ -0,0 +1,75 @@
+<template>
+  <BasicDrawer
+    v-bind="$attrs"
+    destroyOnClose
+    @register="registerDrawer"
+    :title="getTitle"
+    :width="width"
+    @ok="handleSubmit"
+    :showFooter="true"
+  >
+    <BasicForm @register="registerForm" layout="vertical" />
+  </BasicDrawer>
+</template>
+<script lang="ts" setup>
+  import { ref, computed, unref } from 'vue';
+  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
+  import { BasicForm, useForm } from '/@/components/Form';
+  import { useMessage } from '/@/hooks/web/useMessage';
+  import { dataFormSchema } from './data';
+
+  import {
+    sysConstantAdd,
+    sysConstantEdit,
+    sysConstantDetail,
+  } from '/@/api/sys/sysConstantMenuApi';
+
+  const emit = defineEmits(['success', 'register']);
+
+  const getTitle = computed(() => (!unref(isUpdate) ? '新增常量菜单' : '编辑常量菜单'));
+  const width = '45%';
+  const isUpdate = ref(false);
+  const rowId = ref();
+
+  const { createMessage } = useMessage();
+  const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
+    labelWidth: 100,
+    schemas: dataFormSchema,
+    showActionButtonGroup: false,
+    actionColOptions: {
+      span: 23,
+    },
+  });
+  const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async data => {
+    await resetFields();
+    setDrawerProps({ confirmLoading: false });
+    isUpdate.value = !!data?.isUpdate;
+
+    if (unref(isUpdate)) {
+      const resData = await sysConstantDetail(data.record.id);
+      rowId.value = resData.id;
+      await setFieldsValue({
+        ...resData,
+      });
+    }
+  });
+
+  // 提交按钮事件
+  async function handleSubmit() {
+    try {
+      const values = await validate();
+      setDrawerProps({ confirmLoading: true });
+      !unref(isUpdate)
+        ? await sysConstantAdd({ ...values })
+        : await sysConstantEdit({ ...values, id: rowId.value });
+      !unref(isUpdate) ? createMessage.success('新增成功!') : createMessage.success('编辑成功!');
+      closeDrawer();
+      emit('success', {
+        isUpdate: unref(isUpdate),
+        values: { ...values, id: rowId.value },
+      });
+    } finally {
+      setDrawerProps({ confirmLoading: false });
+    }
+  }
+</script>

+ 197 - 0
src/views/sys/sysConstant/menu/index.vue

@@ -0,0 +1,197 @@
+<template>
+  <div>
+    <BasicTable @register="registerTable">
+      <template #bodyCell="{ column, record }">
+        <template v-if="column.key === 'disable'">
+          <Tag :color="formatDictColor(disableOptions, record.disable)">
+            {{ formatDictValue(disableOptions, record.disable) }}
+          </Tag>
+        </template>
+        <template v-if="column.key === 'action'">
+          <TableAction
+            :actions="[
+              {
+                auth: 'constant:constant:query',
+                icon: 'icon-eye|iconfont',
+                tooltip: '查看',
+                label: '查看',
+                onClick: handleView.bind(null, record),
+              },
+              {
+                auth: 'constant:constant:edit',
+                icon: 'icon-edit|iconfont',
+                tooltip: '编辑',
+                label: '编辑',
+                onClick: handleEdit.bind(null, record),
+              },
+              {
+                auth: 'constant:constant: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="['constant:constantmenu:add']"
+          type="primary"
+          @click="handleCreate"
+          preIcon="icon-plus|iconfont"
+        >
+          新增
+        </Button>
+        <Button
+          v-auth="['constant:constantmenu: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 { Tag } from 'ant-design-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 { sysConstantQueryPage, sysConstantRemove } from '/@/api/sys/sysConstantMenuApi';
+  import { listDictModel } from '/@/api/common';
+  import { formatDictColor, formatDictValue } from '/@/utils';
+  import { useDrawer } from '/@/components/Drawer';
+
+  const disableOptions = ref();
+  onBeforeMount(async () => {
+    disableOptions.value = await listDictModel({ dictCode: 'sys_disable_type' });
+  });
+
+  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: sysConstantQueryPage,
+    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 sysConstantRemove([record.id]);
+      createMessage.success('删除成功!');
+      await reload();
+    } else {
+      createConfirm({
+        content: '你确定要删除?',
+        iconType: 'warning',
+        onOk: async () => {
+          const keys = getSelectRowKeys();
+          await sysConstantRemove(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>

+ 46 - 0
src/views/sys/sysConstant/menu/viewDrawer.vue

@@ -0,0 +1,46 @@
+<template>
+  <BasicDrawer
+    v-bind="$attrs"
+    destroyOnClose
+    @register="registerDrawer"
+    :title="getTitle"
+    :width="width"
+  >
+    <Description @register="registerDesc" :data="descData" />
+  </BasicDrawer>
+</template>
+<script lang="ts" setup>
+  import { onBeforeMount, ref } from 'vue'; // onBeforeMount,
+  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
+  import { Description, useDescription } from '/@/components/Description';
+  import { viewSchema } from './data';
+
+  import { sysConstantDetail } from '/@/api/sys/sysConstantMenuApi';
+  import { listDictModel } from '/@/api/common';
+  import { formatDictValue } from '/@/utils';
+
+  const descData = ref({});
+  const getTitle = '查看常量菜单';
+  const width = '45%';
+
+  const disableOptions = ref();
+  onBeforeMount(async () => {
+    disableOptions.value = await listDictModel({ dictCode: 'sys_disable_type' });
+  });
+  const [registerDrawer] = useDrawerInner(async data => {
+    console.log('::::::::::', data.record);
+    const resData = await sysConstantDetail(data.record.id);
+    descData.value = {
+      ...resData,
+      disable: formatDictValue(disableOptions.value, resData.disable),
+    };
+  });
+  const [registerDesc] = useDescription({
+    schema: viewSchema,
+    column: 2,
+    size: 'middle',
+    labelStyle: {
+      width: '120px',
+    },
+  });
+</script>