Commit 4c4624fe authored by 白舜's avatar 白舜 🎱

改造字典管理的headers的处理逻辑, 完善端口管理字典

parent e9b4437b
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
<!-- 序号 --> <!-- 序号 -->
</el-table-column> </el-table-column>
<el-table-column <el-table-column
v-for="(header, index) in headers" v-for="(header) in headers"
:width="header.width" :width="header.width"
:min-width="header.minWidth" :min-width="header.minWidth"
:align="header.align" :align="header.align"
:key="'col_' + index" :key="'col_' + header.prop"
:fixed="header.fixed" :fixed="header.fixed"
show-overflow-tooltip> show-overflow-tooltip>
<template v-slot:header> <template v-slot:header>
......
...@@ -25,15 +25,22 @@ ...@@ -25,15 +25,22 @@
</div> </div>
<div class="flex_right"> <div class="flex_right">
<div class="main_container"> <div class="main_container">
<bg-filter-group @search="changeSearch" v-model="filter.search" placeholder="请输入关键字"> <bg-filter-group
<template v-slot:left_action v-if="nodeClassifyId != '263758a4-0349-4d49-a816-e8ff8d33a8bb'"> @search="changeSearch"
v-model="filter.search"
placeholder="请输入关键字">
<template
v-slot:left_action
v-if="nodeClassifyId != '263758a4-0349-4d49-a816-e8ff8d33a8bb'">
<div class="apaas_button"> <div class="apaas_button">
<el-button type="primary" @click="backDict" v-if="dictLevel != 1"> <el-button type="primary" @click="backDict" v-if="dictLevel != 1">
<!-- <bg-icon style="font-size: 12px; color: #fff; margin-right: 8px" icon="#bg-ic-add"></bg-icon> --> <!-- <bg-icon style="font-size: 12px; color: #fff; margin-right: 8px" icon="#bg-ic-add"></bg-icon> -->
返回上级 返回上级
</el-button> </el-button>
<el-button type="primary" @click="register"> <el-button type="primary" @click="register">
<bg-icon style="font-size: 12px; color: #fff; margin-right: 8px" icon="#bg-ic-add"></bg-icon> <bg-icon
style="font-size: 12px; color: #fff; margin-right: 8px"
icon="#bg-ic-add"></bg-icon>
新增 新增
</el-button> </el-button>
</div> </div>
...@@ -60,9 +67,14 @@ ...@@ -60,9 +67,14 @@
</bg-filter-group> </bg-filter-group>
<div class="table_container"> <div class="table_container">
<div class="table bg-scroll"> <div class="table bg-scroll">
<bg-table ref="bgTable" :headers="isLang && dictLevel == 1 ? langHeaders : headers" :rows="tableRows" :isIndex="true" :stripe="true"> <bg-table
ref="bgTable"
:headers="headers"
:rows="tableRows"
:isIndex="true"
:stripe="true">
<template v-slot:name="{ row }"> <template v-slot:name="{ row }">
<span class="can_click_text" @click="getChildren(row)" v-if="isLang && dictLevel == 1"> <span class="can_click_text" @click="getChildren(row)" v-if="row.children">
{{ row.name }} {{ row.name }}
</span> </span>
<span v-else> <span v-else>
...@@ -81,17 +93,33 @@ ...@@ -81,17 +93,33 @@
</template> </template>
<template v-slot:action="{ row }"> <template v-slot:action="{ row }">
<!-- 除技术类型之外的字典可以删除 --> <!-- 除技术类型之外的字典可以删除 -->
<bg-table-btns2 :limit="3" v-if="nodeClassifyId !== '263758a4-0349-4d49-a816-e8ff8d33a8bb'"> <bg-table-btns2
<bg-table-btn @click="edit_row(row)" :disabled="row.state == 1">编辑</bg-table-btn> :limit="3"
<bg-table-btn @click="delete_row(row)" :disabled="row.state == 1">删除</bg-table-btn> v-if="nodeClassifyId !== '263758a4-0349-4d49-a816-e8ff8d33a8bb'">
<bg-table-btn @click="moveRow(row, 1)" :disabled="!row.canMoveUp">上移</bg-table-btn> <bg-table-btn @click="edit_row(row)" :disabled="row.state == 1"
<bg-table-btn @click="moveRow(row, 2)" :disabled="!row.canMoveDown">下移</bg-table-btn> >编辑</bg-table-btn
>
<bg-table-btn @click="delete_row(row)" :disabled="row.state == 1"
>删除</bg-table-btn
>
<bg-table-btn @click="moveRow(row, 1)" :disabled="!row.canMoveUp"
>上移</bg-table-btn
>
<bg-table-btn @click="moveRow(row, 2)" :disabled="!row.canMoveDown"
>下移</bg-table-btn
>
</bg-table-btns2> </bg-table-btns2>
<!-- 技术类型字典不可删除 --> <!-- 技术类型字典不可删除 -->
<bg-table-btns2 :limit="3" v-else> <bg-table-btns2 :limit="3" v-else>
<bg-table-btn @click="edit_row(row)" :disabled="row.state == 1">编辑</bg-table-btn> <bg-table-btn @click="edit_row(row)" :disabled="row.state == 1"
<bg-table-btn @click="moveRow(row, 1)" :disabled="!row.canMoveUp">上移</bg-table-btn> >编辑</bg-table-btn
<bg-table-btn @click="moveRow(row, 2)" :disabled="!row.canMoveDown">下移</bg-table-btn> >
<bg-table-btn @click="moveRow(row, 1)" :disabled="!row.canMoveUp"
>上移</bg-table-btn
>
<bg-table-btn @click="moveRow(row, 2)" :disabled="!row.canMoveDown"
>下移</bg-table-btn
>
</bg-table-btns2> </bg-table-btns2>
</template> </template>
</bg-table> </bg-table>
...@@ -108,7 +136,11 @@ ...@@ -108,7 +136,11 @@
</div> </div>
</div> </div>
<!-- 新增/编辑弹窗 --> <!-- 新增/编辑弹窗 -->
<el-dialog class="dialog_box" :title="addType == 1 ? '新增' : '编辑'" v-model="addDialog" width="758px"> <el-dialog
class="dialog_box"
:title="addType == 1 ? '新增' : '编辑'"
v-model="addDialog"
width="758px">
<el-form ref="bgForm" :model="formData" :rules="rules" label-width="80px" class="bg_form"> <el-form ref="bgForm" :model="formData" :rules="rules" label-width="80px" class="bg_form">
<el-form-item label="名称" prop="name"> <el-form-item label="名称" prop="name">
<el-input <el-input
...@@ -176,21 +208,15 @@ ...@@ -176,21 +208,15 @@
</template> </template>
<script setup> <script setup>
import { reactive, ref, onBeforeMount, toRefs, computed, watch, nextTick } from "vue"; import { reactive, ref, onBeforeMount, toRefs, computed, watch, nextTick, watchEffect } from "vue";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import axios from "../../../../request/http.js"; import axios from "../../../../request/http.js";
import { Search } from "@element-plus/icons-vue"; import { Search } from "@element-plus/icons-vue";
import bgBreadcrumb from "@/components/bg-breadcrumb.vue"; import bgBreadcrumb from "@/components/bg-breadcrumb.vue";
const bgForm = ref(null); const bgForm = ref(null);
const state = reactive({
bgForm, const headers = computed(() => {
typeList: [], // 分类数据 let _headers = [
typeKeyword: "", // 分类删选关键词
nodeClassifyId: null, // 当前选中分类的uuid 用于新增字典
nodeId: null, // 当前选中分类的id 用于请求列表
timer: null, // 定时器
headers: [
{ {
label: "名称", label: "名称",
prop: "name", prop: "name",
...@@ -215,37 +241,29 @@ const state = reactive({ ...@@ -215,37 +241,29 @@ const state = reactive({
width: 176, width: 176,
fixed: "right", fixed: "right",
}, },
], // 表格数据表头 ];
langHeaders: [
{ if (state.nodeClassifyId === "59315100-5c2a-4381-83fe-32934605f0a9") {
label: "名称", _headers.splice(1, 0, {
prop: "name",
},
{
label: "版本数", label: "版本数",
prop: "total_children", prop: "total_children",
}, });
{ }
label: "描述", if (state.nodeClassifyId === "b3a083ee-a8c1-8ca4-f9a1-ea01692a0f1a") {
prop: "describe", _headers.splice(1, 0, {
minWidth: 360, label: "服务名称",
}, prop: "service_name",
{ });
label: "更新时间", }
prop: "updated_time", return _headers;
width: 220, });
}, const state = reactive({
{ bgForm,
label: "是否启用", typeList: [], // 分类数据
prop: "state", typeKeyword: "", // 分类删选关键词
}, nodeClassifyId: null, // 当前选中分类的uuid 用于新增字典
{ nodeId: null, // 当前选中分类的id 用于请求列表
label: "操作", timer: null, // 定时器
prop: "action",
width: 176,
fixed: "right",
},
],
tableRows: [], // 表格数据 tableRows: [], // 表格数据
tableTotal: 0, // 表格数据条数 tableTotal: 0, // 表格数据条数
filter: { filter: {
...@@ -289,27 +307,23 @@ const state = reactive({ ...@@ -289,27 +307,23 @@ const state = reactive({
fatherRow: null, fatherRow: null,
}); });
const isLang = computed(() => { const dictLevel = ref(1);
return state.nodeClassifyId == "59315100-5c2a-4381-83fe-32934605f0a9"
})
const dictLevel = ref(1)
const getChildren = (row) => { const getChildren = (row) => {
dictLevel.value = 2 dictLevel.value = 2;
state.tableRows = row.children || [] state.tableRows = row.children || [];
state.tableTotal = row.total_children state.tableTotal = row.total_children;
state.fatherRow = row state.fatherRow = row;
} };
const backDict = () => { const backDict = () => {
dictLevel.value = 1 dictLevel.value = 1;
state.fatherRow = null state.fatherRow = null;
changePage(1); changePage(1);
} };
const nodeClick = (item) => { const nodeClick = (item) => {
state.nodeId = item.id; state.nodeId = item.id;
dictLevel.value = 1 dictLevel.value = 1;
state.fatherRow = null state.fatherRow = null;
state.nodeClassifyId = item.classify_id; state.nodeClassifyId = item.classify_id;
state.filter = { state.filter = {
state: "", state: "",
...@@ -380,14 +394,16 @@ const getTableRows = () => { ...@@ -380,14 +394,16 @@ const getTableRows = () => {
}) })
.then((res) => { .then((res) => {
if (res.data.code == 200) { if (res.data.code == 200) {
let data = res.data.data || [] let data = res.data.data || [];
if (dictLevel.value == 1) { if (dictLevel.value == 1) {
state.tableRows = data; state.tableRows = data;
state.tableTotal = res.data.total; state.tableTotal = res.data.total;
}else { } else {
let row = data.filter(e => {return e.dict_id == state.fatherRow.dict_id}) let row = data.filter((e) => {
state.tableRows = row[0].children return e.dict_id == state.fatherRow.dict_id;
state.tableTotal = row[0].total_children });
state.tableRows = row[0].children;
state.tableTotal = row[0].total_children;
} }
if (state.tableRows.length > 0) { if (state.tableRows.length > 0) {
state.tableRows.forEach((e) => { state.tableRows.forEach((e) => {
...@@ -455,7 +471,7 @@ const edit_row = (row) => { ...@@ -455,7 +471,7 @@ const edit_row = (row) => {
name: state.actionRow.name, name: state.actionRow.name,
describe: state.actionRow.describe, describe: state.actionRow.describe,
state: state.actionRow.state, state: state.actionRow.state,
p_dict_id: state.actionRow.p_dict_id p_dict_id: state.actionRow.p_dict_id,
}; };
} else { } else {
ElMessage.error(res.data.data); ElMessage.error(res.data.data);
...@@ -580,7 +596,6 @@ const { ...@@ -580,7 +596,6 @@ const {
typeList, typeList,
typeKeyword, typeKeyword,
nodeClassifyId, nodeClassifyId,
headers,
tableRows, tableRows,
tableTotal, tableTotal,
filter, filter,
...@@ -590,7 +605,6 @@ const { ...@@ -590,7 +605,6 @@ const {
addDialog, addDialog,
formData, formData,
rules, rules,
langHeaders,
} = toRefs(state); } = toRefs(state);
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment