fix: 内置报告 全选bug修复
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
@header-dragend="dragend"
|
@header-dragend="dragend"
|
||||||
@sort-change="tableDataSort"
|
@sort-change="tableDataSort"
|
||||||
@selection-change="selectionChange"
|
@selection-change="selectionChange"
|
||||||
@select-all="selectionChangeAll"
|
|
||||||
@select="select"
|
@select="select"
|
||||||
>
|
>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
@@ -39,6 +38,9 @@
|
|||||||
{{scope.row.startTime}}-{{scope.row.endTime}}
|
{{scope.row.startTime}}-{{scope.row.endTime}}
|
||||||
</template>
|
</template>
|
||||||
</span>
|
</span>
|
||||||
|
<span v-if="item.prop === 'type'">
|
||||||
|
{{scope.row.reportTemp.name}}
|
||||||
|
</span>
|
||||||
<span v-else>{{scope.row[item.prop]}}</span>
|
<span v-else>{{scope.row[item.prop]}}</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -59,18 +61,16 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<div class="table-operation-all">
|
<div class="table-operation-all">
|
||||||
<el-checkbox v-model="checkboxAll" @change="builtinReportCheckbox"></el-checkbox>
|
<el-checkbox v-model="checkboxAll" @change="builtinReportCheckbox(tableData)"></el-checkbox>
|
||||||
<div class="table-operation-all-span">
|
<div class="table-operation-all-span">
|
||||||
<span>{{ $t('overall.all') }}</span>
|
<span>{{ $t('overall.all') }}</span>
|
||||||
<span :class="{'table-operation-all-checkbox': checkboxAll}" @click="batchDownload">{{$t('report.batchDow')}}</span>
|
<span :class="{'table-operation-all-checkbox': batchDow}" :disabled="checkboxAll" @click="tableOperation(['download', this.checkboxIds, 'builtin'])">{{$t('report.batchDow')}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import table from '@/mixins/table'
|
import table from '@/mixins/table'
|
||||||
import { get } from '@/utils/http'
|
|
||||||
import axios from 'axios'
|
|
||||||
export default {
|
export default {
|
||||||
name: 'builtinReportTable',
|
name: 'builtinReportTable',
|
||||||
mixins: [table],
|
mixins: [table],
|
||||||
@@ -102,74 +102,26 @@ export default {
|
|||||||
],
|
],
|
||||||
checkboxAll: false,
|
checkboxAll: false,
|
||||||
checkboxIds: '',
|
checkboxIds: '',
|
||||||
builtinId: ''
|
batchDow: false,
|
||||||
|
builtinId: '',
|
||||||
|
indeterminate: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
select (objs) {
|
selectionChange (objs) {
|
||||||
|
this.$emit('selectionChange', objs)
|
||||||
this.checkboxIds = objs.map(item => { return item.id }).join(',')
|
this.checkboxIds = objs.map(item => { return item.id }).join(',')
|
||||||
if (objs.length > 0) {
|
this.checkboxAll = objs.length > 0 || objs.length === this.tableData.length
|
||||||
this.checkboxAll = true
|
this.batchDow = objs.length > 0
|
||||||
} else {
|
|
||||||
this.checkboxAll = false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
builtinReportCheckbox (objs) {
|
builtinReportCheckbox (objs) {
|
||||||
if (objs) {
|
if (objs) {
|
||||||
this.selectionChangeAll(this.tableData)
|
objs.forEach(item => {
|
||||||
}
|
this.$refs.dataTable.toggleAllSelection(item)
|
||||||
},
|
|
||||||
selectionChangeAll (objs) {
|
|
||||||
console.log(objs)
|
|
||||||
},
|
|
||||||
batchDownload: function () {
|
|
||||||
const fileName = 'builtinReport' + '-' + this.getTimeString() + '.zip'
|
|
||||||
const params = {
|
|
||||||
ids: this.checkboxIds
|
|
||||||
}
|
|
||||||
axios.get('/report/job/batchDownloadPdf', { responseType: 'blob', params: params }).then(res => {
|
|
||||||
if (window.navigator.msSaveOrOpenBlob) {
|
|
||||||
// 兼容ie11
|
|
||||||
const blobObject = new Blob([res.data])
|
|
||||||
window.navigator.msSaveOrOpenBlob(blobObject, fileName)
|
|
||||||
} else {
|
|
||||||
const url = URL.createObjectURL(new Blob([res.data]))
|
|
||||||
const a = document.createElement('a')
|
|
||||||
document.body.appendChild(a) // 此处增加了将创建的添加到body当中
|
|
||||||
a.href = url
|
|
||||||
a.download = fileName
|
|
||||||
a.target = '_blank'
|
|
||||||
a.click()
|
|
||||||
a.remove() // 将a标签移除
|
|
||||||
}
|
|
||||||
}, error => {
|
|
||||||
const $self = this
|
|
||||||
const reader = new FileReader()
|
|
||||||
reader.onload = function (event) {
|
|
||||||
const responseText = reader.result
|
|
||||||
const exception = JSON.parse(responseText)
|
|
||||||
if (exception.message) {
|
|
||||||
$self.$message.error(exception.message)
|
|
||||||
} else {
|
|
||||||
console.error(error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reader.readAsText(error.response.data)
|
|
||||||
})
|
})
|
||||||
},
|
} else {
|
||||||
getTimeString () {
|
this.$refs.dataTable.clearSelection()
|
||||||
const split = '-'
|
}
|
||||||
const date = new Date()
|
|
||||||
const year = date.getFullYear()
|
|
||||||
const month = this.formatNum(date.getMonth() + 1)
|
|
||||||
const day = this.formatNum(date.getDate())
|
|
||||||
const hours = this.formatNum(date.getHours())
|
|
||||||
const minutes = this.formatNum(date.getMinutes())
|
|
||||||
const seconds = this.formatNum(date.getSeconds())
|
|
||||||
return year + split + month + split + day + ' ' + hours + split + minutes + split + seconds
|
|
||||||
},
|
|
||||||
formatNum (num) {
|
|
||||||
return num > 9 ? num : '0' + num
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export default {
|
|||||||
asce: tableSort.asce,
|
asce: tableSort.asce,
|
||||||
desc: tableSort.desc,
|
desc: tableSort.desc,
|
||||||
strToDate: tableSort.strToDate,
|
strToDate: tableSort.strToDate,
|
||||||
tableOperation ([command, row]) {
|
tableOperation ([command, row, param]) {
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 'edit': {
|
case 'edit': {
|
||||||
this.edit(row)
|
this.edit(row)
|
||||||
@@ -57,7 +57,7 @@ export default {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'download': {
|
case 'download': {
|
||||||
this.download(row)
|
this.download(row, param)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'preview': {
|
case 'preview': {
|
||||||
@@ -146,12 +146,24 @@ export default {
|
|||||||
this.object = { ...u, name: 'Copy from ' + u.name, id: '' }
|
this.object = { ...u, name: 'Copy from ' + u.name, id: '' }
|
||||||
this.rightBox.show = true
|
this.rightBox.show = true
|
||||||
},
|
},
|
||||||
download (u) {
|
download (u, n) {
|
||||||
const fileName = 'builtinReport' + '-' + this.getTimeString() + '.pdf'
|
let fileName = ''
|
||||||
const params = {
|
let url = ''
|
||||||
|
let params = {}
|
||||||
|
if (n === 'builtin') {
|
||||||
|
fileName = 'builtinReport' + '-' + this.getTimeString() + '.zip' // 文件名称
|
||||||
|
url = '/report/job/batchDownloadPdf' // 批量 zip 下载
|
||||||
|
params = {
|
||||||
|
ids: u
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fileName = 'builtinReport' + '-' + this.getTimeString() + '.pdf' // 文件名称
|
||||||
|
url = '/report/job/downloadPdf' // 单个 pdf 下载
|
||||||
|
params = {
|
||||||
id: u.id
|
id: u.id
|
||||||
}
|
}
|
||||||
axios.get('/report/job/downloadPdf', { responseType: 'blob', params: params }).then(res => {
|
}
|
||||||
|
axios.get(url, { responseType: 'blob', params: params }).then(res => {
|
||||||
if (window.navigator.msSaveOrOpenBlob) {
|
if (window.navigator.msSaveOrOpenBlob) {
|
||||||
// 兼容ie11
|
// 兼容ie11
|
||||||
const blobObject = new Blob([res.data])
|
const blobObject = new Blob([res.data])
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export default {
|
|||||||
tableOperation ([command, row, param]) {
|
tableOperation ([command, row, param]) {
|
||||||
switch (command) {
|
switch (command) {
|
||||||
default:
|
default:
|
||||||
this.$emit(command, row)
|
this.$emit(command, row, param)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user