xiejun
2023-08-12 a19d26e88360c9760b2286bac4dfb1710fd2fa21
Source/UBCS-WEB/src/components/Master/MasterTransfer.vue
@@ -1,5 +1,7 @@
<template>
<el-dialog :visible.sync="dialogPush" append-to-body  :close-on-click-modal="false"  @close="escHandler" title="导出" style="width: 1550px; margin: auto">
  <el-dialog :close-on-click-modal="false" :visible.sync="dialogPush" append-to-body style="width: 1550px; margin: auto"
             title="导出"
             @close="escHandler">
  <div style="margin-bottom: 20px;">
    <div>
      <span>导出方式:</span>
@@ -8,23 +10,24 @@
        <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 style="width: 150px" v-model="pageExport"></el-input> (输入页码或者页面范围,如:1-10))</span>
        <span v-if="radio === 2" style="margin-left: 20px;"><el-input v-model="pageExport"
                                                                      style="width: 150px"></el-input> (输入页码或者页面范围,如:1-10))</span>
    </div>
  </div>
  <div style="text-align: center">
  <el-transfer
    style="text-align: left; display: inline-block;height: 400px"
    filterable
    :filter-method="filterMethod"
    filter-placeholder="关键词搜索"
    v-model="value"
        :data="data"
        :filter-method="filterMethod"
    :titles="['未选属性', '已选属性']"
    :data="data">
        filter-placeholder="关键词搜索"
        filterable
        style="text-align: left; display: inline-block;height: 400px">
  </el-transfer>
  </div>
  <div style="display: flex;justify-content: flex-end;">
    <el-button size="small" plain type="success" @click="handleExcel">确定</el-button>
    <el-button size="small" plain @click="escHandler">取消</el-button>
      <el-button plain size="small" type="success" @click="handleExcel">确定</el-button>
      <el-button plain size="small" @click="escHandler">取消</el-button>
  </div>
</el-dialog>
</template>
@@ -32,6 +35,7 @@
<script>
import {exportCode,FindData} from '@/api/GetItem'
import func from "@/util/func";
export default {
name: "MasterTransfer",
  props:['visible','tableHeadData','codeClassifyOid','tableData','selectRow','templateOid','limit'],
@@ -57,6 +61,7 @@
        data: []
      },
      exportArr:{},
      exportArrTwo: {},
      ids:""
    };
  },
@@ -68,8 +73,9 @@
    //表头数据 用来渲染穿梭框
    tableHeadData:{
      handler(newval,oldval){
        console.log(newval)
       if(newval){
          // 清空data数组
          this.data = [];
         //excel表头数据转换
         this.tableHeadFindData=newval.map(obj => obj.label);
         this.tableHeadFindData.forEach((city, index) => {
@@ -104,11 +110,14 @@
    codeClassifyOid:{
      handler(newval,oldval){
      }
    },
    value: {
      handler(newval, oldval) {
        console.log('value', newval)
      }
    }
  },
  computed:{
  },
  computed: {},
  mounted() {
  },
  methods:{
@@ -122,9 +131,6 @@
      this.$emit('update:visible', false);
    },
    handleExcel(){
      if(this.value <= 0){
        this.$message.warning('请选择属性')
      }else {
        this.value.map(index => this.tableHeadData[index].prop).forEach((item, index) => {
          this.exportArr[`attrIdIndexMap[${index}]`] = item
        })
@@ -136,30 +142,65 @@
            const selectList=[]
            //已选择属性
            let exportArr={}
            const ids = this.selectRow.map(item => item.oid).join(',')
          this.ids = this.selectRow.map(item => item.oid).join(',')
            this.selectRow.forEach(item=>{
              selectList.push(
                item.oid
              )
            })
            exportCode({codeClassifyOid:this.codeClassifyOid,'conditionMap[oid]':this.ids,...this.exportArr}).then(res=>{
          if (this.value <= 0) {
            this.tableHeadData.map(item => item.prop)
              .forEach((prop, index) => {
                this.exportArrTwo[`attrIdIndexMap[${index}]`] = prop;
              });
            exportCode({
              codeClassifyOid: this.codeClassifyOid,
              'conditionMap[oid]': this.ids, ...this.exportArrTwo,
              limit: -1
            }).then(res => {
              // console.log('res',res)
              if(res){
                func.downloadFileByBlob(res);
                func.downloadFileByBlobHandler(res);
                this.escHandler()
              }
            })
          } else {
            exportCode({
              codeClassifyOid: this.codeClassifyOid,
              'conditionMap[oid]': this.ids, ...this.exportArr
            }).then(res => {
              // console.log('res',res)
              if (res) {
                func.downloadFileByBlobHandler(res);
                this.escHandler()
              }
            })
          }
        }
        }else if(this.radio === 1){
          this.ids=this.tableData.map(item => item.oid).join(',')
          exportCode({codeClassifyOid:this.codeClassifyOid,...this.exportArr,limit:-1}).then(res=>{
        if (this.value <= 0) {
          this.tableHeadData.map(item => item.prop)
            .forEach((prop, index) => {
              this.exportArrTwo[`attrIdIndexMap[${index}]`] = prop;
            });
          exportCode({codeClassifyOid: this.codeClassifyOid, ...this.exportArrTwo, limit: -1}).then(res => {
            // console.log('res',res)
            if(res){
              func.downloadFileByBlob(res);
              func.downloadFileByBlobHandler(res);
              this.escHandler()
            }
          })
        } else {
          exportCode({codeClassifyOid: this.codeClassifyOid, ...this.exportArr, limit: -1}).then(res => {
            // console.log('res',res)
            if (res) {
              func.downloadFileByBlobHandler(res);
              this.escHandler()
            }
          })
        }
        }else if(this.radio === 2){
          const input = this.pageExport.trim();
          let start, end;
@@ -185,22 +226,43 @@
              return;
            }
          }
          exportCode({ codeClassifyOid: this.codeClassifyOid, ...this.exportArr, limit: this.limit, page: start, endPage: end }).then((res) => {
        if (this.value >= 1) {
          exportCode({
            codeClassifyOid: this.codeClassifyOid, ...this.exportArr,
            limit: this.limit,
            page: start,
            endPage: end
          }).then((res) => {
            // console.log('res',res)
            if (res) {
              func.downloadFileByBlobHandler(res);
              this.escHandler()
            }
          });
        } else {
          this.tableHeadData.map(item => item.prop)
            .forEach((prop, index) => {
              this.exportArrTwo[`attrIdIndexMap[${index}]`] = prop;
            });
          exportCode({
            codeClassifyOid: this.codeClassifyOid, ...this.exportArrTwo,
            limit: this.limit,
            page: start,
            endPage: end
          }).then(res => {
            // console.log('res',res)
            if (res) {
              func.downloadFileByBlobHandler(res);
              this.escHandler()
        }
          })
      }
      }
    },
  }
}
</script>
<style scoped lang="scss">
<style lang="scss" scoped>
</style>