修改功能
This commit is contained in:
+28
-10
@@ -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;
|
||||
@@ -213,7 +222,7 @@
|
||||
var appUserId = normalizeId(item && item.appUserId);
|
||||
var relativeName = String(item && item.relativeName || '').trim();
|
||||
var status = stringValue(item && item.status);
|
||||
var mediaOssIds = stringValue(item && item.mediaOssIds);
|
||||
var mediaFiles = MediaDisplay ? MediaDisplay.normalizeFileList(item && item.mediaFiles) : [];
|
||||
var giftAmount = normalizeAmount(item && item.giftAmount);
|
||||
var sortOrder = optionalSafeInteger(item && item.sortOrder);
|
||||
var record;
|
||||
@@ -221,7 +230,6 @@
|
||||
if (!relativeId || !genealogyId || !relativeName || (status !== '0' && status !== '1')) return null;
|
||||
if (item.appUserId !== undefined && item.appUserId !== null && item.appUserId !== '' && !appUserId) return null;
|
||||
if (item.giftAmount !== undefined && item.giftAmount !== null && item.giftAmount !== '' && giftAmount === '') return null;
|
||||
if (mediaOssIds && !/^[1-9][0-9]*(,[1-9][0-9]*)*$/.test(mediaOssIds)) return null;
|
||||
if (item.sortOrder !== undefined && item.sortOrder !== null && item.sortOrder !== '' && sortOrder === undefined) return null;
|
||||
record = {
|
||||
relativeId: relativeId,
|
||||
@@ -237,10 +245,10 @@
|
||||
eventTime: stringValue(item.eventTime),
|
||||
giftAmount: giftAmount,
|
||||
recordContent: stringValue(item.recordContent),
|
||||
mediaOssIds: mediaOssIds,
|
||||
status: status,
|
||||
remark: stringValue(item.remark)
|
||||
};
|
||||
if (mediaFiles.length) record.mediaFiles = mediaFiles;
|
||||
if (appUserId) record.appUserId = appUserId;
|
||||
if (sortOrder !== undefined) record.sortOrder = sortOrder;
|
||||
return record;
|
||||
@@ -265,8 +273,8 @@
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
function attachmentCount(mediaOssIds) {
|
||||
return mediaOssIds ? mediaOssIds.split(',').filter(Boolean).length : 0;
|
||||
function attachmentCount(mediaFiles) {
|
||||
return Array.isArray(mediaFiles) ? mediaFiles.length : 0;
|
||||
}
|
||||
|
||||
function buildListUrl(genealogyId, relativeId) {
|
||||
@@ -312,14 +320,15 @@
|
||||
var actions = '';
|
||||
|
||||
if (!record) return stateHtml('empty', '请选择一条亲友记录查看详情');
|
||||
count = attachmentCount(record.mediaOssIds);
|
||||
count = attachmentCount(record.mediaFiles);
|
||||
if (canEditContent) {
|
||||
actions = '<div class="bottom-actions"><a class="btn ghost" href="' +
|
||||
escapeHtml(buildEditUrl(record.genealogyId, record.relativeId)) + '">编辑记录</a>' +
|
||||
'<button class="btn ghost" type="button" data-relative-delete-id="' +
|
||||
'<button class="btn danger" type="button" data-relative-delete-id="' +
|
||||
escapeHtml(record.relativeId) + '">删除记录</button></div>';
|
||||
}
|
||||
return '<div class="form-like relative-detail">' +
|
||||
return (MediaDisplay ? MediaDisplay.renderGallery(record.mediaFiles, { label: '亲友记录附件' }) : '') +
|
||||
'<div class="form-like relative-detail">' +
|
||||
detailValue('亲友姓名', record.relativeName) +
|
||||
detailValue('关系名称', record.relationName) +
|
||||
detailValue('事件名称', record.eventName) +
|
||||
@@ -666,7 +675,7 @@
|
||||
var record = recordsById[relativeId];
|
||||
|
||||
if (writePending || !canEditContent || !genealogyId || !normalizeId(relativeId) || redirectUnauthorized(api)) return;
|
||||
if (root.confirm && !root.confirm('确认删除“' + (record ? record.relativeName : '该亲友记录') + '”吗?删除后不可恢复,并会释放附件引用。')) return;
|
||||
if (!await confirmAction('确认删除“' + (record ? record.relativeName : '该亲友记录') + '”吗?删除后不可恢复,并会释放附件引用。')) return;
|
||||
setWritePending(true);
|
||||
try {
|
||||
await api.deleteRelativeRecord(genealogyId, relativeId);
|
||||
@@ -696,10 +705,19 @@
|
||||
var detailButton = event.target.closest('[data-relative-detail-id]');
|
||||
var deleteButton = event.target.closest('[data-relative-delete-id]');
|
||||
var clearMediaButton = event.target.closest('[data-relative-clear-media]');
|
||||
var relativeId;
|
||||
var genealogyId;
|
||||
|
||||
if (detailButton) {
|
||||
event.preventDefault();
|
||||
loadRelativeDetail(detailButton.getAttribute('data-relative-detail-id'));
|
||||
relativeId = detailButton.getAttribute('data-relative-detail-id');
|
||||
genealogyId = requireGenealogyId();
|
||||
if (root.history && genealogyId) root.history.replaceState(null, '', buildListUrl(genealogyId, relativeId));
|
||||
loadRelativeDetail(relativeId).then(function (record) {
|
||||
if (record && root.ProfileUI && root.ProfileUI.revealDetail) {
|
||||
root.ProfileUI.revealDetail(query('[data-relative-detail-heading]'));
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (deleteButton) {
|
||||
|
||||
Reference in New Issue
Block a user