上传文件新增可以拖动
This commit is contained in:
parent
49a4f25a15
commit
75006daec7
@ -6,7 +6,8 @@
|
||||
<el-input v-model="queryParams.fileId" placeholder="请输入文件id" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="">
|
||||
<el-date-picker v-model="dateRangeAddTime" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" placeholder="请选择上传时间"></el-date-picker>
|
||||
<el-date-picker v-model="dateRangeAddTime" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
|
||||
placeholder="请选择上传时间"></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="" prop="storeType">
|
||||
<el-select v-model="queryParams.storeType" placeholder="请选择存储类型" clearable="">
|
||||
@ -41,7 +42,8 @@
|
||||
</el-table-column>
|
||||
<el-table-column prop="accessUrl" align="center" label="预览图" width="100">
|
||||
<template #default="{row}">
|
||||
<el-image preview-teleported :src="row.accessUrl" :preview-src-list="[row.accessUrl]" :hide-on-click-modal="true" fit="contain" lazy class="el-avatar">
|
||||
<el-image preview-teleported :src="row.accessUrl" :preview-src-list="[row.accessUrl]" :hide-on-click-modal="true" fit="contain" lazy
|
||||
class="el-avatar">
|
||||
<template #error>
|
||||
<i class="document" />
|
||||
</template>
|
||||
@ -61,17 +63,22 @@
|
||||
<el-table-column label="操作" align="center" width="200">
|
||||
<template #default="scope">
|
||||
<el-button type="text" icon="view" @click="handleView(scope.row)">查看</el-button>
|
||||
<el-button class="copy-btn-main" icon="document-copy" type="text" v-clipboard:copy="scope.row.accessUrl" v-clipboard:success="clipboardSuccess">
|
||||
<el-button class="copy-btn-main" icon="document-copy" type="text" v-clipboard:copy="scope.row.accessUrl"
|
||||
v-clipboard:success="clipboardSuccess">
|
||||
复制
|
||||
</el-button>
|
||||
<el-button v-hasPermi="['tool:file:delete']" type="text" icon="delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination class="mt10" background :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
<pagination class="mt10" background :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList" />
|
||||
|
||||
<!-- 添加或修改文件存储对话框 -->
|
||||
<el-dialog :title="title" :lock-scroll="false" v-model="open" width="400px">
|
||||
<template #title>
|
||||
<div v-drag="['.el-dialog', '.el-dialog__header']">{{title}}</div>
|
||||
</template>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="90px" label-position="left">
|
||||
<el-row>
|
||||
<el-col :lg="24">
|
||||
@ -103,8 +110,9 @@
|
||||
</el-col>
|
||||
<el-col :lg="24">
|
||||
<!-- <el-form-item prop="accessUrl" labelwidth="0px"> -->
|
||||
<UploadFile ref="upload" v-model="form.accessUrl" :fileType="[]" :limit="5" :fileSize="15" :drag="true" :data="{ 'fileDir' : form.storePath, 'fileName': form.fileName, 'storeType': form.storeType}"
|
||||
:autoUpload="false" column="accessUrl" @success="handleUploadSuccess" />
|
||||
<UploadFile ref="upload" v-model="form.accessUrl" :fileType="[]" :limit="5" :fileSize="15" :drag="true"
|
||||
:data="{ 'fileDir' : form.storePath, 'fileName': form.fileName, 'storeType': form.storeType}" :autoUpload="false" column="accessUrl"
|
||||
@success="handleUploadSuccess" />
|
||||
<!-- </el-form-item> -->
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -156,7 +164,8 @@
|
||||
</el-col>
|
||||
<el-col :lg="24">
|
||||
<el-form-item label="访问路径">{{formView.accessUrl}}
|
||||
<el-button class="copy-btn-main" icon="document-copy" type="text" v-clipboard:copy="formView.accessUrl" v-clipboard:success="clipboardSuccess">
|
||||
<el-button class="copy-btn-main" icon="document-copy" type="text" v-clipboard:copy="formView.accessUrl"
|
||||
v-clipboard:success="clipboardSuccess">
|
||||
复制
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
@ -170,14 +179,14 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { listSysfile, delSysfile, getSysfile } from "@/api/tool/file.js";
|
||||
import { listSysfile, delSysfile, getSysfile } from '@/api/tool/file.js'
|
||||
|
||||
export default {
|
||||
name: "sysfile",
|
||||
name: 'sysfile',
|
||||
data() {
|
||||
return {
|
||||
labelWidth: "100px",
|
||||
formLabelWidth: "100px",
|
||||
labelWidth: '100px',
|
||||
formLabelWidth: '100px',
|
||||
// 选中id数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
@ -196,7 +205,7 @@ export default {
|
||||
fileId: undefined,
|
||||
},
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
title: '',
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
openView: false,
|
||||
@ -208,8 +217,8 @@ export default {
|
||||
dateRangeAddTime: [],
|
||||
// 存储类型选项列表
|
||||
storeTypeOptions: [
|
||||
{ dictLabel: "本地存储", dictValue: 1 },
|
||||
{ dictLabel: "阿里云存储", dictValue: 2 },
|
||||
{ dictLabel: '本地存储', dictValue: 1 },
|
||||
{ dictLabel: '阿里云存储', dictValue: 2 },
|
||||
],
|
||||
// 存储类型 1、本地 2、阿里云
|
||||
storeType: 0,
|
||||
@ -225,122 +234,122 @@ export default {
|
||||
accessUrl: [
|
||||
{
|
||||
required: true,
|
||||
message: "上传文件不能为空",
|
||||
trigger: "blur",
|
||||
message: '上传文件不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
storeType: [
|
||||
{
|
||||
required: true,
|
||||
message: "存储类型不能为空",
|
||||
trigger: "blur",
|
||||
message: '存储类型不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 列表数据查询
|
||||
this.getList();
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
// 查询数据
|
||||
getList() {
|
||||
this.addDateRange(this.queryParams, this.dateRangeAddTime, "Create_time");
|
||||
this.loading = true;
|
||||
this.addDateRange(this.queryParams, this.dateRangeAddTime, 'Create_time')
|
||||
this.loading = true
|
||||
listSysfile(this.queryParams).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.dataList = res.data.result;
|
||||
this.total = res.data.totalNum;
|
||||
this.loading = false;
|
||||
this.dataList = res.data.result
|
||||
this.total = res.data.totalNum
|
||||
this.loading = false
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
this.open = false
|
||||
this.reset()
|
||||
},
|
||||
// 重置数据表单
|
||||
reset() {
|
||||
this.form = {
|
||||
fileName: "",
|
||||
fileUrl: "",
|
||||
storePath: "uploads",
|
||||
fileName: '',
|
||||
fileUrl: '',
|
||||
storePath: 'uploads',
|
||||
fileSize: 0,
|
||||
fileExt: "",
|
||||
fileExt: '',
|
||||
storeType: 1,
|
||||
accessUrl: "",
|
||||
};
|
||||
this.resetForm("form");
|
||||
accessUrl: '',
|
||||
}
|
||||
this.resetForm('form')
|
||||
},
|
||||
/** 重置查询操作 */
|
||||
resetQuery() {
|
||||
this.timeRange = [];
|
||||
this.timeRange = []
|
||||
// 上传时间时间范围
|
||||
this.dateRangeAddTime = [];
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
this.dateRangeAddTime = []
|
||||
this.resetForm('queryForm')
|
||||
this.handleQuery()
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map((item) => item.id);
|
||||
this.single = selection.length != 1;
|
||||
this.multiple = !selection.length;
|
||||
this.ids = selection.map((item) => item.id)
|
||||
this.single = selection.length != 1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "上传文件";
|
||||
this.form.storeType = this.queryParams.storeType;
|
||||
this.reset()
|
||||
this.open = true
|
||||
this.title = '上传文件'
|
||||
this.form.storeType = this.queryParams.storeType
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const Ids = row.id || this.ids;
|
||||
const Ids = row.id || this.ids
|
||||
|
||||
this.$confirm('是否确认删除参数编号为"' + Ids + '"的数据项?')
|
||||
.then(function () {
|
||||
return delSysfile(Ids);
|
||||
return delSysfile(Ids)
|
||||
})
|
||||
.then(() => {
|
||||
this.handleQuery();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
this.handleQuery()
|
||||
this.$modal.msgSuccess('删除成功')
|
||||
})
|
||||
.catch(() => {});
|
||||
.catch(() => {})
|
||||
},
|
||||
/** 查看按钮操作 */
|
||||
handleView(row) {
|
||||
const id = row.id || this.ids;
|
||||
const id = row.id || this.ids
|
||||
getSysfile(id).then((res) => {
|
||||
const { code, data } = res;
|
||||
const { code, data } = res
|
||||
if (code == 200) {
|
||||
this.openView = true;
|
||||
this.formView = data;
|
||||
this.openView = true
|
||||
this.formView = data
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
// 上传成功方法
|
||||
handleUploadSuccess(columnName, filelist, data) {
|
||||
this.form[columnName] = filelist;
|
||||
this.open = false;
|
||||
this.getList();
|
||||
this.form[columnName] = filelist
|
||||
this.open = false
|
||||
this.getList()
|
||||
},
|
||||
// 手动上传
|
||||
submitUpload() {
|
||||
this.$refs.upload.submitUpload();
|
||||
this.$refs.upload.submitUpload()
|
||||
},
|
||||
/** 复制代码成功 */
|
||||
clipboardSuccess() {
|
||||
this.$modal.msgSuccess("复制成功");
|
||||
this.$modal.msgSuccess('复制成功')
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.el-avatar {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user