修改功能
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 memosById = Object.create(null);
|
||||
var canEditContent = false;
|
||||
@@ -161,7 +170,7 @@
|
||||
var appUserId = normalizeId(item && item.appUserId);
|
||||
var memoTitle = String(item && item.memoTitle || '').trim();
|
||||
var completed = stringValue(item && item.completed);
|
||||
var mediaOssIds = stringValue(item && item.mediaOssIds);
|
||||
var mediaFiles = MediaDisplay ? MediaDisplay.normalizeFileList(item && item.mediaFiles) : [];
|
||||
var status = stringValue(item && item.status);
|
||||
var sortOrder = optionalSafeInteger(item && item.sortOrder);
|
||||
var memo;
|
||||
@@ -170,7 +179,6 @@
|
||||
return null;
|
||||
}
|
||||
if (item.appUserId !== undefined && item.appUserId !== null && item.appUserId !== '' && !appUserId) 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;
|
||||
if (item.remindTime && !isValidBackendDateTime(String(item.remindTime))) return null;
|
||||
memo = {
|
||||
@@ -185,10 +193,10 @@
|
||||
memoContent: stringValue(item.memoContent),
|
||||
remindTime: stringValue(item.remindTime),
|
||||
completed: completed,
|
||||
mediaOssIds: mediaOssIds,
|
||||
status: status,
|
||||
remark: stringValue(item.remark)
|
||||
};
|
||||
if (mediaFiles.length) memo.mediaFiles = mediaFiles;
|
||||
if (appUserId) memo.appUserId = appUserId;
|
||||
if (sortOrder !== undefined) memo.sortOrder = sortOrder;
|
||||
return memo;
|
||||
@@ -213,8 +221,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, memoId) {
|
||||
@@ -259,14 +267,15 @@
|
||||
var actions = '';
|
||||
|
||||
if (!memo) return stateHtml('empty', '请选择一条备忘录查看详情');
|
||||
count = attachmentCount(memo.mediaOssIds);
|
||||
count = attachmentCount(memo.mediaFiles);
|
||||
if (canEditContent) {
|
||||
actions = '<div class="bottom-actions"><a class="btn ghost" href="' +
|
||||
escapeHtml(buildEditUrl(memo.genealogyId, memo.memoId)) + '">编辑备忘录</a>' +
|
||||
'<button class="btn ghost" type="button" data-memo-delete-id="' +
|
||||
'<button class="btn danger" type="button" data-memo-delete-id="' +
|
||||
escapeHtml(memo.memoId) + '">删除备忘录</button></div>';
|
||||
}
|
||||
return '<div class="form-like memo-detail">' +
|
||||
return (MediaDisplay ? MediaDisplay.renderGallery(memo.mediaFiles, { label: '备忘录附件' }) : '') +
|
||||
'<div class="form-like memo-detail">' +
|
||||
detailValue('备忘标题', memo.memoTitle) +
|
||||
detailValue('备忘内容', memo.memoContent) +
|
||||
detailValue('提醒时间', memo.remindTime) +
|
||||
@@ -606,7 +615,7 @@
|
||||
var memo = memosById[memoId];
|
||||
|
||||
if (writePending || !canEditContent || !genealogyId || !normalizeId(memoId) || redirectUnauthorized(api)) return;
|
||||
if (root.confirm && !root.confirm('确认删除“' + (memo ? memo.memoTitle : '该备忘录') + '”吗?删除后不可恢复,并会释放附件引用。')) return;
|
||||
if (!await confirmAction('确认删除“' + (memo ? memo.memoTitle : '该备忘录') + '”吗?删除后不可恢复,并会释放附件引用。')) return;
|
||||
setWritePending(true);
|
||||
try {
|
||||
await api.deleteMemo(genealogyId, memoId);
|
||||
@@ -636,10 +645,19 @@
|
||||
var detailButton = event.target.closest('[data-memo-detail-id]');
|
||||
var deleteButton = event.target.closest('[data-memo-delete-id]');
|
||||
var clearMediaButton = event.target.closest('[data-memo-clear-media]');
|
||||
var memoId;
|
||||
var genealogyId;
|
||||
|
||||
if (detailButton) {
|
||||
event.preventDefault();
|
||||
loadMemoDetail(detailButton.getAttribute('data-memo-detail-id'));
|
||||
memoId = detailButton.getAttribute('data-memo-detail-id');
|
||||
genealogyId = requireGenealogyId();
|
||||
if (root.history && genealogyId) root.history.replaceState(null, '', buildListUrl(genealogyId, memoId));
|
||||
loadMemoDetail(memoId).then(function (memo) {
|
||||
if (memo && root.ProfileUI && root.ProfileUI.revealDetail) {
|
||||
root.ProfileUI.revealDetail(query('[data-memo-detail-heading]'));
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (deleteButton) {
|
||||
|
||||
Reference in New Issue
Block a user