Files
laws-sinotruk-client/src/views/documentTool/documentSplit/DocumentSplit.vue
T
2023-10-20 09:34:37 +08:00

339 lines
11 KiB
Vue

<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="12">
<a-form-item :label="$t('standardSelect.standardNumOrName')">
<a-input :placeholder="$t('pleaseEnter') + $t('standardSelect.standardNumOrName')" v-model="queryParam.serialNumberOrName"></a-input>
</a-form-item>
</a-col>
<!--拆分状态-->
<a-col :md="6" :sm="12">
<a-form-item :label="$t('docTool.split.splitState')">
<j-dict-select-tag
class="box-input"
v-model="queryParam.splitStatus"
:placeholder="$t('pleaseSelect') + $t('docTool.split.splitState')"
:type="'select'"
:triggerChange="false"
dictCode="split_status" />
</a-form-item>
</a-col>
<!--编辑人-->
<a-col :md="6" :sm="12">
<a-form-item :label="$t('docTool.split.editor')">
<a-input :placeholder="$t('pleaseEnter') + $t('docTool.split.editor')" v-model="queryParam.author"></a-input>
</a-form-item>
</a-col>
<a-col :md="6" :sm="8">
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-button type="primary" @click="searchReset" icon="reload" ghost>{{ $t('reset') }}</a-button>
<a-button type="primary" @click="searchQuery" icon="search" style="margin-left: 8px" v-has="'split:sarFileSplitInfo:search'">
{{ $t('query') }}
</a-button>
</span>
</a-col>
</a-row>
</a-form>
</div>
<div class="table-operator">
<!--拆分已入库文本-->
<a-button icon="plus" type="primary" @click="handleModule" v-has="'split:sarFileSplitInfo:splitFile'">{{
$t('docTool.split.splitText')
}}
</a-button>
<!--TODO 导入拆分结果-->
<a-button icon="download" type="primary" ghost @click="handleExport" v-has="'split:sarFileSplitInfo:splitResult'">
{{ $t('docTool.split.importResults') }}
</a-button>
<!--批量删除-->
<a-button type="primary" icon="delete" ghost @click="batchDel" v-has="'split:sarFileSplitInfo:deleteBatch'">
{{ $t('batchDelete') }}
</a-button>
<!--更改权限-->
<a-button type="primary" icon="sync" ghost @click="handleChangePermission" v-has="'split:sarFileSplitInfo:changePermissions'">
{{ $t('docTool.split.changePermissions') }}
</a-button>
</div>
<div>
<j-table
:columns="columns"
:dataSource="dataSource"
:can-drag="true"
rowKey="id"
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
:pagination="ipagination"
:scroll="{x: '100%'}"
:loading="loading"
:operation-list="operationList"
@change="handleTableChange"
@operationClick="operationClick">
</j-table>
</div>
<!--拆分已入库文本弹框-->
<split-text ref="splitText" @ok="modalFormOk" />
<!--导入拆分结果-->
<import-split-result-modal ref="importResultModal" @ok="modalFormOk" />
<!--更改权限-->
<user-select-modal ref="userSelectModal" check-required @change="continueChangePermission" />
</a-card>
</template>
<script>
import '../../../assets/less/common.less'
import JTable from '../../../components/jero/JTable.vue'
import SplitText from './modules/SplitText.vue'
import { JeroListMixin } from '../../../mixins/JeroListMixin.js'
import { releaseSplitStandard, changePermission, withdraw } from '../../../api/documentToolApi.js'
import ImportSplitResultModal from './modules/ImportSplitResultModal.vue'
import UserSelectModal from '../../../components/selection/UserSelectModal.vue'
import { SplitStatus } from '../../../enums/commonEnums.js'
import { mapState } from 'vuex'
export default {
name: 'DocumentSplit',
components: { JTable, SplitText, ImportSplitResultModal, UserSelectModal },
mixins: [JeroListMixin],
data () {
return {
userInfo: this.$store.getters.userInfo,
operationList: [
// 发布
{
text: this.$t('release'),
clickEvent: 'handleRelease',
has: 'split:sarFileSplitInfo:release',
show: (record) => {
// 创建人(更改权限更改的是这个字段)是当前登录人,且状态为编辑中可以发布
return record.createBy === this.userInfo.username && record.splitStatus === SplitStatus.EDITING.value
}
},
// 撤回
{
text: this.$t('withdraw'),
clickEvent: 'handleWithdraw',
has: 'split:sarFileSplitInfo:withdraw',
show: (record) => {
// 创建人(更改权限更改的是这个字段)是当前登录人,且状态为已发布可以撤回
return record.createBy === this.userInfo.username && record.splitStatus === SplitStatus.RELEASED.value
}
},
// 查看
{
text: this.$t('view'),
clickEvent: 'handleDetail',
has: 'split:sarFileSplitItems:page'
},
// 编辑
{
text: this.$t('edit'),
clickEvent: 'handleEdit',
has: 'split:sarFileSplitItems:edit',
show: (record) => {
// 创建人(更改权限更改的是这个字段)是当前登录人,且状态为编辑中可以编辑
return record.createBy === this.userInfo.username && record.splitStatus === SplitStatus.EDITING.value
}
},
// 删除
{
text: this.$t('delete'),
clickEvent: 'handleDelete',
has: 'split:sarFileSplitInfo:delete',
show: (record) => {
// 创建人(更改权限更改的是这个字段)是当前登录人,且状态为编辑中可以删除
return record.createBy === this.userInfo.username && record.splitStatus === SplitStatus.EDITING.value
}
}
],
columns: [
// 标准号
{
dataIndex: 'serialNumber',
title: this.$t('standardSelect.standardNumber'),
width: 150
},
// 标准名称
{
dataIndex: 'title',
title: this.$t('standardSelect.standardName'),
width: 150
},
// 文件状态
{
dataIndex: 'fileType_dictText',
title: this.$t('docTool.split.fileStatus'),
width: 150
},
// 文件名称
{
dataIndex: 'fileName',
title: this.$t('fileName'),
width: 180
},
// 拆分状态
{
dataIndex: 'splitStatus_dictText',
title: this.$t('docTool.split.splitState'),
width: 150
},
// 编辑人
{
dataIndex: 'author',
title: this.$t('docTool.split.editor'),
width: 150
},
// 拆分时间
{
dataIndex: 'createTime',
title: this.$t('docTool.split.splitTime'),
width: 150
},
// 拆分结果
{
dataIndex: 'splitResult',
title: this.$t('docTool.split.splitResult'),
sorter: true,
width: 150
},
// 操作
{
title: this.$t('operation'),
fixed: 'right',
width: 150,
scopedSlots: { customRender: 'action' }
}
],
url: {
list: '/laws/DocumentTool/documentSplit/queryByPage', // 表格数据
deleteBatch: '/laws/DocumentTool/documentSplit/deleteBatch', // 批量删除
delete: '/laws/DocumentTool/documentSplit/delete',
backDocument: '' // 回传至文档库
}
}
},
methods: {
// 拆分已入库文本按钮点击
handleModule () {
this.$refs.splitText.open()
},
// 导入拆分结果
handleExport () {
this.$refs.importResultModal.open()
},
/**
* 发布
*/
handleRelease ({ id }) {
this.$confirm({
title: this.$t('confirmRelease'),
content: this.$t('confirmReleaseContent'),
onOk: () => {
this.loading = true
releaseSplitStandard({ id }).then(res => {
if (res.success) {
this.$message.success(res.message)
this.modalFormOk()
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.loading = false
})
}
})
},
/**
* TODO 撤回
* @param id
*/
handleWithdraw ({ id }) {
this.$confirm({
title: this.$t('confirmWithdraw'),
content: this.$t('confirmWithdrawContent'),
onOk: () => {
this.loading = true
withdraw({ id }).then(res => {
if (res.success) {
this.$message.success(res.message)
this.modalFormOk()
} else {
this.$message.warn(res.message)
}
}).finally(() => {
this.loading = false
})
}
})
},
// 编辑
handleEdit (record) {
this.$router.push({
path: '/documentTool/DocumentSplitDetail',
query: {
infoId: record.id,
infoNumber: record.serialNumber,
createBy: record.createBy,
standardName: record.title
}
})
},
/**
* 表格操作列的查看
* @param id
*/
handleDetail ({ id }) {
this.$openPageNewSheet({
path: '/documentTool/StandardSplitSheet',
query: {
id
}
})
},
splitTextVisible (val, num) {
if (num === 1) {
this.$refs.tableData.$emit('searchGetData')
}
},
importResultVisible (val, num) {
if (num === 1) {
this.$refs.tableData.$emit('searchGetData')
}
},
/**
* 更改权限
*/
handleChangePermission () {
if (!this.selectedRowKeys || this.selectedRowKeys.length === 0) {
this.$message.warning(this.$t('selectARecord'))
return
}
this.$refs.userSelectModal.open()
},
continueChangePermission (id) {
this.loading = true
const params = {
ids: this.selectedRowKeys.join(','),
createBy: id
}
changePermission(params).then(res => {
if (res.success) {
this.$message.success(res.message)
this.modalFormOk()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
}
}
}
</script>
<style scoped>
</style>