src/views/standard/standardLibrary/components/BatchCopy.vue
@@ -229,11 +229,11 @@
                <span
                  ><i
                    :class="`node_i ${
                      data.children != undefined
                        ? data.code === '[1]'
                      isLeaf(data)
                        ? 'el-icon-tickets'
                        : data.code === '[1]'
                          ? 'el-icon-folder-opened'
                          : 'el-icon-folder'
                        : 'el-icon-tickets'
                    }`"
                  ></i>
                  {{ data.code }} {{ data.label }}</span
@@ -467,6 +467,12 @@
  selectStandardTreeList2,
  selectsStandardMethodByFLSSM,
} from "@/api/standard/standardLibrary";
import {
  isLeaf,
  buildSelectTree,
  deriveTreeFields,
  dropLastLabel,
} from "@/utils/standardTree";
export default {
  name: "BatchCopy",
  // import 引入的组件需要注入到对象中才能使用
@@ -498,6 +504,8 @@
      search: null,
      expandedKeys: [],
      selectTree: null,
      // 当前选中的树节点,用于按层级推导字段
      treeNode: null,
      standardMethodListId: null,
      methodLoad: false,
      methods: [],
@@ -516,6 +524,8 @@
  },
  // 方法集合
  methods: {
    // 供模板判断叶子(标准)节点
    isLeaf,
    // 获取左边表格数据
    getList() {
      this.batchCopyDia = true;
@@ -685,7 +695,8 @@
    selectStandardTreeList() {
      this.selectStandardTreeLoading = true;
      selectStandardTreeList2().then((res) => {
        this.list = res.data;
        this.list = res.data || [];
        this.expandedKeys = [];
        this.list.forEach((a) => {
          this.expandedKeys.push(a.label);
        });
@@ -694,39 +705,8 @@
    },
    // 选择样品名称的回调
    handleNodeClick(val, node, el) {
      this.selectTree = "";
      this.getNodeParent(node);
      let flag = false;
      if (node.level == 3) {
        if (node.data.children.length > 0) {
          node.data.children.forEach((a) => {
            let key = Object.keys(a);
            if (!key.includes("level")) {
              flag = true;
            }
          });
        }
      }
      this.selectTree = this.selectTree.replace(" - ", "");
      if (flag) {
        this.selectTree = " -  - " + this.selectTree;
      }
      let data = this.selectTree.split(" - ");
      let data2 = "";
      for (let index = data.length - 1; index >= 0; index--) {
        data2 += " - " + data[index];
      }
      this.selectTree = data2.replace(" - ", "");
    },
    getNodeParent(val) {
      if (val.parent != null) {
        if (val.data.children === null) {
          this.selectTree += " - " + val.label + " - " + "null";
        } else {
          this.selectTree += " - " + val.label;
        }
        this.getNodeParent(val.parent);
      }
      this.treeNode = node;
      this.selectTree = buildSelectTree(node, "null");
    },
    changeStandardMethodListId() {
      // 根据检验标准查右边table数据
@@ -753,38 +733,29 @@
        tree: this.selectTree,
      }).then((res) => {
        this.methodLoad = false;
        try {
          if (
            res.data.standardMethodList.length == 0 &&
            this.selectTree.split("-").length == 5
          ) {
            let arr = this.selectTree.split("-");
            let arr0 = arr.slice(0, arr.length - 1);
            let selectTree = arr0
              .join("-")
              .substring(0, arr0.join("-").length - 1);
        const list = (res.data && res.data.standardMethodList) || [];
        // 当前是叶子(标准)却查不到标准时,回退到父级再查一次
        if (list.length === 0 && this.treeNode && isLeaf(this.treeNode.data)) {
          const parentTree = dropLastLabel(this.selectTree);
          if (parentTree) {
            selectsStandardMethodByFLSSM({
              tree: selectTree,
              tree: parentTree,
            }).then((ress) => {
              this.methods = ress.data.standardMethodList;
              this.methods = (ress.data && ress.data.standardMethodList) || [];
            });
          } else {
            this.methods = res.data.standardMethodList;
            return;
          }
        } catch (e) {}
        }
        this.methods = list;
      });
    },
    activeStandardTree() {
      let trees = this.selectTree.split(" - ");
      if (trees.length < 3) {
      const { labels, sample, sampleType } = deriveTreeFields(this.treeNode);
      if (labels.length < 2) {
        this.$message.error("未选择对象");
        return;
      }
      if (trees[3] === undefined || trees[3] === "" || trees[3] === "- ") {
        this.sample = trees[2];
      } else {
        this.sample = trees[3];
      }
      this.sample = sample || sampleType;
      this.selectStandardTree = false;
    },
    handleSelectionChange0(val) {