AnalysisSystemForRadionucli.../src/views/statistics/list.vue

316 lines
9.0 KiB
Vue

<template>
<div style="height: 100%">
<a-spin :spinning="spinning">
<a-card v-if="!isDetail" :bordered="false" style="margin-left: 20px">
<search-form :items="formItems" v-model="queryParam" @search="searchQueryData">
<a-space style="float: right" class="btn-group" slot="additional">
<a-button @click="handleExcel" type="primary">
<a-icon v-if="excelLoading" style="margin-right: 10px" type="loading" />
<img class="icon-edit" src="@/assets/images/global/edit.png" alt="" />
Excel
</a-button>
</a-space>
</search-form>
<custom-table
size="middle"
rowKey="sampleId"
:columns="columns"
:list="dataSource"
:pagination="ipagination"
:loading="loading"
@change="handleTableChange"
@detail="handleDetail"
:selectedRowKeys.sync="selectedRowKeys"
:scroll="{ y: 'calc(100vh - 306px)' }"
>
<template slot="index" slot-scope="{ index }">
{{ index + 1 }}
</template>
</custom-table>
</a-card>
</a-spin>
<Detail
v-if="isDetail"
:type="fileName"
:sampleId="currSampleId"
:allData="detailJson"
:currName="currFileName"
@back="handleBack"
></Detail>
</div>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction, getFileAction } from '../../api/manage'
import dateFormat from '../../components/jeecg/JEasyCron/format-date'
import Detail from './detail.vue'
import moment from 'moment'
export default {
name: 'menuTree',
props: {
stationList: {
type: Array,
default: () => [],
},
columns: {
type: Array,
default: () => [],
},
dataType: {
type: String,
default: '',
},
fileName: {
type: String,
default: '',
},
spectralQualifie: {
type: String,
default: '',
},
pageType: {
type: String,
default: '',
},
menuType: {
type: String,
default: '',
},
},
mixins: [JeecgListMixin],
components: {
Detail,
},
watch: {
stationList: {
handler(val) {
let arr = sessionStorage.getItem(`selectedSta_${this.menuType}`)
? sessionStorage.getItem(`selectedSta_${this.menuType}`).split(',')
: []
this.queryParam.stationIds = arr.map((item) => Number(item))
;(this.queryParam.startTime = sessionStorage.getItem(`currStartDate_${this.menuType}`)
? sessionStorage.getItem(`currStartDate_${this.menuType}`)
: moment().subtract(6, 'days').format('YYYY-MM-DD')),
(this.queryParam.endTime = sessionStorage.getItem(`currEndDate_${this.menuType}`)
? sessionStorage.getItem(`currEndDate_${this.menuType}`)
: moment().format('YYYY-MM-DD')),
this.loadData()
},
},
},
data() {
this.disableMixinCreated = true
return {
excelLoading: false,
spinning: false,
isImmediate: true,
isDetail: false,
queryParam: {
dataType: this.dataType,
startTime: '',
endTime: '',
stationIds: [],
spectralQualifie: this.spectralQualifie,
},
url: {
list: '/webStatistics/findParticulatePage',
delete: '/gardsSampleData/deleteById',
findStationList: '/webStatistics/findStationList',
findParticulatePage: '/jeecg-web-statistics/webStatistics/findParticulatePage',
},
dataSource: [],
detailJson: {},
allChecked: false,
currSampleId: '',
currFileName: '',
}
},
methods: {
handleExcel() {
if (this.dataSource.length > 0) {
this.excelLoading = true
let params = {
...this.queryParam,
pageType: this.pageType,
}
getFileAction('/webStatistics/radionuclideExport', params).then((res) => {
this.excelLoading = false
if (res.code && res.code == 500) {
this.$message.warning('This operation fails. Contact your system administrator')
} else {
const blob = new Blob([res], { type: 'application/vnd.ms-excel' })
let link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = this.fileName
document.body.appendChild(link)
link.click()
URL.revokeObjectURL(link.href)
document.body.removeChild(link)
}
})
} else {
this.$message.warning('No downloadable data')
}
},
searchQueryData() {
this.isImmediate = false
this.loading = true
let params = {
...this.queryParam,
pageNo: 1,
pageSize: 10,
}
getAction(this.url.list, params).then((res) => {
this.loading = false
if (res.success) {
this.ipagination.current = res.result.current
this.ipagination.pageSize = res.result.size
this.ipagination.total = res.result.total
this.dataSource = res.result.records
} else {
this.$message.warning('This operation fails. Contact your system administrator')
}
})
},
handleDetail(record) {
this.spinning = true
this.currSampleId = record.sampleId
let length = record.inputFileName.split('/').length
this.currFileName = record.inputFileName.split('/')[length - 1]
getAction('webStatistics/findGeneratedReport', { sampleId: record.sampleId })
.then((res) => {
this.spinning = false
if (res.success) {
this.detailJson = res.result
this.detailJson = JSON.parse(JSON.stringify(this.detailJson))
this.isDetail = true
} else {
this.$message.warning('This operation fails. Contact your system administrator')
}
})
.catch((err) => {
this.spinning = false
})
},
handleBack(flag) {
this.isDetail = flag
},
handleSelectChange(val) {
console.log(val)
window.sessionStorage.setItem(`selectedSta_${this.menuType}`, val)
let length = this.stationList.length
if (val.length === length) {
this.allChecked = true
} else {
this.allChecked = false
}
},
handleSelectChangeAll(val) {
this.allChecked = val
if (val) {
this.queryParam.stationIds = this.stationList.map((item) => item.value)
window.sessionStorage.setItem(`selectedSta_${this.menuType}`, this.queryParam.stationIds)
} else {
this.queryParam.stationIds = []
window.sessionStorage.setItem(`selectedSta_${this.menuType}`, [])
}
},
filterOption(input, option) {
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
},
handleStartDateChange(date) {
window.sessionStorage.setItem(`currStartDate_${this.menuType}`, date)
},
handleEndDateChange(date) {
window.sessionStorage.setItem(`currEndDate_${this.menuType}`, date)
},
},
computed: {
formItems() {
return [
// {
// type: 'a-input',
// label: '',
// name: 'search',
// props: {
// placeholder: 'search...',
// style: {
// width: '166px',
// },
// },
// style: {
// width: 'auto',
// },
// },
{
type: 'custom-all-select',
label: 'Stations',
name: 'stationIds',
props: {
allChecked: this.allChecked,
filterOption: this.filterOption,
placeholder: 'select stations',
mode: 'multiple',
maxTagCount: 1,
options: [...this.stationList],
style: {
width: '200px',
},
},
on: {
change: this.handleSelectChange,
changeAll: this.handleSelectChangeAll,
},
style: {
width: 'auto',
},
},
{
label: 'Start date',
type: 'custom-date-picker',
name: 'startTime',
props: {
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
style: {
minWidth: 'auto',
width: '200px',
},
},
on: {
change: this.handleStartDateChange,
},
style: {
width: 'auto',
},
},
{
label: 'End date',
type: 'custom-date-picker',
name: 'endTime',
props: {
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
style: {
minWidth: 'auto',
width: '200px',
},
},
on: {
change: this.handleEndDateChange,
},
style: {
width: 'auto',
},
},
]
},
},
}
</script>
<style lang="less" scoped>
.icon-edit {
margin-right: 10px;
}
</style>