Files
laws_weilai/jero-web/src/views/documentTools/documentTranslation/index.vue
T
2022-07-27 14:43:25 +08:00

446 lines
14 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>
<j-input class="box-input" :placeholder="$t('PleaseEnter')+$t('standard')"
v-model="queryParam.serialNumber"></j-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>
<j-input class="box-input" :placeholder="$t('PleaseEnter')+$t('title')"
v-model="queryParam.title"></j-input>
</div>
</a-col>
<a-col :md="6" :sm="8">
<div class="box-title-text tree-select">
<div class="title-text" :title="$t('translationResults')">
<span>{{$t('translationResults')}}</span>
</div>
<j-dict-select-tag class="box-input" v-model="queryParam.translationResult"
:placeholder="$t('PleaseSelect')+$t('translationResults')"
:type="'select'"
:triggerChange="false" dictCode="translation_result"/>
</div>
</a-col>
<template v-if="toggleSearchStatus">
<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.releaseCondition"
:placeholder="$t('PleaseSelect')+$t('releaseSituation')"
:type="'select'"
:triggerChange="false" dictCode="release_condition"/>
</div>
</a-col>
</template>
<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 @click="handleToggleSearch" style="margin-left: 8px">
{{ !toggleSearchStatus ? $t('open') : $t('away') }}
<a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
</a>
</a-col>
</span>
</a-row>
</a-form>
</div>
<div class="table-operator">
<div @click="uploadClick" class="operator-text">
<a-icon type="cloud-upload"/>
{{$t('upload1')}}
</div>
<div @click="RetrieveFilesClick" class="operator-text">
<a-icon type="database"/>
{{$t('RetrieveFiles')}}
</div>
<div @click="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%'}"
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="viewClick(record)">{{$t('view')}}</a>
<!-- <a class="text-operation" @click="checkClick(record)">{{$t('check')}}</a>-->
<a class="text-operation"
v-if="record.createBy == userInfoQuery.username"
@click="subscribe(record)">
{{!record.releaseCondition || record.releaseCondition == 'draft' ? $t('release') :$t('withdraw')}}
</a>
<a class="text-operation"
v-if="record.translationResult == 'Translation done'"
@click="downloadData(record)">{{$t('download')}}</a>
<a class="text-operation"
v-if="record.createBy == userInfoQuery.username && record.releaseCondition == 'draft'"
@click="deleteData(record)">{{$t('delete')}}</a>
</span>
<span slot="translationLanguage" slot-scope="text,record"
:title="record.sourceLanguage_dictText +' -- '+record.targetLanguage_dictText">
<span class="translationLanguageText" style="margin-top: -2px">{{record.sourceLanguage_dictText}}</span>
<a-icon class="translationLanguageText" type="arrow-right" style="font-size: 16px"/>
<span class="translationLanguageText">{{record.targetLanguage_dictText}}</span>
</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>
<addModel ref="addModelRef" @addModelForm="addModelForm"/>
<RetrieveFilesList ref="RetrieveFilesListRef" @RetrieveFilesListForm="RetrieveFilesListForm"/>
</a-card>
</template>
<script>
import { getAction, postAction, deleteAction, downloadFile } from '@/api/manage'
import addModel from './components/addModel'
import RetrieveFilesList from './components/RetrieveFilesList'
import eventBUs from '../../../common/event'
import { mapGetters } from 'vuex'
export default {
name: 'index',
components: {
addModel,
RetrieveFilesList
},
data() {
return {
//url传参严格按照当前命名
url: {
list: '/docTranslation/docTranslationEO/page',
deleteBatch: '/docTranslation/docTranslationEO/deleteBatch'
},
toggleSearchStatus: false,
loading: false,
dataSource: [{}],
selectedRowKeys: [],
total: 0,
pageSize: 10,
pageNo: 1,
queryParam: {},
userInfoQuery: {},
selectedRowKeysRecord: [],
columns: [
{
title: this.$t('standard'),
align: 'center',
dataIndex: 'serialNumber',
width: 170
},
{
title: this.$t('title'),
align: 'center',
dataIndex: 'title',
width: 170
},
{
title: this.$t('TextStatus'),
align: 'center',
width: 170,
ellipsis: true,
dataIndex: 'textStatus_dictText'
},
{
title: this.$t('fileName'),
align: 'center',
width: 170,
ellipsis: true,
dataIndex: 'fileName'
},
{
title: this.$t('translationLanguage'),
align: 'center',
dataIndex: 'targetLanguage_dictText',
width: 240,
scopedSlots: { customRender: 'translationLanguage' }
},
{
title: this.$t('translationResults'),
align: 'center',
dataIndex: 'translationResult_dictText',
width: 170
},
{
title: this.$t('conversionTime'),
align: 'center',
width: 170,
ellipsis: true,
dataIndex: 'translationTime'
},
{
title: this.$t('releaseSituation'),
align: 'center',
width: 170,
ellipsis: true,
dataIndex: 'releaseCondition_dictText'
},
{
title: this.$t('operation'),
align: 'center',
fixed: 'right',
width: 260,
scopedSlots: { customRender: 'operation' }
}
]
}
},
mounted() {
this.getList()
this.userInfoQuery = this.userInfo()
},
methods: {
...mapGetters(['userInfo']),
addModelForm() {
this.pageNo = 1
this.getList()
},
RetrieveFilesListForm() {
this.pageNo = 1
this.getList()
},
handleToggleSearch() {
this.toggleSearchStatus = !this.toggleSearchStatus
},
searchQuery() {
this.pageNo = 1
this.getList()
},
searchReset() {
this.queryParam = {}
this.pageNo = 1
this.getList()
},
pageOnChange(page) {
this.pageNo = page
this.getList()
},
SizeChange(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) {
this.dataSource = res.result.records || []
this.total = res.result.total
this.loading = false
} else {
this.loading = false
}
})
},
onSelectChange(value, record) {
this.selectedRowKeys = value
this.selectedRowKeysRecord = record
},
viewClick(row) {
let newUrl = this.$router.resolve({
path: '/documentTranslationResults',
query: {
targetFileId: row.targetFileId,
sourceFileId: row.sourceFileId,
fileName: row.fileName
}
})
window.open(newUrl.href, '_blank')
},
// checkClick(row) {
//
// },
downloadData(fileQuery) {
downloadFile('/sys/common/downLoadFile', fileQuery.fileName, { id: fileQuery.targetFileId })
},
subscribe(record) {
let _this = this
this.$confirm({
content: record.releaseCondition == 'draft' ? _this.$t('confirmRelease') : _this.$t('confirmWithdraw'),
onOk() {
let releaseCondition = ''
if (record.releaseCondition == 'draft') {
releaseCondition = 'published'
} else {
releaseCondition = 'draft'
}
let query = {
releaseCondition: releaseCondition,
ids: record.id
}
postAction('/docTranslation/docTranslationEO/updateRleaseConditionBatch', query).then((res) => {
if (res.success) {
_this.$message.success(_this.$t('OperationSuccessful'))
_this.getList()
} else {
_this.$message.warning(_this.$t('operationFailed'))
}
})
}
})
},
uploadClick() {
this.$refs.addModelRef.add()
},
RetrieveFilesClick() {
this.$refs.RetrieveFilesListRef.addModel()
},
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].releaseCondition == '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'))
}
},
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)
}
})
}
})
}
}
}
</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;
}
.translationLanguageText {
margin-right: 4px;
display: inline-block;
}
</style>