|
|
@@ -0,0 +1,273 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <!-- <el-input
|
|
|
+ placeholder="请输入图层名称"
|
|
|
+ prefix-icon="Search"
|
|
|
+ size="small"
|
|
|
+ v-model="search"
|
|
|
+ class="search_ipt"
|
|
|
+ >
|
|
|
+ </el-input> -->
|
|
|
+ <div class="zttc flex-box column">
|
|
|
+ <el-tree
|
|
|
+ :data="datas.treeList"
|
|
|
+ :props="defaultProps"
|
|
|
+ node-key="bsm"
|
|
|
+ show-checkbox
|
|
|
+ @check="handleNodeClick"
|
|
|
+ :filter-node-method="filterNode"
|
|
|
+ ref="tree"
|
|
|
+ >
|
|
|
+ <template #default="{ node, data }">
|
|
|
+ <span class="custom-tree-node max-width">
|
|
|
+ <el-tooltip
|
|
|
+ v-if="data.parent == '0'"
|
|
|
+ class="item"
|
|
|
+ effect="dark"
|
|
|
+ placement="right"
|
|
|
+ >
|
|
|
+ <template #content
|
|
|
+ >入库人:{{ data.createperson }} <br />入库时间:{{
|
|
|
+ data.datetime
|
|
|
+ }}</template
|
|
|
+ >
|
|
|
+ <span :class="data.disabled ? 'treetitle ' : ''">{{
|
|
|
+ node.label
|
|
|
+ }}</span>
|
|
|
+ </el-tooltip>
|
|
|
+ <span v-else :class="data.disabled ? 'treetitle ' : ''">{{
|
|
|
+ node.label
|
|
|
+ }}</span>
|
|
|
+
|
|
|
+ <!-- <span
|
|
|
+ v-if="!data.children"
|
|
|
+ style="float: right; margin-right: 15px"
|
|
|
+ @click="changCollect(data)"
|
|
|
+ >
|
|
|
+ <i
|
|
|
+ class="iconfont icon-041xingxing"
|
|
|
+ style="vertical-align: middle"
|
|
|
+ v-if="data.my == null || data.my == false"
|
|
|
+ ></i>
|
|
|
+ <i
|
|
|
+ class="iconfont icon-xingxing2"
|
|
|
+ v-else
|
|
|
+ style="vertical-align: middle; color: #eab565"
|
|
|
+ ></i>
|
|
|
+ </span> -->
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-tree>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { toRefs, onMounted, reactive, ref, watch } from "vue";
|
|
|
+import * as api from "@/api/ghyzt/zzllApi";
|
|
|
+import { useStore } from "vuex";
|
|
|
+export default {
|
|
|
+ props: {
|
|
|
+ currentRemoveCollect: {
|
|
|
+ type: Object,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ setup(prop, context) {
|
|
|
+ const defaultProps = {
|
|
|
+ children: "children",
|
|
|
+ label: "label",
|
|
|
+ disabled: (data, node) => {
|
|
|
+ // parent == '0':服务资源,1:目录 sjlx附件 type图层服务
|
|
|
+ if (data.parent == "0") {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ // 2023/5/7 修改 多图层一键开启关闭功能
|
|
|
+ // 子级全部为图层,图层同级没有目录或附件,则上一级目录节点显示复选框
|
|
|
+ let state = false;
|
|
|
+ if (data.children.length > 0) {
|
|
|
+ state = data.children.every((item) => {
|
|
|
+ return item.parent == "0" && !item.sjlx;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return !state;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ };
|
|
|
+ const store = useStore();
|
|
|
+ const tree = ref(null);
|
|
|
+ let search = ref("");
|
|
|
+ let datas = reactive({
|
|
|
+ treeList: [],
|
|
|
+ getList() {
|
|
|
+ // 从Vuex获取zyml数据,替代原接口调用
|
|
|
+ let zymlData = store.state.xmgl.zymlData;
|
|
|
+ console.log(zymlData, "zymlData");
|
|
|
+ if (zymlData) {
|
|
|
+ var temp = {};
|
|
|
+ var list = [];
|
|
|
+ var zytc = [];
|
|
|
+ zymlData.forEach((item, index) => {
|
|
|
+ if (item.parent == "0" && !item.sjlx) {
|
|
|
+ zytc.push({
|
|
|
+ name: item.name,
|
|
|
+ bsm: item.bsm,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ temp[item.bsm] = item;
|
|
|
+ item.label = item.name;
|
|
|
+ if (item.parent) {
|
|
|
+ item.children = [];
|
|
|
+ }
|
|
|
+ if (item.pbsm) {
|
|
|
+ try {
|
|
|
+ temp[item.pbsm].children.push(item);
|
|
|
+ } catch {
|
|
|
+ // 错误处理保持不变
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ list.push(item);
|
|
|
+ }
|
|
|
+ if (item.count > 0) {
|
|
|
+ item.name = item.name + " [" + item.count + "]";
|
|
|
+ }
|
|
|
+ });
|
|
|
+ datas.treeList = list;
|
|
|
+ store.commit("SET_ZYTC", zytc);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ changCollect(item) {
|
|
|
+ api.Collect({ bsm: item.bsm }).then((res) => {
|
|
|
+ if (res.success) {
|
|
|
+ item.my = !item.my;
|
|
|
+ context.emit("changCollect", item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
+ let checkedKeys = [];
|
|
|
+ onMounted(() => {
|
|
|
+ datas.getList();
|
|
|
+ });
|
|
|
+ const collection = (node, data) => {
|
|
|
+ console.log(node, data);
|
|
|
+ };
|
|
|
+ watch(
|
|
|
+ () => store.state.xmgl.zymlData,
|
|
|
+ (newVal) => {
|
|
|
+ datas.getList();
|
|
|
+ }
|
|
|
+ );
|
|
|
+ watch(
|
|
|
+ () => prop.currentRemoveCollect,
|
|
|
+ (item) => {
|
|
|
+ datas.getList();
|
|
|
+ }
|
|
|
+ );
|
|
|
+ watch(
|
|
|
+ () => store.state.zyll.czzyId,
|
|
|
+ (count, prevCount) => {
|
|
|
+ switch (count.num) {
|
|
|
+ case 9:
|
|
|
+ /* ..删除图层改变tree.. */
|
|
|
+ delTreeNode(count.bsm);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ );
|
|
|
+ watch(
|
|
|
+ () => store.state.zyll.zylist,
|
|
|
+ (list, prevCount) => {
|
|
|
+ var c = [];
|
|
|
+ list.map((item) => {
|
|
|
+ c.push(item.bsm);
|
|
|
+ });
|
|
|
+ tree.value.setCheckedKeys(c, true);
|
|
|
+ checkedKeys = c;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ const delTreeNode = (bsm) => {
|
|
|
+ tree.value.setChecked(bsm, false);
|
|
|
+ resetDom(bsm);
|
|
|
+ };
|
|
|
+ // 重新设置部分图层组件
|
|
|
+ const resetDom = (bsm) => {
|
|
|
+ // 属性表
|
|
|
+ store.state.zyll.czzyId = "";
|
|
|
+ store.state.zyll.zylist = store.state.zyll.zylist.filter((item) => {
|
|
|
+ return bsm != item.bsm;
|
|
|
+ });
|
|
|
+ // 属性过滤
|
|
|
+ store.state.zyll.queryfilter.bsm == bsm &&
|
|
|
+ store.commit("SET_QUERYFILTER", {});
|
|
|
+ // 图层对比
|
|
|
+ store.state.zyll.screencontrast = store.state.zyll.screencontrast.filter(
|
|
|
+ (item) => {
|
|
|
+ return bsm != item.bsm;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ };
|
|
|
+ // 返回当前点击节点的数据
|
|
|
+ const handleNodeClick = (data, checked) => {
|
|
|
+ if (data.parent == "0") {
|
|
|
+ store.commit("SET_ZYLIST", data);
|
|
|
+ } else {
|
|
|
+ store
|
|
|
+ .dispatch("MULTI_SET_ZYLIST", { data, checked })
|
|
|
+ .then((res) => {
|
|
|
+ // console.log(res);
|
|
|
+ })
|
|
|
+ .catch((e) => {
|
|
|
+ console.log(e);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ };
|
|
|
+ // 过滤
|
|
|
+ watch(search, (newValue, oldValue) => {
|
|
|
+ tree.value.filter(newValue);
|
|
|
+ });
|
|
|
+ const filterNode = (value, data) => {
|
|
|
+ if (!value) return true;
|
|
|
+ return data.label.indexOf(value) !== -1;
|
|
|
+ };
|
|
|
+ return {
|
|
|
+ ...toRefs(datas),
|
|
|
+ search,
|
|
|
+ defaultProps,
|
|
|
+ handleNodeClick,
|
|
|
+ filterNode,
|
|
|
+ tree,
|
|
|
+ datas,
|
|
|
+ collection,
|
|
|
+ };
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+.search_ipt {
|
|
|
+ width: 94%;
|
|
|
+ margin: 10px;
|
|
|
+ height: 30px !important;
|
|
|
+}
|
|
|
+.zttc {
|
|
|
+ height: calc(100vh - 170px);
|
|
|
+ overflow: auto;
|
|
|
+ :deep(.el-tree-node__label) {
|
|
|
+ font-size: 16px !important;
|
|
|
+ line-height: 25px;
|
|
|
+ }
|
|
|
+ .treetitle {
|
|
|
+ //margin-left: -10px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|
|
|
+<style lang="less">
|
|
|
+.zttc {
|
|
|
+ .el-tree {
|
|
|
+ // 不可全选样式
|
|
|
+ .el-tree-node .is-disabled {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|