feat: 审核配方只通知管理员 + 指派高级编辑审核
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 14s
Test / e2e-test (push) Failing after 53s

- 去审核按钮仅管理员可见,其他用户显示已读
- 共享配方通知只发管理员
- 管理员待审核栏加"指派"按钮,选择高级编辑者审核
- 指派后发送通知给被指派人
- 新增 /api/recipes/{id}/assign-review 端点

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 15:54:16 +00:00
parent 27f82d2dd1
commit 1d9631f5df
3 changed files with 70 additions and 9 deletions

View File

@@ -130,7 +130,7 @@ function isSearchMissing(n) {
}
function isReviewable(n) {
if (!n.title) return false
if (!auth.isAdmin || !n.title) return false
return n.title.includes('待审核') || n.title.includes('商业认证') || n.title.includes('申请')
}

View File

@@ -11,6 +11,14 @@
<span class="pending-owner">{{ r._owner_name }}</span>
<button class="btn-sm btn-approve" @click="approveRecipe(r)">通过</button>
<button class="btn-sm btn-reject" @click="rejectRecipe(r)">拒绝</button>
<button class="btn-sm btn-outline" @click="r._showAssign = !r._showAssign">指派</button>
<div v-if="r._showAssign" class="assign-row">
<select v-model="r._assignTo" class="assign-select">
<option value="">选择审核人...</option>
<option v-for="u in seniorEditors" :key="u.id" :value="u.id">{{ u.display_name || u.username }}</option>
</select>
<button class="btn-sm btn-primary" @click="assignReview(r)" :disabled="!r._assignTo">发送</button>
</div>
</div>
</div>
@@ -416,6 +424,7 @@ const editingRecipe = ref(null)
const showPending = ref(false)
const pendingRecipes = ref([])
const pendingCount = ref(0)
const seniorEditors = ref([])
// Form state
const formName = ref('')
@@ -1069,6 +1078,13 @@ onMounted(async () => {
const res = await api('/api/recipe-reviews')
if (res.ok) reviewHistory.value = await res.json()
} catch {}
try {
const res = await api('/api/users')
if (res.ok) {
const users = await res.json()
seniorEditors.value = users.filter(u => u.role === 'senior_editor')
}
} catch {}
}
// Open recipe editor if redirected from card view
const editId = localStorage.getItem('oil_edit_recipe_id')
@@ -1092,6 +1108,24 @@ function editDiaryRecipe(diary) {
showAddOverlay.value = true
}
async function assignReview(recipe) {
const userId = recipe._assignTo
if (!userId) return
try {
const res = await api('/api/recipes/' + recipe._id + '/assign-review', {
method: 'POST',
body: JSON.stringify({ user_id: userId }),
})
if (res.ok) {
recipe._showAssign = false
recipe._assignTo = ''
ui.showToast('已指派审核')
}
} catch {
ui.showToast('指派失败')
}
}
function openRecipeDetail(recipe) {
const idx = recipeStore.recipes.findIndex(r => r._id === recipe._id)
if (idx >= 0) previewRecipeIndex.value = idx
@@ -1700,6 +1734,9 @@ watch(() => recipeStore.recipes, () => {
padding: 0; margin-right: 4px; line-height: 1;
}
.mini-select.active { background: #4a9d7e; border-color: #4a9d7e; color: #fff; }
.assign-row { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.assign-select { padding: 4px 8px; border: 1px solid #d4cfc7; border-radius: 6px; font-size: 12px; font-family: inherit; }
.btn-primary { background: linear-gradient(135deg, #7ec6a4, #4a9d7e); color: #fff; border: none; border-radius: 8px; cursor: pointer; font-family: inherit; }
.tag-list-bar {
display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; padding: 8px 0;
}