Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: 上传多图时多图之间可拖拽排序 #142

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion public/static/admin/css/public.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ html, body {
border: 1px solid #e2e2e2;
}

.layuimini-upload-show a img {
.layuimini-upload-show li img {
height: 80px;
object-fit: cover;
}
Expand All @@ -149,6 +149,7 @@ html, body {
position: absolute;
right: 10px;
font-size: 12px;
cursor: pointer;
}

.bg-red {
Expand Down
1 change: 1 addition & 0 deletions public/static/config-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require.config({
"xmSelect": ["plugs/lay-module/xmSelect/xm-select"],
"vue": ["plugs/vue-2.6.10/vue.min"],
"ckeditor": ["plugs/ckeditor4/ckeditor"],
"sortable": ["plugs/sortable/Sortable.min"],
}
});

Expand Down
17 changes: 15 additions & 2 deletions public/static/plugs/easy-admin/easy-admin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(["jquery", "tableSelect","xmSelect", "ckeditor"], function ($, tableSelect, xmSelect, undefined) {
define(["jquery", "xmSelect", "sortable", "tableSelect", "ckeditor"], function ($, xmSelect, Sortable) {

var form = layui.form,
layer = layui.layer,
Expand Down Expand Up @@ -1375,9 +1375,22 @@ define(["jquery", "tableSelect","xmSelect", "ckeditor"], function ($, tableSelec
var parant = $(this).parent('div');
var liHtml = '';
$.each(urlArray, function (i, v) {
liHtml += '<li><a><img src="' + v + '" data-image onerror="this.src=\'' + BASE_URL + 'admin/images/upload-icons/' + uploadIcon + '.png\';this.onerror=null"></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 data-id="' + i + '"><img src="' + v + '" data-image onerror="this.src=\'' + BASE_URL + 'admin/images/upload-icons/' + uploadIcon + '.png\';this.onerror=null"><small class="uploads-delete-tip bg-red badge" data-upload-delete="' + uploadName + '" data-upload-url="' + v + '" data-upload-sign="' + uploadSign + '">×</small></li>\n';
});
parant.after('<ul id="bing-' + uploadName + '" class="layui-input-block layuimini-upload-show">\n' + liHtml + '</ul>');
// 多图时可拖拽排序
if (uploadNumber !== 'one') {
var sortable = Sortable.create(document.getElementById('bing-' + uploadName), {
animation: 800,
onUpdate: function (evt) {
var newUrlArray = []
$.each(sortable.toArray(), function (i, v) {
newUrlArray.push(urlArray[v])
})
$(event.currentTarget).val(newUrlArray.join(uploadSign));
}
});
}
}

});
Expand Down
Loading