修改功能
This commit is contained in:
@@ -13,6 +13,15 @@
|
||||
})(typeof globalThis !== 'undefined' ? globalThis : window, function (root) {
|
||||
'use strict';
|
||||
|
||||
function confirmAction(message) {
|
||||
if (root.ProfileUI && typeof root.ProfileUI.confirmAction === 'function') {
|
||||
return root.ProfileUI.confirmAction(message);
|
||||
}
|
||||
return Promise.resolve(!root['confirm'] || root['confirm'](message));
|
||||
}
|
||||
|
||||
var MediaDisplay = root.MediaDisplay || (typeof require === 'function' ? require('./media-display.js') : null);
|
||||
|
||||
var documentRef = root.document;
|
||||
var recordsById = Object.create(null);
|
||||
var canEditContent = false;
|
||||
@@ -249,6 +258,8 @@
|
||||
status: status,
|
||||
remark: stringValue(item.remark)
|
||||
};
|
||||
var mediaFiles = MediaDisplay ? MediaDisplay.normalizeFileList(item && item.mediaFiles) : [];
|
||||
if (mediaFiles.length) record.mediaFiles = mediaFiles;
|
||||
if (appUserId) record.appUserId = appUserId;
|
||||
if (sortOrder !== undefined) record.sortOrder = sortOrder;
|
||||
return record;
|
||||
@@ -316,10 +327,11 @@
|
||||
if (canEditContent) {
|
||||
actions = '<div class="bottom-actions"><a class="btn ghost" href="' +
|
||||
escapeHtml(buildEditUrl(record.genealogyId, record.meritId)) + '">编辑功德记录</a>' +
|
||||
'<button class="btn ghost" type="button" data-merit-delete-id="' +
|
||||
'<button class="btn danger" type="button" data-merit-delete-id="' +
|
||||
escapeHtml(record.meritId) + '">删除功德记录</button></div>';
|
||||
}
|
||||
return '<div class="form-like merit-detail">' +
|
||||
return (MediaDisplay ? MediaDisplay.renderGallery(record.mediaFiles, { label: '功德记录附件' }) : '') +
|
||||
'<div class="form-like merit-detail">' +
|
||||
detailValue('功德人', record.donorName) +
|
||||
detailValue('功德类型', meritTypes[record.meritType]) +
|
||||
detailValue('功德标题', record.meritTitle) +
|
||||
@@ -670,7 +682,7 @@
|
||||
var record = recordsById[meritId];
|
||||
|
||||
if (writePending || !canEditContent || !genealogyId || !normalizeId(meritId) || redirectUnauthorized(api)) return;
|
||||
if (root.confirm && !root.confirm('确认删除“' + (record ? record.meritTitle : '该功德记录') + '”吗?删除后不可恢复。')) return;
|
||||
if (!await confirmAction('确认删除“' + (record ? record.meritTitle : '该功德记录') + '”吗?删除后不可恢复。')) return;
|
||||
setWritePending(true);
|
||||
try {
|
||||
await api.deleteMeritRecord(genealogyId, meritId);
|
||||
@@ -689,10 +701,19 @@
|
||||
documentRef.addEventListener('click', function (event) {
|
||||
var detailButton = event.target.closest('[data-merit-detail-id]');
|
||||
var deleteButton = event.target.closest('[data-merit-delete-id]');
|
||||
var meritId;
|
||||
var genealogyId;
|
||||
|
||||
if (detailButton) {
|
||||
event.preventDefault();
|
||||
loadMeritDetail(detailButton.getAttribute('data-merit-detail-id'));
|
||||
meritId = detailButton.getAttribute('data-merit-detail-id');
|
||||
genealogyId = requireGenealogyId();
|
||||
if (root.history && genealogyId) root.history.replaceState(null, '', buildListUrl(genealogyId, meritId));
|
||||
loadMeritDetail(meritId).then(function (record) {
|
||||
if (record && root.ProfileUI && root.ProfileUI.revealDetail) {
|
||||
root.ProfileUI.revealDetail(query('[data-merit-detail-heading]'));
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (deleteButton) {
|
||||
|
||||
Reference in New Issue
Block a user