Browse Source

优化展示及字段,添加更新上传接口

master
李磊 3 years ago
parent
commit
43a156b580
  1. 13
      src/api/common.js
  2. 55
      src/views/document/index.vue

13
src/api/common.js

@ -209,4 +209,15 @@ export function uploadFileFn(params) {
data: params,
responseType: 'blob'
})
}
}
export function updateInspectionSystemFile(params) {
return preview({
url: '/inspectionSystemFile',
method: 'put',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: params,
responseType: 'blob'
})
}

55
src/views/document/index.vue

@ -38,18 +38,18 @@
<el-table-column
slot="operation"
align="center"
width="100"
width="200"
label="操作"
>
<template slot-scope="scope">
<el-button type="text" @click="downLoad(scope.row)">
在线预览
预览
</el-button>
<el-button type="text" @click="downLoadFn(scope.row)">
下载
</el-button>
<el-button type="text" @click="checkHistory(scope.row)">
查看历史版本
历史
</el-button>
</template>
</el-table-column>
@ -57,10 +57,10 @@
<pagination />
<el-dialog title="查看历史版本" :visible.sync="dialogTableVisible">
<el-table :data="gridData">
<el-table-column property="inspectionSystemFileId" label="文件ID" />
<el-table-column :formatter="formatterFlowName" property="flowname" label="操作环节" />
<el-table-column property="filename" label="文件名称" />
<el-table-column property="suffix" label="文件后缀" />
<el-table-column property="updateTime" label="更新时间" />
<el-table-column :formatter="formatter.getChineseName" property="createBy" label="创建人" />
<el-table-column property="createTime" label="创建时间" />
</el-table>
<el-pagination
:page-size="params.pageSize"
@ -78,7 +78,7 @@ import Query from '@/components/Crud/Query'
import CustomTable from '@/components/Crud/Table'
import Pagination from '@/components/Crud/Pagination'
import CrudDocumentArchives from '@/api/document_archives'
import { uploadFileFn } from '@/api/common'
import { uploadFileFn, updateInspectionSystemFile } from '@/api/common'
import { downloadFileUrl } from '@/utils'
import download from 'downloadjs'
// crudpresenter
@ -104,11 +104,7 @@ export default {
{ prop: 'filename', label: '文件名', align: 'center' },
{ prop: 'createBy', label: '创建人', align: 'center', formatter: this.formatter.getChineseName },
{ prop: 'createTime', label: '创建时间', align: 'center' },
{
prop: 'suffix',
label: '文件名后缀',
align: 'center'
},
{ prop: 'updateBy', label: '更新人', align: 'center', formatter: this.formatter.getChineseName },
{
prop: 'updateTime',
label: '更新时间',
@ -130,7 +126,7 @@ export default {
},
gridData: [],
subTotal: 0,
url: process.env.VUE_APP_PREVIEW_API + process.env.VUE_APP_PROJECT_NAME
url: process.env.VUE_APP_PREVIEW_API + process.env.VUE_APP_PROJECT_NAME + '/inspectionSystemFile'
}
},
mounted() {
@ -170,12 +166,25 @@ export default {
},
// EXCEL
beforeUpload(file) {
if (this.$refs.customTable.$refs.table.selection.length > 1) {
this.$notify.warning('请选择单份体系文件进行更新上传!')
return false
}
const fd = new FormData()
fd.append('file', file)
uploadFileFn(fd).then(() => {
this.$notify.success('导入数据成功。')
this.crud.toQuery()
})
if (this.$refs.customTable.$refs.table.selection.length) {
fd.append('id', this.$refs.customTable.$refs.table.selection[0].id)
updateInspectionSystemFile(fd).then(() => {
this.$notify.success('体系更新成功。')
this.crud.toQuery()
})
} else {
uploadFileFn(fd).then(() => {
this.$notify.success('体系上传成功。')
this.crud.toQuery()
})
}
return false
},
downLoad(item) {
downloadFileUrl(this.url + '/' + item.id + item.suffix, item.filename, item.suffix)
@ -188,6 +197,18 @@ export default {
},
closeReportDialog() {
this.$refs['reportForm'].resetFields()
},
formatterFlowName(row, column, cellValue) {
switch (cellValue) {
case 0:
return '保存'
case 1:
return '更新'
case 2:
return '删除'
default:
break
}
}
}
}

Loading…
Cancel
Save