|
|
@@ -0,0 +1,280 @@
|
|
|
+<script lang="ts" setup name="oc_cat_List">
|
|
|
+import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
+import RepoCatComponent from './components/RepoCat.vue'
|
|
|
+import { getRepoTypeByList } from '@/api/repo/repoTypeApi'
|
|
|
+import { deleteRepoCatById, getRepoCatListById } from '@/api/repo/repoCatApi'
|
|
|
+
|
|
|
+interface TreeNode {
|
|
|
+ label: string
|
|
|
+ isLeaf: boolean
|
|
|
+ repoTypeId: number
|
|
|
+ children?: TreeNode[]
|
|
|
+}
|
|
|
+
|
|
|
+interface Object {
|
|
|
+ repoTypeId: number
|
|
|
+ repoCatId: number
|
|
|
+ repoCatTitle: string
|
|
|
+ repoCatDesc: string
|
|
|
+}
|
|
|
+
|
|
|
+const state = reactive({
|
|
|
+ loading: false,
|
|
|
+ keywords: '',
|
|
|
+ treeData: [] as TreeNode[],
|
|
|
+ curRepoTypeId: 0,
|
|
|
+ repoCatList: [] as Object[],
|
|
|
+ dialogState: 1,
|
|
|
+ search: {
|
|
|
+ keywords: '',
|
|
|
+ },
|
|
|
+})
|
|
|
+
|
|
|
+const leftTreeRef = ref()
|
|
|
+const getRepoCatData = async () => {
|
|
|
+ const curRepoTypeId = state.curRepoTypeId
|
|
|
+ if (curRepoTypeId > 0) {
|
|
|
+ state.loading = true
|
|
|
+ const { data } = await getRepoCatListById(curRepoTypeId)
|
|
|
+ state.repoCatList = data
|
|
|
+ state.loading = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const getRepoTypeData = async () => {
|
|
|
+ const { data } = await getRepoTypeByList({})
|
|
|
+ const children: TreeNode[] = []
|
|
|
+ data.forEach((item: any) => {
|
|
|
+ return children.push({
|
|
|
+ label: item.repoTypeTitle,
|
|
|
+ repoTypeId: item.repoTypeId,
|
|
|
+ isLeaf: true,
|
|
|
+ })
|
|
|
+ })
|
|
|
+ state.treeData = [
|
|
|
+ {
|
|
|
+ label: '数据仓库类型',
|
|
|
+ isLeaf: false,
|
|
|
+ repoTypeId: -1,
|
|
|
+ children,
|
|
|
+ },
|
|
|
+ ]
|
|
|
+
|
|
|
+ if (data && data.length > 0) {
|
|
|
+ state.curRepoTypeId = data[0].repoTypeId
|
|
|
+ nextTick(() => {
|
|
|
+ leftTreeRef.value.setCurrentKey(data[0].repoTypeId)
|
|
|
+ })
|
|
|
+ await getRepoCatData()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getRepoTypeData()
|
|
|
+})
|
|
|
+
|
|
|
+// 模型选择
|
|
|
+const onTreeNodeClick = (node: TreeNode) => {
|
|
|
+ if (node.isLeaf) {
|
|
|
+ state.curRepoTypeId = node.repoTypeId
|
|
|
+ getRepoCatData()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const repoCatTableRef = ref()
|
|
|
+const repoCatRef = ref()
|
|
|
+
|
|
|
+// 检索对象
|
|
|
+const onSearch = () => {
|
|
|
+ getRepoCatData()
|
|
|
+}
|
|
|
+
|
|
|
+// 新增
|
|
|
+const onRepoCatAdd = () => {
|
|
|
+ const repoTypeId = state.curRepoTypeId
|
|
|
+ if (repoTypeId > 0) {
|
|
|
+ repoCatRef.value.showAddModel(repoTypeId)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 编辑
|
|
|
+const onRepoCatEdit = (row: { repoCatId: number }) => {
|
|
|
+ const repoTypeId = state.curRepoTypeId
|
|
|
+ if (repoTypeId > 0) {
|
|
|
+ repoCatRef.value.showEditModel(repoTypeId, row.repoCatId)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 删除对象
|
|
|
+const onRepoCatDelete = (row: any) => {
|
|
|
+ const { ocTypeId, ocCatId, ocCatTitle } = row
|
|
|
+ ElMessageBox.confirm(`确认删除「${ocCatTitle}」吗?`, '确认信息').then(async () => {
|
|
|
+ const { msg } = await deleteRepoCatById(ocTypeId, ocCatId)
|
|
|
+ ElMessage.success(msg)
|
|
|
+ await getRepoCatData()
|
|
|
+ })
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="absolute-container">
|
|
|
+ <tool-header title="仓库分类" />
|
|
|
+
|
|
|
+ <div class="page-main">
|
|
|
+ <LayoutContainer left-side-width="250px" hide-left-side-toggle>
|
|
|
+ <template #leftSide>
|
|
|
+ <el-scrollbar class="tree">
|
|
|
+ <ElTree ref="leftTreeRef" :data="state.treeData" default-expand-all node-key="repoCatId" @node-click="onTreeNodeClick">
|
|
|
+ <template #default="{ node, data }">
|
|
|
+ <div class="custom-tree-node">
|
|
|
+ <div class="label" :title="node.label">
|
|
|
+ <el-icon v-if="data.isLeaf" size="16px" style="margin-right: 5px;">
|
|
|
+ <svg-icon name="ep:office-building" />
|
|
|
+ </el-icon>
|
|
|
+ <div class="text">
|
|
|
+ {{ data.label }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </ElTree>
|
|
|
+ </el-scrollbar>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <div class="container">
|
|
|
+ <tool-bar>
|
|
|
+ <template #right>
|
|
|
+ <el-input v-model="state.search.keywords" placeholder="请输入名称,支持模糊查询" style="padding-right: 10px;" clearable />
|
|
|
+ <el-button type="primary" @click="onSearch">
|
|
|
+ <template #icon>
|
|
|
+ <el-icon>
|
|
|
+ <svg-icon name="i-ep:search" />
|
|
|
+ </el-icon>
|
|
|
+ </template>
|
|
|
+ </el-button>
|
|
|
+
|
|
|
+ <el-button size="default" @click.stop="onRepoCatAdd">
|
|
|
+ <template #icon>
|
|
|
+ <el-icon>
|
|
|
+ <svg-icon name="i-ep:plus" />
|
|
|
+ </el-icon>
|
|
|
+ </template>
|
|
|
+ 数据仓库分类
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </tool-bar>
|
|
|
+
|
|
|
+ <el-table ref="repoCatTableRef" v-loading="state.loading" class="list-table" :data="state.repoCatList" size="small" border stripe highlight-current-row height="100%">
|
|
|
+ <el-table-column type="index" label="序号" header-align="center" align="center" width="60" />
|
|
|
+
|
|
|
+ <el-table-column prop="repoCatTitle" label="名称" header-align="center" align="center" width="200">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ scope.row.repoCatTitle }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column prop="repoCatDesc" label="说明" header-align="center" align="left">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ scope.row.repoCatDesc }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="操作" header-align="center" align="center" width="220">
|
|
|
+ <template #default="scope">
|
|
|
+ <div>
|
|
|
+ <el-button type="warning" size="small" plain @click="onRepoCatEdit(scope.row)">
|
|
|
+ 编辑
|
|
|
+ </el-button>
|
|
|
+ <el-button v-if="scope.row.isFixed <= 0" type="danger" size="small" plain @click="onRepoCatDelete(scope.row)">
|
|
|
+ 删除
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </LayoutContainer>
|
|
|
+ </div>
|
|
|
+ <RepoCatComponent ref="repoCatRef" @success="getRepoCatData" />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.container {
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+}
|
|
|
+
|
|
|
+.absolute-container {
|
|
|
+ :deep(.left-side) {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ height: 100%;
|
|
|
+
|
|
|
+ .btns {
|
|
|
+ display: inline-flex;
|
|
|
+ width: 100%;
|
|
|
+ margin-bottom: var(--container-padding);
|
|
|
+
|
|
|
+ .add {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .tree {
|
|
|
+ flex: 1;
|
|
|
+ overflow-y: auto;
|
|
|
+
|
|
|
+ .el-tree {
|
|
|
+ .el-tree-node__content {
|
|
|
+ height: 40px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .is-current > .el-tree-node__content {
|
|
|
+ background-color: var(--el-color-primary-light-9);
|
|
|
+ }
|
|
|
+
|
|
|
+ .custom-tree-node {
|
|
|
+ flex: 1;
|
|
|
+ position: relative;
|
|
|
+ width: 0;
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ justify-content: center;
|
|
|
+
|
|
|
+ .label {
|
|
|
+ display: inline-flex;
|
|
|
+ align-items: center;
|
|
|
+ width: calc(100% - 10px);
|
|
|
+ color: var(--el-text-color-primary);
|
|
|
+
|
|
|
+ .text {
|
|
|
+ @include text-overflow;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ .actions {
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .actions {
|
|
|
+ display: none;
|
|
|
+ position: absolute;
|
|
|
+ right: 10px;
|
|
|
+ top: 50%;
|
|
|
+ transform: translateY(-50%);
|
|
|
+
|
|
|
+ .el-button {
|
|
|
+ padding: 5px 8px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|