|
@@ -0,0 +1,147 @@
|
|
|
+<template>
|
|
|
+ <div class="table-box">
|
|
|
+ <ProTable
|
|
|
+ ref="proTable"
|
|
|
+ title="数据列表"
|
|
|
+ row-key="menuId"
|
|
|
+ :columns="columns"
|
|
|
+ :pagination="true"
|
|
|
+ :data="dataManageList"
|
|
|
+ :init-param="initParam"
|
|
|
+ :data-callback="dataCallback"
|
|
|
+ >
|
|
|
+ <!-- 表格 header 按钮 -->
|
|
|
+ <template #tableHeader>
|
|
|
+ <el-button type="primary" v-auth="['system:menu:add']" @click="openDialog(1, '菜单新增')">新增</el-button>
|
|
|
+ </template>
|
|
|
+ <!-- 菜单图标 -->
|
|
|
+ <template #icon="scope">
|
|
|
+ <el-icon :size="18">
|
|
|
+ <component :is="scope.row.icon"></component>
|
|
|
+ </el-icon>
|
|
|
+ </template>
|
|
|
+ <!-- 表格操作 -->
|
|
|
+ <template #operation="scope">
|
|
|
+ <el-button type="primary" link :icon="EditPen" v-auth="['system:menu:edit']" @click="openDialog(2, '菜单编辑', scope.row)"> 编辑 </el-button>
|
|
|
+ <el-button type="primary" link :icon="CirclePlus" v-auth="['system:menu:add']" @click="openDialog(1, '菜单新增')"> 查看 </el-button>
|
|
|
+ <el-button type="primary" link :icon="Delete" v-auth="['system:menu:remove']" @click="deleteMenu(scope.row)"> 删除 </el-button>
|
|
|
+ </template>
|
|
|
+ </ProTable>
|
|
|
+ <FormDialog ref="formDialogRef" />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup lang="tsx" name="dataManage">
|
|
|
+import { ref, reactive } from 'vue'
|
|
|
+import { useHandleData } from '@/hooks/useHandleData'
|
|
|
+import ProTable from '@/components/ProTable/index.vue'
|
|
|
+import FormDialog from '@/components/FormDialog/index.vue'
|
|
|
+import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
|
|
+import { Delete, EditPen, CirclePlus } from '@element-plus/icons-vue'
|
|
|
+import { handleTree } from '@/utils/common'
|
|
|
+import { delMenuApi, addMenuApi, updateMenuApi, getMenuApi } from '@/api/modules/system/menu'
|
|
|
+import { getDictsApi } from '@/api/modules/system/dictData'
|
|
|
+import { getdataManageListApi } from '@/api/modules/wca/mockData'
|
|
|
+
|
|
|
+const dataManageList = getdataManageListApi()
|
|
|
+// ProTable 实例
|
|
|
+const proTable = ref<ProTableInstance>()
|
|
|
+
|
|
|
+// 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
|
|
|
+const initParam = reactive({})
|
|
|
+const menuOptions = ref<any[]>([])
|
|
|
+// dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total && pageNum && pageSize 这些字段,可以在这里进行处理成这些字段
|
|
|
+const dataCallback = (res: any) => {
|
|
|
+ const data = handleTree(res, 'menuId')
|
|
|
+ menuOptions.value = []
|
|
|
+ const menu: any = { menuId: 0, menuName: '主类目', children: [] }
|
|
|
+ menu.children = data
|
|
|
+ menuOptions.value.push(menu)
|
|
|
+ setItemsOptions()
|
|
|
+ return data
|
|
|
+}
|
|
|
+
|
|
|
+// 删除用户信息
|
|
|
+const deleteMenu = async (params: any) => {
|
|
|
+ await useHandleData(delMenuApi, params.menuId, `删除【${params.dataName}】菜单`)
|
|
|
+ proTable.value?.getTableList()
|
|
|
+}
|
|
|
+
|
|
|
+const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
|
|
|
+// 打开弹框的功能
|
|
|
+const openDialog = async (type: number, title: string, row?: any) => {
|
|
|
+ let res = { data: {} }
|
|
|
+ if (row?.menuId) {
|
|
|
+ res = await getMenuApi(row?.menuId || null)
|
|
|
+ }
|
|
|
+ const params = {
|
|
|
+ title,
|
|
|
+ width: 720,
|
|
|
+ isEdit: type !== 3,
|
|
|
+ itemsOptions: itemsOptions,
|
|
|
+ model: type == 1 ? {} : res.data,
|
|
|
+ api: type == 1 ? addMenuApi : updateMenuApi,
|
|
|
+ getTableList: proTable.value?.getTableList
|
|
|
+ }
|
|
|
+ formDialogRef.value?.openDialog(params)
|
|
|
+}
|
|
|
+
|
|
|
+// 表格配置项
|
|
|
+const columns = reactive<ColumnProps<any>[]>([
|
|
|
+ {
|
|
|
+ prop: 'dataName',
|
|
|
+ label: '名称',
|
|
|
+ search: {
|
|
|
+ el: 'input'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'type',
|
|
|
+ label: '所属分类',
|
|
|
+ search: {
|
|
|
+ el: 'select'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'status',
|
|
|
+ label: '已评估',
|
|
|
+ tag: true,
|
|
|
+ enum: () => getDictsApi('sys_yes_no'),
|
|
|
+ search: {
|
|
|
+ el: 'tree-select'
|
|
|
+ },
|
|
|
+ fieldNames: { label: 'dictLabel', value: 'dictValue' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'createTime',
|
|
|
+ label: '评估时间',
|
|
|
+ search: {
|
|
|
+ el: 'date-picker',
|
|
|
+ props: { type: 'datetimerange', valueFormat: 'YYYY-MM-DD HH:mm:ss' }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: 'brand-model',
|
|
|
+ label: '品牌及型号',
|
|
|
+ search: {
|
|
|
+ el: 'input'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
|
|
|
+])
|
|
|
+let itemsOptions: ProForm.ItemsOptions[] = []
|
|
|
+const setItemsOptions = () => {
|
|
|
+ itemsOptions = [
|
|
|
+ {
|
|
|
+ label: '数据名称',
|
|
|
+ prop: 'dataName',
|
|
|
+ span: 12,
|
|
|
+ rules: [{ required: true, message: '数据名称不能为空', trigger: 'blur' }],
|
|
|
+ compOptions: {
|
|
|
+ elTagName: 'input',
|
|
|
+ placeholder: '请输入菜单名称'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+}
|
|
|
+</script>
|