2023-12-17 16:05:38 +08:00
|
|
|
<template>
|
2023-12-18 18:30:33 +08:00
|
|
|
<div class="table-page">
|
2023-12-27 16:49:37 +08:00
|
|
|
<div class="search-part" v-show="isSearch">
|
2023-12-18 18:30:33 +08:00
|
|
|
<div class="search-cell">
|
|
|
|
<span class="label">菜单名称</span>
|
|
|
|
<el-input v-model="queryParams.menuName" placeholder="请输入菜单名称"></el-input>
|
|
|
|
</div>
|
|
|
|
<el-button type="primary" icon="Search" @click="queryData(queryParams)">查询</el-button>
|
|
|
|
<el-button icon="Refresh" @click="queryParams = {}">重置</el-button>
|
|
|
|
</div>
|
|
|
|
<div class="button-part" style="justify-content: space-between;">
|
|
|
|
<div>
|
|
|
|
<el-button type="primary" icon="FirstAidKit" @click="addData">新增</el-button>
|
|
|
|
<el-button @click="expandTable">展开/折叠</el-button>
|
|
|
|
</div>
|
2023-12-27 16:49:37 +08:00
|
|
|
<TableAbility :isDownload="false" @searchBtn="isSearch = !isSearch" @refreshBtn="initData()"></TableAbility>
|
2023-12-18 18:30:33 +08:00
|
|
|
</div>
|
|
|
|
<div class="table-part">
|
|
|
|
<el-table ref="tableRef" :data="tableData" row-key="id" height="100%" border show-overflow-tooltip
|
|
|
|
@row-click="tableRowClick">
|
2023-12-19 09:47:27 +08:00
|
|
|
<el-table-column property="menuName" label="菜单名称" width="180" align="center" />
|
2023-12-18 18:30:33 +08:00
|
|
|
<el-table-column property="order" label="排序" width="80" align="center" />
|
2023-12-27 16:49:37 +08:00
|
|
|
<el-table-column label="图标" width="80" align="center">
|
2023-12-19 09:47:27 +08:00
|
|
|
<template #default="scope"><i class="main-color f20" :class="scope.row.icon"></i></template>
|
2023-12-18 18:30:33 +08:00
|
|
|
</el-table-column>
|
2023-12-19 09:47:27 +08:00
|
|
|
<el-table-column property="route" label="路由" width="260" align="center" />
|
2023-12-18 18:30:33 +08:00
|
|
|
<el-table-column property="type" label="类型" width="180" align="center" />
|
|
|
|
<el-table-column label="操作" align="center">
|
|
|
|
<template #default="scope">
|
|
|
|
<span @click.stop>
|
|
|
|
<el-button link icon="EditPen" @click="editData(scope.row)">修改</el-button>
|
|
|
|
<el-button link icon="Delete" @click="removeData(scope.row)">删除</el-button>
|
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
</div>
|
|
|
|
<div class="pagination-part">
|
|
|
|
<CommonPagination :total="100" @paginationChange="paginationChange" />
|
|
|
|
</div>
|
2023-12-17 16:05:38 +08:00
|
|
|
</div>
|
2023-12-27 16:49:37 +08:00
|
|
|
<el-dialog v-model="isFormDialog" :title="formDialogTitle" width="30%">
|
|
|
|
<MenuForm ref="doctorFormRef" :type="formDialogTitle === '添加' ? 'add' : 'edit'" @close="isFormDialog = false" />
|
|
|
|
</el-dialog>
|
2023-12-17 16:05:38 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang='ts' setup>
|
|
|
|
import { onMounted, reactive, ref, toRefs, watch } from 'vue'
|
2023-12-18 18:30:33 +08:00
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
|
import { tableRemoveRow, exportData } from '@/utils/table-util'
|
2023-12-28 14:26:39 +08:00
|
|
|
import { getMenuData } from '@/static-data/menu'
|
2023-12-18 18:30:33 +08:00
|
|
|
import CommonPagination from '@/components/common-pagination.vue'
|
|
|
|
import MenuForm from './form/menu-form.vue'
|
2023-12-17 16:05:38 +08:00
|
|
|
|
2023-12-18 18:30:33 +08:00
|
|
|
let isExpand = false // 表格展开状态
|
2023-12-17 16:05:38 +08:00
|
|
|
|
2023-12-18 18:30:33 +08:00
|
|
|
const tableRef = ref()
|
|
|
|
const doctorFormRef = ref()
|
2023-12-27 16:49:37 +08:00
|
|
|
const isSearch = ref(true)
|
|
|
|
const loading = ref(true)
|
2023-12-18 18:30:33 +08:00
|
|
|
const isFormDialog = ref(false)
|
|
|
|
const formDialogTitle = ref('')
|
|
|
|
const queryParams = ref({
|
|
|
|
menuName: ''
|
|
|
|
} as any)
|
|
|
|
const tableData = ref([] as any)
|
|
|
|
|
2023-12-27 16:49:37 +08:00
|
|
|
initData()
|
|
|
|
|
|
|
|
function initData() {
|
|
|
|
loading.value = true
|
|
|
|
tableData.value = []
|
|
|
|
setTimeout(() => {
|
2023-12-28 14:26:39 +08:00
|
|
|
tableData.value = getMenuData()
|
2023-12-27 16:49:37 +08:00
|
|
|
loading.value = false
|
|
|
|
}, 200);
|
2023-12-18 18:30:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const queryData = (e: any) => {
|
2023-12-27 16:49:37 +08:00
|
|
|
loading.value = true
|
2023-12-18 18:30:33 +08:00
|
|
|
tableData.value = []
|
2023-12-27 16:49:37 +08:00
|
|
|
setTimeout(() => {
|
|
|
|
while (tableData.value.length < 10) {
|
|
|
|
tableData.value.push({
|
|
|
|
id: tableData.value.length,
|
|
|
|
menuName: e.menuName,
|
|
|
|
order: tableData.value.length + 1,
|
|
|
|
icon: 'icon-shouye-zhihui',
|
|
|
|
route: '/permissions-manage',
|
|
|
|
type: '菜单',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
loading.value = false
|
|
|
|
}, 200);
|
2023-12-18 18:30:33 +08:00
|
|
|
}
|
|
|
|
const addData = () => {
|
|
|
|
isFormDialog.value = true
|
|
|
|
formDialogTitle.value = '添加'
|
|
|
|
setTimeout(() => {
|
|
|
|
doctorFormRef.value.resetData()
|
|
|
|
}, 0)
|
|
|
|
}
|
|
|
|
const expandTable = () => {
|
|
|
|
isExpand = !isExpand
|
|
|
|
tableData.value.forEach((row: any) => {
|
|
|
|
tableRef.value.toggleRowExpansion(row, isExpand)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
const removeData = (e?: any) => {
|
|
|
|
const selectRow = e || tableRef.value.getSelectionRows()
|
|
|
|
tableRemoveRow({ data: selectRow }, (res: boolean) => {
|
|
|
|
if (res) {
|
|
|
|
console.log('调用删除', selectRow)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
const editData = (e: any) => {
|
|
|
|
isFormDialog.value = true
|
|
|
|
formDialogTitle.value = '修改'
|
|
|
|
setTimeout(() => {
|
|
|
|
doctorFormRef.value.resetData()
|
2023-12-24 16:15:33 +08:00
|
|
|
doctorFormRef.value.formData = JSON.parse(JSON.stringify(e))
|
2023-12-18 18:30:33 +08:00
|
|
|
}, 0)
|
|
|
|
}
|
|
|
|
const tableRowClick = (row: any) => {
|
|
|
|
tableRef.value.toggleRowExpansion(row)
|
|
|
|
}
|
|
|
|
const paginationChange = (page: number, size: number) => {
|
|
|
|
|
|
|
|
}
|
2023-12-17 16:05:38 +08:00
|
|
|
</script>
|
|
|
|
|
2023-12-27 16:49:37 +08:00
|
|
|
<style lang='scss' scoped></style>
|