xiejun
2023-07-19 ded6e8d2312e139e8ce770c7f1d5830bf2db4af6
Source/UBCS-WEB/src/components/BatchImport/ShowImportData.vue
@@ -57,11 +57,12 @@
                border
                :data="tab1Table"
                style="width: 100%"
                height="400px"
                height="40vh"
                highlight-current-row
                @current-change="resembleRowChange"
                @selection-change="tab1TableSelectChange"
                v-if="cloNamesList.length > 1"
                v-loading="tab1Loading"
              >
                <el-table-column
                  v-if="type !== 'batchApplyCode'"
@@ -103,7 +104,8 @@
                  border
                  :data="currentSelectedResemble"
                  style="width: 100%"
                  height="200px"
                  height="20vh"
                  v-loading="tab1BottomTableLoading"
                >
                  <el-table-column
                    v-for="item in resembleColumList"
@@ -138,12 +140,9 @@
            <el-tab-pane :label="tab2Name" name="tab2">
              <el-table
                border
                v-loading="tab2Loading"
                :data="tab2Table"
                :height="
                  type === 'batchApplyCode' && tab2Table.length > 0
                    ? '400px'
                    : '700px'
                "
                height="60vh"
              >
                <el-table-column
                  v-for="item in successTableColumns"
@@ -179,7 +178,7 @@
    </div>
    <template #footer>
      <div>
        <el-button size="small" type="primary" @click="submit"
        <el-button size="small" type="primary" @click="submit" :loading="submitLoading"
          >确定导入</el-button
        >
        <el-button size="small" @click="dialogVisible = false">取消</el-button>
@@ -282,8 +281,12 @@
        title: "查看详细信息",
        setForm: {},
      },
      batchApplyCodeTableData: {},
      batchSelectTableData: {},
      savedList: [],
      tab1Loading: false,
      tab2Loading: false,
      tab1BottomTableLoading: false,
      submitLoading: false
    };
  },
@@ -305,7 +308,7 @@
        if (first === true) {
          this.codeRuleOid = data.codeRuleOid;
          // 第一次打开直接赋值不校验
          this.batchApplyCodeTableData[data.codeRuleOid] = {
          this.batchSelectTableData[data.codeRuleOid] = {
            name: data.name,
            templateOid: data.oid,
            cloNamesList: data.cloNamesList,
@@ -325,8 +328,8 @@
            }
          }
        }
        if (!this.batchApplyCodeTableData[data.codeRuleOid]) {
          this.batchApplyCodeTableData[data.codeRuleOid] = {
        if (!this.batchSelectTableData[data.codeRuleOid]) {
          this.batchSelectTableData[data.codeRuleOid] = {
            name: data.name,
            templateOid: data.oid,
            cloNamesList: data.cloNamesList,
@@ -335,37 +338,74 @@
          };
        }
      }
      if (this.type === 'historyImport') {
        if (first === true) {
          // 第一次打开直接赋值不校验
          this.batchSelectTableData[data.codeClassifyOid] = {
            name: data.name,
            templateOid: data.oid,
            cloNamesList: data.cloNamesList,
            codeClassifyOid: data.codeClassifyOid,
            codeRuleOid: data.codeRuleOid,
          };
          // 不是第一次打开需要优先校验
        }else if (this.localCodeClassifyOid === data.codeClassifyOid) {
          console.log("重复点击");
        }
        if (!this.batchSelectTableData[data.codeClassifyOid]) {
          this.batchSelectTableData[data.codeClassifyOid] = {
            name: data.name,
            templateOid: data.oid,
            cloNamesList: data.cloNamesList,
            codeClassifyOid: data.codeClassifyOid,
            tab1Selected: []
          };
        }
        this.selection = this.batchSelectTableData[this.localCodeClassifyOid]['tab1Selected']
      }
      this.localCodeClassifyOid = data.codeClassifyOid;
      this.cloNamesList = data.cloNamesList;
      this.templateOid = data.oid;
      this.tab1Loading = true
      getResembleTable({
        codeClassifyOid:
          this.type === "batchApplyCode" ? data.codeRuleOid : this.templateOid,
        redisOid: this.redisOid + "-resemble",
      }).then((res) => {
        this.tab1Loading = false
        this.tab1Table = res.data.data.filter(
          (item) => !this.savedList.includes(item.oid)
        );
        if (this.type === "batchApplyCode") {
          this.batchApplyCodeTableData[data.codeRuleOid]["tab1"] =
          this.batchSelectTableData[data.codeRuleOid]["tab1"] =
            this.tab1Table;
        }
        if (this.type === "historyImport") {
          this.batchSelectTableData[data.codeClassifyOid]["tab1"] =
            this.tab1Table;
        }
      });
      this.tab2Loading = true
      // 获取正确数据
      getSuccessTable({
        codeClassifyOid:
          this.type === "batchApplyCode" ? data.codeRuleOid : this.templateOid,
        redisOid: this.redisOid + "-ok",
      }).then((res) => {
        this.tab2Loading = false
        this.tab2Table = res.data.data;
        if (this.tab2Table.length > 0 && this.type === "batchApplyCode") {
          this.batchApplyCodeTableData[data.codeRuleOid]["codeApply"] = {};
          this.batchApplyCodeTableData[data.codeRuleOid]["tab2"] =
            res.data.data;
          this.batchSelectTableData[data.codeRuleOid]["codeApply"] = {};
          this.batchSelectTableData[data.codeRuleOid]["tab2"] =
            this.tab2Table
          if (this.$refs.CodeApply) {
            this.$refs.CodeApply.loading = true;
          }
          this.getCodeRule();
        }
        if (this.type === "historyImport") {
          this.batchSelectTableData[data.codeClassifyOid]["tab2"] =
            this.tab2Table
        }
      });
      getFormTemplate({
@@ -377,15 +417,20 @@
    },
    tab1TableSelectChange(selection) {
      this.selectedTab1Table = selection;
      if (this.batchSelectTableData[this.localCodeClassifyOid]) {
        this.batchSelectTableData[this.localCodeClassifyOid]['tab1Selected'] = selection
      }
    },
    resembleRowChange(row) {
      if (!row || !row.oid) {
        return;
      }
      this.tab1BottomTableLoading = true
      getCurretnSelectedRowResemble({
        redisOid: this.redisOid + "-resemble-data",
        dataOid: row.oid,
      }).then((res) => {
        this.tab1BottomTableLoading = false
        this.currentSelectedResemble = res.data.data;
      });
    },
@@ -416,7 +461,7 @@
            return false;
          }
        }
        let lookedCodeRuleOidList = Object.keys(this.batchApplyCodeTableData);
        let lookedCodeRuleOidList = Object.keys(this.batchSelectTableData);
        let noLookCodeRuleOidList = this.leftTree.filter(
          (item) => !lookedCodeRuleOidList.includes(item.codeRuleOid)
        );
@@ -427,9 +472,9 @@
        }
        let errorData = [];
        let successData = [];
        for (const key in this.batchApplyCodeTableData) {
          if (Object.hasOwnProperty.call(this.batchApplyCodeTableData, key)) {
            const element = this.batchApplyCodeTableData[key];
        for (const key in this.batchSelectTableData) {
          if (Object.hasOwnProperty.call(this.batchSelectTableData, key)) {
            const element = this.batchSelectTableData[key];
            if (element.tab1.length > 0) {
              errorData.push(element);
            }
@@ -470,6 +515,27 @@
            },
          };
        });
      } else if (this.type === 'historyImport') {
        let lookedCodeRuleOidList = Object.keys(this.batchSelectTableData);
        let noLookCodeRuleOidList = this.leftTree.filter(
          (item) => !lookedCodeRuleOidList.includes(item.codeClassifyOid)
        );
        let noLookName = noLookCodeRuleOidList.map((item) => item.name);
        if (noLookName.length > 0) {
          this.$message.warning(`数据${noLookName}还未曾查看,请先查看!`);
          return false;
        }
        params.codeImprotSaveDatVOList = this.batchSelectTableData.map(item => {
          return {
            Clos: item.cloNamesList,
            dataList: item.tab2.concat(item.tab1Selected),
            orderDTO: {
              codeClassifyOid: item.codeClassifyOid,
              templateOid: item.templateOid,
              secDTOList: this.secDTOList,
            },
          }
        })
      } else {
        params.codeImprotSaveDatVOList = [
          {
@@ -483,18 +549,16 @@
          },
        ];
      }
        this.submitLoading = true
      submitHistoryimport(params).then((res) => {
        console.log(res);
        this.submitLoading = false
        if (res.data.code === 200) {
          this.$message.success(res.data.msg);
        } else {
          this.$message.error(res.data.msg);
        }
      });
    },
    // 重新编辑
    reEdit(row) {
      console.log(row, "row");
      this.currentSelectedResembleRow = {
        templateOid: row.codetemplateoid,
        codeClassifyOid: row.codeclassifyid,
@@ -508,7 +572,6 @@
    // 直接编辑后保存
    FormTemplateSubmit(form) {
      addSaveCode(form).then((res) => {
        console.log(res);
        if (res.data.code === 200) {
          this.savedList.push(form.oid);
          this.$message.success("新增成功!");
@@ -572,6 +635,7 @@
    }
  }
  .right {
    transition: all 0.5s;
    margin-left: 20px;
    margin-top: 30px;
  }