田源
2024-05-25 fc31bda418c337ba9d3650186b8f1547ba9c5ad0
Source/UBCS-WEB/src/components/Master/MasterTransfer.vue
@@ -10,11 +10,11 @@
          <el-radio :label="1">全部</el-radio>
          <el-radio :label="2">页码</el-radio>
        </el-radio-group>
        <span v-if="radio === 2" style="margin-left: 20px;"><el-input v-model="pageExport"
                                                                      style="width: 150px"></el-input> (输入页码或者页面范围,如:1-10)</span>
        <span v-if="radio === 2" style="margin-left: 20px;color: #F56C6C; ">
          <el-input v-model="pageExport" style="width: 150px"></el-input> (输入页码或者页面范围,如:1-10)</span>
      </div>
    </div>
    <div style="text-align: center">
    <div v-loading="isLoading" style="text-align: center">
      <el-transfer
        v-model="value"
        :data="data"
@@ -44,6 +44,7 @@
      pageExport: "",
      data: [],
      value: [],
      isLoading: false,
      filterMethod(query, item) {
        return item.label.indexOf(query) > -1;
      },
@@ -122,20 +123,22 @@
  },
  methods: {
    handlerFile(res) {
      let reader = new FileReader();
      reader.readAsText(res.data);
      reader.onload = (result) => {
        try {
          let resData = JSON.parse(result.target.result);  // 解析对象成功
          if (resData.code != 200) {
            this.$message.error(resData.msg);
          }
        } catch (err) {
          // console.log("err",err)// 解析成对象失败,说明是正常的文件流
          func.downloadFileByBlobHandler(res);
          this.$message.success('下载成功,请查看!');
        }
      };
      // let reader = new FileReader();
      // reader.readAsText(res.data);
      // reader.onload = (result) => {
      //   try {
      //     let resData = JSON.parse(result.target.result);  // 解析对象成功
      //     if (resData.code != 200) {
      //       this.$message.error(resData.msg);
      //     }
      //   } catch (err) {
      //   // 解析成对象失败,说明是正常的文件流
      //     func.downloadFileByBlobHandler(res);
      //     this.$message.success('下载成功,请查看!');
      //   }
      // };
      func.downloadFileByBlobHandler(res);
      this.$message.success('下载成功,请查看!');
    },
    escHandler() {
      this.$emit('update:visible', false);
@@ -154,6 +157,7 @@
        if (this.selectRow.length <= 0) {
          this.$message.warning('请选择要导出的模板')
        } else {
          this.isLoading = true;
          //已选择多选
          const selectList = []
          //已选择属性
@@ -176,6 +180,9 @@
            }).then(res => {
              this.handlerFile(res);
              this.escHandler();
              this.isLoading = false;
            }).catch(error => {
              this.isLoading = false;
            })
          } else {
@@ -186,12 +193,15 @@
              // console.log('res',res)
              this.handlerFile(res);
              this.escHandler();
              this.isLoading = false;
            }).catch(error => {
              this.isLoading = false;
            })
          }
        }
      } else if (this.radio === 1) {
        this.isLoading = true;
        if (this.value <= 0) {
          this.tableHeadData.map(item => item.prop)
            .forEach((prop, index) => {
@@ -201,12 +211,18 @@
            if (res) {
              func.downloadFileByBlobHandler(res);
              this.escHandler();
              this.isLoading = false;
            }
          }).catch(error => {
            this.isLoading = false;
          })
        } else {
          exportCode({codeClassifyOid: this.codeClassifyOid, ...this.exportArr, limit: -1}).then(res => {
            this.handlerFile(res);
            this.escHandler();
            this.isLoading = false;
          }).catch(error => {
            this.isLoading = false;
          })
        }
      } else if (this.radio === 2) {
@@ -235,6 +251,7 @@
          }
        }
        if (this.value >= 1) {
          this.isLoading = true;
          exportCode({
            codeClassifyOid: this.codeClassifyOid, ...this.exportArr,
            limit: this.limit,
@@ -244,9 +261,12 @@
            // console.log('res',res)
            this.handlerFile(res);
            this.escHandler();
            this.isLoading = false;
          }).catch(error => {
            this.isLoading = false;
          });
        } else {
          this.isLoading = true;
          this.tableHeadData.map(item => item.prop)
            .forEach((prop, index) => {
              this.exportArrTwo[`attrIdIndexMap[${index}]`] = prop;
@@ -257,10 +277,12 @@
            page: start,
            endPage: end
          }).then(res => {
            console.log('res', res)
            this.isLoading = false;
            this.handlerFile(res);
            this.escHandler();
          })
          }).catch(error => {
            this.isLoading = false;
          });
        }
      }
    },