Files
laws_weilai/jero-web/src/views/documentManage/library/index.vue
T
2022-06-30 10:52:36 +08:00

316 lines
10 KiB
Java

<template>
<a-card :bordered="false">
<div class="table-page-search-wrapper">
<search ref="searchRef" :flag="'1'" :url="url"/>
</div>
<div class="table-operator">
<div @click="handleDel" class="operator-text" v-has="'document:deleteBatch'">
<a-icon type="delete"/>
{{$t('BatchDelete')}}
</div>
<div @click="handleExport" class="operator-text" v-has="'document:exportExcel'">
<a-icon type="export" :rotate="-90"/>
{{$t('dataExport')}}
</div>
<div @click="handleFileExport" class="operator-text" v-has="'document:exportZip'">
<a-icon type="mail"/>
{{$t('exportWithFile')}}
</div>
<div @click="handleCompare" class="operator-text" v-has="'document:pullMessage'">
<a-icon type="rocket" :rotate="45"/>
{{$t('Push')}}
</div>
<div @click="handleModule" class="operator-text" v-has="'document:exportTemplate'">
<a-icon type="download"/>
{{$t('templateDownload')}}
</div>
<div class="operator-text" v-has="'document:importZip'">
<ImportFile :url="url" :isTrue="false" :accept="'.zip'"/>
</div>
<div @click="handleAdd" class="operator-text" v-has="'document:getInfoById'">
<a-icon type="plus"/>
{{$t('newlyAdded')}}
</div>
</div>
<div>
<!--
showAction是否有操作按钮
OperationList操作列表的list
onSelectChange 选中的id值
editTable再传操作按钮的同时把事件定义名称也传过去
-->
<tableData
ref="tableDataRef"
:flag="'1'"
:OperationList="OperationList"
@editTable="editTable"
@deleteTable="deleteTable"
:url="url"
showAction
@Collection="Collection"
@subscribe="subscribe"
@onSelectChange="onSelectChange"
@detailClick="detailClick"
/>
</div>
<addForm
ref="addFormRef"
:url="url"
:flag="'1'"
/>
<libraryPush
:url="url"
ref="libraryPushRef"
@clearSelected="clearSelected"
/>
</a-card>
</template>
<script>
import search from '@/components/search/index'
import tableData from '@/components/tableDate/index'
import addForm from './modules/addForm'
import libraryPush from '@/components/libraryPush/index'
import { getAction, postAction, deleteAction, downloadFile } from '@/api/manage'
import eventBUs from '../../../common/event'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import ImportFile from '@/components/ImportFile/index'
import Vue from 'vue'
import moment from 'moment'
export default {
name: 'docLibrary',
components: {
search,
addForm,
tableData,
libraryPush,
ImportFile
},
data() {
return {
OperationList: [
{
text: this.$t('CancelCollection'),
ClickEvent: 'Collection',
has: 'document:addCollect'
},
{
text: this.$t('CancelSubscribe'),
ClickEvent: 'subscribe',
has: 'document:addSubscribe'
},
{
text: this.$t('edit'),
ClickEvent: 'editTable',
has: 'document:updateInfo'
},
{
text: this.$t('deleteLib'),
ClickEvent: 'deleteTable',
has: 'document:deleteBatch'
}
],
selectedRowKeys: [],
loading: false,
tokenHeader: { 'X-Access-Token': Vue.ls.get(ACCESS_TOKEN) },
//url传参严格按照当前命名
url: {
tableHeader: 'document/bussDocumentLibraryEO/getHeader', //表格头部字段
seachList: 'document/bussDocumentLibraryEO/queryCondition', //搜索字段
tableList: 'document/bussDocumentLibraryEO/queryPageInfo', //表格数据
getAddForm: 'document/bussDocumentLibraryEO/getAddForm', // 表单的字段
addInfo: 'document/bussDocumentLibraryEO/addInfo', //新增
updateInfo: 'document/bussDocumentLibraryEO/updateInfo', //编辑
getDocumentInfo: 'document/bussDocumentLibraryEO/getDocumentInfoById', //查看
deleteBatch: 'document/bussDocumentLibraryEO/deleteBatch', //删除
pullMessage: 'document/bussDocumentLibraryEO/pullMessage',//推送
importZipUrl: '/document/bussDocumentLibraryEO/importZip',//导入
verifyBind: '/document/bussDocumentLibraryEO/verifyBind' //验证当前的数据是否可以删除
},
idList: []
}
},
mounted() {
},
methods: {
//导出
handleExport() {
let query = {
...this.$refs.searchRef.queryParam,
id: this.idList.join(',')
}
let handlingTime = moment(new Date()).format('YYYY-MM-DD')
downloadFile('document/bussDocumentLibraryEO/exportExcel', this.$t('DocumentLibrary')+handlingTime+'.xls', query, this.Deselect)
},
Deselect() {
this.$refs.tableDataRef.selectedRowKeys = []
this.idList = []
},
//带文件导出
handleFileExport() {
if (this.idList.length > 0) {
let query = {
...this.$refs.searchRef.queryParam,
id: this.idList.join(','),
flag: 'file'
}
let handlingTime = moment(new Date()).format('YYYY-MM-DD')
downloadFile('document/bussDocumentLibraryEO/exportZip', this.$t('DocumentLibrary')+handlingTime+'.zip', query, this.Deselect)
}else{
this.$message.warning(this.$t('selectLeastOne'))
}
},
//新增
handleAdd() {
this.$refs.addFormRef.add()
},
//下载模板
handleModule() {
downloadFile('document/bussDocumentLibraryEO/exportTemplate', this.$t('DocumentLibrary')+this.$t('importTemplate')+'.xls', {})
},
//批量删除
handleDel() {
if (this.idList.length > 0) {
let _this = this
this.$confirm({
content: _this.$t('ConfirmBatchDeletion'),
onOk() {
let idList = JSON.parse(JSON.stringify(_this.idList))
_this.verifyBind(idList.join(','), () => {
getAction(_this.url.deleteBatch, { ids: idList.join(',') }).then((res) => {
if (res.success) {
_this.$message.success(_this.$t('OperationSuccessful'))
_this.idList = []
eventBUs.$emit('searchReset')
} else {
_this.$message.warning(_this.$t('operationFailed'))
}
})
})
}
})
} else {
this.$message.warning(this.$t('selectLeastOne'))
}
},
verifyBind(idList, callBack) {
getAction(this.url.verifyBind, { ids: idList }).then((res) => {
if (res.success) {
callBack && callBack()
} else {
this.$message.warning(res.message)
}
})
},
//推送
handleCompare() {
if (this.idList.length > 0) {
this.$nextTick(() => {
this.$refs.libraryPushRef.getPush(this.idList)
})
} else {
this.$message.warning(this.$t('selectLeastOne'))
}
},
//导入
handleImport() {
},
//编辑按钮
editTable(val) {
this.$refs.addFormRef.edit(val)
},
//删除按钮
deleteTable(val) {
let _this = this
this.$confirm({
content: _this.$t('ConfirmDelete'),
onOk() {
_this.verifyBind(val.id, () => {
getAction(_this.url.deleteBatch, { ids: val.id }).then((res) => {
if (res.success) {
_this.$message.success(_this.$t('OperationSuccessful'))
eventBUs.$emit('searchReset')
} else {
_this.$message.warning(_this.$t('operationFailed'))
}
})
})
}
})
},
//收藏按钮
Collection(val) {
let _this = this
this.$confirm({
content: val.collectFlag == 0 || !val.collectFlag ? _this.$t('ConfirmCollection') : _this.$t('cancelConfirmCollection'),
onOk() {
let url = ''
if (val.collectFlag == 0 || !val.collectFlag) {
url = 'document/bussDocumentLibraryEO/addCollect'
} else {
url = 'document/bussDocumentLibraryEO/cancelCollect'
}
getAction(url, { id: val.id }).then((res) => {
if (res.success) {
_this.$message.success(_this.$t('OperationSuccessful'))
eventBUs.$emit('searchGetData')
} else {
_this.$message.warning(_this.$t('operationFailed'))
}
})
}
})
},
//订阅按钮
subscribe(val) {
let _this = this
this.$confirm({
content: val.subscribeFlag == 0 || !val.subscribeFlag ? _this.$t('ConfirmSubscribe') : _this.$t('cancelConfirmSubscribe'),
onOk() {
let url = ''
if (val.subscribeFlag == 0 || !val.subscribeFlag) {
url = 'document/bussDocumentLibraryEO/addSubscribe'
} else {
url = 'document/bussDocumentLibraryEO/cancelSubscribe'
}
getAction(url, { id: val.id }).then((res) => {
if (res.success) {
_this.$message.success(_this.$t('OperationSuccessful'))
eventBUs.$emit('searchGetData')
} else {
_this.$message.warning(_this.$t('operationFailed'))
}
})
}
})
},
//选中的id
onSelectChange(value) {
this.idList = value
},
//处理列表中的点击事件
detailClick(item) {
let newUrl = this.$router.resolve({
path: '/docManage/library/detail',
query: item
})
window.open(newUrl.href, '_blank')
},
clearSelected() {
this.idList = []
}
}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
ddd {
background: #fff;
}
</style>