|
|
|
|
@ -1,45 +1,66 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<Modal
|
|
|
|
|
<Drawer
|
|
|
|
|
ref="dialog"
|
|
|
|
|
width="600px"
|
|
|
|
|
placement="right"
|
|
|
|
|
v-model="isShow"
|
|
|
|
|
title="附件"
|
|
|
|
|
:footer-hide="true"
|
|
|
|
|
>
|
|
|
|
|
<el-upload
|
|
|
|
|
style="width: 400px"
|
|
|
|
|
ref="upload"
|
|
|
|
|
multiple
|
|
|
|
|
:on-success="successHandle"
|
|
|
|
|
:before-upload="uploadBefore"
|
|
|
|
|
:before-remove="beforeRemove"
|
|
|
|
|
accept=".jpg,.jpeg,.png,.gif,.PDF,.pdf, .doc, .docx, .xls, .xlsx"
|
|
|
|
|
:action="action"
|
|
|
|
|
:file-list="fileList"
|
|
|
|
|
:on-remove="removeHande"
|
|
|
|
|
:limit="100"
|
|
|
|
|
:headers="{
|
|
|
|
|
Authorization: `Bearer ${getToken()}`,
|
|
|
|
|
}"
|
|
|
|
|
>
|
|
|
|
|
<template #file="{ file }">
|
|
|
|
|
<div style="display: flex;align-items: center;">
|
|
|
|
|
<i :style="{ 'color': file.status === 'success' ? 'green' : '' }" :class="{ 'el-icon-circle-check': file.status === 'success','el-icon-loading': file.status === 'uploading' }"></i>
|
|
|
|
|
<a href="javascript:" style="flex: 1;margin-left: 6px;" @click="openDownload(file)">{{ file.name }}</a>
|
|
|
|
|
<i class="el-icon-close" @click="deleteFile(file)"></i>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<el-button slot="trigger" size="small" type="primary"
|
|
|
|
|
>选取文件
|
|
|
|
|
</el-button
|
|
|
|
|
>
|
|
|
|
|
<div slot="tip" class="el-upload__tip">
|
|
|
|
|
<br/>单个文件不能超过50M
|
|
|
|
|
</div>
|
|
|
|
|
</el-upload>
|
|
|
|
|
<div style="display: flex;align-items: center;">
|
|
|
|
|
<el-select size="small" collapse-tags style="width: 200px;" filterable allow-create clearable v-model="filterTag" placeholder="标签" multiple>
|
|
|
|
|
<el-option v-for="item in ['工程类','资产类']" :value="item" :label="item">
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
<Button type="primary" style="margin-left: 10px;" @click="isShowModal = true">新增</Button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Table :data="fileList" :columns="table">
|
|
|
|
|
<Table stripe style="margin-top: 20px;" size="small" :data="fileData" :columns="table">
|
|
|
|
|
</Table>
|
|
|
|
|
</Drawer>
|
|
|
|
|
|
|
|
|
|
<Modal title="新增附件" width="580px" v-model="isShowModal" @on-ok="submit">
|
|
|
|
|
<el-form size="small" label-width="100px">
|
|
|
|
|
<el-form-item label="年份选择">
|
|
|
|
|
<el-date-picker v-model="form.year" value-format="yyyy" style="width: 300px;" placeholder="年份选择" type="year"></el-date-picker>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="年限信息">
|
|
|
|
|
<el-input v-model="form.nianxian" style="width: 300px;" placeholder="年限信息"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="标签">
|
|
|
|
|
<el-select style="width: 300px;" filterable allow-create clearable v-model="form.tag" placeholder="标签">
|
|
|
|
|
<el-option v-for="item in ['工程类','资产类']" :value="item" :label="item">
|
|
|
|
|
</el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="附件">
|
|
|
|
|
<el-upload
|
|
|
|
|
style="width: 400px"
|
|
|
|
|
ref="upload"
|
|
|
|
|
multiple
|
|
|
|
|
:on-success="successHandle"
|
|
|
|
|
:before-upload="uploadBefore"
|
|
|
|
|
:before-remove="beforeRemove"
|
|
|
|
|
accept=".jpg,.jpeg,.png,.gif,.PDF,.pdf, .doc, .docx, .xls, .xlsx"
|
|
|
|
|
:action="action"
|
|
|
|
|
:file-list="fileList"
|
|
|
|
|
:on-remove="removeHande"
|
|
|
|
|
:limit="100"
|
|
|
|
|
:headers="{
|
|
|
|
|
Authorization: `Bearer ${getToken()}`,
|
|
|
|
|
}"
|
|
|
|
|
>
|
|
|
|
|
<el-button slot="trigger" size="small" type="primary"
|
|
|
|
|
>选取文件
|
|
|
|
|
</el-button
|
|
|
|
|
>
|
|
|
|
|
<div slot="tip" class="el-upload__tip">
|
|
|
|
|
<br/>单个文件不能超过50M
|
|
|
|
|
</div>
|
|
|
|
|
</el-upload>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
</Modal>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
@ -52,25 +73,45 @@ export default {
|
|
|
|
|
props: {},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
filterTag: [],
|
|
|
|
|
isShowModal: false,
|
|
|
|
|
table: [
|
|
|
|
|
{
|
|
|
|
|
key: 'original_name',
|
|
|
|
|
title: '文件名称',
|
|
|
|
|
render: (h, { row }) => (h('span',row.response?.original_name))
|
|
|
|
|
width: 180,
|
|
|
|
|
render: (h, { row }) => (h('div',[
|
|
|
|
|
h('a',{ class: 'original-name-a', on: { click: () => this.openDownload(row) } },row.response?.original_name)
|
|
|
|
|
]))
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'tag',
|
|
|
|
|
title: "标签"
|
|
|
|
|
title: "标签",
|
|
|
|
|
align: 'center',
|
|
|
|
|
render: (h, { row }) => (h('Tag',{
|
|
|
|
|
props: {
|
|
|
|
|
color: 'primary'
|
|
|
|
|
}
|
|
|
|
|
},row.response?.tag))
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'year',
|
|
|
|
|
title: '年份',
|
|
|
|
|
align: 'center',
|
|
|
|
|
render: (h, { row }) => (h('span',row.response?.year))
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'year',
|
|
|
|
|
key: 'nianxian',
|
|
|
|
|
title: '年限',
|
|
|
|
|
align: 'center',
|
|
|
|
|
render: (h, { row }) => (h('span',row.response?.nianxian))
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'btns',
|
|
|
|
|
title: '操作',
|
|
|
|
|
render: (h,{ row }) => (h('div',[
|
|
|
|
|
h('Button',{ props: { type: 'error',size: 'small' },on: { click: ()=>this.deleteFile(row) } },'删除')
|
|
|
|
|
]))
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
isShow: false,
|
|
|
|
|
@ -78,9 +119,12 @@ export default {
|
|
|
|
|
type: '',
|
|
|
|
|
action: process.env.VUE_APP_UPLOAD_API,
|
|
|
|
|
fileList: [],
|
|
|
|
|
lists: [],
|
|
|
|
|
|
|
|
|
|
form: {
|
|
|
|
|
file: []
|
|
|
|
|
year: '',
|
|
|
|
|
tag: '',
|
|
|
|
|
nianxian: '',
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
name: [
|
|
|
|
|
@ -114,7 +158,9 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
init() {
|
|
|
|
|
this.form = {
|
|
|
|
|
file: []
|
|
|
|
|
year: '',
|
|
|
|
|
tag: '',
|
|
|
|
|
nianxian: '',
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
setId(id) {
|
|
|
|
|
@ -152,8 +198,6 @@ export default {
|
|
|
|
|
//上传
|
|
|
|
|
successHandle(response, file, fileList) {
|
|
|
|
|
this.fileList = fileList
|
|
|
|
|
|
|
|
|
|
this.submit(response)
|
|
|
|
|
},
|
|
|
|
|
removeHande(file, fileList) {
|
|
|
|
|
this.fileList = fileList
|
|
|
|
|
@ -190,47 +234,49 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
this.fileList = res.data.map((item) => {
|
|
|
|
|
this.lists = res.data.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
name: item.original_name,
|
|
|
|
|
url: item.url,
|
|
|
|
|
response: item
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
this.$integrateData(this.form, res)
|
|
|
|
|
console.log(this.fileList)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
submit(response) {
|
|
|
|
|
submit() {
|
|
|
|
|
save({
|
|
|
|
|
table_name: 'asset_file_files',
|
|
|
|
|
file_id: response.id,
|
|
|
|
|
file_id: this.fileList[0]?.response?.id,
|
|
|
|
|
[/\/land/g.test(this.$route.path) ? 'land_id' : 'house_id']: this.id,
|
|
|
|
|
name: response.name,
|
|
|
|
|
original_name: response.original_name,
|
|
|
|
|
name: this.fileList[0]?.response?.name,
|
|
|
|
|
original_name: this.fileList[0]?.response?.original_name,
|
|
|
|
|
//TODO: 待修改
|
|
|
|
|
url: response.url.replace(/:\/\/:\/\//g, '://')
|
|
|
|
|
url: this.fileList[0]?.response?.url.replace(/:\/\/:\/\//g, '://'),
|
|
|
|
|
...this.form
|
|
|
|
|
}).then(res => {
|
|
|
|
|
this.$message({
|
|
|
|
|
type: 'success',
|
|
|
|
|
message: '附件上传成功'
|
|
|
|
|
})
|
|
|
|
|
this.getDetail()
|
|
|
|
|
this.isShowModal = false
|
|
|
|
|
this.init()
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
openDownload (file) {
|
|
|
|
|
window.open(file.url)
|
|
|
|
|
openDownload (row) {
|
|
|
|
|
window.open(row.url)
|
|
|
|
|
},
|
|
|
|
|
deleteFile (file) {
|
|
|
|
|
deleteFile (row) {
|
|
|
|
|
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (file.response?.id) {
|
|
|
|
|
if (row.response?.id) {
|
|
|
|
|
destroy({
|
|
|
|
|
table_name: "asset_file_files",
|
|
|
|
|
id: file.response.id
|
|
|
|
|
id: row.response.id
|
|
|
|
|
}).then(res => {
|
|
|
|
|
this.$message({
|
|
|
|
|
type: 'success',
|
|
|
|
|
@ -242,6 +288,12 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
fileData () {
|
|
|
|
|
if (this.filterTag.length === 0) return this.lists;
|
|
|
|
|
return this.lists.filter(i => (this.filterTag.find(j => j === i.response?.tag)))
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
isShow(val) {
|
|
|
|
|
if (val) {
|
|
|
|
|
@ -308,4 +360,17 @@ export default {
|
|
|
|
|
::v-deep .el-input__inner {
|
|
|
|
|
text-align: left;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|
<style>
|
|
|
|
|
.original-name-a {
|
|
|
|
|
color: red;
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
transition: all 0.2s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.original-name-a:hover {
|
|
|
|
|
color: red;
|
|
|
|
|
text-decoration: underline;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|