部门列表

This commit is contained in:
仲么了
2024-03-06 16:13:25 +08:00
parent cf70adb959
commit cb58426706
7 changed files with 433 additions and 15 deletions

View File

@@ -0,0 +1,174 @@
<template>
<div class="default-main">
<div class="custom-table-header">
<div class="title">部门列表</div>
<el-input
v-model="tableStore.table.params.searchValue"
style="width: 240px"
placeholder="请输入部门名称"
class="ml10"
clearable
@input="search"
/>
</div>
<Table />
<PopupForm ref="popupFormRef" @init="tableStore.index()"></PopupForm>
<PopupPoint ref="popupPointRef"></PopupPoint>
</div>
</template>
<script setup lang="ts">
import { ref, nextTick, inject, provide, watch, onMounted } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import PopupForm from './popupForm.vue'
import PopupPoint from './popupPoint.vue'
defineOptions({
name: 'auth/department'
})
const popupFormRef = ref()
const popupPointRef = ref()
let originData: any[]
const tableStore = new TableStore({
publicHeight: 60,
showPage: false,
url: '/user-boot/dept/deptTree',
method: 'POST',
column: [
{
title: '名称',
field: 'name',
align: 'left',
treeNode: true
},
{ title: '区域', field: 'areaName', align: 'center' },
{
title: '类型',
field: 'type',
align: 'center',
render: 'renderFormatter',
renderFormatter: data => {
const typeArr = ['非自定义', 'web自定义', 'App自定义', 'Web测试']
return typeArr[data.type] || '/'
}
},
{
title: '描述',
field: 'remark',
align: 'center',
render: 'renderFormatter',
renderFormatter: data => {
return data.remark || '/'
}
},
{
title: '状态',
field: 'state',
align: 'center',
render: 'renderFormatter',
renderFormatter: data => {
return data.state === 1 ? '正常' : '删除'
}
},
{
title: '操作',
align: 'center',
width: '180',
render: 'buttons',
buttons: [
{
name: 'edit',
text: '新增',
type: 'primary',
icon: 'el-icon-Plus',
render: 'basicButton',
click: row => {
popupFormRef.value.open('新增部门', {
pid: row.id,
pArea: row.area
})
}
},
{
name: 'edit',
text: '编辑',
type: 'primary',
icon: 'el-icon-EditPen',
render: 'basicButton',
click: row => {
popupFormRef.value.open('编辑部门', {
...row,
})
}
},
{
name: 'del',
text: '删除',
type: 'danger',
icon: 'el-icon-Delete',
render: 'confirmButton',
popconfirm: {
confirmButtonText: '确认',
cancelButtonText: '取消',
confirmButtonType: 'danger',
title: '确定删除该菜单吗?'
},
click: row => {}
},
{
name: 'edit',
text: '绑定监测点',
type: 'primary',
icon: 'el-icon-Plus',
render: 'basicButton',
disabled: (row: any) => {
return row.children.length > 0
},
click: row => {
popupPointRef.value.open('绑定监测点', row)
}
}
]
}
],
loadCallback: () => {
originData = JSON.parse(JSON.stringify(tableStore.table.data))
tableStore.table.data.forEach((item: any) => {
item.stateName = item.state === 1 ? '正常' : '删除'
item.remark = item.remark || '/'
})
nextTick(() => {
tableStore.table.ref?.setAllTreeExpand(true)
})
}
})
provide('tableStore', tableStore)
onMounted(() => {
tableStore.index()
})
const addMenu = () => {}
const search = () => {
tableStore.table.data = filterData(JSON.parse(JSON.stringify(originData)))
nextTick(() => {
tableStore.table.ref?.setAllTreeExpand(true)
})
}
// 过滤
const filterData = (arr: treeData[]): treeData[] => {
if (!tableStore.table.params.searchValue) {
return arr
}
return arr.filter((item: treeData) => {
if (item.name!.includes(tableStore.table.params.searchValue)) {
return true
} else if (item.children?.length > 0) {
item.children = filterData(item.children)
return item.children.length > 0
} else {
return false
}
})
}
</script>