Files
laws_weilai/jero-web/src/views/regulatoryEarlyWarning/index.vue
T
2022-08-15 10:30:14 +08:00

308 lines
8.8 KiB
Java

<template>
<a-card :bordered="false">
<div class="table-page-search-wrapper">
<search ref="searchRef"
:searchQueryList="searchQueryList"
:flag="'1'"
:isDefault="true"
:url="url"/>
</div>
<div class="table-operator">
<div @click="handleCompare" class="operator-text">
<a-icon type="rocket" :rotate="45"/>
{{$t('Push')}}
</div>
<div @click="handleExport" class="operator-text">
<a-icon type="export" :rotate="-90"/>
{{$t('export')}}
</div>
</div>
<div>
<a-tabs :model="activeTab" @change="callback">
<a-tab-pane :key="$t('ImplementationDate')" :tab="$t('ImplementationDate')">
</a-tab-pane>
<a-tab-pane :key="$t('vehicleInProductionDate')" :tab="$t('vehicleInProductionDate')">
</a-tab-pane>
</a-tabs>
<a-table
ref="table"
size="middle"
:loading="loading"
:pagination="false"
:scroll="{x: '100%',y:'calc(100vh - 180px)'}"
rowKey="id"
:data-source="dataSource"
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
:columns="columns"
>
</a-table>
<div class="page" v-if="dataSource && dataSource.length > 0">
<a-pagination
:show-total="total => $t('total')+` ${total} `+$t('strip')"
show-quick-jumper
show-size-changer
:page-size.sync="pageSize"
:total="total"
:current="pageNo"
@change="pageOnChange"
@showSizeChange="SizeChange"
/>
</div>
</div>
<libraryPush
:url="url"
ref="libraryPushRef"
@clearSelected="clearSelected"
/>
</a-card>
</template>
<script>
import search from '@/components/search/index'
import libraryPush from '@/components/libraryPush/index'
import { getAction, postAction, deleteAction, downloadFile } from '@/api/manage'
import moment from 'moment'
import eventBUs from '../../common/event'
export default {
name: 'index',
components: {
search,
libraryPush
},
data() {
return {
//url传参严格按照当前命名
url: {
seachList: 'document/bussDocumentLibraryEO/queryCondition', //搜索字段
list: '/LawsWarn/queryPageInfo',
exportData: 'LawsWarn/exportExcel',
pullMessage: '/LawsWarn/warnPullMessage'
},
activeTab: this.$t('ImplementationDate'),
loading: false,
dataSource: [],
selectedRowKeys: [],
total: 0,
pageSize: 10,
pageNo: 1,
searchParmes: {},
searchQueryList: [
{
field_show_type: 6,
db_field_txt: this.$t('warningTime'),
db_field_name: 'WarnTime'
}
],
columnsAll: [
{
title: this.$t('standard'),
align: 'center',
dataIndex: 'serial_number',
ellipsis: true,
width: 170,
scopedSlots: { customRender: 'serial_number' }
},
{
title: this.$t('title'),
align: 'center',
dataIndex: 'title',
ellipsis: true,
width: 170,
scopedSlots: { customRender: 'titleName' }
},
{
title: this.$t('status'),
align: 'center',
width: 140,
ellipsis: true,
dataIndex: 'state'
},
{
title: this.$t('zoneOfApplication'),
align: 'center',
width: 170,
ellipsis: true,
dataIndex: 'region'
},
{
title: this.$t('technicalField'),
align: 'center',
ellipsis: true,
width: 170,
dataIndex: 'technology_territory'
},
{
title: this.$t('vehicleInProductionDate'),
align: 'center',
ellipsis: true,
width: 210,
dataIndex: 'implement_time'
},
{
title: this.$t('ImplementationDate'),
align: 'center',
ellipsis: true,
width: 210,
dataIndex: 'xin1_che1_xing2_shi2_shi1_ri4_qi1'
}
]
}
},
computed: {
columns() {
let columnsAll = JSON.parse(JSON.stringify(this.columnsAll))
if (this.activeTab == this.$t('ImplementationDate')) {
for (let i = 0; i < columnsAll.length; i++) {
if (columnsAll[i].dataIndex == 'implement_time') {
columnsAll.splice(i, 1)
i--
}
}
} else if (this.activeTab == this.$t('vehicleInProductionDate')) {
for (let i = 0; i < columnsAll.length; i++) {
if (columnsAll[i].dataIndex == 'xin1_che1_xing2_shi2_shi1_ri4_qi1') {
columnsAll.splice(i, 1)
i--
}
}
}
return columnsAll
}
},
mounted() {
// this.getList()
eventBUs.$on('searchQuery', search => {
Object.keys(search).forEach(res => {
if (search[res] instanceof Array) {
search[res] = search[res].join(',')
}
})
this.pageNo = 1
this.searchParmes = search
this.getList()
})
},
beforeDestroy() {
eventBUs.$off('searchQuery')
},
methods: {
callback(tab) {
this.selectedRowKeys = []
this.activeTab = tab
this.getList()
},
onSelectChange(value) {
this.selectedRowKeys = value
},
handleCompare() {
if (this.selectedRowKeys.length > 0) {
this.$nextTick(() => {
this.$refs.libraryPushRef.getPush(JSON.parse(JSON.stringify(this.selectedRowKeys)))
})
} else {
this.$message.warning(this.$t('selectLeastOne'))
}
},
handleExport() {
if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
let selectedRowKeys = JSON.parse(JSON.stringify(this.selectedRowKeys))
let text = ''
let flag
if (this.activeTab == this.$t('ImplementationDate')) {
flag = 0
text = this.$t('ImplementationDate')
} else {
text = this.$t('vehicleInProductionDate')
flag = 1
}
let query = {
id: selectedRowKeys.join(','),
...this.searchParmes,
flag: flag
}
downloadFile(this.url.exportData, text + '.xls', query, this.Deselect)
} else {
this.$message.warning(this.$t('selectLeastOne'))
}
},
Deselect() {
this.selectedRowKeys = []
},
clearSelected() {
let startTime = moment(new Date()).format('YYYY-MM-DD')
let endTime = this.haflYear()
this.searchParmes['WarnTime'] = [startTime, endTime]
this.searchParmes = { ...this.searchParmes }
this.pageNo = 1
this.getList()
},
haflYear() {
// 先获取当前时间
var curDate = (new Date()).getTime()
// 将半年的时间单位换算成毫秒
var halfYear = 365 / 2 * 24 * 3600 * 1000
// 半年前的时间(毫秒单位)
var pastResult = curDate + halfYear
// 日期函数,定义起点为半年前
var pastDate = new Date(pastResult)
var pastYear = pastDate.getFullYear()
var pastMonth = pastDate.getMonth() + 1
var pastDay = pastDate.getDate()
if (pastMonth >= 1 && pastMonth <= 9) {
pastMonth = '0' + pastMonth
}
if (pastDay >= 0 && pastDay <= 9) {
pastDay = '0' + pastDay
}
var endDate = pastYear + '-' + pastMonth + '-' + (pastDay + 1)
return endDate
},
pageOnChange(page) {
this.pageNo = page
this.getList()
},
SizeChange(page, pageSize) {
this.pageNo = 1
this.pageSize = pageSize
this.getList()
},
getList() {
let flag
if (this.activeTab == this.$t('ImplementationDate')) {
flag = 0
} else {
flag = 1
}
let params = {
...this.searchParmes,
pageNo: this.pageNo,
pageSize: this.pageSize,
flag: flag
}
this.loading = true
postAction(this.url.list, params).then((res) => {
if (res.success) {
this.dataSource = res.result.records
this.total = res.result.total
this.loading = false
} else {
this.loading = false
}
}).finally(() => {
this.loading = false
})
}
}
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
.page {
text-align: right;
margin-top: 20px;
}
</style>