mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-09 19:42:47 +08:00
优化url功能;优化filePreview表现;
This commit is contained in:
@@ -8,7 +8,7 @@ define(["jquery", "easy-admin"], function ($, ea) {
|
|||||||
edit_url: 'system.uploadfile/edit',
|
edit_url: 'system.uploadfile/edit',
|
||||||
delete_url: 'system.uploadfile/delete',
|
delete_url: 'system.uploadfile/delete',
|
||||||
modify_url: 'system.uploadfile/modify',
|
modify_url: 'system.uploadfile/modify',
|
||||||
export_url:'system.uploadfile/export',
|
export_url: 'system.uploadfile/export',
|
||||||
};
|
};
|
||||||
|
|
||||||
var Controller = {
|
var Controller = {
|
||||||
@@ -17,16 +17,20 @@ define(["jquery", "easy-admin"], function ($, ea) {
|
|||||||
ea.table.render({
|
ea.table.render({
|
||||||
init: init,
|
init: init,
|
||||||
cols: [[
|
cols: [[
|
||||||
{type: "checkbox"},
|
{ type: "checkbox" },
|
||||||
{field: 'id', width: 80, title: 'ID'},
|
{ field: 'id', width: 80, title: 'ID' },
|
||||||
{field: 'upload_type', minWidth: 80, title: '存储位置', search: 'select', selectList: {'local': '本地', 'alioss': '阿里云', 'qnoss': '七牛云', ',txcos': '腾讯云'}},
|
{ field: 'upload_type', minWidth: 80, title: '存储位置', search: 'select', selectList: { 'local': '本地', 'alioss': '阿里云', 'qnoss': '七牛云', ',txcos': '腾讯云' } },
|
||||||
{field: 'url', minWidth: 80, search: false, title: '图片信息', templet: ea.table.filePreview},
|
{ field: 'url', minWidth: 80, search: false, title: '文件预览', templet: ea.table.filePreview },
|
||||||
{field: 'url', minWidth: 120, title: '保存地址', templet: ea.table.url},
|
{
|
||||||
{field: 'original_name', minWidth: 80, title: '文件原名'},
|
field: 'url', minWidth: 120, title: '保存地址', templet: ea.table.url, urlNameField: function (data) {
|
||||||
{field: 'mime_type', minWidth: 80, title: 'mime类型'},
|
return data.url;
|
||||||
{field: 'file_ext', minWidth: 80, title: '文件后缀'},
|
}
|
||||||
{field: 'create_time', minWidth: 80, title: '创建时间', search: 'range'},
|
},
|
||||||
{width: 250, title: '操作', templet: ea.table.tool, operat: ['delete'],fixed:'right'}
|
{ field: 'original_name', minWidth: 80, title: '文件原名' },
|
||||||
|
{ field: 'mime_type', minWidth: 80, title: 'mime类型' },
|
||||||
|
{ field: 'file_ext', minWidth: 80, title: '文件后缀' },
|
||||||
|
{ field: 'create_time', minWidth: 80, title: '创建时间', search: 'range' },
|
||||||
|
{ width: 250, title: '操作', templet: ea.table.tool, operat: ['delete'], fixed: 'right' }
|
||||||
]],
|
]],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine
|
|||||||
'video': ['mp4', 'avi', 'wmv', '3gp', 'flv'],
|
'video': ['mp4', 'avi', 'wmv', '3gp', 'flv'],
|
||||||
// visio扩展名数组
|
// visio扩展名数组
|
||||||
'visio': ['vsd', 'vsdx'],
|
'visio': ['vsd', 'vsdx'],
|
||||||
|
'file': []
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const extGroupName in extGroup) {
|
for (const extGroupName in extGroup) {
|
||||||
@@ -852,18 +853,25 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
filePreview: function (data) {
|
filePreview: function (data) {
|
||||||
|
var option = data.LAY_COL;
|
||||||
if (!data.mime_type) {
|
|
||||||
return admin.table.url(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
var mimeName = data.mime_type.split('/')[0];
|
var mimeName = data.mime_type.split('/')[0];
|
||||||
|
var field = option.field;
|
||||||
|
|
||||||
if (mimeName == 'image') {
|
if (mimeName == 'image') {
|
||||||
return admin.table.image(data);
|
return admin.table.image(data);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
try {
|
||||||
|
var value = eval("data." + field);
|
||||||
|
} catch (e) {
|
||||||
|
var value = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
var groupName = admin.getExtGroupName(data.file_ext);
|
||||||
|
|
||||||
|
return '<a href="' + value + '"><img style="height:40px;width:40px" src="/static/admin/images/upload-icons/' + groupName + '.png" /></a>'
|
||||||
}
|
}
|
||||||
|
|
||||||
return admin.table.url(data);
|
|
||||||
},
|
},
|
||||||
image: function (data) {
|
image: function (data) {
|
||||||
var option = data.LAY_COL;
|
var option = data.LAY_COL;
|
||||||
@@ -893,12 +901,32 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine
|
|||||||
url: function (data) {
|
url: function (data) {
|
||||||
var option = data.LAY_COL;
|
var option = data.LAY_COL;
|
||||||
var field = option.field;
|
var field = option.field;
|
||||||
|
var urlNameField = option.urlNameField || '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var value = eval("data." + field);
|
var value = eval("data." + field);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
var value = undefined;
|
var value = undefined;
|
||||||
}
|
}
|
||||||
return '<a class="layuimini-table-url" href="' + value + '" target="_blank" class="label bg-green">' + value + '</a>';
|
|
||||||
|
var urlName = value;
|
||||||
|
|
||||||
|
if (urlNameField != '') {
|
||||||
|
try {
|
||||||
|
var urlNameFieldType = typeof urlNameField;
|
||||||
|
|
||||||
|
if (urlNameFieldType == 'string') {
|
||||||
|
urlName = data[urlNameField]
|
||||||
|
} else if (urlNameFieldType == 'function') {
|
||||||
|
urlName = urlNameField(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '<a class="layuimini-table-url" href="' + value + '" target="_blank" class="label bg-green">' + urlName + '</a>';
|
||||||
},
|
},
|
||||||
switch: function (data) {
|
switch: function (data) {
|
||||||
var option = data.LAY_COL;
|
var option = data.LAY_COL;
|
||||||
@@ -1705,15 +1733,7 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine
|
|||||||
// 不是图片
|
// 不是图片
|
||||||
// 遍历extGroup数组找到扩展名所在的索引
|
// 遍历extGroup数组找到扩展名所在的索引
|
||||||
|
|
||||||
for (const extGroupName in extGroup) {
|
uploadIcon = admin.getExtGroupName(ext);
|
||||||
if (Object.hasOwnProperty.call(extGroup, extGroupName)) {
|
|
||||||
const extGroupList = extGroup[extGroupName];
|
|
||||||
if (extGroupList.indexOf(ext) != -1) {
|
|
||||||
uploadIcon = extGroupName;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
liHtml += '<li><a title="点击打开文件" target="_blank" href="' + v + '" ><img src="/static/admin/images/upload-icons/' + uploadIcon + '.png"></a><small class="uploads-delete-tip bg-red badge" data-upload-delete="' + uploadName + '" data-upload-url="' + v + '" data-upload-sign="' + uploadSign + '">×</small></li>\n';
|
liHtml += '<li><a title="点击打开文件" target="_blank" href="' + v + '" ><img src="/static/admin/images/upload-icons/' + uploadIcon + '.png"></a><small class="uploads-delete-tip bg-red badge" data-upload-delete="' + uploadName + '" data-upload-url="' + v + '" data-upload-sign="' + uploadSign + '">×</small></li>\n';
|
||||||
|
|
||||||
@@ -1923,6 +1943,20 @@ define(["jquery", "tableSelect", "ckeditor"], function ($, tableSelect, undefine
|
|||||||
|
|
||||||
return this.dataBrage[name];
|
return this.dataBrage[name];
|
||||||
|
|
||||||
|
},
|
||||||
|
getExtGroupName(ext) {
|
||||||
|
var groupName = 'file';
|
||||||
|
for (const extGroupName in extGroup) {
|
||||||
|
if (Object.hasOwnProperty.call(extGroup, extGroupName)) {
|
||||||
|
const extGroupList = extGroup[extGroupName];
|
||||||
|
if (extGroupList.indexOf(ext) != -1) {
|
||||||
|
groupName = extGroupName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return groupName;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user