Files
laws_weilai/jero-web/src/views/documentManage/splitting/modules/ImportResult.vue
T
2022-04-12 13:47:33 +08:00

393 lines
11 KiB
Java

<template>
<div class="imports">
<a-drawer
class="imports-table-drawer"
:title="$t('ImportResults')"
placement="right"
:visible="visible"
:after-visible-change="afterVisibleChange"
@close="onClose"
width="1100"
>
<div class="imports-table-content">
<div class="imports-header">
<search :url="url" :flag="'condition'"></search>
</div>
</div>
<div class="table-operator">
<div class="operator-text">
<!-- <a-icon type="copy" />-->
<!-- 拆分文件-->
<split-upload ref="uploadFile" :accept="accept" :disabled="disabled" :module="'split'" @uploadSuccess="uploadSuccess"></split-upload>
</div>
<div class="operator-text" @click="downLoad" v-has="'split:sarFileSplitItems:template'">
<a-icon type="download" />
模板下载
</div>
</div>
<div class="imports-table-detail">
<tableData
:flag="'header'"
:url="url"
:type="type"
:showAction="false"
:OperationList="OperationList"
@onSelectChange="onSelectChange"
/>
</div>
<div class="imports-footer">
<div class="imports-footer-wrap">
<a-button class="imports-btn imports-sub" type="primary" @click="handleSubmit" v-has="'split:sarFileSplitItems:importSplitResult'">{{$t('preservation')}}</a-button>
<a-button class="imports-btn" type="primary" @click="cancleImports">{{$t('cancel')}}</a-button>
</div>
</div>
<a-modal
:title="''"
class="split-error"
:visible="preErrVisible"
@cancel="handleErrCancel"
:footer="false"
>
<span class="err-value">{{errValue}}</span>
</a-modal>
<!-- <split-upload ref="uploadFile" :disabled="disabled" :title="upload1" :accept="accept" @uploadSuccess="uploadSuccess"></split-upload>-->
</a-drawer>
</div>
</template>
<script>
import { getAction, postAction, deleteAction, downloadFile } from '@/api/manage'
import SplitUpload from '@/components/importSplitUpload/index'
import search from '@/components/search/index'
import TableData from '@/components/SplitTable/DocTable'
import axios from 'axios'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import eventBUs from '../../../../common/event'
import Vue from 'vue'
export default {
name: 'import',
components:{
SplitUpload,
search,
TableData
},
data(){
return{
labelCol: { span:4 },
wrapperCol: { span: 18 },
visible:false,
contentVisible:true,
disabled:false,
tableSource:[], //列表数据
selectedRowKeys:[],
queryParams:{
pageNo:1,
pageSize:10
}, //搜索条件
total:0,
columns: [
{
title:this.$t('standard'),
key: 'standNumber',
align:"center",
dataIndex: 'standNumber',
ellipsis: true,
},
{
title:this.$t('title'),
key: 'standName',
align:"center",
dataIndex: 'standName',
ellipsis: true,
},
{
title:this.$t('fileName'),
key: 'fileName',
align:"center",
dataIndex: 'fileName',
ellipsis: true,
},
{
title:this.$t('TextStatus'),
key: 'fileType_dictText',
align:"center",
dataIndex: 'fileType_dictText',
ellipsis: true,
},
],
file:'',
form:{},
rules:{
file:[
{ required: true, message: this.$t('pleaseUploadFile'), trigger: 'change' },
],
},
spinning:false, //loading标识
type:'',
url:{
tableHeader: 'document/bussDocumentLibraryEO/getHeaderOrConditionForSplit', //表格头部字段
seachList: 'document/bussDocumentLibraryEO/getHeaderOrConditionForOcr', //搜索字段
tableList: 'document/bussDocumentLibraryEO/ocrPageInfo', //表格数据
},
OperationList:[],
upload1:this.$t('upload1'),
// accept:'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/msword',
accept:'application/x-zip-compressed,application/zip',
rows:[],
token:Vue.ls.get(ACCESS_TOKEN),
flag:false, //提交表单标识
cut:'',
preErrVisible:false,
errValue:''
}
},
props:{
importsVisible:Boolean
},
watch:{
'form.file'(val){
// console.log('val111',val)
},
},
mounted() {
this.visible=this.importsVisible
let long = localStorage.getItem('language')
this.cut = ''
if (long && long === 'zh-cn') {
this.cut = 'cn'
} else if (long && long === 'en-us') {
this.cut = 'en'
}
// console.log('visibleSplit',this.visible)
},
methods:{
//获取列表数据
loadData(){
this.spinning=true
let params={
}
getAction(``,params).then(res=>{
}).finally(()=>{
this.spinning=false
})
},
afterVisibleChange(val) {
// console.log('visible', val);
},
onClose() {
this.visible = false;
this.$emit('visible',false)
},
onSelectChange(keys,rows){
// console.log('keys',keys,rows)
this.selectedRowKeys=keys
this.rows=rows
},
//搜索
searchQuery(){
},
//清空
searchReset(){
},
//点击页数
onChangePage(page,pageSize){
this.queryParams.pageNo = page
this.loadData()
},
//一页显示条数
SizeChange(page,pageSize){
this.queryParams.pageSize = pageSize
this.queryParams.pageNo = 1
this.loadData()
},
cancleImports(){
this.$emit('visible',false)
},
fileUpload(){
this.$refs.uploadFile.visible=true
},
//上传文件
uploadSuccess(data) {
// console.log('updata',data)
let attIdList = []
if(data && data.length>0) {
data.map(item => {
attIdList.push(item.id || data.name)
})
}
// /** 赋值给当前对应的表单文件 */
this.form.file = attIdList.join(',')
// console.log('this.form.file',this.form.file)
},
//模板下载
downLoad(){
let name = this.$t('documentSplitTemplate')+'.xls'
downloadFile('split/sarFileSplitItems/exportTemplate',name, {})
},
//保存
handleSubmit(){
// console.log('seleced',this.selectedRowKeys,this.rows)
// console.log('this.form.file,',this.form.file)
if(this.rows.length===0){
this.$message.warning(this.$t('PleaseSelectData'))
}else if(this.rows&&this.rows.length>1){
this.$message.warning(this.$t('OnlyOneSelected'))
}else if(!this.form.file) {
this.$message.warning(this.$t('pleaseUploadSplitFile'))
}else if(this.rows&&this.rows.length===1){
let params={
connectId:this.rows[0].connect_id,
splitFileId:this.form.file,
fileName:this.rows[0].file_name,
serialNumber:this.rows[0].serial_number,
title:this.rows[0].title,
}
params.fileType=this.rows[0].text_info
params.cut=this.cut
let formData = new FormData()
Object.keys(params).forEach((key) => {
// console.log('key',key,params[key])
formData.append(key, params[key]);
});
// console.log('formData',params,formData.getAll)
if(this.form.file) {
// this.$refs.ruleForm.validate(valid => {
// if (valid) {
if (!this.flag) {
this.flag = true
axios({
url: '/jero-boot/split/sarFileSplitItems/importSplitResult',
method: 'post',
data: formData,
headers: {
'Content-Type': 'multipart/form-data',
// 'Content-Type': 'application/x-www-form-urlencoded',
'X-Access-Token': this.token
}
}).then(res => {
if (res.data.success) {
this.$message.success(this.$t('OperationSuccessful'))
eventBUs.$emit('searchReset')
this.visible = false;
this.$emit('visible',false)
}else{
this.$message.warning(res.data.message)
if(res.data.code==1){
this.$message.error(res.data.message);
}else{
this.preErrVisible=true
this.errValue=res.data.message
}
}
}).finally(() => [
this.flag = false
])
}
// }
// })
}
// else {
//
// this.$refs.ruleForm.clearValidate()
// if (!this.flag) {
// this.flag = true
// axios({
// url: '/jero-boot/split/sarFileSplitItems/importSplitResult',
// method: 'post',
// data: formData,
// headers: {
// 'Content-Type': 'multipart/form-data',
// // 'Content-Type': 'application/x-www-form-urlencoded',
// 'X-Access-Token': this.token
// }
// }).then(res => {
// if (res.data.success) {
// this.$message.success(this.$t('OperationSuccessful'))
// eventBUs.$emit('searchReset')
// }else{
// this.$message.warning(res.data.message)
// }
// }).finally(() => [
// this.flag = false
// ])
// }
// }
}
},
handleErrCancel(){
this.preErrVisible=false
},
}
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
.imports-table-content{
.imports-header{
margin-bottom: 20px;
}
}
.imports-table-detail{
.page{
margin: 20px 0;
text-align: right;
}
}
.imports-files{
position: relative;
margin:20px 0;
.file-down{
position: absolute;
left: 320px;
top: 5px;
}
}
.imports-footer{
.imports-footer-wrap{
margin:20px 0;
text-align: center;
.imports-sub{
margin-right: 20px;
}
}
}
</style>
<style lang="less">
.imports-table-content {
.imports-header {
.ant-col-sm-24{
display: flex;
}
}
}
.imports-table-drawer{
.table-operator{
display: flex;
justify-content: end;
text-align: right;
margin-bottom: 20px;
span{
color:#040B29;
}
}
}
</style>