@@ -0,0 +1,679 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
let vue = new Vue({
|
||||
el: '#vue',
|
||||
data: {
|
||||
breadcrumb: [],
|
||||
checkAll: false,
|
||||
sortList: [{
|
||||
id: 1,
|
||||
value: '添加时间升序'
|
||||
}, {
|
||||
id: 2,
|
||||
value: '添加时间降序'
|
||||
}, {
|
||||
id: 3,
|
||||
value: '文件名升序'
|
||||
}, {
|
||||
id: 4,
|
||||
value: '文件名降序'
|
||||
}],
|
||||
// 搜索字段
|
||||
search: {
|
||||
keyword: '',
|
||||
type: 1,
|
||||
nav: '',
|
||||
order: 2
|
||||
},
|
||||
// 默认每页数据量
|
||||
pageSize: 50,
|
||||
// 当前页码
|
||||
currentPage: 1,
|
||||
// 默认数据总数
|
||||
totalCount: 0,
|
||||
navList: [],
|
||||
dirList: [],
|
||||
fileList: [],
|
||||
formData: {
|
||||
nav: ''
|
||||
},
|
||||
navDialog: false,
|
||||
multipleSelection: [],
|
||||
fileListUrl: []
|
||||
},
|
||||
created() {
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
},
|
||||
methods: {
|
||||
// 刷新页面
|
||||
refreshPage() {
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
},
|
||||
handleOrderChange() {
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
},
|
||||
// 节点点击
|
||||
handleClickNode(e) {
|
||||
this.search.nav = e.value;
|
||||
this.currentPage = 1;
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
},
|
||||
// 选择文件
|
||||
handleSelectFile(index) {
|
||||
this.fileList[index].checked = !this.fileList[index].checked;
|
||||
this.fileList[index].showTools = !this.fileList[index].showTools;
|
||||
},
|
||||
// 文件目录管理
|
||||
handleOpenNav() {
|
||||
Fast.api.open('general/nav/index', '文件目录管理', {
|
||||
area: ['100%', '100%'],
|
||||
callback: res => {
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
// 回收站
|
||||
handleOpenRecycle() {
|
||||
Fast.api.open('general/file/recycle', '回收站管理', {
|
||||
area: ['100%', '100%'],
|
||||
callback: res => {
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
// 文件移入
|
||||
enterFileItem(e, index) {
|
||||
this.fileList[index].showTools = true;
|
||||
},
|
||||
// 文件移出
|
||||
leaveFileItem(e, index) {
|
||||
this.fileList[index].showTools = false;
|
||||
},
|
||||
// 上传前
|
||||
beforeFileUpload(file) {
|
||||
// 文件大小验证
|
||||
if (file.size / 1024 / 1024 > 30) {
|
||||
this.$message.warning('上传的文件大小不能超过30M');
|
||||
return false;
|
||||
}
|
||||
|
||||
this.uploadLoading = this.$loading({
|
||||
lock: true,
|
||||
text: '正在上传中...',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.1)'
|
||||
});
|
||||
},
|
||||
// 上传成功后
|
||||
uploadFileSuccess(res, file, fileList) {
|
||||
this.uploadLoading.close();
|
||||
if (res.code === 1) {
|
||||
this.$message.success(res.msg);
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
} else {
|
||||
this.$message.warning(res.msg);
|
||||
}
|
||||
},
|
||||
// 打开目录
|
||||
handleOpenDir(id) {
|
||||
this.search.nav = id;
|
||||
this.currentPage = 1;
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
},
|
||||
// 打开文件
|
||||
handleOpenFile(url) {
|
||||
window.open(url, '_blank');
|
||||
},
|
||||
// 打开归类
|
||||
handleNavDialog() {
|
||||
this.getSelectFileIds();
|
||||
|
||||
if (this.multipleSelection.length === 0) {
|
||||
this.$message.warning('请选择至少一个文件进行归类!');
|
||||
return;
|
||||
}
|
||||
this.formData = {
|
||||
nav: ''
|
||||
};
|
||||
this.navDialog = true;
|
||||
},
|
||||
submitNav() {
|
||||
if (this.formData.nav === '') {
|
||||
this.$message.warning('请您选择分类!');
|
||||
return;
|
||||
}
|
||||
// 提交
|
||||
let loading = this.$loading({
|
||||
lock: true,
|
||||
text: '正在归类中...',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.3)'
|
||||
});
|
||||
|
||||
this.formData.ids = this.multipleSelection;
|
||||
|
||||
$.ajax({
|
||||
url: 'general/file/nav',
|
||||
type: 'POST',
|
||||
data: this.formData,
|
||||
success: res => {
|
||||
loading.close();
|
||||
if (res.code === 200) {
|
||||
this.$message.success(res.msg);
|
||||
this.navDialog = false;
|
||||
this.multipleSelection = [];
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
} else {
|
||||
this.$message.warning(res.msg);
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
onSelectFile(item, type) {
|
||||
let url = [];
|
||||
if (type === 'multiple') {
|
||||
this.getSelectFileUrl();
|
||||
// 多选
|
||||
if (this.fileListUrl.length === 0) {
|
||||
this.$message.warning('请您选择文件');
|
||||
return;
|
||||
}
|
||||
|
||||
url = this.fileListUrl.join(',');
|
||||
} else {
|
||||
// 单选
|
||||
url = item.url
|
||||
}
|
||||
|
||||
var multiple = Backend.api.query('multiple');
|
||||
multiple = multiple == 'true' ? true : false;
|
||||
|
||||
Fast.api.close({url, multiple});
|
||||
},
|
||||
// 搜索
|
||||
searchData() {
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
},
|
||||
// 从服务器读取数据
|
||||
loadData(key, currentPage, pageSize, order) {
|
||||
// 提交
|
||||
let loading = this.$loading({
|
||||
lock: true,
|
||||
text: '图片加载中...',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.3)'
|
||||
});
|
||||
|
||||
$.getJSON('general/file/index', {
|
||||
keyword: key,
|
||||
type: this.search.type,
|
||||
nav: this.search.nav,
|
||||
page: currentPage,
|
||||
rows: pageSize,
|
||||
order,
|
||||
}, data => {
|
||||
loading.close();
|
||||
this.totalCount = data.total;
|
||||
this.breadcrumb = data.breadcrumb;
|
||||
|
||||
if (!this.navList.length) {
|
||||
this.navList = data.navList;
|
||||
}
|
||||
|
||||
this.dirList = data.dirList;
|
||||
this.fileList = data.list;
|
||||
});
|
||||
},
|
||||
// 每页显示数据量变更
|
||||
handleSizeChange(val) {
|
||||
this.pageSize = val;
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
},
|
||||
// 页码变更
|
||||
handleCurrentChange(val) {
|
||||
this.currentPage = val;
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
},
|
||||
// 批量删除
|
||||
del() {
|
||||
this.getSelectFileIds();
|
||||
|
||||
if (this.multipleSelection.length === 0) {
|
||||
this.$message.warning('请选择至少一个文件进行删除!');
|
||||
return;
|
||||
}
|
||||
|
||||
this.$confirm('您确定要删除所选的文件吗?', '温馨提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
let loading = this.$loading({
|
||||
lock: true,
|
||||
text: '正在删除中..',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.3)'
|
||||
});
|
||||
$.ajax({
|
||||
url: 'general/file/dell',
|
||||
data: "ids=" + this.multipleSelection,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
success: res => {
|
||||
loading.close();
|
||||
if (res.code === 1) {
|
||||
this.$message.success('删除文件成功');
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
} else {
|
||||
this.$message.warning(res.msg);
|
||||
}
|
||||
},
|
||||
error: function (er) {
|
||||
|
||||
}
|
||||
});
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
// 单条删除
|
||||
dell(id) {
|
||||
this.$confirm('您确定要删除此文件吗?', '温馨提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
let loading = this.$loading({
|
||||
lock: true,
|
||||
text: '正在删除中..',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.3)'
|
||||
});
|
||||
$.ajax({
|
||||
url: 'general/file/dell',
|
||||
data: {
|
||||
ids: id
|
||||
},
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
success: res => {
|
||||
loading.close();
|
||||
if (res.code === 1) {
|
||||
this.$message.success('删除文件成功');
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
} else {
|
||||
this.$message.warning(res.msg);
|
||||
}
|
||||
},
|
||||
error: function (er) {
|
||||
|
||||
}
|
||||
});
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
handleInpClear() {
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
},
|
||||
checkAllChange(e) {
|
||||
this.fileList.map(item => {
|
||||
item.checked = e;
|
||||
item.showTools = e;
|
||||
});
|
||||
},
|
||||
// 获取选中的文件
|
||||
getSelectFileIds() {
|
||||
this.fileList.map(item => {
|
||||
if (item.checked) {
|
||||
this.multipleSelection.push(item.id);
|
||||
}
|
||||
});
|
||||
},
|
||||
// 获取选中文件路径
|
||||
getSelectFileUrl() {
|
||||
this.fileList.map(item => {
|
||||
if (item.checked) {
|
||||
this.fileListUrl.push(item.url);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
recycle: function () {
|
||||
let vue = new Vue({
|
||||
el: '#vue',
|
||||
data: {
|
||||
uploadLoading: '',
|
||||
uploadData: {},
|
||||
navList: [],
|
||||
// 表格当前页数据
|
||||
tableData: [],
|
||||
// 多选数组
|
||||
multipleSelection: [],
|
||||
// 搜索条件
|
||||
key: '',
|
||||
// 默认每页数据量
|
||||
pageSize: 10,
|
||||
// 当前页码
|
||||
currentPage: 1,
|
||||
// 默认数据总数
|
||||
totalCount: 0,
|
||||
// 列表加载遮罩
|
||||
listLoading: false,
|
||||
// 搜索字段
|
||||
search: {
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
keyword: '',
|
||||
type: '',
|
||||
sort: 'id',
|
||||
typeIndex: '',
|
||||
category: '',
|
||||
},
|
||||
// 类型
|
||||
typeList: [{
|
||||
index: 1,
|
||||
name: '图片',
|
||||
key: 'image/'
|
||||
}, {
|
||||
index: 2,
|
||||
name: '音频',
|
||||
key: 'audio/'
|
||||
}, {
|
||||
index: 3,
|
||||
name: '视频',
|
||||
key: 'video/'
|
||||
}, {
|
||||
index: 4,
|
||||
name: '文档',
|
||||
key: 'text/'
|
||||
}, {
|
||||
index: 5,
|
||||
name: '应用',
|
||||
key: 'application/'
|
||||
}, {
|
||||
index: 6,
|
||||
name: '压缩包',
|
||||
key: 'zip/'
|
||||
}],
|
||||
searchOpt: [{
|
||||
id: 1,
|
||||
value: '文件名'
|
||||
}],
|
||||
sendStartTime: '',
|
||||
sendEndTime: '',
|
||||
// 时间格式化
|
||||
dateFormat: function (row, column) {
|
||||
var date = row[column.property];
|
||||
if (date === undefined || date === 0) {
|
||||
return '';
|
||||
}
|
||||
return moment(date * 1000).format("YYYY-MM-DD HH:mm:ss");
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
},
|
||||
methods: {
|
||||
handleClearSelect(field) {
|
||||
// 重新加载
|
||||
this.$set(this.search, field, '');
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
},
|
||||
handleClearSearchInp() {
|
||||
if (this.search.type) {
|
||||
// 重新加载
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.order);
|
||||
}
|
||||
},
|
||||
// 刷新页面
|
||||
refreshPage() {
|
||||
this.search = {
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
keyword: '',
|
||||
type: '',
|
||||
sort: 'id',
|
||||
category: '',
|
||||
typeIndex: '',
|
||||
};
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize);
|
||||
},
|
||||
// 从服务器读取数据
|
||||
loadData(key, currentPage, pageSize) {
|
||||
this.listLoading = true;
|
||||
$.getJSON('general/file/recycle', {
|
||||
keyword: key,
|
||||
type: this.search.type,
|
||||
status: this.search.status,
|
||||
nav: this.search.nav,
|
||||
start_time: this.sendStartTime,
|
||||
end_time: this.sendEndTime,
|
||||
category: this.search.category,
|
||||
mimetype: this.search.typeIndex > 0 ? this.typeList[this.search.typeIndex - 1].key :'',
|
||||
page: currentPage,
|
||||
rows: pageSize,
|
||||
}, data => {
|
||||
this.totalCount = data.total;
|
||||
this.tableData = data.list;
|
||||
this.listLoading = false;
|
||||
});
|
||||
},
|
||||
handleNavChange(e) {
|
||||
if (e.length === 0) {
|
||||
// 重新加载
|
||||
this.$set(this.search, 'nav', '');
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize);
|
||||
}
|
||||
},
|
||||
handleSelectCategory(index) {
|
||||
for (let item of this.categoryOpt) {
|
||||
item.selected = false;
|
||||
}
|
||||
this.categoryOpt[index].selected = true;
|
||||
this.search.category = this.categoryOpt[index].category === 'all' ? '' : this.categoryOpt[index].category;
|
||||
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize);
|
||||
},
|
||||
// 搜索
|
||||
searchData() {
|
||||
this.sendStartTime = this.search.startTime !== '' ? +this.search.startTime / 1000 : '';
|
||||
this.sendEndTime = this.search.endTime !== '' ? +this.search.endTime / 1000 : '';
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize);
|
||||
},
|
||||
// 每页显示数据量变更
|
||||
handleSizeChange(val) {
|
||||
this.pageSize = val;
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize);
|
||||
},
|
||||
// 页码变更
|
||||
handleCurrentChange(val) {
|
||||
this.currentPage = val;
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize);
|
||||
},
|
||||
// 多选响应
|
||||
handleSelectionChange(val) {
|
||||
this.multipleSelection = val;
|
||||
},
|
||||
// 批量恢复
|
||||
restoreMany() {
|
||||
if (this.multipleSelection.length === 0) {
|
||||
this.$message.warning('请选择至少一个文件进行恢复!');
|
||||
return;
|
||||
}
|
||||
var array = [];
|
||||
this.multipleSelection.forEach((row) => {
|
||||
array.push(row.id);
|
||||
});
|
||||
|
||||
this.$confirm('您确定要恢复所选的文件吗?', '温馨提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
let loading = this.$loading({
|
||||
lock: true,
|
||||
text: '正在删除中..',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.3)'
|
||||
});
|
||||
$.ajax({
|
||||
url: 'general/file/restoreData',
|
||||
data: "ids=" + array,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
success: res => {
|
||||
loading.close();
|
||||
if (res.code === 1) {
|
||||
this.$message.success('恢复文件成功');
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize);
|
||||
} else {
|
||||
this.$message.warning(res.msg);
|
||||
}
|
||||
},
|
||||
error: function (er) {
|
||||
|
||||
}
|
||||
});
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
restore(id) {
|
||||
this.$confirm('您确定要恢复此文件吗?', '温馨提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
let loading = this.$loading({
|
||||
lock: true,
|
||||
text: '正在恢复中..',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.3)'
|
||||
});
|
||||
$.ajax({
|
||||
url: 'general/file/restoreData',
|
||||
data: {
|
||||
ids: id
|
||||
},
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
success: res => {
|
||||
loading.close();
|
||||
if (res.code === 1) {
|
||||
this.$message.success('删除恢复成功');
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize);
|
||||
} else {
|
||||
this.$message.warning(res.msg);
|
||||
}
|
||||
},
|
||||
error: function (er) {
|
||||
|
||||
}
|
||||
});
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
// 批量删除
|
||||
del() {
|
||||
if (this.multipleSelection.length === 0) {
|
||||
this.$message.warning('请选择至少一个文件进行删除!');
|
||||
return;
|
||||
}
|
||||
var array = [];
|
||||
this.multipleSelection.forEach((row) => {
|
||||
array.push(row.id);
|
||||
});
|
||||
|
||||
this.$confirm('您确定要删除所选的文件吗?', '温馨提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
let loading = this.$loading({
|
||||
lock: true,
|
||||
text: '正在删除中..',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.3)'
|
||||
});
|
||||
$.ajax({
|
||||
url: 'general/attachment/del',
|
||||
data: "ids=" + array,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
success: res => {
|
||||
loading.close();
|
||||
if (res.code === 1) {
|
||||
this.$message.success('删除文件成功');
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize);
|
||||
} else {
|
||||
this.$message.warning(res.msg);
|
||||
}
|
||||
},
|
||||
error: function (er) {
|
||||
|
||||
}
|
||||
});
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
// 单条删除
|
||||
dell(id) {
|
||||
this.$confirm('您确定要删除此文件吗?', '温馨提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
let loading = this.$loading({
|
||||
lock: true,
|
||||
text: '正在删除中..',
|
||||
spinner: 'el-icon-loading',
|
||||
background: 'rgba(0, 0, 0, 0.3)'
|
||||
});
|
||||
$.ajax({
|
||||
url: 'general/attachment/del',
|
||||
data: {
|
||||
ids: id
|
||||
},
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
success: res => {
|
||||
loading.close();
|
||||
if (res.code === 1) {
|
||||
this.$message.success('删除文件成功');
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize);
|
||||
} else {
|
||||
this.$message.warning(res.msg);
|
||||
}
|
||||
},
|
||||
error: function (er) {
|
||||
|
||||
}
|
||||
});
|
||||
}).catch(() => {
|
||||
|
||||
});
|
||||
},
|
||||
}
|
||||
})
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
在新工单中引用
屏蔽一个用户