Files
laws_weilai/jero-web/src/views/documentTools/documentComparison/index.vue
T
2022-10-13 11:03:10 +08:00

533 lines
18 KiB
Java

<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 :md="6" :sm="8">
<div class="box-title-text">
<div class="title-text" :title="$t('standard')">
<span>{{$t('standard')}}</span>
</div>
<a-input class="box-input" :placeholder="$t('enterStandard')"
v-model="queryParam.serialNumber"></a-input>
</div>
</a-col>
<a-col :md="6" :sm="8">
<div class="box-title-text">
<div class="title-text" :title="$t('title')">
<span>{{$t('title')}}</span>
</div>
<a-input class="box-input" :placeholder="$t('entertitle')"
v-model="queryParam.title"></a-input>
</div>
</a-col>
<a-col :md="6" :sm="8">
<div class="box-title-text tree-select">
<div class="title-text" :title="$t('releaseSituation')">
<span>{{$t('releaseSituation')}}</span>
</div>
<j-dict-select-tag class="box-input" v-model="queryParam.releaseState"
:placeholder="$t('PleaseSelect')+$t('releaseSituation')"
:type="'select'"
:triggerChange="false" dictCode="release_condition"/>
</div>
</a-col>
<span style="float: right;overflow: hidden;margin-right: 11px" class="table-page-search-submitButtons">
<a-col :md="6" :sm="24">
<a-button class="box-button" type="primary" @click="searchQuery">{{$t('query')}}</a-button>
<a-button class="box-button" style="margin-left: 8px" @click="searchReset">{{$t('reset')}}</a-button>
</a-col>
</span>
</a-row>
</a-form>
</div>
<div class="table-operator">
<div @click="initiatingProcessClick" v-has="'documentComparison:Initiate'" class="operator-text">
<a-icon type="apartment"/>
{{$t('initiateComparison')}}
</div>
<div @click="BatchDelete" v-has="'documentComparison:batchDelete'" class="operator-text">
<a-icon type="delete"/>
{{$t('BatchDelete')}}
</div>
</div>
<div>
<a-table
ref="table"
size="middle"
:loading="loading"
:pagination="false"
:scroll="{x: '100%',y:'calc(100vh - 280px)'}"
rowKey="id"
:data-source="dataSource"
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
:columns="columns"
>
<!-- -->
<span slot="operation" slot-scope="text,record">
<a class="text-operation" @click="comparisonResultsClick(record)">{{$t('comparisonResults')}}</a>
<a class="text-operation"
v-if="record.createBy == userInfoQuery.username || administrators"
@click="subscribe(record)">
{{!record.releaseState || record.releaseState == 'draft' ? $t('release') :$t('withdraw')}}
</a>
<a class="text-operation"
v-if="(record.createBy == userInfoQuery.username || administrators) && record.releaseState == 'draft'"
@click="edit(record)">{{$t('edit')}}</a>
<a class="text-operation"
v-if="(record.createBy == userInfoQuery.username || administrators) && record.releaseState == 'draft'"
@click="deleteData(record)">{{$t('delete')}}</a>
</span>
<span slot="serialNumberRight" :title="text" slot-scope="text,record">
<a @click="serialNumberRightClick(record)">{{text}}</a>
</span>
<span slot="serialNumberLeft" :title="text" slot-scope="text,record">
<a @click="serialNumberLeftClick(record)">{{text}}</a>
</span>
<span slot="fileNameLeft" :title="text" slot-scope="text,record">
<a @click="fileNameLeftClick(record)">{{text}}</a>
</span>
<span slot="fileNameRight" :title="text" slot-scope="text,record">
<a @click="fileNameRightClick(record)">{{text}}</a>
</span>
</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>
</a-card>
</template>
<script>
import { getAction, postAction, deleteAction, downloadFile } from '@/api/manage'
import { mapGetters } from 'vuex'
import { Base64 } from 'js-base64'
export default {
name: 'index',
components: {},
data() {
return {
//url传参严格按照当前命名
url: {
list: '/compare/sarFileCompareInfo/page',
deleteBatch: '/compare/sarFileCompareInfo/deleteBatch'
},
loading: false,
dataSource: [],
selectedRowKeys: [],
downLoadFileUrl: window._CONFIG['domianPreviewURL'] + '/sys/common/download',
downLoadImgUrl: window._CONFIG['domianWebImgURL'] + '/sys/common/download',
total: 0,
pageSize: 10,
pageNo: 1,
queryParam: {},
userInfoQuery: {},
administrators:false,
selectedRowKeysRecord: [],
columns: [
{
title: this.$t('standard') + ' 1',
align: 'center',
dataIndex: 'serialNumberLeft',
width: 170,
ellipsis: true,
scopedSlots: { customRender: 'serialNumberLeft' }
},
{
title: this.$t('title') + ' 1',
align: 'center',
dataIndex: 'titleLeft',
width: 170,
ellipsis: true,
scopedSlots: { customRender: 'serialNumberLeft' }
},
{
title: this.$t('TextStatus') + ' 1',
align: 'center',
width: 200,
ellipsis: true,
dataIndex: 'fileTypeLeft'
},
// {
// title: this.$t('fileName'),
// align: 'center',
// width: 270,
// ellipsis: true,
// dataIndex: 'fileNameLeft',
// scopedSlots: { customRender: 'fileNameLeft' }
// },
{
title: this.$t('standard') + ' 2',
align: 'center',
dataIndex: 'serialNumberRight',
ellipsis: true,
scopedSlots: { customRender: 'serialNumberRight' },
width: 170
},
{
title: this.$t('title') + ' 2',
align: 'center',
dataIndex: 'titleRight',
scopedSlots: { customRender: 'serialNumberRight' },
ellipsis: true,
width: 170
},
{
title: this.$t('TextStatus') + ' 2',
align: 'center',
width: 200,
ellipsis: true,
dataIndex: 'fileTypeRight'
},
// {
// title: this.$t('fileName'),
// align: 'center',
// width: 270,
// ellipsis: true,
// dataIndex: 'fileNameRight',
// scopedSlots: { customRender: 'fileNameRight' }
// },
{
title: this.$t('releaseSituation'),
align: 'center',
width: 170,
ellipsis: true,
dataIndex: 'releaseStateTitle'
},
{
title: this.$t('creater'),
align: 'center',
width: 170,
ellipsis: true,
dataIndex: 'createBy'
},
{
title: this.$t('remarks'),
align: 'center',
ellipsis: true,
width: 270,
dataIndex: 'remark'
},
{
title: this.$t('operation'),
align: 'center',
fixed: 'right',
width: 310,
scopedSlots: { customRender: 'operation' }
}
]
}
},
mounted() {
if (this.$route.query.serial_number) {
this.queryParam.serialNumber = this.$route.query.serial_number
this.queryParam = { ...this.queryParam }
}
this.userInfoQuery = this.userInfo()
this.administrators = false
if (this.userInfo().userRoleList && this.userInfo().userRoleList.length > 0) {
this.userInfo().userRoleList.forEach(res => {
if (res.roleCode == 'admin') {
this.administrators = true
}
})
}
this.getList()
},
methods: {
...mapGetters(['userInfo']),
searchQuery() {
this.pageNo = 1
this.getList()
},
searchReset() {
this.queryParam = {}
this.pageNo = 1
this.getList()
},
pageOnChange(page) {
this.pageNo = page
this.getList()
},
SizeChange(page, pageSize) {
this.pageNo = 1
this.pageSize = pageSize
this.getList()
},
getList() {
let queryParam = JSON.parse(JSON.stringify(this.queryParam))
Object.keys(queryParam).forEach(val => {
if (queryParam[val] instanceof Array) {
queryParam[val] = queryParam[val].join(',')
}
})
let query = {
pageNo: this.pageNo,
pageSize: this.pageSize,
...queryParam
}
this.loading = true
getAction(this.url.list, query).then((res) => {
if (res.success) {
if (res.result.current > 1 && res.result.records.length == 0) {
this.pageNo = 1
this.getList()
return
}
this.dataSource = res.result.records || []
this.total = res.result.total
this.loading = false
} else {
this.loading = false
}
})
},
BatchDelete() {
if (this.selectedRowKeys.length > 0) {
let _this = this
this.$confirm({
content: _this.$t('ConfirmBatchDeletion'),
onOk() {
let idList = []
let selectedRowKeysRecord = JSON.parse(JSON.stringify(_this.selectedRowKeysRecord))
for (let i = 0; i < selectedRowKeysRecord.length; i++) {
if (selectedRowKeysRecord[i].createBy == _this.userInfo().username &&
selectedRowKeysRecord[i].releaseState == 'draft') {
idList.push(selectedRowKeysRecord[i].id)
}
}
if (idList.length > 0) {
deleteAction(_this.url.deleteBatch, { ids: idList.join(',') }).then((res) => {
if (res.success) {
_this.$message.success(_this.$t('OperationSuccessful'))
_this.selectedRowKeys = []
_this.getList()
} else {
_this.$message.warning(res.message)
}
})
} else {
_this.$message.warning(_this.$t('doNotHavePermissionDeleteData'))
}
}
})
} else {
this.$message.warning(this.$t('selectLeastOne'))
}
},
onSelectChange(value, record) {
this.selectedRowKeys = value
this.selectedRowKeysRecord = record
},
comparisonResultsClick(item) {
if (item.createBy == this.userInfo().username && item.releaseState == 'draft') {
item.isDisplay = 2
} else {
item.isDisplay = 1
}
let newUrl = this.$router.resolve({
path: '/comparisonResults',
query: {
id: item.id,
isDisplay: item.isDisplay
}
})
window.open(newUrl.href, '_blank')
},
subscribe(record) {
let _this = this
this.$confirm({
content: record.releaseState == 'draft' ? _this.$t('confirmRelease') : _this.$t('confirmWithdraw'),
onOk() {
let releaseState = ''
if (record.releaseState == 'draft') {
releaseState = 'draft'
} else {
releaseState = 'published'
}
let query = {
releaseState: releaseState,
id: record.id
}
postAction('/compare/sarFileCompareInfo/changeState', query).then((res) => {
if (res.success) {
_this.$message.success(_this.$t('OperationSuccessful'))
_this.getList()
} else {
_this.$message.warning(_this.$t('operationFailed'))
}
})
}
})
},
edit(row) {
let newUrl = this.$router.resolve({
path: '/documentDataComparison',
query: {
id: row.id
}
})
window.open(newUrl.href, '_blank')
},
initiatingProcessClick() {
this.$router.push({
path: '/initiateDocumentComparison'
})
// let newUrl = this.$router.resolve({
// path: '/initiateDocumentComparison'
// })
// window.open(newUrl.href, '_blank')
},
deleteData(val) {
let _this = this
this.$confirm({
content: _this.$t('ConfirmDelete'),
onOk() {
deleteAction(_this.url.deleteBatch, { ids: val.id }).then((res) => {
if (res.success) {
_this.$message.success(_this.$t('OperationSuccessful'))
_this.getList()
} else {
_this.$message.warning(res.message)
}
})
}
})
},
serialNumberRightClick(row) {
let newUrl = this.$router.resolve({
path: '/docManage/library/detail',
query: {
id: row.fileKeyRight
}
})
window.open(newUrl.href, '_blank')
},
serialNumberLeftClick(row) {
let newUrl = this.$router.resolve({
path: '/docManage/library/detail',
query: {
id: row.fileKeyLeft
}
})
window.open(newUrl.href, '_blank')
},
fileNameLeftClick(row) {
let fileName = row.fileNameLeft
let index1 = fileName.lastIndexOf('.')
let index2 = fileName.length
let fileSuffix = fileName.substring(index1, index2)
if (fileSuffix === '.pdf') {
window.open('/pdf/web/viewer.html?file=' + encodeURIComponent('/jero-boot/sys/common/pdf/viewFile?id=' + row.fileIdLeft + '&userName=' + this.userInfo().username))
} else if (fileSuffix === '.docx' || fileSuffix === '.doc') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + row.fileIdLeft + fileSuffix)
window.open(url, '_blank')
} else if (fileSuffix === '.xlsx' || fileSuffix === '.xls') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + row.fileIdLeft + fileSuffix)
window.open(url, '_blank')
}else if(fileSuffix == '.png' || fileSuffix == '.jpeg' || fileSuffix == '.gif' || fileSuffix == '.jpg'){
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadImgUrl + '/' + row.fileIdLeft + fileSuffix)
window.open(url, '_blank')
} else {
downloadFile('/sys/common/downLoadFile', row.fileNameLeft, { id: row.fileIdLeft })
}
},
fileNameRightClick(row) {
let fileName = row.fileNameRight
let index1 = fileName.lastIndexOf('.')
let index2 = fileName.length
let fileSuffix = fileName.substring(index1, index2)
if (fileSuffix === '.pdf') {
window.open('/pdf/web/viewer.html?file=' + encodeURIComponent('/jero-boot/sys/common/pdf/viewFile?id=' + row.fileIdRight + '&userName=' + this.userInfo().username))
} else if (fileSuffix === '.docx' || fileSuffix === '.doc') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + row.fileIdRight + fileSuffix)
window.open(url, '_blank')
} else if (fileSuffix === '.xlsx' || fileSuffix === '.xls') {
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + row.fileIdRight + fileSuffix)
window.open(url, '_blank')
}else if(fileSuffix == '.png' || fileSuffix == '.jpeg' || fileSuffix == '.gif' || fileSuffix == '.jpg'){
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadImgUrl + '/' + row.fileIdRight + fileSuffix)
window.open(url, '_blank')
} else {
downloadFile('/sys/common/downLoadFile', row.fileNameRight, { id: row.fileIdRight })
}
}
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
.page {
text-align: right;
margin-top: 20px;
}
.box-title-text {
line-height: 1.4;
display: flex;
align-items: center;
margin-bottom: 10px;
}
.title-text {
width: 20%;
min-width: 110px;
color: #000F16;
display: inline-block;
font-weight: 500;
font-size: 14px;
margin-right: 16px;
margin-top: 3px;
text-align: right;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.box-input {
display: inline-block;
width: 70%;
height: 38px;
margin-top: 2px;
}
.box-button {
height: 38px;
/*margin-top: 2px;*/
}
.text-operation {
margin-right: 8px;
}
.itemModel {
width: calc(100% - 130px);
display: inline-block;
margin-top: 2px;
}
.Required {
color: red;
margin-right: 4px;
}
::v-deep .ant-table-row:first-child {
background: #fff !important;
opacity: 0.9;
}
::v-deep .ant-table-body {
background: transparent !important;
}
</style>