licp
2024-05-14 ef48e4b7a4d34e63ffd2cb23c406f4da6eb72ed7
src/components/view/b3-classes.vue
@@ -44,7 +44,7 @@
      <el-button size="small" type="primary" @click="refreshTable()">查 询</el-button>
    </div>
    <div class="search_thing btns" style="padding-left: 30px;">
      <el-button size="small" type="primary" v-if="downPower">导 出</el-button>
      <el-button size="small" type="primary" v-if="downPower" @click="handleDown" :loading="downLoading">导 出</el-button>
      <el-button size="small" type="primary" @click="schedulingVisible = true" v-if="addPower">排 班</el-button>
    </div>
  </div>
@@ -286,7 +286,8 @@
      pageLoading: false, // 组件loading的展示,默认为true
      finishLoding: false, // 加载完成,显示已经没有更多了
      monthList:[],
      yearList:[]
      yearList:[],
      downLoading:false,
    }
  },
  watch: {
@@ -516,6 +517,40 @@
        this.refresh()
      })
    },
    handleDown(){
      let year = this.query.year.getFullYear()
      let time = '';
      if(this.query.month){
        let month = this.query.month>9?this.query.month:'0'+this.query.month
        time = year+'-'+month+'-01 00:00:00'
      }else{
        time = year+'-01-01 00:00:00'
      }
      this.downLoading = true
      this.$axios.get(this.$api.performanceShift.export+`?time=${time}&userName=${this.query.userName}&laboratory=${this.query.laboratory}&isMonth=${this.query.month?true:false}`,{responseType: 'blob'}).then(res => {
        this.$message.success('下载成功')
        this.downLoading = false
        const blob = new Blob([res], {
          type: 'application/force-download'
        })
        let fileName="";
        if(this.query.month){
          fileName = year +'-'+this.query.month+' 班次信息'
        }else{
          fileName = year+' 班次汇总'
        }
        const filename = decodeURI(fileName+'.xlsx')
        // 创建一个超链接,将文件流赋进去,然后实现这个超链接的单击事件
        const elink = document.createElement('a')
        elink.download = filename
        elink.style.display = 'none'
        elink.href = URL.createObjectURL(blob)
        document.body.appendChild(elink)
        elink.click()
        URL.revokeObjectURL(elink.href) // 释放URL 对象
        document.body.removeChild(elink)
      })
    },
    selectEnumByCategory() {
      this.$axios.post(this.$api.enums.selectEnumByCategory, {
        category: "班次类型"