修改功能
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;
|
||||
@@ -161,14 +170,13 @@
|
||||
var lineagePersonId = normalizeId(item && item.lineagePersonId);
|
||||
var title = String(item && item.recordTitle || '').trim();
|
||||
var status = stringValue(item && item.status);
|
||||
var mediaOssIds = stringValue(item && item.mediaOssIds);
|
||||
var mediaFiles = MediaDisplay ? MediaDisplay.normalizeFileList(item && item.mediaFiles) : [];
|
||||
var sortOrder = optionalSafeInteger(item && item.sortOrder);
|
||||
var record;
|
||||
|
||||
if (!recordId || !genealogyId || !title || (status !== '0' && status !== '1')) return null;
|
||||
if (item.appUserId !== undefined && item.appUserId !== null && item.appUserId !== '' && !appUserId) return null;
|
||||
if (item.lineagePersonId !== undefined && item.lineagePersonId !== null && item.lineagePersonId !== '' && !lineagePersonId) 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 = {
|
||||
recordId: recordId,
|
||||
@@ -185,10 +193,10 @@
|
||||
recordContent: stringValue(item.recordContent),
|
||||
recordDate: stringValue(item.recordDate),
|
||||
remindTime: stringValue(item.remindTime),
|
||||
mediaOssIds: mediaOssIds,
|
||||
status: status,
|
||||
remark: stringValue(item.remark)
|
||||
};
|
||||
if (mediaFiles.length) record.mediaFiles = mediaFiles;
|
||||
if (appUserId) record.appUserId = appUserId;
|
||||
if (lineagePersonId) record.lineagePersonId = lineagePersonId;
|
||||
if (sortOrder !== undefined) record.sortOrder = sortOrder;
|
||||
@@ -238,8 +246,8 @@
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function attachmentCount(mediaOssIds) {
|
||||
return mediaOssIds ? mediaOssIds.split(',').filter(Boolean).length : 0;
|
||||
function attachmentCount(mediaFiles) {
|
||||
return Array.isArray(mediaFiles) ? mediaFiles.length : 0;
|
||||
}
|
||||
|
||||
function buildListUrl(genealogyId, recordId) {
|
||||
@@ -285,14 +293,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.recordId)) + '">编辑记录</a>' +
|
||||
'<button class="btn ghost" type="button" data-growth-delete-id="' +
|
||||
'<button class="btn danger" type="button" data-growth-delete-id="' +
|
||||
escapeHtml(record.recordId) + '">删除记录</button></div>';
|
||||
}
|
||||
return '<div class="form-like growth-detail">' +
|
||||
return (MediaDisplay ? MediaDisplay.renderGallery(record.mediaFiles, { label: '成长记录附件' }) : '') +
|
||||
'<div class="form-like growth-detail">' +
|
||||
detailValue('标题', record.recordTitle) +
|
||||
detailValue('关联人物', record.lineagePersonName || record.lineagePersonNo) +
|
||||
detailValue('记录类型', record.recordType) +
|
||||
@@ -664,7 +673,7 @@
|
||||
var record = recordsById[recordId];
|
||||
|
||||
if (writePending || !canEditContent || !genealogyId || !normalizeId(recordId) || redirectUnauthorized(api)) return;
|
||||
if (root.confirm && !root.confirm('确认删除“' + (record ? record.recordTitle : '该成长记录') + '”吗?删除后不可恢复,并会释放附件引用。')) return;
|
||||
if (!await confirmAction('确认删除“' + (record ? record.recordTitle : '该成长记录') + '”吗?删除后不可恢复,并会释放附件引用。')) return;
|
||||
setWritePending(true);
|
||||
try {
|
||||
await api.deleteGrowthRecord(genealogyId, recordId);
|
||||
@@ -694,10 +703,19 @@
|
||||
var detailButton = event.target.closest('[data-growth-detail-id]');
|
||||
var deleteButton = event.target.closest('[data-growth-delete-id]');
|
||||
var clearMediaButton = event.target.closest('[data-growth-clear-media]');
|
||||
var recordId;
|
||||
var genealogyId;
|
||||
|
||||
if (detailButton) {
|
||||
event.preventDefault();
|
||||
loadGrowthDetail(detailButton.getAttribute('data-growth-detail-id'));
|
||||
recordId = detailButton.getAttribute('data-growth-detail-id');
|
||||
genealogyId = requireGenealogyId();
|
||||
if (root.history && genealogyId) root.history.replaceState(null, '', buildListUrl(genealogyId, recordId));
|
||||
loadGrowthDetail(recordId).then(function (record) {
|
||||
if (record && root.ProfileUI && root.ProfileUI.revealDetail) {
|
||||
root.ProfileUI.revealDetail(query('[data-growth-detail-heading]'));
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (deleteButton) {
|
||||
|
||||
Reference in New Issue
Block a user