From b9f48174581e5575baa49552e095a17d28ecf1a8 Mon Sep 17 00:00:00 2001
From: wen <1515>
Date: Wed, 26 Oct 2022 19:40:25 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=89=80=E6=9C=89=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3=EF=BC=8C=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/user.js | 36 ++
.../components/Sidebar/leftMenusData.js | 2 +-
src/router/index.js | 6 +-
src/views/subfile/index.js | 517 ++++++++++++++++++
src/views/subfile/index.vue | 324 +++++++++--
src/views/systme/switchtheme.vue | 90 +++
6 files changed, 915 insertions(+), 60 deletions(-)
create mode 100644 src/views/subfile/index.js
create mode 100644 src/views/systme/switchtheme.vue
diff --git a/src/api/user.js b/src/api/user.js
index 3367667..5a5d0fb 100644
--- a/src/api/user.js
+++ b/src/api/user.js
@@ -50,4 +50,40 @@ export function rmdirs(datas) {
method: 'post',
data: datas
})
+}
+
+// 删除文件
+export function deletefile(datas) {
+ return request({
+ url: '/api/delete',
+ method: 'post',
+ data: datas
+ })
+}
+
+// 重命名文件
+export function renamefile(datas) {
+ return request({
+ url: '/api/rename',
+ method: 'post',
+ data: datas
+ })
+}
+
+// 移动目录
+export function movefiledir(datas) {
+ return request({
+ url: '/api/move',
+ method: 'post',
+ data: datas
+ })
+}
+
+// 更换皮肤
+export function switchthemeApi(datas) {
+ return request({
+ url: '/api/switchtheme/',
+ method: 'post',
+ data: datas
+ })
}
\ No newline at end of file
diff --git a/src/layout/components/Sidebar/leftMenusData.js b/src/layout/components/Sidebar/leftMenusData.js
index 54ca272..2a89293 100644
--- a/src/layout/components/Sidebar/leftMenusData.js
+++ b/src/layout/components/Sidebar/leftMenusData.js
@@ -59,7 +59,7 @@ var menusdata = [
meta: { title: '用户相关', icon: 'tree' }
},
{
- path: 'userrelated2',
+ path: 'switchtheme',
meta: { title: '皮肤更换', icon: 'tree' }
}
]
diff --git a/src/router/index.js b/src/router/index.js
index c985284..adb872d 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -107,9 +107,9 @@ export const constantRoutes = [
meta: { title: '用户相关', icon: 'tree' }
},
{
- path: 'userrelated2',
- name: 'userrelated2',
- component: () => import('@/views/systme/userrelated'),
+ path: 'switchtheme',
+ name: 'Switchtheme',
+ component: () => import('@/views/systme/switchtheme'),
meta: { title: '皮肤更换', icon: 'tree' }
}
]
diff --git a/src/views/subfile/index.js b/src/views/subfile/index.js
new file mode 100644
index 0000000..66110da
--- /dev/null
+++ b/src/views/subfile/index.js
@@ -0,0 +1,517 @@
+import { mirlist, mkdir, uploadrequest, rmdirs, deletefile, renamefile, movefiledir } from '@/api/user'
+
+export default {
+
+ watch: {
+ // 点击不同目录请求不同接口
+ $route(to, from) {
+
+ this.getFileData();
+ }
+ },
+ // beforeRouteUpdate(to, from, next) {
+ // alert(0);
+ // next();
+ // },
+
+ // 实例还没挂载
+ created() {
+ this.getFileData();
+ },
+
+ // 实例已经挂载
+
+
+ filters: {
+
+ },
+ data() {
+ return {
+ // 按日期查询
+ // pickerOptions: {
+ // shortcuts: [{
+ // text: '最近一周',
+ // onClick(picker) {
+ // const end = new Date();
+ // const start = new Date();
+ // start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
+ // picker.$emit('pick', [start, end]);
+ // }
+ // }, {
+ // text: '最近一个月',
+ // onClick(picker) {
+ // const end = new Date();
+ // const start = new Date();
+ // start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
+ // picker.$emit('pick', [start, end]);
+ // }
+ // }, {
+ // text: '最近三个月',
+ // onClick(picker) {
+ // const end = new Date();
+ // const start = new Date();
+ // start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
+ // picker.$emit('pick', [start, end]);
+ // }
+ // }]
+ // },
+ // value2: '',
+
+ //haveRealpath: 0,
+ // 当前目录文件数据
+ tableData: [],
+
+ // 当前目录子目录数据
+ dirdata: [],
+
+ // 创建目录弹出框数据
+ dirbox: false,
+ dirform: {
+ dir: '',
+ parent: ''
+ },
+ formLabelWidth: '',
+
+ //删除目录数据
+ rmdirform: {
+ dir: '',
+ parent: ''
+ },
+
+ // 删除文件数据
+ rmfileform: {
+ file: '',
+ parent: ''
+ },
+
+ // 重命名文件数据
+ renamebox: false,
+ renamefileform: {
+ from: '',
+ to: '',
+ parent: ''
+ },
+
+ // 移动目录或者文件数据
+ movebox: false,
+ movefileform: {
+ from: '',
+ to: ''
+ },
+
+ subloading: false, //切换目录loading
+ mkdirloadings: false, //创建目录loading
+
+ // 图片上传弹出框数据
+ uploadDrawer: false,
+ direction: 'ttb',
+
+ // 图片上传相关数据
+ dialogImageUrl: '',
+ dialogVisible: false,
+ disabled: false,
+ imgUploadData: {
+ name: '',
+ file: '',
+ parent: ''
+ },
+ uploadLoad: false
+ };
+ },
+ methods: {
+ // 图片上传相关函数
+ handleRemove(file, fileList) {
+ console.log(fileList);
+ //this.$refs.upload.clearFiles;
+ },
+ handlePictureCardPreview(file) {
+ this.dialogImageUrl = file.url;
+ this.dialogVisible = true;
+ },
+ handleDownload(file) {
+ this.$message({
+ showClose: true,
+ message: '右键点击或者长按图片自行下载'
+ });
+ },
+ // 超出上传文件个数限制处理函数
+ fileexceed(files, fileList) {
+ //this.$message({showClose:true, message:`当前版本限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`, type:'warning'});
+ this.$message({ showClose: true, message: `当前版本限制上传一个文件`, type: 'warning' });
+ //this.$message.warning(``);
+ },
+
+ filechange(files, fileList) {
+ //console.log(files);
+ const isLt2M = files.size / 1024 / 1024 < 5;
+
+ if (!isLt2M) {
+ this.$message.error('文件大小不能超过 5MB!' + files.name + '已超过,重新选择');
+ fileList.splice(-1, 1); // 移除错误文件
+ //window.setTimeout(() => {fileList.splice(-1, 1);}, 3000);
+
+ //console.log(fileList);
+ return;
+ }
+
+ // 获取传给后台的图片参数
+ this.imgUploadData.name = files.name;
+ this.getBase64(files.raw).then(res => {
+ //this.dialogImageUrl = 1;
+ this.imgUploadData.file = res;
+ //console.log(res)
+ })
+ },
+
+ // 获取图片base64
+ getBase64(file) {
+ let thiss = this;
+ return new Promise(function (resolve, reject) {
+
+ if (window.FileReader && file) {
+ let reader = new FileReader();
+ let imgResult = "";
+ reader.readAsDataURL(file);
+ reader.onload = function () {
+ imgResult = reader.result;
+ };
+ reader.onerror = function (error) {
+ reject(error);
+ };
+ reader.onloadend = function () {
+ resolve(imgResult);
+ };
+ } else {
+ thiss.$message({ showClose: true, message: '获取base64出错', type: 'error' });
+ }
+
+ });
+ // if (window.FileReader && file) {
+ // //调用图片读取方法
+ // var reader = new FileReader();
+ // //读取图片
+ // reader.readAsDataURL(file);
+ // //监听图片读取进度
+ // reader.onloadend = function(e) {
+ // //读取成功,拿到base64编码
+ // let imgBase64 = e.target.result;
+ // console.log(imgBase64);
+ // }
+ // }
+ },
+ // 确认上传文件
+ UploadRequest() {
+ let thiss = this;
+ //console.log(file);
+ this.uploadLoad = true;
+ uploadrequest(this.imgUploadData).then(response => {
+ let datamain = response.data;
+ if (datamain.code == 1) {
+ console.log(datamain);
+ this.$message({ showClose: true, message: datamain.msg, type: 'success' });
+ this.uploadDrawer = false;
+ this.getFileData();
+ }
+ this.uploadLoad = false;
+ }).catch(error => {
+ if (error.response) {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ this.uploadLoad = false;
+ } else if (error.request) {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ } else {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ }
+ });
+ },
+ getFileData() {
+ let can = {};
+ const menusindex = window.location.href
+ if (menusindex.indexOf('?id') != -1) {
+ //console.log(menusindex.split('?id=')[1]);
+ can.id = menusindex.split('?id=')[1]
+ }
+
+ let thiss = this;
+ this.subloading = true;
+ mirlist(can).then(response => {
+ let datamain = response.data;
+ let maindata = datamain.data.dirTree;
+ if (datamain.code == 1) {
+ //console.log(maindata.directories.length);
+ this.dirdata = []
+ this.tableData = []
+ if (maindata.directories) {
+ this.dirdata = this.forObjectData(maindata.directories);
+ }
+
+ if (maindata.files) {
+ this.tableData = this.forObjectData(maindata.files);
+
+ }
+
+ //this.haveRealpath = maindata.realpath;
+ //console.log(this.haveRealpath);
+ this.dirform.parent = maindata.realpath; //获取当前目录的位置
+ this.rmdirform.parent = maindata.realpath; //获取当前目录的位置 删除目录
+ this.rmfileform.parent = maindata.realpath; //获取当前目录的位置 删除文件
+ this.renamefileform.parent = maindata.realpath; //获取当前目录的位置 删除文件
+ this.imgUploadData.parent = maindata.realpath; // 上传图片
+ this.movefileform.from = maindata.realpath; // 移动目录
+ //console.log(this.movefileform.from);
+
+
+
+ this.subloading = false;
+
+
+ }
+ }).catch(error => {
+ if (error.response) {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ } else if (error.request) {
+ thiss.$message({ showClose: true, message: error, type: 'error' });
+ } else {
+ thiss.$message({ showClose: true, message: error.message, type: 'error' });
+ }
+
+ this.subloading = false;
+ });
+ },
+
+ forObjectData(objectd) {
+ let newObject = null, arrObjs = [];
+
+ Object.keys(objectd).forEach(item => {
+ let names = null;
+ if (objectd[item].filename) {
+ names = objectd[item].filename + '.' + objectd[item].extension;
+ }
+ newObject = {
+ date: '2016-05-03',
+ image: objectd[item].path,
+ name: names || objectd[item].directory,
+ id: objectd[item].id,
+ frealpath: objectd[item].realpath
+ }
+
+ arrObjs.push(newObject);
+ });
+
+ return arrObjs;
+ //console.log(arrObjs);
+ },
+
+ // 创建目录
+ mkdirs() {
+ let thiss = this;
+ if (!this.dirform.dir) {
+ thiss.$message({ showClose: true, message: '目录名不能为空', type: 'error' });
+ return;
+ }
+ //console.log(this.dirform);
+ this.mkdirloadings = true;
+ mkdir(this.dirform).then(response => {
+ let datamain = response.data;
+ if (datamain.code == 1) {
+
+ EventBus.$emit('mkdirSuccess'); //触发菜单栏刷新
+ this.getFileData();
+
+ this.dirform.dir = '';
+ thiss.$message({ showClose: true, message: datamain.msg, type: 'success' });
+ //this.subloading = false;
+ }
+
+ this.mkdirloadings = false;
+ this.dirbox = false;
+ }).catch(error => {
+ if (error.response) {
+ thiss.mkdirloadings = false;
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ } else if (error.request) {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ } else {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ }
+ });
+ },
+
+ // 删除目录
+ rmdirm() {
+ let thiss = this;
+ this.subloading = true;
+ //console.log(this.rmdirform);
+ rmdirs(this.rmdirform).then(response => {
+ let datamain = response.data;
+ let maindata = datamain.data.dirTree;
+ if (datamain.code == 1) {
+
+ EventBus.$emit('mkdirSuccess'); //触发菜单栏刷新
+ this.getFileData();
+ thiss.$message({ showClose: true, message: datamain.msg, type: 'success' });
+ //this.subloading = false;
+ } else {
+ thiss.$message({ showClose: true, message: datamain.err, type: 'error' });
+ }
+ this.subloading = false;
+ //this.dirbox = false;
+ }).catch(error => {
+ if (error.response) {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ } else if (error.request) {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ } else {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ }
+ this.subloading = false;
+ });
+ },
+
+ // 删除文件
+ rmfile() {
+ let thiss = this;
+ this.subloading = true;
+ //console.log(this.rmfileform);
+ deletefile(this.rmfileform).then(response => {
+ let datamain = response.data;
+ if (datamain.code == 1) {
+
+ this.getFileData();
+ thiss.$message({ showClose: true, message: datamain.msg, type: 'success' });
+ //this.subloading = false;
+ } else {
+ thiss.$message({ showClose: true, message: datamain.err, type: 'error' });
+ }
+
+ this.subloading = false;
+
+ //this.dirbox = false;
+ }).catch(error => {
+ this.subloading = false;
+ if (error.response) {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ } else if (error.request) {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ } else {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ }
+ });
+ },
+
+ // 重命名文件和目录
+ renameFileDir() {
+ if (!this.renamefileform.to) {
+ this.$message({ showClose: true, message: '新名称不能为空', type: 'error' });
+ return;
+ }
+ let thiss = this;
+ this.subloading = true;
+ //console.log(this.rmfileform);
+ renamefile(this.renamefileform).then(response => {
+ let datamain = response.data;
+ if (datamain.code == 1) {
+
+ this.getFileData();
+ thiss.$message({ showClose: true, message: datamain.msg, type: 'success' });
+ //this.subloading = false;
+ } else {
+ thiss.$message({ showClose: true, message: datamain.err, type: 'error' });
+ }
+
+ this.subloading = false;
+
+ this.renamebox = false;
+ }).catch(error => {
+ this.subloading = false;
+ if (error.response) {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ } else if (error.request) {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ } else {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ }
+ });
+ },
+
+ // 移动目录或者文件
+ moveFileDir() {
+ if (!this.movefileform.to || !this.movefileform.from) {
+ this.$message({ showClose: true, message: '不能为空', type: 'error' });
+ return;
+ }
+ let thiss = this;
+ this.subloading = true;
+ //console.log(this.rmfileform);
+ movefiledir(this.movefileform).then(response => {
+ let datamain = response.data;
+ if (datamain.code == 1) {
+
+ this.getFileData();
+ thiss.$message({ showClose: true, message: datamain.msg, type: 'success' });
+ //this.subloading = false;
+ } else {
+ thiss.$message({ showClose: true, message: datamain.err, type: 'error' });
+ }
+
+ this.subloading = false;
+
+ this.movebox = false;
+ }).catch(error => {
+ this.subloading = false;
+ if (error.response) {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ } else if (error.request) {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ } else {
+ thiss.$message({ showClose: true, message: error.response.data.err, type: 'error' });
+ }
+ });
+ },
+
+ // table块事件监听
+ fileTableMClick(e) {
+ let dangQian = e.target, labelname = dangQian.tagName.toLowerCase(), chufazhe = e.currentTarget; //currentTarget得到调用当前函数的元素
+ let getbutton = dangQian, objmark = null;
+ if (labelname == 'span') {
+ //console.log(dangQian.parentNode);
+ getbutton = dangQian.parentNode;
+ }
+
+ objmark = getbutton.getAttribute('mark');
+
+ // 点击删除目录
+ if (objmark == 'dirdelete') {
+ this.rmdirform.dir = getbutton.getAttribute('filenames');
+ this.rmdirm();
+ return;
+ }
+
+ // 点击删除文件
+ if (objmark == 'filedelete') {
+ this.rmfileform.file = getbutton.getAttribute('filenames');
+ this.rmfile();
+ return;
+ }
+
+ // 点击重命名文件和目录
+ if (objmark == 'rename') {
+ this.renamefileform.from = getbutton.getAttribute('filenames');
+ this.renamefileform.to = '';
+ this.renamebox = true;
+ //this.renameFileDir();
+ return;
+ }
+
+ // 点击移动目录或文件
+ if (objmark == 'movefiledir') {
+ //this.movefileform.from = getbutton.getAttribute('filenames');
+ this.movefileform.to = '';
+ this.movebox = true;
+ //this.renameFileDir();
+ return;
+ }
+ //console.log(dangQian);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/views/subfile/index.vue b/src/views/subfile/index.vue
index 4b27cdf..3d206f4 100644
--- a/src/views/subfile/index.vue
+++ b/src/views/subfile/index.vue
@@ -1,5 +1,5 @@
-
+
-
-
- 移动
-
- 删除
-
-
+
重命名
+
+
+
+ 移动
+ 删除
+
+
-
-
@@ -112,36 +109,62 @@
-
- 重命名
-
-
-
- 移动
- 删除
-
-
+
+
+ 重命名
+
+
+
+ 移动
+ 删除
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
import EventBus from '@/utils/EventBus.js'
-import { mirlist, mkdir, uploadrequest, rmdirs} from '@/api/user'
-import defaultSettings from '@/settings.js'
+import { mirlist, mkdir, uploadrequest, rmdirs, deletefile, renamefile, movefiledir} from '@/api/user'
+//import defaultSettings from '@/settings.js'
export default {
@@ -196,11 +219,14 @@ export default {
// next();
// },
+ // 实例还没挂载
created() {
this.getFileData();
-
},
+ // 实例已经挂载
+
+
filters: {
},
@@ -236,8 +262,13 @@ export default {
// },
// value2: '',
+ //haveRealpath: 0,
+ // 当前目录文件数据
tableData: [],
+ // 当前目录子目录数据
+ dirdata: [],
+
// 创建目录弹出框数据
dirbox: false,
dirform: {
@@ -246,11 +277,35 @@ export default {
},
formLabelWidth: '',
- // 更新当前目录的子目录
- dirdata: [],
+ //删除目录数据
+ rmdirform: {
+ dir: '',
+ parent: ''
+ },
+
+ // 删除文件数据
+ rmfileform: {
+ file: '',
+ parent: ''
+ },
+
+ // 重命名文件数据
+ renamebox: false,
+ renamefileform: {
+ from: '',
+ to: '',
+ parent: ''
+ },
+
+ // 移动目录或者文件数据
+ movebox: false,
+ movefileform: {
+ from: '',
+ to: ''
+ },
subloading: false, //切换目录loading
- mkdirloadings: false,
+ mkdirloadings: false, //创建目录loading
// 图片上传弹出框数据
uploadDrawer: false,
@@ -400,10 +455,21 @@ export default {
}
- this.dirform.parent = maindata.realpath;
+ //this.haveRealpath = maindata.realpath;
+ //console.log(this.haveRealpath);
+ this.dirform.parent = maindata.realpath; //获取当前目录的位置
+ this.rmdirform.parent = maindata.realpath; //获取当前目录的位置 删除目录
+ this.rmfileform.parent = maindata.realpath; //获取当前目录的位置 删除文件
+ this.renamefileform.parent = maindata.realpath; //获取当前目录的位置 删除文件
+ this.imgUploadData.parent = maindata.realpath; // 上传图片
+ this.movefileform.from = maindata.realpath; // 移动目录
+ //console.log(this.movefileform.from);
+
+
+
this.subloading = false;
- this.imgUploadData.parent = maindata.realpath;
+
}
}).catch(error => {
if (error.response) {
@@ -413,6 +479,8 @@ export default {
} else {
thiss.$message({showClose: true,message: error.message,type: 'error'});
}
+
+ this.subloading = false;
});
},
@@ -420,12 +488,16 @@ export default {
let newObject = null, arrObjs = [];
Object.keys(objectd).forEach(item => {
-
+ let names = null;
+ if (objectd[item].filename) {
+ names = objectd[item].filename+'.'+objectd[item].extension;
+ }
newObject = {
date: '2016-05-03',
image: objectd[item].path,
- name: objectd[item].filename || objectd[item].directory,
- id: objectd[item].id
+ name: names || objectd[item].directory,
+ id: objectd[item].id,
+ frealpath: objectd[item].realpath
}
arrObjs.push(newObject);
@@ -442,6 +514,7 @@ export default {
thiss.$message({showClose: true,message: '目录名不能为空',type: 'error'});
return;
}
+ //console.log(this.dirform);
this.mkdirloadings = true;
mkdir(this.dirform).then(response => {
let datamain = response.data;
@@ -451,7 +524,7 @@ export default {
this.getFileData();
this.dirform.dir = '';
- thiss.$message({showClose: true,message: '创建成功',type: ''});
+ thiss.$message({showClose: true,message: datamain.msg,type: 'success'});
//this.subloading = false;
}
@@ -469,22 +542,129 @@ export default {
});
},
- // 删除目录
+ // 删除目录
rmdirm() {
let thiss = this;
- this.rmdirloadings = true;
- this.dirform.dir = 'test';
- rmdirs(this.dirform).then(response => {
+ this.subloading = true;
+ //console.log(this.rmdirform);
+ rmdirs(this.rmdirform).then(response => {
let datamain = response.data;
let maindata = datamain.data.dirTree;
if (datamain.code == 1) {
+ EventBus.$emit('mkdirSuccess'); //触发菜单栏刷新
+ this.getFileData();
+ thiss.$message({showClose: true,message: datamain.msg,type: 'success'});
+ //this.subloading = false;
+ } else {
+ thiss.$message({showClose: true,message: datamain.err,type: 'error'});
+ }
+ this.subloading = false;
+ //this.dirbox = false;
+ }).catch(error => {
+ if (error.response) {
+ thiss.$message({showClose: true,message: error.response.data.err,type: 'error'});
+ } else if (error.request) {
+ thiss.$message({showClose: true,message: error.response.data.err,type: 'error'});
+ } else {
+ thiss.$message({showClose: true,message: error.response.data.err,type: 'error'});
+ }
+ this.subloading = false;
+ });
+ },
+ // 删除文件
+ rmfile() {
+ let thiss = this;
+ this.subloading = true;
+ //console.log(this.rmfileform);
+ deletefile(this.rmfileform).then(response => {
+ let datamain = response.data;
+ if (datamain.code == 1) {
+
+ this.getFileData();
+ thiss.$message({showClose: true,message: datamain.msg,type: 'success'});
//this.subloading = false;
+ } else {
+ thiss.$message({showClose: true,message: datamain.err,type: 'error'});
+ }
+
+ this.subloading = false;
+
+ //this.dirbox = false;
+ }).catch(error => {
+ this.subloading = false;
+ if (error.response) {
+ thiss.$message({showClose: true,message: error.response.data.err,type: 'error'});
+ } else if (error.request) {
+ thiss.$message({showClose: true,message: error.response.data.err,type: 'error'});
+ } else {
+ thiss.$message({showClose: true,message: error.response.data.err,type: 'error'});
}
+ });
+ },
+
+ // 重命名文件和目录
+ renameFileDir() {
+ if (!this.renamefileform.to) {
+ this.$message({showClose: true,message: '新名称不能为空',type: 'error'});
+ return;
+ }
+ let thiss = this;
+ this.subloading = true;
+ //console.log(this.rmfileform);
+ renamefile(this.renamefileform).then(response => {
+ let datamain = response.data;
+ if (datamain.code == 1) {
+
+ EventBus.$emit('mkdirSuccess'); //触发菜单栏刷新
+ this.getFileData();
+ thiss.$message({showClose: true,message: datamain.msg,type: 'success'});
+ //this.subloading = false;
+ } else {
+ thiss.$message({showClose: true,message: datamain.err,type: 'error'});
+ }
+
+ this.subloading = false;
- this.dirbox = false;
+ this.renamebox = false;
+ }).catch(error => {
+ this.subloading = false;
+ if (error.response) {
+ thiss.$message({showClose: true,message: error.response.data.err,type: 'error'});
+ } else if (error.request) {
+ thiss.$message({showClose: true,message: error.response.data.err,type: 'error'});
+ } else {
+ thiss.$message({showClose: true,message: error.response.data.err,type: 'error'});
+ }
+ });
+ },
+
+ // 移动目录或者文件
+ moveFileDir() {
+ if (!this.movefileform.to || !this.movefileform.from) {
+ this.$message({showClose: true,message: '不能为空',type: 'error'});
+ return;
+ }
+ let thiss = this;
+ this.subloading = true;
+ //console.log(this.rmfileform);
+ movefiledir(this.movefileform).then(response => {
+ let datamain = response.data;
+ if (datamain.code == 1) {
+
+ this.getFileData();
+ thiss.$message({showClose: true,message: datamain.msg,type: 'success'});
+ //this.subloading = false;
+ } else {
+ thiss.$message({showClose: true,message: datamain.err,type: 'error'});
+ }
+
+ this.subloading = false;
+
+ this.movebox = false;
}).catch(error => {
+ this.subloading = false;
if (error.response) {
thiss.$message({showClose: true,message: error.response.data.err,type: 'error'});
} else if (error.request) {
@@ -495,17 +675,48 @@ export default {
});
},
+ // table块事件监听
fileTableMClick(e) {
let dangQian = e.target, labelname = dangQian.tagName.toLowerCase(), chufazhe = e.currentTarget; //currentTarget得到调用当前函数的元素
- let objmark = dangQian.getAttribute('mark');
+ let getbutton = dangQian, objmark = null;
if (labelname == 'span') {
//console.log(dangQian.parentNode);
- objmark = dangQian.parentNode.getAttribute('mark');
+ getbutton = dangQian.parentNode;
}
- // 点击删除
+ objmark = getbutton.getAttribute('mark');
+
+ // 点击删除目录
if (objmark == 'dirdelete') {
+ this.rmdirform.dir = getbutton.getAttribute('filenames');
this.rmdirm();
+ return;
+ }
+
+ // 点击删除文件
+ if (objmark == 'filedelete') {
+ this.rmfileform.file = getbutton.getAttribute('filenames');
+ this.rmfile();
+ return;
+ }
+
+ // 点击重命名文件和目录
+ if (objmark == 'rename') {
+ this.renamefileform.from = getbutton.getAttribute('filenames');
+ this.renamefileform.to = '';
+ this.renamebox = true;
+ //this.renameFileDir();
+ return;
+ }
+
+ // 点击移动目录或文件
+ if (objmark == 'movefiledir') {
+ //this.movefileform.from = getbutton.getAttribute('filenames');
+ this.movefileform.from = getbutton.getAttribute('realpath');
+ this.movefileform.to = '';
+ this.movebox = true;
+ //this.renameFileDir();
+ return;
}
//console.log(dangQian);
}
@@ -514,6 +725,7 @@ export default {
\ No newline at end of file