Files
laws-sinotruk-client/src/views/enterpriseStandardLibrary/publicize/EnterpriseStandardPublicize.vue
T
2023-11-27 15:52:47 +08:00

284 lines
11 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<a-card :bordered="false">
<!-- 搜索区域 -->
<div class="table-page-search-wrapper">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<!-- 企标编号 -->
<a-col :span="6">
<a-form-item :label="$t('enterpriseStandardLibrary.publicize.enterpriseStandardNum')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input :placeholder="$t('pleaseEnter')+$t('enterpriseStandardLibrary.publicize.enterpriseStandardNum')" v-model="queryParam.standardNo"></a-input>
</a-form-item>
</a-col>
<!-- 企标名称 -->
<a-col :span="6">
<a-form-item :label="$t('enterpriseStandardLibrary.publicize.enterpriseStandardName')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input :placeholder="$t('pleaseEnter')+$t('enterpriseStandardLibrary.publicize.enterpriseStandardName')" v-model="queryParam.standardName"></a-input>
</a-form-item>
</a-col>
<!-- 宣贯日期 -->
<a-col :span="6">
<a-form-item :label="$t('enterpriseStandardLibrary.publicize.publicizeData')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-range-picker
value-format="YYYY-MM-DD"
format="YYYY-MM-DD"
@change="publicizeDataChange"
v-model="queryParam.publicizeData">
</a-range-picker>
</a-form-item>
</a-col>
<template v-if="toggleSearchStatus">
<!-- 宣贯人 -->
<a-col :span="6">
<a-form-item :label="$t('enterpriseStandardLibrary.publicize.publicist')" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-input :placeholder="$t('pleaseEnter')+$t('enterpriseStandardLibrary.publicize.publicist')" v-model="queryParam.declareUserName"></a-input>
</a-form-item>
</a-col>
</template>
<div style="float: right;overflow: hidden;" class="table-page-search-submitButtons">
<a @click="handleToggleSearch">
{{ toggleSearchStatus ? $t('putAway') : $t('open') }}
<a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
</a>
<a-button type="primary" @click="searchQuery" icon="search" style="margin-left: 8px" v-has="'enterpriseStandardLibrary:publicize:search'">{{ $t('query') }}</a-button>
<a-button type="primary" ghost @click="searchReset" icon="reload" style="margin-left: 8px">{{ $t('reset') }}</a-button>
</div>
</a-row>
</a-form>
</div>
<!-- 操作区域 -->
<div class="table-operator">
<!-- 导出-->
<a-button icon="upload" type="primary" ghost v-has="'enterpriseStandardLibrary:publicize:export'"
@click="handleExportXls($t('enterpriseStandardLibrary.publicize.exportName'))">
{{ $t('export') }}
</a-button>
<a-button icon="upload" type="primary" ghost v-has="'enterpriseStandardLibrary:publicize:fileExport'"
@click="handleFileExport($t('enterpriseStandardLibrary.publicize.fileExportName'))">{{ $t('exportWithFile') }}</a-button>
</div>
<div>
<j-table
:can-drag="true"
:scroll="{x: '100%', y: yScrollHeight}"
ref="table"
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
@change="handleTableChange">
<!-- 企标编号 -->
<template v-slot:enterpriseStandardNum="{text, record}">
<a-tooltip overlay-class-name="tooltip-style">
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
<a v-if="text" class="link-a" @click="handleGoDetail(record)">{{ text }}</a>
<div v-else class="table-text">{{ global.emptyLine }}</div>
</a-tooltip>
</template>
<!-- 企标名称 -->
<template v-slot:enterpriseStandardName="{text, record}">
<a-tooltip overlay-class-name="tooltip-style">
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
<a v-if="text" class="link-a" @click="handleGoDetail(record)">{{ text }}</a>
<div v-else class="table-text">{{ global.emptyLine }}</div>
</a-tooltip>
</template>
<!-- 相关材料 -->
<template v-slot:relatedMaterial="{text, record}">
<a-tooltip overlay-class-name="tooltip-style">
<template slot="title">{{ text || text === 0 ? text : global.emptyLine }}</template>
<a v-if="text" class="link-a" @click="handleRelatedMaterialClick(record)">{{ text }}</a>
<div v-else class="table-text">{{ global.emptyLine }}</div>
</a-tooltip>
</template>
</j-table>
</div>
</a-card>
</template>
<script>
import JTable from '@/components/jero/JTable'
import { JeroListMixin } from '@/mixins/JeroListMixin'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { previewPdf } from '@/utils/previewPdf'
import { getFileAccessHttpUrl } from '@/api/manage'
import { downFile } from '../../../api/manage'
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
const FILE_TYPE_PDF = 'pdf'
const Base64 = require('js-base64').Base64
export default {
name: 'EnterpriseStandardPublicize',
components: { JTable },
mixins: [JeroListMixin],
data () {
return {
labelCol: {
span: 4
},
wrapperCol: {
span: 18
},
columns: [
{ // 企标编号
title: this.$t('enterpriseStandardLibrary.publicize.enterpriseStandardNum'),
align: 'center',
width: 180,
dataIndex: 'standardNo',
scopedSlots: { customRender: 'enterpriseStandardNum' }
},
{ // 企标名称
title: this.$t('enterpriseStandardLibrary.publicize.enterpriseStandardName'),
align: 'center',
width: 180,
dataIndex: 'standardName',
scopedSlots: { customRender: 'enterpriseStandardName' }
},
{ // 发布日期
title: this.$t('enterpriseStandardLibrary.publicize.releaseDate'),
align: 'center',
width: 180,
dataIndex: 'releaseDate',
scopedSlots: { customRender: 'text' }
},
{ // 实施日期
title: this.$t('enterpriseStandardLibrary.publicize.materialDate'),
align: 'center',
width: 180,
dataIndex: 'implementationDate',
scopedSlots: { customRender: 'text' }
},
{ // 宣贯日期
title: this.$t('enterpriseStandardLibrary.publicize.publicizeData'),
align: 'center',
width: 180,
dataIndex: 'declareDate',
scopedSlots: { customRender: 'text' }
},
{ // 宣贯人
title: this.$t('enterpriseStandardLibrary.publicize.publicist'),
align: 'center',
width: 180,
dataIndex: 'declareUserName',
scopedSlots: { customRender: 'text' }
},
{ // 相关材料
title: this.$t('enterpriseStandardLibrary.publicize.relatedMaterial'),
align: 'center',
width: 180,
dataIndex: 'declareFileName',
scopedSlots: { customRender: 'relatedMaterial' }
}
],
url: {
list: '/enterprise/declare/page',
exportXlsUrl: '/enterprise/declare/exportData',
exportZipUrl: '/enterprise/declare/exportDataWithFile'
}
}
},
methods: {
// 宣贯日期查询条件修改
publicizeDataChange (date) {
console.log(date)
this.queryParam.declareStartDate = date[0]
this.queryParam.declareEndDate = date[1]
},
// 点击跳转企标详情
handleGoDetail (record) {
this.$openPageNewSheet({
path: '/enterpriseStandardLibrary/enterpriseStandardDetail',
query: {
standardNumber: record.standardNo
}
})
},
// 点击相关材料
handleRelatedMaterialClick (record) {
// 截取文件后缀名
const fileSuffix = record.declareFileName ? record.declareFileName.split('.')[record.declareFileName.split('.').length - 1] : ''
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${record.declareFile}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${record.declareFileName}`
// 图片预览,使用自己添加的组件
if (FILE_TYPE_IMGS.includes(fileSuffix)) {
this.imageUrl = getFileAccessHttpUrl(record.declareFile)
// 获取viewer实例
const viewer = this.$el.querySelector('.image').$viewer
// 调用show方法进行显示预览图
viewer.show()
// this.$refs.imagePreviewModal.open(file)
return
}
// pdf预览
if (FILE_TYPE_PDF.includes(fileSuffix)) {
const url = previewPdf(record.declareFile)
window.open(url)
return
}
// 其余可预览文件仍使用KKFile进行预览
const url = `${window._CONFIG.onlinePreviewDomainURL}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}`
window.open(url)
},
// 导出
handleExportXls (fileName) {
if (!fileName || typeof fileName !== 'string') {
fileName = '导出文件'
}
const param = this.getQueryParams()
if (this.selectedRowKeys && this.selectedRowKeys.length > 0) {
param.selections = this.selectedRowKeys.join(',')
}
console.log('导出参数', param)
// 加一个大的提示
const modalLoading = this.$info({
title: '提示',
content: <span>正在导出,请稍候 <a-spin size="small" /></span>,
keyboard: false
})
// 把知道了这个按钮去掉
this.$nextTick(() => {
document.getElementsByClassName('ant-modal-confirm-btns')[0].style = 'display:none'
})
downFile(this.url.exportXlsUrl, param).then((data) => {
if (!data) {
this.$message.warning('文件下载失败')
return
}
if (typeof window.navigator.msSaveBlob !== 'undefined') {
window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
} else {
const url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', fileName + '.xls')
document.body.appendChild(link)
link.click()
document.body.removeChild(link) // 下载完成移除元素
window.URL.revokeObjectURL(url) // 释放掉blob对象
}
}).finally(() => {
// 销毁这个提示
modalLoading.destroy()
})
}
}
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
/deep/ .ant-form-item-label{
min-width: 70px !important;
}
</style>