Browse Source

档案管理 - 附件/list操作

master
xuhuajiao 3 years ago
parent
commit
63770b0a65
  1. 9
      src/api/archivesManage/archivesList.js
  2. 13
      src/assets/styles/archives-manage.scss
  3. 15
      src/utils/index.js
  4. 10
      src/utils/upload.js
  5. 25
      src/views/archivesManage/archivesList/index.vue
  6. 24
      src/views/archivesManage/archivesList/module/archivesAnjuan/index.vue
  7. 10
      src/views/archivesManage/archivesList/module/archivesInfo/index.vue
  8. 35
      src/views/archivesManage/archivesList/module/archivesJuannei/index.vue
  9. 215
      src/views/archivesManage/archivesList/module/uploadFile/index.vue

9
src/api/archivesManage/archivesList.js

@ -87,6 +87,15 @@ export function FetchInitArchiveFilesView(params) {
})
}
// 上传档案附件
export function FetchUploadFile(parameter) {
return request({
url: 'api/archives/uploadFile',
method: 'post',
data: parameter
})
}
// 编辑附件
export function FetchEditFile(parameter) {
return request({

13
src/assets/styles/archives-manage.scss

@ -540,3 +540,16 @@ $arcCyan: #0FBED9;
overflow: hidden;
overflow-y: scroll;
}
.upload-btn{
position: relative;
margin-right: 10px;
overflow: hidden;
#upFile{
position: absolute;
left: 0;
top: 0;
opacity: 0;
height: 34px;
}
}

15
src/utils/index.js

@ -390,8 +390,7 @@ export function downloadFile(obj, name, suffix) {
// new - 导出 - TEST
export function exportFile(StingParams, fileName) {
const baseURL = process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_API : 'http://192.168.99.84:7070/'
const url = baseURL + StingParams
const url = StingParams
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
@ -401,3 +400,15 @@ export function exportFile(StingParams, fileName) {
link.click()
document.body.removeChild(link)
}
// 获取当前日期时间
export function getCurrentTime() {
const yy = new Date().getFullYear()
const mm = new Date().getMonth() + 1
const dd = new Date().getDate()
const hh = new Date().getHours()
const mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
const ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
const time = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss
return time
}

10
src/utils/upload.js

@ -9,3 +9,13 @@ export function upload(api, file) {
}
return axios.post(api, data, config)
}
export function archivesUpload(api, file, categoryId) {
var data = new FormData()
data.append('file', file)
data.append('categoryId', categoryId)
const config = {
headers: { 'Authorization': getToken() }
}
return axios.post(api, data, config)
}

25
src/views/archivesManage/archivesList/index.vue

@ -244,11 +244,34 @@ export default {
this.$refs.anjuan.getTableList()
})
},
getSelections(data) {
getSelections(data, selectData) {
if (selectData) {
if (selectData.length > 1 || selectData.length === 0) {
this.anjuanSelection = {}
this.$refs.file.junneiData = []
} else if (selectData.length === 1) {
this.anjuanSelection = selectData[0]
this.$nextTick(() => {
if (this.$refs.file) {
this.$refs.file.getTableList()
}
})
} else {
this.anjuanSelection = data
this.$nextTick(() => {
if (this.$refs.file) {
this.$refs.file.getTableList()
}
})
}
} else {
this.anjuanSelection = data
this.$nextTick(() => {
if (this.$refs.file) {
this.$refs.file.getTableList()
}
})
}
},
//
handleIntellNodeClick(val) {

24
src/views/archivesManage/archivesList/module/archivesAnjuan/index.vue

@ -36,7 +36,8 @@
</div>
<div class="archives-handler-btn">
<!-- 装盒btn 多选 -->
<el-button class="packing-btn iconfont icon-weibiaoti-2" type="primary" :disabled="selections.length === 0" @click="handlePacking(selections)">装盒</el-button>
<!-- <svg-icon icon-class="zhuanghe" /> -->
<el-button class="packing-btn iconfont icon-sr-dn-pz" type="primary" :disabled="selections.length === 0" @click="handlePacking(selections)">装盒</el-button>
<!-- 分卷装盒btn 针对案卷-单选 -->
<el-button v-if="selectedCategory.isType === 3" class="part-btn iconfont icon-weibiaoti-2" type="primary" :disabled="selections.length !== 1" @click="handlePartPacking(selections)">分卷装盒</el-button>
<!-- <el-button class="warehousing-btn iconfont icon-weibiaoti-2" type="primary">入库</el-button> -->
@ -179,6 +180,7 @@
import qs from 'qs'
import { del, FetchTableDisplayFields, FetchInitArchivesView, FetchFormDisplayFields, FetchArchivesDetails, FetchArchivesMetadata } from '@/api/archivesManage/archivesList'
import { header, form } from '@crud/crud'
import { mapGetters } from 'vuex'
import { exportFile } from '@/utils/index'
// import { initData } from '@/api/data'
// import crudOperation from '@crud/CRUD.operation'
@ -271,6 +273,11 @@ export default {
archivesDetailsMetadata: ''
}
},
computed: {
...mapGetters([
'baseApi'
])
},
watch: {
selectedCategory: function(newValue, oldValue) {
},
@ -293,8 +300,9 @@ export default {
methods: {
doExport(fileName = '未知文件') {
this.crud.downloadLoading = true
console.log(this.selectedCategory)
if (this.selectedCategory.pid !== '0') {
this.parentsId = this.categoryId
this.parentsId = this.selectedCategory.pid
} else {
this.parentsId = null
}
@ -302,7 +310,8 @@ export default {
'categoryId': this.selectedCategory.id,
'parentsId': this.parentsId
}
exportFile('api/archives/exportArchives?' + qs.stringify(params))
console.log(params)
exportFile(this.baseApi + '/api/archives/exportArchives?' + qs.stringify(params))
this.crud.downloadLoading = false
},
// -select
@ -413,8 +422,12 @@ export default {
},
// table - row
clickRowHandler(row) {
// this.$refs.table.toggleRowSelection(row)
this.$emit('getSelections', row)
this.$refs.table.clearSelection()
this.$refs.table.toggleRowSelection(row)
this.selections = this.crud.selections
this.isAnjuan = this.crud.selections.length !== 1
this.$emit('getJnInAjBtnState', this.isAnjuan)
this.$emit('getSelections', row, null)
},
//
handleCurrentChange(selection, row) {
@ -422,6 +435,7 @@ export default {
// -btn-
this.isAnjuan = selection.length !== 1
this.$emit('getJnInAjBtnState', this.isAnjuan)
this.$emit('getSelections', row, selection)
},
//
toDelete(data) {

10
src/views/archivesManage/archivesList/module/archivesInfo/index.vue

@ -20,7 +20,7 @@
</el-row>
</div>
<!-- 附件 -->
<UploadFile v-if="archivesTabIndex==1" class="item-content" :is-upload-detail="false" />
<UploadFile v-if="archivesTabIndex==1 " class="item-content" :is-upload-detail="false" />
<!-- 元数据 -->
<div v-if="archivesTabIndex==2" class="item-content">
<pre v-highlightjs="xml_show">
@ -59,6 +59,12 @@ export default {
default: function() {
return ''
}
},
doubleCurrentRow: {
type: Object,
default: function() {
return {}
}
}
},
data() {
@ -106,7 +112,7 @@ export default {
}
return output.join('')
},
// ---xml--
// xml
showXml(str) {
var that = this
var text = str

35
src/views/archivesManage/archivesList/module/archivesJuannei/index.vue

@ -10,7 +10,7 @@
<!-- 删除btn 多选 -->
<el-button v-permission="permission.del" icon="el-icon-delete" size="mini" :loading="crud.delAllLoading" :disabled="selections.length === 0" @click="toDelete(selections)">删除</el-button>
<!-- 导出btn :disabled="!crud.data.length" -->
<el-button v-permission="permission.download" :loading="crud.downloadLoading" size="mini" icon="el-icon-download" @click="doExport">导出</el-button>
<el-button v-permission="permission.download" :disabled="isAnjuan" :loading="crud.downloadLoading" size="mini" icon="el-icon-download" @click="doExport">导出</el-button>
<!-- 上传附件btn 针对卷内/文件 单选 -->
<el-button :disabled="selections.length !== 1" size="mini" icon="el-icon-download" @click="uploadFile">上传附件</el-button>
</div>
@ -122,17 +122,14 @@
</el-card>
<!-- 档案详情 -->
<ArchivesInfo ref="archivesInfo" :archives-details-data="archivesDetailsData" :archives-details-metadata.sync="archivesDetailsMetadata" />
<ArchivesInfo ref="archivesInfo" :is-has-file="true" :archives-details-data="archivesDetailsData" :archives-details-metadata.sync="archivesDetailsMetadata" />
<!-- 上传附件 -->
<el-dialog class="upload-dialog" :modal-append-to-body="false" :close-on-click-modal="false" :before-close="handleClose" :visible.sync="uploadFileVisible" title="上传附件">
<span class="dialog-right-top" />
<span class="dialog-left-bottom" />
<div class="setting-dialog">
<UploadFile ref="uploadFile" />
<div slot="footer" class="dialog-footer">
<el-button :loading="crud.status.cu === 2" type="primary" @click="uploadFileSave">保存</el-button>
</div>
<UploadFile ref="uploadFile" :category-id="categoryId" :arc-id="arcId" />
</div>
</el-dialog>
</div>
@ -142,6 +139,7 @@
import qs from 'qs'
import { del, FetchTableDisplayFields, FetchInitArchivesView, FetchFormDisplayFields, FetchArchivesDetails, FetchArchivesMetadata } from '@/api/archivesManage/archivesList'
import { header, form } from '@crud/crud'
import { mapGetters } from 'vuex'
import { exportFile } from '@/utils/index'
// import { initData } from '@/api/data'
// import crudOperation from '@crud/CRUD.operation'
@ -229,9 +227,15 @@ export default {
totalSumAll: 0,
yearGroup: [],
archivesDetailsData: [],
archivesDetailsMetadata: ''
archivesDetailsMetadata: '',
doubleCurrentRow: null
}
},
computed: {
...mapGetters([
'baseApi'
])
},
watch: {
selectedCategory: function(newValue, oldValue) {
this.setCategory = newValue
@ -257,16 +261,16 @@ export default {
methods: {
doExport(fileName = '未知文件') {
this.crud.downloadLoading = true
if (this.selectedCategory.pid !== '0') {
this.parentsId = this.selectedCategory.pid
if (this.selectedCategory.isType !== 4) {
this.parentsId = this.anjuanSelection.id
} else {
this.parentsId = null
}
const params = {
'categoryId': this.selectedCategory.id,
'categoryId': this.categoryId,
'parentsId': this.parentsId
}
exportFile('api/archives/exportArchives?' + qs.stringify(params))
exportFile(this.baseApi + '/api/archives/exportArchives?' + qs.stringify(params))
this.crud.downloadLoading = false
},
// -select
@ -366,6 +370,8 @@ export default {
tableDoubleClick(row) {
this.$refs.archivesInfo.archivesInfoVisible = true
this.$refs.archivesInfo.archivesTabIndex = 0
this.doubleCurrentRow = row
console.log(this.selectedCategory)
const params = {
categoryId: this.categoryId,
archivesId: row.id
@ -436,9 +442,10 @@ export default {
//
uploadFile() {
this.uploadFileVisible = true
},
uploadFileSave() {
this.uploadFileVisible = false
this.arcId = this.selections[0].id
this.$nextTick(() => {
this.$refs.uploadFile.getFileList()
})
}
}
}

215
src/views/archivesManage/archivesList/module/uploadFile/index.vue

@ -3,14 +3,18 @@
<!-- 上传附件curd -->
<div v-if="isUploadDetail" class="upload-curd">
<!-- <el-button icon="el-icon-plus">新增</el-button> -->
<el-upload
<!-- <el-upload
class="upload-demo"
action="#"
:on-preview="handlePreview"
:file-list="fileList"
>
<el-button icon="el-icon-plus" size="small" type="primary">新增</el-button>
</el-upload>
</el-upload> -->
<div class="upload-btn">
<el-button icon="el-icon-plus" size="small" type="primary">添加</el-button>
<input id="upFile" type="file" name="upFile" @change="changeFile($event)">
</div>
<el-button icon="el-icon-delete" :disabled="selections.length === 0" @click="toDelete(selections)">删除</el-button>
<el-button icon="el-icon-sort" @click="sortVisible = true">排序</el-button>
</div>
@ -26,21 +30,22 @@
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="fileName" label="文件名称" min-width="140" align="center" />
<el-table-column prop="fileFormat" label="格式" min-width="60" align="center" />
<el-table-column prop="fileSize" label="大小" min-width="85" align="center" />
<el-table-column prop="fileDpi" label="分辨率" min-width="85" align="center" />
<el-table-column prop="fileCover" label="缩览图" min-width="60" align="center">
<el-table-column prop="file_name" label="文件名称" min-width="140" align="center" />
<el-table-column prop="file_type" label="格式" min-width="60" align="center" />
<el-table-column prop="file_size" label="大小" min-width="85" align="center" />
<el-table-column prop="file_dpi" label="分辨率" min-width="85" align="center" />
<el-table-column prop="file_thumbnail" label="缩览图" min-width="60" align="center">
<template slot-scope="scope">
<div v-if="scope.row.fileCover">
<img width="60px" height="32px" class="screenshot" :src="scope.row.fileCover" @click="showCoverVisible=true">
<div v-if="scope.row.file_thumbnail">
<img width="60px" height="32px" class="screenshot" :src="scope.row.file_thumbnail" @click="showCoverVisible=true">
</div>
</template>
</el-table-column>
<el-table-column prop="create_date" label="创建时间" min-width="100" align="center" />
<el-table-column v-if="!isUploadDetail" label="操作" min-width="100" align="center">
<template>
<el-button class="file-down iconfont icon-weibiaoti-2">下载</el-button>
<el-table-column prop="create_time" label="创建时间" min-width="100" align="center" />
<!-- v-if="!isUploadDetail" -->
<el-table-column label="操作" min-width="100" align="center">
<template slot-scope="scope">
<el-button class="file-down iconfont icon-weibiaoti-2" @click="downloadFile(scope.row)">下载</el-button>
</template>
</el-table-column>
</el-table>
@ -87,9 +92,13 @@
</template>
<script>
import { FetchInitArchiveFilesView, FetchEditFile, FetchDeleteFile } from '@/api/archivesManage/archivesList'
import { archivesUpload } from '@/utils/upload'
import { getCurrentTime } from '@/utils/index'
import { mapGetters } from 'vuex'
import { form } from '@crud/crud'
import Sortable from 'sortablejs'
import data from '../data.json'
// import data from '../data.json'
export default {
name: 'UploadFile',
components: {},
@ -100,31 +109,156 @@ export default {
isUploadDetail: {
type: Boolean,
default: true
},
categoryId: {
type: String,
default: function() {
return ''
}
},
arcId: {
type: String,
default: function() {
return ''
}
}
},
data() {
return {
tableData: [],
tableData: [], // list
selections: [],
showCoverVisible: false,
fileList: [], // list
sortVisible: false, //
sortTableData: [],
deleteVisible: false,
deleteData: []
showCoverVisible: false, // dialog
sortVisible: false, // dialog
sortTableData: [], // table
deleteVisible: false, // dialog
deleteData: [], // data
file: null, // change
fileNames: '', // - name
formatType: '', // - type
postfix: '', // -
fileSize: '',
filePath: '',
px: '',
fileBase64: '',
nowDate: ''
}
},
created() {
this.tableData = data.data
computed: {
...mapGetters([
'baseApi'
])
},
watch: {
arcId: function(newValue, oldValue) {
}
},
methods: {
//
handlePreview(file) {
console.log(file)
async changeFile(e) {
this.file = e.target.files[0]
this.fileSize = this.file.size
this.formatType = this.file.type.substring(0, this.file.type.indexOf('/'))
this.fileNames = this.file.name
this.postfix = this.file.name.substring(
this.fileNames.lastIndexOf('.') + 1,
this.fileNames.length
)
console.log(this.postfix)
// this.fileSize = (this.file.size / 1024).toFixed(2) + 'kB'
if (this.formatType === 'image') {
this.fileBase64 = await this.getBase64(this.file)
const res = await this.getImgPx(this.fileBase64)
this.px = res.width + 'px*' + res.height + 'px'
} else {
this.px = ''
}
//
archivesUpload(this.baseApi + '/api/archives/uploadFile', this.file, this.categoryId).then(res => {
console.log(res.data)
if (res.data.code === 200) {
this.filePath = res.data.data
this.uploadSave()
}
})
},
uploadSave() {
this.nowDate = getCurrentTime()
const json = {
'file_name': this.fileNames,
'file_size': this.fileSize,
'file_type': this.postfix,
'file_path': this.filePath,
'sequence': null,
'archive_id': this.arcId,
'file_dpi': this.px,
'file_thumbnail': '',
'create_time': this.nowDate,
'id': null
}
console.log(json)
const arrayUpload = []
arrayUpload.push(json)
const params = {
'categoryId': this.categoryId,
'jsonString': JSON.stringify(arrayUpload)
}
FetchEditFile(params).then(data => {
this.$notify({
title: '上传附件成功',
type: 'success',
duration: 2500
})
this.crud.refresh()
this.getFileList()
})
},
// base64
getBase64(file) {
const reader = new FileReader()
reader.readAsDataURL(file)
return new Promise((resolve) => {
reader.onload = () => {
resolve(reader.result)
}
})
},
//
getImgPx(img) {
const image = new Image()
image.src = img
return new Promise((resolve) => {
image.onload = () => {
const width = image.width
const height = image.height
resolve({ width, height })
}
})
},
// list
getFileList() {
const params = {
'categoryId': this.categoryId,
'archiveId': this.arcId
}
FetchInitArchiveFilesView(params).then(data => {
this.tableData = data.returnlist
})
},
downloadFile(row) {
console.log(row.file_path)
const url = this.baseApi + '/downloadFile' + row.file_path
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('target', '_blank')
link.setAttribute('download', 'testFile')
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
},
//
toDelete(data) {
console.log(data)
this.deleteData = data
this.deleteVisible = true
},
@ -135,20 +269,21 @@ export default {
this.deleteData.forEach(val => {
ids.push(val.id)
})
// const params = {
// 'ids': ids,
// 'categoryId': this.selectedCategory.id
// }
const params = {
'ids': ids,
'categoryId': this.categoryId
}
// fetch
// del(params).then(res => {
// this.crud.delAllLoading = false
// this.$notify({
// title: '',
// type: 'success',
// duration: 2500
// })
// this.crud.refresh()
// })
FetchDeleteFile(params).then(res => {
this.crud.delAllLoading = false
this.$notify({
title: '删除成功',
type: 'success',
duration: 2500
})
this.crud.refresh()
this.getFileList()
})
},
// -
rowDrop(className, targetName) {

Loading…
Cancel
Save