qa-prevention-xgf-app/components/hidden_level/hidden_level.vue

122 lines
2.3 KiB
Vue

<template>
<next-tree
ref="nextTreeRef"
func-mode="radio"
:select-parent="false"
:check-strictly="false"
:if-search="false"
:tree-data="treeData"
theme-color="#3377ff"
page-height="92vh"
:label-key="'name'"
:value-key="'id'"
:children-key="'children'"
@confirm="fnTreeConfirm"
@cancel="fnTreeCancel"
></next-tree>
</template>
<script>
import { getHiddenLevelTree } from "@/api";
export default {
props: {
value: {
type: String,
default: "",
},
isShowNeglect: {
type: Boolean,
default: true,
},
isShowMore: {
type: Boolean,
default: true,
},
isShowMajor: {
type: Boolean,
default: true,
},
visible: {
type: Boolean,
required: false,
},
},
data() {
return {
treeData: [],
};
},
watch: {
visible: {
handler: function (newVal, oldVal) {
if (newVal) {
this.$nextTick(() => {
if (this.$refs.nextTreeRef) {
this.$refs.nextTreeRef._show();
this.$refs.nextTreeRef.checkedFunc(this.value);
}
});
} else {
this.$nextTick(() => {
if (this.$refs.nextTreeRef) {
this.$refs.nextTreeRef._hide();
}
});
}
},
immediate: true,
},
},
mounted() {
if (this.visible) {
// this.fnGetData(); // 请求数据接口
}
},
methods: {
// 结构树弹框确定
fnTreeConfirm(event) {
this.$emit("confirm", evt);
this.$emit("update:visible", false);
},
// 关闭结构树弹框
fnTreeCancel() {
this.$emit("update:visible", false);
},
async fnGetData() {
const resData = await getHiddenLevelTree({
DICTIONARIES_ID: "5e7cf8620ba54ad89719d0be62133c7a",
loading: false,
});
const data = JSON.parse(resData.zTreeNodes);
for (let i = 0; i < data.length; i++) {
for (let j = 0; j < data[i].children.length; j++) {
if (!this.isShowMore) {
if (data[i].children[j].id === "jdyh001") {
data[i].children.splice(j, 1);
}
}
if (!this.isShowNeglect) {
if (data[i].children[j].id === "hiddenLevel1001") {
data[i].children.splice(j, 1);
}
}
}
if (!this.isShowMajor) {
if (data[i].id === "hiddenLevel0002") {
data.splice(i, 1);
}
}
}
this.treeData = data;
},
},
};
</script>
<style scoped lang="scss"></style>