update 文件管理

qianlishi 3 years ago
parent 806b6b40be
commit 2ad012f7cf

@ -1,199 +1,242 @@
<template> <template>
<anji-crud ref="listPage" :option="crudOption"> <anji-crud ref="listPage" :option="crudOption">
<template v-slot:buttonLeftOnTable> <template v-slot:buttonLeftOnTable>
<el-upload class="el-upload" ref="upload" :action="uploadUrl" :headers="headers" :on-success="handleUpload" <el-upload
:on-error="handleError" :show-file-list="false" :limit="1"> class="el-upload"
<el-button type="primary" icon="el-icon" v-permission="'fileManage:upload'"></el-button> ref="upload"
:action="uploadUrl"
:headers="headers"
:on-success="handleUpload"
:on-error="handleError"
:show-file-list="false"
:limit="1"
>
<el-button
type="primary"
icon="el-icon"
v-permission="'fileManage:upload'"
>文件上传</el-button
>
</el-upload> </el-upload>
</template> </template>
<template slot="edit" slot-scope="props">
<template slot="rowButton" slot-scope="props">
<el-button type="text" @click="copyUrlPath(props)">url</el-button> <el-button type="text" @click="copyUrlPath(props)">url</el-button>
</template>
<template slot="rowButton" slot-scope="props">
<el-button type="text" @click="customButtom(props)"></el-button> <el-button type="text" @click="customButtom(props)"></el-button>
</template> </template>
</anji-crud> </anji-crud>
</template> </template>
<script> <script>
import {fileList, fileAdd, fileDel, fileUpdate, fileDetail} from '@/api/file' import { fileList, fileAdd, fileDel, fileUpdate, fileDetail } from "@/api/file";
import {getToken} from '@/utils/auth' import { getToken } from "@/utils/auth";
export default { export default {
name: 'File', name: "File",
components: { components: {
anjiCrud: require('@/components/AnjiPlus/anji-crud/anji-crud').default, anjiCrud: require("@/components/AnjiPlus/anji-crud/anji-crud").default
}, },
data() { data() {
return { return {
selectedList: [], selectedList: [],
uploadUrl: process.env.BASE_API + '/file/upload', uploadUrl: process.env.BASE_API + "/file/upload",
crudOption: { crudOption: {
// 使 // 使
title: '文件管理', title: "文件管理",
// //
labelWidth: '120px', labelWidth: "120px",
// //
queryFormFields: [ queryFormFields: [
{ {
inputType: 'input', inputType: "input",
label: '文件路径', label: "文件路径",
field: 'filePath', field: "filePath"
}, }
], ],
// //
buttons: { buttons: {
query: { query: {
api: fileList, api: fileList,
permission: 'fileManage:query', permission: "fileManage:query",
sort: 'create_time', sort: "create_time",
order: 'DESC', order: "DESC"
}, },
queryByPrimarykey: { queryByPrimarykey: {
api: fileDetail, api: fileDetail,
permission: 'fileManage:query', permission: "fileManage:query"
}, },
add: { add: {
api: fileAdd, api: fileAdd,
permission: 'fileManage:upload', permission: "fileManage:upload",
isShow: false, isShow: false
}, },
delete: { delete: {
api: fileDel, api: fileDel,
permission: 'fileManage:delete', permission: "fileManage:delete"
}, },
edit: { edit: {
api: fileUpdate, api: fileUpdate,
permission: 'fileManage:update', permission: "fileManage:update",
isShow: false, isShow: false
}, },
// //
customButton: { customButton: {
operationWidth: 100, // row operationWidth: 150 // row
}, }
}, },
// //
columns: [ columns: [
{ {
label: '', label: "",
field: 'id', field: "id",
primaryKey: true, // , primaryKey: true, // ,
tableHide: true, // tableHide: true, //
editHide: true, // editHide: true //
}, },
{ {
// //
label: '图片缩略图', // label: "图片缩略图", //
field: 'urlPath', // field: "urlPath", //
columnType: 'imgPreview', // text columnType: "imgPreview", // text
editHide: true, // editHide: true, //
// //
// inputType: 'input', // input anji-select // inputType: 'input', // input anji-select
placeholder: '', placeholder: "",
disabled: false, disabled: false
}, },
{ {
label: '文件标识', // label: "文件标识", //
placeholder: '', placeholder: "",
field: 'fileId', field: "fileId",
editField: 'fileId', editField: "fileId",
tableHide: true, // tableHide: true, //
inputType: 'input', inputType: "input",
rules: [{min: 1, max: 64, message: '不超过64个字符', trigger: 'blur'}], rules: [
disabled: false, { min: 1, max: 64, message: "不超过64个字符", trigger: "blur" }
],
disabled: false
}, },
{ {
label: '文件类型', // label: "文件类型", //
placeholder: '', placeholder: "",
field: 'fileType', field: "fileType",
editField: 'fileType', editField: "fileType",
inputType: 'input', inputType: "input",
rules: [{min: 1, max: 1024, message: '不超过1024个字符', trigger: 'blur'}], rules: [
disabled: false, {
min: 1,
max: 1024,
message: "不超过1024个字符",
trigger: "blur"
}
],
disabled: false
}, },
{ {
label: '文件路径', // label: "文件路径", //
placeholder: '', placeholder: "",
field: 'filePath', field: "filePath",
editField: 'filePath', editField: "filePath",
inputType: 'input', inputType: "input",
rules: [{min: 1, max: 1024, message: '不超过1024个字符', trigger: 'blur'}], rules: [
disabled: false, {
min: 1,
max: 1024,
message: "不超过1024个字符",
trigger: "blur"
}
],
disabled: false
}, },
{ {
label: 'url路径', // url label: "url路径", // url
placeholder: '', placeholder: "",
field: 'urlPath', field: "urlPath",
editField: 'urlPath', editField: "urlPath",
inputType: 'input', inputType: "input",
rules: [{min: 1, max: 1024, message: '不超过1024个字符', trigger: 'blur'}], rules: [
disabled: false, {
min: 1,
max: 1024,
message: "不超过1024个字符",
trigger: "blur"
}
],
disabled: false
}, },
{ {
label: '内容说明', // label: "内容说明", //
placeholder: '', placeholder: "",
field: 'fileInstruction', field: "fileInstruction",
editField: 'fileInstruction', editField: "fileInstruction",
inputType: 'input', inputType: "input",
rules: [{min: 1, max: 1024, message: '不超过1024个字符', trigger: 'blur'}], rules: [
disabled: false, {
min: 1,
max: 1024,
message: "不超过1024个字符",
trigger: "blur"
}
],
disabled: false
}, },
{ {
label: '创建人', label: "创建人",
field: 'createByView', field: "createByView",
columnType: 'expand', // columnType: "expand", //
inputType: 'input', // input inputType: "input", // input
disabled: true, // disabled: true //
}, },
{ {
label: '创建时间', label: "创建时间",
field: 'createTime', field: "createTime",
columnType: 'expand', columnType: "expand",
inputType: 'input', inputType: "input",
disabled: true, disabled: true
}, }
], ]
},
} }
};
}, },
computed: { computed: {
headers() { headers() {
return { return {
Authorization: getToken(), // token Authorization: getToken() // token
};
} }
}, },
},
created() { created() {},
},
methods: { methods: {
// //
handleUpload(response, file, fileList) { handleUpload(response, file, fileList) {
console.log(this) console.log(this);
// //
this.$refs.listPage.handleQueryForm() this.$refs.listPage.handleQueryForm();
//el-upload //el-upload
this.$refs.upload.clearFiles() this.$refs.upload.clearFiles();
}, },
handleError() { handleError() {
this.$message({ this.$message({
message: '上传失败!', message: "上传失败!",
type: 'error', type: "error"
}) });
}, },
async downloadFile(row) { async downloadFile(row) {
window.open(row.urlPath) window.open(row.urlPath);
}, },
customButtom(val) { customButtom(val) {
this.downloadFile(val.msg) this.downloadFile(val.msg);
}, },
copyUrlPath(val) { copyUrlPath(val) {
this.copyToClip(val.msg.urlPath) this.copyToClip(val.msg.urlPath);
this.$message({ this.$message({
message: '已将url路径复制至剪切板', message: "已将url路径复制至剪切板",
type: 'success', type: "success"
}) });
}, },
copyToClip(content, message) { copyToClip(content, message) {
var aux = document.createElement("input"); var aux = document.createElement("input");
@ -202,10 +245,9 @@ export default {
aux.select(); aux.select();
document.execCommand("copy"); document.execCommand("copy");
document.body.removeChild(aux); document.body.removeChild(aux);
},
},
} }
}
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.el-upload { .el-upload {

Loading…
Cancel
Save