Commit 28e60feb authored by jingnan's avatar jingnan 👀

履历本附件修改

parent 94b7ef88
import {
get, post, del, downloadFile
} from '../utils/http'
// 文件下载
export function downPdf(params) {
return get('/dfs/fileManager/downloadCipher', params, true)
}
// 分片上传准备
export function uploadPartPrepare(params) {
return post(`/dfs/fileManager/uploadPartPrepare`, params, true)
}
// 获取存储库id
export function getBucketByAppID(params) {
return get('/RepoBucket/getBucketByAppID', params)
}
// 文件下载
export function downloadFileById(id) {
return get(`/dfs/fileManager/download?fileId=${id}`, null, true)
}
// 查询所有上传记录
export function getUploadRecord(params) {
// return post('/RepoFileUpload/find/recursion', params)
return post('/RepoFileUpload/findWithCondition', params)
}
// 删除上传文件
export function delUploadFileOrRecord(id) {
return del(`/RepoFileUpload/${id}`)
}
// 修改文件状态
export function changeFileStatusByUploadId(status, uploadId) {
return post(`/dfs/fileManager/changeFileStatusByUploadId?status=${status}&uploadId=${uploadId}`, null, true)
}
// 下载文件
export function downFileByFileId(objName, objId, linkId) {
return downloadFile(`/dfs/fileManager/downloadio?objName=${objName}&objId=${objId}&linkId=${linkId}`)
}
export function downFileUseFileId(fileId) {
return downloadFile(`/dfs/fileManager/downloadio?fileId=${fileId}`)
}
<template> <template>
<div v-dee-loading="loading" class="BiographicDataUpload"> <div class="BiographicDataUpload">
<dee-tools slot="header" :tools="tools" mode="normal" :collapse="false" /> <dee-tools slot="header" :tools="tools" mode="normal" :collapse="false" />
<div class="dee-table dee-table-dis-border"> <div class="dee-table dee-table-dis-border">
<el-table <el-table
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
/> />
<el-table-column prop="contentType" label="附件类型"> <el-table-column prop="contentType" label="附件类型">
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-if="showBtns" v-model="scope.row.contentType" placeholder="请选择"> <el-select v-if="!scope.row.id&&showBtns" v-model="scope.row.contentType" placeholder="请选择">
<el-option <el-option
v-for="i in contentTypeOptions" v-for="i in contentTypeOptions"
:key="i.value" :key="i.value"
...@@ -24,10 +24,20 @@ ...@@ -24,10 +24,20 @@
<span v-else>{{ scope.row.contentType }}</span> <span v-else>{{ scope.row.contentType }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="fileName" label="文件名" /> <el-table-column prop="fileName" label="文件名">
<el-table-column prop="fileName" label="上传附件">
<template slot-scope="scope"> <template slot-scope="scope">
<div class="importTemp-com"> <span
class="link"
@click="(val)=> {
loadFile(scope.row)
}"
>{{ scope.row.fileName }}
</span>
</template>
</el-table-column>
<el-table-column prop="uoloadfileName" label="上传附件">
<template slot-scope="scope">
<div v-if="!scope.row.id&&showBtns" class="importTemp-com">
<el-upload <el-upload
ref="upload" ref="upload"
class="upload-demo" class="upload-demo"
...@@ -71,6 +81,7 @@ ...@@ -71,6 +81,7 @@
<script> <script>
import { post } from '@/utils/http' import { post } from '@/utils/http'
import { downFileByFileId } from '@/api/file'
export default { export default {
name: 'BiographicDataUpload', name: 'BiographicDataUpload',
componentName: '履历本上传附件', componentName: '履历本上传附件',
...@@ -85,7 +96,6 @@ export default { ...@@ -85,7 +96,6 @@ export default {
loading: false, loading: false,
showBtns: false, showBtns: false,
tableData: [], tableData: [],
contentTypeOptions: [],
tools: [{ tools: [{
name: '新增', name: '新增',
icon: '/icons/c-add.png', icon: '/icons/c-add.png',
...@@ -107,20 +117,28 @@ export default { ...@@ -107,20 +117,28 @@ export default {
} }
}], }],
extension: [], extension: [],
options: [],
currentSelection: [] currentSelection: []
} }
}, },
computed: { computed: {
contentTypeOptions() {
if (this.basicData.subTypeName === 'BiographicData') {
return this.options.filter(item => item.value !== 'AirworthinessLabelOrCertificate')
} else if (this.basicData.subTypeName === 'ProductCertificate') {
return this.options.filter(item => item.value === 'briefTechnicalPerformance' || item.value === 'acceptanceCertificate' || item.value === 'match' || item.value === 'lifeAndReliability')
} else {
return this.options.filter(item => item.value === 'AirworthinessLabelOrCertificate')
}
}
}, },
watch: { watch: {
basicData: { 'basicData.id': {
immediate: true, immediate: true,
deep: true, deep: true,
handler(val) { handler(val) {
if (val && val.subTypeName) { if (val) {
this.getDicData()
}
if (val && val.objFileLinks) {
this.$nextTick(() => { this.$nextTick(() => {
this.getTableData() this.getTableData()
}) })
...@@ -129,36 +147,65 @@ export default { ...@@ -129,36 +147,65 @@ export default {
} }
}, },
created() { created() {
this.getDicData()
}, },
mounted() { mounted() {
}, },
methods: { methods: {
getDicData() { getDicData() {
this.$utils.getDicListByCode('resumeBookConentType').then(res => { this.$utils.getDicListByCode('resumeBookConentType').then(res => {
if (this.basicData.subTypeName === 'BiographicData') { this.options = res
this.contentTypeOptions = res.filter(item => item.value !== 'AirworthinessLabelOrCertificate')
} else if (this.basicData.subTypeName === 'ProductCertificate') {
this.contentTypeOptions = res.filter(item => item.value === 'briefTechnicalPerformance' || item.value === 'acceptanceCertificate' || item.value === 'match' || item.value === 'lifeAndReliability')
} else {
this.contentTypeOptions = res.filter(item => item.value === 'AirworthinessLabelOrCertificate')
}
}) })
}, },
getTableData() { getTableData() {
const params = {
'pageFrom': 1,
'pageSize': 1,
'searchItems': {
'items': [
{
'fieldName': 'id',
'operator': 'EQ',
'value': this.basicData.id
}
]
},
'sortItem': [
{
'fieldName': 'modifyTime',
'sortOrder': 'asc'
}
],
'openProps': [
{
'name': 'objFileLinks',
'openProps': [
{
'name': 'target'
}
]
}
]
}
this.loading = true
this.$api.searchApi('BiographicData', params).then(res => {
this.tableData = [] this.tableData = []
if (this.basicData.objFileLinks.length) { if (res.items && res.items.content && res.items.content[0] && res.items.content[0].objFileLinks) {
this.basicData.objFileLinks.map(item => { res.items.content[0].objFileLinks.map(item => {
if (item.target && item.target.originalFileName) { if (item.target && item.target.originalFileName) {
this.tableData.push({ this.tableData.push({
id: item.id, ...item,
fileName: item.target.originalFileName, fileName: item.target.originalFileName,
fileListRaw: item, contentType: this.$utils.getParamsFromLists(this.options, 'value', item.contentType, 'label')
contentType: this.$utils.getParamsFromLists(this.contentTypeOptions, 'value', item.contentType, 'label')
}) })
} }
}) })
} }
this.loading = false
}).catch(() => {
this.loading = false
})
}, },
handleAdd() { handleAdd() {
this.tableData.push({ this.tableData.push({
...@@ -178,27 +225,29 @@ export default { ...@@ -178,27 +225,29 @@ export default {
} }
}, },
fileChange(fileList, scope) { fileChange(fileList, scope) {
// console.log('scope: ', scope)
// console.log('fileList: ', fileList)
this.showBtns = true this.showBtns = true
this.$set(scope.row, 'fileName', fileList.name) this.$set(scope.row, 'fileName', fileList.name)
this.$set(scope.row, 'fileListRaw', fileList.raw) this.$set(scope.row, 'fileListRaw', fileList.raw)
}, },
submitUpload() { submitUpload() {
const flag = this.tableData.find(item => !item.fileName || !item.contentType)
if (flag) return this.$utils.showMessageWarning('请完成列表内数据的填写!')
this.loading = true this.loading = true
const fileExtVOS = [] const fileExtVOS = [] // 新增文件的名称和附件类型
const objFileLinkIds = [] // 已有的文件
const formData = new FormData() const formData = new FormData()
this.tableData.forEach(row => { this.tableData.forEach(row => {
if (!row.id) {
formData.append('multipartFiles', row.fileListRaw) // 新增文件
fileExtVOS.push({ fileExtVOS.push({
'fileName': row.fileName, 'fileName': row.fileName,
'contentType': row.contentType 'contentType': row.contentType
}) })
if (row.fileListRaw.id) {
formData.append('multipartFiles', new Blob([JSON.stringify(row.fileListRaw)], { type: 'application/json' }))
} else { } else {
formData.append('multipartFiles', row.fileListRaw) objFileLinkIds.push(row.id)
} }
}) })
formData.append('objFileLinkIds', new Blob([JSON.stringify(objFileLinkIds)], { type: 'application/json' }))
formData.append('fileExtVOS', new Blob([JSON.stringify(fileExtVOS)], { type: 'application/json' })) formData.append('fileExtVOS', new Blob([JSON.stringify(fileExtVOS)], { type: 'application/json' }))
post(`/BiographicData/uploadMultiFile/${this.basicData.id}`, formData) post(`/BiographicData/uploadMultiFile/${this.basicData.id}`, formData)
.then((res) => { .then((res) => {
...@@ -208,16 +257,34 @@ export default { ...@@ -208,16 +257,34 @@ export default {
}) })
this.loading = false this.loading = false
this.handleClose() this.handleClose()
this.$emit('getList')
this.$emit('uploadSuccess', res)
}) })
.catch((res) => { .catch((res) => {
this.loading = false this.loading = false
this.$message({
message: res.message,
type: 'error'
}) })
},
loadFile(val) {
downFileByFileId(val.sourceIdType, val.sourceId, val.id).then(res => {
this.downLoadFileUrl(res)
})
},
downLoadFileUrl(res) {
if (res.headers['content-disposition']) {
const fileName = decodeURI(res.headers['content-disposition'].substring(res.headers['content-disposition'].indexOf('=') + 1, res.headers['content-disposition'].length))
const url = window.URL.createObjectURL(new Blob([res.data], { type: res.headers['content-type'] }))
this.$utils.downLoadFileUrl(url, decodeURI(fileName))
} else {
if (res.data instanceof Blob) {
var reader = new FileReader()
reader.addEventListener('loadend', () => {
const message = reader.result && JSON.parse(reader.result)
this.$utils.showMessageWarning(message ? message.message : '数据包下载出错:未找到数据包内容的下载链接,请联系管理员排查问题!')
}) })
reader.readAsText(res.data, 'utf-8')
} else {
const message = res.data && res.data.message
this.$utils.showMessageWarning(message || '数据包下载出错:未找到数据包内容的下载链接,请联系管理员排查问题!')
}
}
}, },
handleClose() { handleClose() {
this.showBtns = false this.showBtns = false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment