1
lkk
2025-04-11 5c8adc16e9b0c0e71998d3cefc35170fa4a60900
src/views/hosp/project/index.vue
@@ -1,7 +1,7 @@
<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="3" :xs="24">
      <el-col :span="4" :xs="24">
        <div class="head-container">
          <el-input v-model="deptName" placeholder="请输入部门名称" clearable size="small" prefix-icon="el-icon-search"
            style="margin-bottom: 15px" />
@@ -9,8 +9,8 @@
        <div class="scrollable-container">
          <div class="content">
            <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false"
  :filter-node-method="filterNode" ref="tree" node-key="id" :default-expanded-keys="treeId"
  highlight-current @node-click="handleNodeClick" :render-content="renderContent" v-loading="loadings" />
              :filter-node-method="filterNode" ref="tree1" node-key="id" :default-expanded-keys="treeId"
              highlight-current @node-click="handleNodeClick" :render-content="renderContent" v-loading="loadings" />
          </div>
        </div>
      </el-col>
@@ -94,7 +94,7 @@
          <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" width="80px">
            <template slot-scope="scope">
              <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
                v-hasPermi="['hosp:project:edit']" title="修改1"></el-button>
                v-hasPermi="['hosp:project:edit']" title="修改"></el-button>
              <el-button v-if="scope.row.proParentId == '0'" size="mini" type="text" icon="el-icon-plus"
                @click="handleAdd(scope.row)" v-hasPermi="['system:dept:add']" title="增加"></el-button>
              <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
@@ -542,6 +542,7 @@
  watch: {
    deptName(val) {
      this.debounceFilter(val);
    },
    treeId(newVal) {
      if (newVal && newVal.length > 0) {
@@ -549,7 +550,7 @@
          const lastId = newVal[newVal.length - 1] || "532";
          const node = this.findNodeById(this.deptOptions, lastId);
          if (node) {
            this.$refs.tree.setCurrentKey(lastId);
            this.$refs.tree1.setCurrentKey(lastId);
            const nodeElement = document.querySelector(`.el-tree-node[data-key="${lastId}"] .el-tree-node__content`);
            if (nodeElement) {
              nodeElement.click();
@@ -587,7 +588,7 @@
  },
  methods: {
    debounceFilter: debounce(function (val) {
      this.$refs.tree.filter(val);
      this.$refs.tree1.filter(val);
    }, 300),
    precomputePinyin() {
      const traverse = (nodes) => {
@@ -603,6 +604,7 @@
      traverse(this.deptOptions);
    },
    filterNode(value, data) {
      console.log(value, data,2233)
      if (!value) return true;
      const cached = this.pinyinCache.get(data.id);
      if (!cached) return false;
@@ -692,13 +694,7 @@
          } else if (this.treeDate.id) {
            if (this.treeDate.qf == "0") {
              this.form.proParentId = "0"
              this.projectOptions.forEach((item) => {
                item.children.forEach((item1) => {
                  if (this.treeDate.id == item1.deptId) {
                    this.form.deptId = item1.deptId;
                  }
                });
              });
              this.form.deptId = this.treeDate.id
            } else {
              this.form.proParentId = this.treeDate.id;
              this.projectOptions.forEach((item) => {
@@ -735,9 +731,12 @@
      } else if (this.form.proParentId) {
        if (this.form.proParentId != 0) {
          this.dialogTableVisible = true;
          this.$nextTick(() => {
            this.chargeId.push(this.deptOptionstree[0].id);
          });
          if (this.deptOptionstree.length != 0) {
            this.$nextTick(() => {
              this.chargeId.push(this.deptOptionstree[0].id);
            });
          }
          this.getlistSfxm();
        } else {
          this.dialogTableVisible = false;
@@ -829,56 +828,31 @@
        this.treeId.push(this.treeDate.id);
      });
    },
    handleNodeClick(date, node) {
  // 当 qf 为 "0" 时,仅执行展开/折叠操作
  if (date.qf === "0") {
    if (node.expanded) {
      node.collapse(); // 折叠节点
    } else {
      node.expand(); // 展开节点
    }
    return; // 直接返回,不执行后续操作
  }
    handleNodeClick(date) {
  // 以下逻辑仅在 qf 不为 "0" 时执行
  this.treeDate = date;
  console.log('Selected node:', this.treeDate);
  this.id = date.id;
  this.queryParams.proId = this.id;
  this.xiugais = date.qf === "0";
  let data = {
    proId: this.queryParams.proId,
    proName: this.queryParams.proName || '',
  };
  this.loading = true;
  getInfoByProId(this.id)
    .then((response) => {
      this.xiugaiList = response.data;
    })
    .catch((error) => {
      console.error('Failed to get info by proId:', error);
      this.$message.error('获取数据失败');
    });
  getAllChildListById(data)
    .then((response) => {
      if (response.code === 200) {
        this.projectList = response.data.list.length >= 1 ? this.handleTree(response.data.list, "proId") : [];
        this.ListId = this.projectList.length && this.projectList[0]?.proId ? [this.projectList[0].proId] : [];
        this.key = response.data.key;
        this.getList();
      }
    })
    .catch((error) => {
      console.error('Failed to get all child list:', error);
      this.$message.error('加载列表失败');
    })
    .finally(() => {
      this.loading = false;
    });
},
      this.treeDate = date;
      console.log(this.treeDate)
      this.xiugais = date.qf === "0";
      let proId = date.id;
      getInfoByProId(proId).then((response) => {
        this.xiugaiList = response.data;
      });
      this.id = date.id;
      this.queryParams.proId = date.id;
      let data = {
        proId: this.queryParams.proId,
        proName: this.queryParams.proName,
      };
      this.loading = true;
      getAllChildListById(data).then((response) => {
        if (response.code == 200) {
          this.projectList = response.data.list.length >= 1 ? this.handleTree(response.data.list, "proId") : [];
          this.ListId = this.projectList.length ? [this.projectList[0].proId] : [];
          this.key = response.data.key;
          this.loading = false;
        }
      });
    },
    toggleExpandAll() {
      this.refreshTable = false;
      this.isExpandAll = !this.isExpandAll;
@@ -892,6 +866,11 @@
      let data = { proId: this.queryParams.proId };
      getAllChildListById(data).then(() => {
        this.loading = false;
      });
      this.deptName = "";
      // 手动调用过滤方法(需等待 DOM 更新)
      this.$nextTick(() => {
        this.$refs.tree1.filter(this.deptName);
      });
    },
    handleClose() {
@@ -931,7 +910,7 @@
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.proId = undefined;
      this.$refs.tree.setCurrentKey(null);
      this.$refs.tree1.setCurrentKey(null);
      this.handleQuery();
    },
    flexColumnWidth(column) {
@@ -1088,6 +1067,11 @@
          }
        }
      });
      this.deptName = "";
      // 手动调用过滤方法(需等待 DOM 更新)
      this.$nextTick(() => {
        this.$refs.tree1.filter(this.deptName);
      });
    },
    processSubmission(isUpdate, isY) {
      if (isUpdate) {
@@ -1130,6 +1114,10 @@
        this.sfxmId = parseInt(item.id);
      });
      this.dialogTableVisible = false;
       this.getDeptList();
    this.getDeptTree().then(() => {
      this.precomputePinyin();
    });
    },
    handleDelete(row) {
      const proIds = row.proId || this.ids;