|
@@ -0,0 +1,127 @@
|
|
|
+<template>
|
|
|
+ <div class="page">
|
|
|
+ <el-card shadow="never">
|
|
|
+ <el-form :model="param" inline ref="queryRef" @keyup.enter="getData">
|
|
|
+ <el-form-item label="" prop="name">
|
|
|
+ <el-input v-model="param.name" placeholder="搜索标签名称或英文标识" style="width: 250px" clearable />
|
|
|
+ <el-button type="primary" class="ml10" @click="getData">
|
|
|
+ <el-icon>
|
|
|
+ <ele-Search />
|
|
|
+ </el-icon>
|
|
|
+ 查询
|
|
|
+ </el-button>
|
|
|
+ <el-button type="primary" class="ml10" @click="onOpenAddDept" v-auth="'add'">
|
|
|
+ <el-icon>
|
|
|
+ <ele-FolderAdd />
|
|
|
+ </el-icon>
|
|
|
+ 新增标签
|
|
|
+ </el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <el-table :data="tableData" style="width: 100%" row-key="id" default-expand-all :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" v-loading="loading">
|
|
|
+ <el-table-column prop="name" v-col="'name'" label="标签名称" min-width="180" show-overflow-tooltip> </el-table-column>
|
|
|
+ <el-table-column prop="code" v-col="'code'" label="英文标识" align="center" width="120">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-tag type="primary" size="small">{{ scope.row.code }}</el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="color" v-col="'color'" label="颜色" align="center" width="120">
|
|
|
+ <template #default="scope">
|
|
|
+ <div class="flex" style="justify-content: center">
|
|
|
+ <div class="color" :style="{ backgroundColor: colorMap.get(scope.row.color)?.color }"></div>
|
|
|
+ {{ colorMap.get(scope.row.color)?.label }}
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="description" v-col="'description'" label="描述" align="center" show-overflow-tooltip min-width="180"></el-table-column>
|
|
|
+ <el-table-column prop="createdAt" v-col="'createdAt'" label="创建时间" align="center" width="180"></el-table-column>
|
|
|
+ <el-table-column le-column label="操作" align="center" width="140" v-col="'handle'">
|
|
|
+ <template #default="scope">
|
|
|
+ <template v-if="scope.row.name !== '硬件设施'">
|
|
|
+ <el-button size="small" text type="primary" @click="onOpenAddDept(scope.row)" v-auth="'add'">新增</el-button>
|
|
|
+ <el-button size="small" text type="warning" @click="onOpenEditDept(scope.row)" v-auth="'edit'">修改</el-button>
|
|
|
+ <el-button size="small" text type="info" @click="onTabelRowDel(scope.row)" v-auth="'del'">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-card>
|
|
|
+ <EditDept ref="editDeptRef" :colorList="colorList" @update="getData" />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { ref, reactive, onMounted } from "vue";
|
|
|
+import { ElMessageBox, ElMessage } from "element-plus";
|
|
|
+import EditDept from "./component/edit.vue";
|
|
|
+import api from "/@/api/datahub";
|
|
|
+
|
|
|
+const colorList = ref([
|
|
|
+ { value: "red", label: "红色", color: "#FF0000" },
|
|
|
+ { value: "green", label: "绿色", color: "#00FF00" },
|
|
|
+ { value: "blue", label: "蓝色", color: "#0000FF" },
|
|
|
+ { value: "yellow", label: "黄色", color: "#E8A92A" },
|
|
|
+ { value: "purple", label: "紫色", color: "#9A4FF0" },
|
|
|
+ { value: "pink", label: "粉色", color: "#E7408C" },
|
|
|
+ { value: "indigo", label: "靛蓝", color: "#525EE9" },
|
|
|
+ { value: "gray", label: "灰色", color: "#606774" },
|
|
|
+ { value: "orange", label: "橙色", color: "#F86724" },
|
|
|
+ { value: "cyan", label: "青色", color: "#00C853" },
|
|
|
+]);
|
|
|
+
|
|
|
+const colorMap = new Map();
|
|
|
+colorList.value.forEach((item) => {
|
|
|
+ colorMap.set(item.value, item);
|
|
|
+});
|
|
|
+
|
|
|
+const editDeptRef = ref();
|
|
|
+const tableData = ref([]);
|
|
|
+const loading = ref(false);
|
|
|
+const param = reactive({
|
|
|
+ name: "",
|
|
|
+});
|
|
|
+
|
|
|
+const getData = () => {
|
|
|
+ loading.value = true;
|
|
|
+ api.tags
|
|
|
+ .getTree(param)
|
|
|
+ .then((res: any) => {
|
|
|
+ tableData.value = res?.data || [];
|
|
|
+ })
|
|
|
+ .finally(() => (loading.value = false));
|
|
|
+};
|
|
|
+
|
|
|
+// 打开新增菜单弹窗
|
|
|
+const onOpenAddDept = (row?: any) => {
|
|
|
+ editDeptRef.value.openDialog(row?.deptId);
|
|
|
+};
|
|
|
+// 打开编辑菜单弹窗
|
|
|
+const onOpenEditDept = (row: any) => {
|
|
|
+ editDeptRef.value.openDialog(row);
|
|
|
+};
|
|
|
+// 删除当前行
|
|
|
+const onTabelRowDel = (row: any) => {
|
|
|
+ ElMessageBox.confirm(`此操作将永久删除组织:${row.deptName}, 是否继续?`, "提示", {
|
|
|
+ confirmButtonText: "删除",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ }).then(() => {
|
|
|
+ api.tags.del(row.id).then(() => {
|
|
|
+ ElMessage.success("删除成功");
|
|
|
+ getData();
|
|
|
+ });
|
|
|
+ });
|
|
|
+};
|
|
|
+// 页面加载时
|
|
|
+onMounted(() => {
|
|
|
+ getData();
|
|
|
+});
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.color {
|
|
|
+ width: 12px;
|
|
|
+ height: 12px;
|
|
|
+ border-radius: 50%;
|
|
|
+ margin-right: 5px;
|
|
|
+}
|
|
|
+</style>
|