|
@@ -425,6 +425,7 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
+ import { mapGetters } from 'vuex'
|
|
|
import { transformWeek, transformAuth } from '@/config/key.config'
|
|
|
import {
|
|
|
scheduleList,
|
|
@@ -443,6 +444,8 @@
|
|
|
import changeClass from './components/changeClass'
|
|
|
import changeTeacher from './components/changeTeacher'
|
|
|
import shenheTip from './components/shenheTip.vue'
|
|
|
+ import axios from 'axios'
|
|
|
+ import { baseURL } from '@/config'
|
|
|
export default {
|
|
|
components: {
|
|
|
addTable,
|
|
@@ -464,6 +467,7 @@
|
|
|
timeSelectList: [], //时间段选择列表
|
|
|
is_admin: false, //当前用户是否为管理员
|
|
|
queryForm: {
|
|
|
+ ids: [],
|
|
|
lesson_name: '',
|
|
|
teacher_name: '',
|
|
|
room_id: '',
|
|
@@ -494,8 +498,14 @@
|
|
|
name: '补课',
|
|
|
},
|
|
|
],
|
|
|
+ term_name: localStorage.getItem('term_name'),
|
|
|
}
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ ...mapGetters({
|
|
|
+ token: 'user/token',
|
|
|
+ }),
|
|
|
+ },
|
|
|
|
|
|
created() {
|
|
|
let roles_list = this.$store.state.user.role_list
|
|
@@ -761,7 +771,67 @@
|
|
|
transformAuth,
|
|
|
//数据导出
|
|
|
handleExport() {
|
|
|
- this.$refs['export'].showEdit()
|
|
|
+ // this.$refs['export'].showEdit()
|
|
|
+ this.queryForm.ids = this.selectRows.map((item) => item.id)
|
|
|
+ delete this.queryForm.page
|
|
|
+ delete this.queryForm.per_page
|
|
|
+ this.$confirm('确定导出此筛选条件下的数据吗', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ axios({
|
|
|
+ baseURL: baseURL, // url = base url + request url
|
|
|
+ timeout: 5000, // request timeout
|
|
|
+ method: 'get',
|
|
|
+ url: '/school/schedule/export',
|
|
|
+ headers: {
|
|
|
+ Authorization: `Bearer ${this.token}`,
|
|
|
+ },
|
|
|
+ params: this.queryForm,
|
|
|
+ responseType: 'blob',
|
|
|
+ }).then((response) => {
|
|
|
+ this.convertRes2Blob(response)
|
|
|
+ this.handleClose()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
+ },
|
|
|
+ convertRes2Blob(response) {
|
|
|
+ // 提取文件名
|
|
|
+ // const fileNameList =
|
|
|
+ // response.headers['content-disposition'].match(/filename=(.*)(.*)/)
|
|
|
+ // console.log(fileNameList, 'Mead')
|
|
|
+ // const fileName = fileNameList[1]
|
|
|
+ let fileName = this.term_name + '' + '教学任务表'
|
|
|
+
|
|
|
+ // 将二进制流转为blob
|
|
|
+ const blob = new Blob([response.data], {
|
|
|
+ type: 'application/vnd.ms-excel',
|
|
|
+ })
|
|
|
+ if (typeof window.navigator.msSaveBlob !== 'undefined') {
|
|
|
+ // 兼容IE,window.navigator.msSaveBlob:以本地方式保存文件
|
|
|
+ window.navigator.msSaveBlob(blob, decodeURI(fileName))
|
|
|
+ } else {
|
|
|
+ // 创建新的URL并指向File对象或者Blob对象的地址
|
|
|
+ const blobURL = window.URL.createObjectURL(blob)
|
|
|
+ // 创建a标签,用于跳转至下载链接
|
|
|
+ const tempLink = document.createElement('a')
|
|
|
+ tempLink.style.display = 'none'
|
|
|
+ tempLink.href = blobURL
|
|
|
+ tempLink.setAttribute('download', decodeURI(fileName))
|
|
|
+ // 兼容:某些浏览器不支持HTML5的download属性
|
|
|
+ if (typeof tempLink.download === 'undefined') {
|
|
|
+ tempLink.setAttribute('target', '_blank')
|
|
|
+ }
|
|
|
+ // 挂载a标签
|
|
|
+ document.body.appendChild(tempLink)
|
|
|
+ tempLink.click()
|
|
|
+ document.body.removeChild(tempLink)
|
|
|
+ // 释放blob URL地址
|
|
|
+ window.URL.revokeObjectURL(blobURL)
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
setSelectRows(val) {
|