进行了一些小修复
This commit is contained in:
+10
-54
@@ -587,60 +587,16 @@
|
||||
});
|
||||
});
|
||||
|
||||
var list = qs('[data-pay-download-list]', box);
|
||||
var tpl = qs('[data-pay-download-tpl]', box);
|
||||
var addBtn = qs('[data-pay-download-add]', box);
|
||||
if (addBtn && list && tpl) {
|
||||
addBtn.addEventListener('click', function () {
|
||||
var node = tpl.content.cloneNode(true);
|
||||
var idx = list.querySelectorAll('[data-pay-download-item]').length;
|
||||
qsa('[data-name]', node).forEach(function (input) {
|
||||
input.name = 'aksrt_pay[downloads][' + idx + '][' + input.getAttribute('data-name') + ']';
|
||||
});
|
||||
list.appendChild(node);
|
||||
});
|
||||
}
|
||||
var uploadBtn = qs('[data-pay-download-upload]', box);
|
||||
if (uploadBtn && list && tpl) {
|
||||
uploadBtn.addEventListener('click', function () {
|
||||
var toastId = 'aksrt-front-submit-resource-upload-toast';
|
||||
App.pickUpload('resource', '*/*').then(function (file) {
|
||||
if (!file) return null;
|
||||
uploadBtn.disabled = true;
|
||||
notyf(i18n.uploading || '正在上传附件…', 'load', '', toastId);
|
||||
return App.uploadFile('resource', file);
|
||||
}).then(function (file) {
|
||||
if (!file) return;
|
||||
var node = tpl.content.cloneNode(true);
|
||||
var idx = list.querySelectorAll('[data-pay-download-item]').length;
|
||||
qsa('[data-name]', node).forEach(function (input) {
|
||||
input.name = 'aksrt_pay[downloads][' + idx + '][' + input.getAttribute('data-name') + ']';
|
||||
});
|
||||
var url = qs('[data-pay-download-url]', node);
|
||||
var label = qs('[data-pay-download-label]', node);
|
||||
if (url) url.value = file.url || '';
|
||||
if (label) label.value = file.name || '';
|
||||
list.appendChild(node);
|
||||
notyf(i18n.uploaded || '附件上传成功', 'success', 5, toastId);
|
||||
}).catch(function (error) {
|
||||
notyf(error.message || i18n.error || '附件上传失败', 'danger', 5, toastId);
|
||||
}).finally(function () {
|
||||
uploadBtn.disabled = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
if (list) {
|
||||
list.addEventListener('click', function (e) {
|
||||
var rm = e.target.closest('[data-pay-download-remove]');
|
||||
if (!rm) {
|
||||
return;
|
||||
}
|
||||
var item = rm.closest('[data-pay-download-item]');
|
||||
if (item) {
|
||||
item.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
window.aksrtSubmitPayDownloads.init({
|
||||
root: box,
|
||||
pickUpload: this.pickUpload.bind(this),
|
||||
uploadFile: this.uploadFile.bind(this),
|
||||
notify: notyf,
|
||||
markDirty: function () {
|
||||
App.isDirty = true;
|
||||
App.form.setAttribute('data-dirty', 'true');
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
bindAi: function () {
|
||||
|
||||
Reference in New Issue
Block a user