拆分结果保存

This commit is contained in:
caoyang
2022-03-31 23:09:51 +08:00
parent e6f40cfafd
commit 72de25242b
9 changed files with 357 additions and 81 deletions
+2
View File
@@ -568,4 +568,6 @@ module.exports = {
searchInResults:'Search in results',
searchContent:'Search content',
viewFile:'view file',
fileFormatIncorrect:'the file format is incorrect',
}
+3 -1
View File
@@ -568,9 +568,11 @@ module.exports = {
selectDirectoryTerms:'请选择添加条款的目录位置',
OnlyWord:'只能导入word文件',
labelAreaDeleted:'若进行删除则该展示区域下标签项都将被删除',
StandardBreakdown:'标准分解单',
searchInResults:'结果中检索',
searchContent:'搜索内容',
viewFile:'查看文件',
fileFormatIncorrect:'文件格式不正确',
}
@@ -101,7 +101,7 @@
const status = info.file.status;
info.fileList.forEach((val,index)=>{
if(val.response && !val.response.result){
this.$message.error(val.response.message);
this.$message.success(val.response.message);
info.fileList.splice(index,1)
}
})
@@ -0,0 +1,252 @@
<template>
<div style="height: 100%">
<div class="box">
<a-table
class="table"
rowKey="id"
:row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
:pagination="false"
:scroll="{x: true}"
:data-source="dataSource"
:loading="loading"
:columns="columns"
@change="tableOnChange"
>
<span slot="operation" slot-scope="record">
<a class="text" v-for="(ol,index) in OperationList"
@click="OperationClick(ol,record)">
<span v-if="ol.text==$t('SyncLibrary')">
{{record.resultContent=='转换成功'&&record.syncState=='未同步'&&record.fileSource=='1'?ol.text:''}}
</span>
<span v-if="ol.text==$t('check')">
{{record.resultContent=='转换成功'&&record.syncState=='未同步'?ol.text:''}}
</span>
<span v-if="ol.text==$t('download')">
{{record.resultContent=='转换成功'?ol.text:''}}
</span>
<span v-if="ol.text==$t('delete')">
{{record.resultContent=='转换成功'?ol.text:''}}
</span>
</a>
</span>
</a-table>
</div>
<div class="page" v-if="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"
@change="onChange"
@showSizeChange="SizeChange"
/>
</div>
</div>
</template>
<script>
import eventBUs from '../../common/event'
import { getAction, postAction } from '@/api/manage'
export default {
name: 'SplitDocTable',
props: {
//接口
url: {
type: Object,
default: {}
},
// 操作按钮
OperationList: {
type: Array,
default: []
},
flag: {
type: String,
default: ''
},
//是否显示操作;默认不显示
showAction: {
type: Boolean,
default: false
},
type:{
type:String,
default:''
}
},
data() {
return {
jsonBody: [],
checkboxList: [],
tableAll: false,
indeterminate: false,
columns: [],
selectedRowKeys: [],
dataSource: [],
pageNo: 1,
pageSize: 10,
total: 0,
searchParmes: {},
loading: false,
orderBy: '1',
orderByField: ''
}
},
mounted() {
eventBUs.$on('searchQuery', search => {
Object.keys(search).forEach(res => {
if (search[res] instanceof Array) {
search[res] = search[res].join(',')
}
})
this.searchParmes = search
this.getData()
this.getTableList()
})
eventBUs.$on('searchReset', target => {
this.searchParmes = {}
this.selectedRowKeys=[]
this.getData()
this.getTableList()
})
this.getData()
this.getTableList()
},
methods: {
getTextWith(text, fontStyle) {
var canvas = document.createElement('canvas')
var context = canvas.getContext('2d')
context.font = fontStyle || '14px' // 设置字体样式
var dimension = context.measureText(text)
return dimension.width + 40
},
getData() {
let params = {
flag: this.flag
}
getAction(this.url.tableHeader, params).then((res) => {
if (res.success) {
var jsonHead = res.result
this.columns = []
// this.columns.push(
// {
// title: this.$t('serialNumber'),
// dataIndex: 'index',
// key: 'index',
// align: 'center',
// customRender: (text,record,index) => `${index+1}`,
// })
jsonHead.forEach((res, index) => {
this.columns.push({
title: res.db_field_txt,
dataIndex: res.db_field_name,
align: 'center',
ellipsis: true,
sorter: res.sort
})
if (res.click) {
this.columns[index].scopedSlots = {
customRender: 'detailClick'
}
} else {
this.columns[index].scopedSlots = {
customRender: 'detailText'
}
}
})
let width = 0
if (this.OperationList.length > 0) {
for (let i = 0; i < this.OperationList.length; i++) {
width += this.getTextWith(this.OperationList[i].text)
}
}
if (this.showAction) {
this.columns.push({
title: this.$t('operation'),
align: 'center',
fixed: 'right',
width: width,
scopedSlots: { customRender: 'operation' }
})
}
}
})
},
tableOnChange(pagination, filters, sorter) {
this.orderBy = sorter.order == 'ascend' ? '1' : '2'
this.orderByField = sorter.columnKey
this.getTableList()
},
getTableList() {
let pageNo = JSON.parse(JSON.stringify(this.pageNo))
let pageSize = JSON.parse(JSON.stringify(this.pageSize))
let params = {
...this.searchParmes,
type:this.type,
orderBy: this.orderBy,
orderByField: this.orderByField,
pageNo: pageNo + '',
pageSize: pageSize + ''
}
this.loading = true
postAction(this.url.tableList, params).then((res) => {
if (res.success) {
this.dataSource = res.result.records
this.total = res.result.total
this.loading = false
} else {
this.loading = false
}
})
},
onChange(page, pageSize) {
this.pageNo = page
this.getTableList()
},
SizeChange(page, pageSize) {
this.pageNo = 1
this.pageSize = pageSize
this.getTableList()
},
onSelectChange(value,rows) {
this.selectedRowKeys = value
this.$emit('onSelectChange', value, rows)
},
OperationClick(ol, item) {
this.$emit(ol.ClickEvent, item)
},
detailClick(item, index) {
this.$emit('detailClick', item)
}
}
}
</script>
<style>
.table .ant-table-column-title {
font-weight: bold;
}
.ant-table td {
white-space: nowrap;
}
</style>
<style scoped>
.box {
width: 100%;
height: calc(100% - 100px);
overflow: auto;
}
.text {
margin-right: 10px;
}
.page {
text-align: right;
margin-top: 20px;
}
</style>
+20 -10
View File
@@ -53,6 +53,7 @@
},
mounted() {
this.visible=this.splitVisible
console.log('accept11111',this.accept)
// console.log(this.thisFileType,this.thisFileSize,this.thisFileUploadUrl);
},
methods: {
@@ -68,16 +69,24 @@
}
},
beforeUpload(file) {
let fileTypes=this.accept.split(',')
let fileFlag=false
fileTypes.forEach(item=>{
if(item==file.type){
fileFlag=true
}
})
console.log('filetype',fileFlag)
if(!fileFlag){
this.$message.warning('文件格式不正确')
console.log('accept',this.accept,file)
// if(this.accept.indexOf(',')!=-1){
// let fileTypes=this.accept.split(',')
// fileTypes.forEach(item=>{
// if(item==file.type){
// fileFlag=true
// }
// })
// }else{
// let fileTypes=this.accept.split('/')
// let fileNowTypes=file.type.split('/')
// fileFlag=fileTypes[0]==fileTypes[0]?true:false
// }
// console.log('filetype',fileFlag)
if(fileFlag){
this.$message.warning(this.$t('fileFormatIncorrect'))
this.fileTypeSatus = false
}else{
// let thisFileType = this.thisFileType.replace(/\s+/g, "");
@@ -96,7 +105,7 @@
window.open(url, '_blank')
},
handleChange(info) {
// console.log('file',info)
let { file,fileList } = info
const status = info.file.status
info.fileList.forEach((val, index) => {
@@ -154,6 +163,7 @@
this.fileList.push(res)
}
})
// console.log('file111111',this.fileList,fileList)
this.$emit('uploadSuccess', this.fileList,fileList)
// console.log('uplossss',this.fileList,fileList)
if (this.myfileList.length > 0) {
@@ -34,8 +34,10 @@
:wrapper-col="wrapperCol"
>
<a-form-model-item ref="file" :label="$t('splitFile')" prop="file">
{{form.file}}
<a-button type="primary" class="button-text"
@click="fileUpload()">
{{ (form.file === 'null' || form.file === '' ||
form.file == null) ? $t('upload1') : $t('viewUploadedFiles')
}}
@@ -46,7 +48,8 @@
</div>
<div class="imports-footer">
<div class="imports-footer-wrap">
<a-button class="imports-btn imports-chai" type="primary">{{$t('preservation')}}</a-button>
<!-- <uploadFile ref="uploadFile" :accept="accept" :disabled="disabled" @uploadSuccess="uploadSuccess"></uploadFile>-->
<a-button class="imports-btn imports-chai" type="primary" @click="handleSubmit">{{$t('preservation')}}</a-button>
<a-button class="imports-btn" type="primary" @click="cancleImports">{{$t('cancel')}}</a-button>
</div>
</div>
@@ -59,8 +62,11 @@
import { getAction, postAction, deleteAction, downloadFile } from '@/api/manage'
import SplitUpload from '@/components/SplitUpload/index'
import search from '@/components/search/index'
import TableData from '@/components/OcrTable/DocTable'
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:{
@@ -123,13 +129,16 @@
spinning:false, //loading标识
type:'',
url:{
tableHeader: 'document/bussDocumentLibraryEO/getHeaderOrConditionForOcr', //表格头部字段
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/vnd.openxmlformats-officedocument.wordprocessingml.document,application/msword',
accept:'application/zip',
rows:[],
token:Vue.ls.get(ACCESS_TOKEN),
}
},
props:{
@@ -137,8 +146,8 @@
},
watch:{
'form.file'(val){
console.log(val)
}
console.log('val111',val)
},
},
mounted() {
@@ -168,6 +177,7 @@
onSelectChange(keys,rows){
console.log('keys',keys,rows)
this.selectedRowKeys=keys
this.rows=rows
},
//搜索
@@ -202,7 +212,6 @@
data.map(item => {
attIdList.push(item.id || data.name)
})
console.log('file',attIdList)
// /** 赋值给当前对应的表单文件 */
this.form.file = attIdList.join(',')
// console.log('this.form.file',this.form.file)
@@ -211,6 +220,53 @@
downLoad(){
let name = this.$t('documentSplitTemplate')+'.xls'
downloadFile('split/sarFileSplitItems/exportTemplate',name, {})
},
//保存
handleSubmit(){
console.log('seleced',this.selectedRowKeys,this.rows)
if(!this.rows){
this.$message.warning(this.$t('PleaseSelectData'))
}else if(this.rows&&this.rows.length>1){
this.$message.warning(this.$t('OnlyOneSelected'))
}else if(this.rows&&this.rows.length===1){
let params={
connectId:this.rows[0].connect_id,
fileId:this.form.file,
fileName:this.rows[0].file_name,
fileType:this.rows[0].text_info,
serialNumber:this.rows[0].serial_number,
title:this.rows[0].title
}
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)
axios({
url: '/jero-boot/split/sarFileSplitItems/importSplitResult',
method: 'post',
data:formData,
// data: params,
// transformRequest: [function (data) {
// // Do whatever you want to transform the data
// let ret = ''
// for (let it in data) {
// ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
// }
// return ret
// }],
headers: {
'Content-Type': 'multipart/form-data',
// 'Content-Type': 'application/x-www-form-urlencoded',
'X-Access-Token':this.token
}
}).then(res => {
if (res.data.success) {
}
})
}
}
}
}
@@ -569,9 +569,10 @@
},
mounted() {
this.visible=this.addVisible
this.formInline=this.item
// this.formInline=this.item
// console.log('form',this.formInline,this.item)
this.loadData()
this.loadFormInfo()
},
methods:{
loadData(){
@@ -584,6 +585,16 @@
}).finally(()=>{
this.loading=false
})
},
//获取表单信息
loadFormInfo(){
getAction(`split/sarFileSplitItems/getSplitItemsById`,{id:this.itemId}).then(res=>{
if(res.success){
this.formInline=[...res.result]
}
})
},
afterVisibleChange(){
@@ -612,6 +612,8 @@
attIdList.push(item.id || data.name)
})
this.attId = attIdList.join(',')
this.loadMenuData()
eventBUs.$emit('searchReset')
}
},
//导出
@@ -664,17 +666,6 @@
})
// getAction(`split/sarFileSplitItems/batchMergeItems`, { ids: ids }).then(res => {
// if (res.success) {
// this.$message.success(this.$t('OperationSuccessful'))
//
// } else {
// this.$message.warning(this.$t('operationFailed'))
// }
// }).finally(()=>{
// this.selectedRowKeys=[]
// })
}
})
}
@@ -744,19 +735,6 @@
});
// postAction(`split/sarFileSplitItems/batchDeleteItems`,params).then(res=> {
// if(res.success){
// this.$message.success(this.$t('OperationSuccessful'))
// // if(this.selecIds.length==this.tableData.length&&this.queryParams.pageNo!=1){
// // this.queryParams.pageNo=this.queryParams.pageNo-1
// // }
// // this.loadData()
// this.loadMenuData()
// eventBUs.$emit('searchReset')
// }else{
// this.$message.warning(this.$t('operationFailed'))
// }
// })
},
onCancel() {},
});
@@ -12,26 +12,6 @@
<div class="split-table-content">
<div class="split-header">
<search :url="url" :flag="'condition'"></search>
<!-- <a-form layout="inline" @keyup.enter.native="searchQuery(queryParams)">-->
<!-- <a-row :gutter="24">-->
<!-- <a-col :md="6" :sm="8">-->
<!-- <a-form-item :label="$t('standard')" class="split-item">-->
<!-- <j-input :placeholder="$t('enterNumber')" v-model="queryParams.standNumber"></j-input>-->
<!-- </a-form-item>-->
<!-- </a-col>-->
<!-- <a-col :md="6" :sm="8">-->
<!-- <a-form-item :label="$t('title')" class="split-item">-->
<!-- <j-input :placeholder="$t('enterTitle')" v-model="queryParams.standName"></j-input>-->
<!-- </a-form-item>-->
<!-- </a-col>-->
<!-- <a-col :md="6" :sm="6">-->
<!-- <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">-->
<!-- <a-button type="primary" @click="searchQuery" icon="search">{{$t('query')}}</a-button>-->
<!-- <a-button @click="searchReset" icon="reload" style="margin-left: 8px">{{$t('reset')}}</a-button>-->
<!-- </span>-->
<!-- </a-col>-->
<!-- </a-row>-->
<!-- </a-form>-->
</div>
</div>
<div class="split-table-detail">
@@ -43,21 +23,6 @@
:OperationList="OperationList"
@onSelectChange="onSelectChange"
/>
<!-- <a-spin :spinning="spinning">-->
<!-- <a-table :data-source="tableSource" :columns="columns" :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" class="tag-con-table" :pagination="false" >-->
<!-- </a-table>-->
<!-- </a-spin>-->
<!-- <div class="page" v-if="tableSource.length > 0">-->
<!-- <a-pagination-->
<!-- :show-total="total => $t('total')+` ${total} `+ $t('strip')"-->
<!-- show-quick-jumper-->
<!-- show-size-changer-->
<!-- :page-size.sync="queryParams.pageSize"-->
<!-- :total="total"-->
<!-- @change="onChangePage"-->
<!-- @showSizeChange="SizeChange"-->
<!-- />-->
<!-- </div>-->
</div>
<div class="split-footer">
<div class="split-footer-wrap">
@@ -72,7 +37,7 @@
<script>
import { getAction, postAction } from '../../../../api/manage'
import search from '@/components/search/index'
import TableData from '@/components/OcrTable/DocTable'
import TableData from '@/components/SplitTable/DocTable'
import eventBUs from '../../../../common/event'
export default {
@@ -123,7 +88,7 @@
],
spinning:false, //loading标识
url:{
tableHeader: 'document/bussDocumentLibraryEO/getHeaderOrConditionForOcr', //表格头部字段
tableHeader: 'document/bussDocumentLibraryEO/getHeaderOrConditionForSplit', //表格头部字段
seachList: 'document/bussDocumentLibraryEO/getHeaderOrConditionForOcr', //搜索字段
tableList: 'document/bussDocumentLibraryEO/ocrPageInfo', //表格数据
},