diff --git a/.gitignore b/.gitignore index 5c227437..3edfba33 100644 --- a/.gitignore +++ b/.gitignore @@ -26,10 +26,6 @@ bin-release/ /.cursor /.codex /.agents -/.claude -/.claude -/.claude -/.kbctx /server/.spool /server/.claude /.spool diff --git a/admin/src/components/list-time-filter/index.vue b/admin/src/components/list-time-filter/index.vue new file mode 100644 index 00000000..00e511ca --- /dev/null +++ b/admin/src/components/list-time-filter/index.vue @@ -0,0 +1,96 @@ + + + + + diff --git a/admin/src/components/tcm-prescription/index.vue b/admin/src/components/tcm-prescription/index.vue index 3601d883..5abc7cc5 100644 --- a/admin/src/components/tcm-prescription/index.vue +++ b/admin/src/components/tcm-prescription/index.vue @@ -88,13 +88,17 @@ 共 {{ formData.herbs.length }} 味(主方 {{ mainHerbCount }} / 辅方 {{ auxHerbCount }})· 可手动添加、从处方库或粘贴药方批量录入

+

+ 禁用修改 + 含「禁用修改」处方库模板,药材已锁定,不可增删改,如需调整请重新「从处方库导入」覆盖 +

+
+ 禁用修改 + 含「禁用修改」处方库模板,药材已锁定,不可增删改,如需调整请重新「从处方库导入」覆盖 +
主方 - 添加主方药材 + 添加主方药材
@@ -699,6 +703,7 @@ :min="0" :precision="1" :step="0.5" + :disabled="herbsLocked" placeholder="剂量" class="w-full" /> @@ -706,7 +711,8 @@ @@ -715,7 +721,7 @@
辅方 - + 添加辅方药材
@@ -723,7 +729,7 @@ @@ -733,6 +739,7 @@ :min="0" :precision="1" :step="0.5" + :disabled="herbsLocked" placeholder="剂量" class="w-full" /> @@ -740,7 +747,8 @@ @@ -1698,7 +1706,7 @@ import jsPDF from 'jspdf' const TcmDiagnosisEditView = defineAsyncComponent(() => import('@/views/tcm/diagnosis/edit.vue')) type FormulaType = '主方' | '辅方' -type HerbRow = { name: string; dosage: number; formula_type: FormulaType } +type HerbRow = { name: string; dosage: number; formula_type: FormulaType; locked?: boolean } type AuxUsageForm = { dosage_amount?: number @@ -1798,11 +1806,15 @@ function normalizeFormulaType(v: unknown): FormulaType { } function normalizeHerbRow(raw: any): HerbRow { - return { + const row: HerbRow = { name: String(raw?.name ?? '').trim(), dosage: Number(raw?.dosage) || 0, formula_type: normalizeFormulaType(raw?.formula_type) } + if (raw?.locked === true || raw?.locked === 1) { + row.locked = true + } + return row } function normalizeSlipHerbs(raw: unknown): HerbRow[] { @@ -2481,6 +2493,12 @@ const auxHerbRows = computed(() => .filter(({ herb }) => normalizeFormulaType(herb.formula_type) === '辅方') ) +/** + * 整张处方是否被锁定:只要任一药材来自「禁用修改」处方库模板即锁定。 + * 锁定后不可增删改任意药材,只能再次「从处方库导入」覆盖。 + */ +const herbsLocked = computed(() => editForm.herbs.some((h) => (h as HerbRow).locked === true)) + const slipDietaryText = computed(() => { const d = slipView.value?.dietary_taboo if (Array.isArray(d)) return d.filter(Boolean).join('、') @@ -3441,10 +3459,18 @@ const handleImportLibrary = (row: any) => { return } const formulaType = normalizeFormulaType(row.formula_type) - const imported = (JSON.parse(JSON.stringify(row.herbs)) as any[]).map((h) => ({ - ...normalizeHerbRow(h), - formula_type: formulaType - })) + // 「禁用修改」模板:导入药材打上锁定标记 → 整张处方锁定(不可增删改,只能再次导入覆盖) + const isLockedTemplate = Number(row?.disable_edit) === 1 + const imported = (JSON.parse(JSON.stringify(row.herbs)) as any[]).map((h) => { + const herb = normalizeHerbRow(h) + herb.formula_type = formulaType + if (isLockedTemplate) { + herb.locked = true + } else { + delete herb.locked + } + return herb + }) if (libraryImportMode.value === 'replace') { const kept = editForm.herbs.filter((h) => normalizeFormulaType(h.formula_type) !== formulaType) editForm.herbs = [...kept, ...imported] @@ -3650,6 +3676,10 @@ async function handlePasteRecipeImport() { // 添加药材(主方 / 辅方) const addHerb = (formulaType: FormulaType = '主方') => { + if (herbsLocked.value) { + feedback.msgWarning('该处方含「禁用修改」模板,药材已锁定,请重新从处方库导入覆盖') + return + } editForm.herbs.push({ name: '', dosage: 0, @@ -3659,6 +3689,10 @@ const addHerb = (formulaType: FormulaType = '主方') => { // 删除药材 const removeHerb = (index: number) => { + if (herbsLocked.value) { + feedback.msgWarning('该处方含「禁用修改」模板,药材已锁定,不可删除') + return + } editForm.herbs.splice(index, 1) } diff --git a/admin/src/views/consumer/prescription/list.vue b/admin/src/views/consumer/prescription/list.vue index 184c1125..b182d2a9 100644 --- a/admin/src/views/consumer/prescription/list.vue +++ b/admin/src/views/consumer/prescription/list.vue @@ -71,6 +71,13 @@ + + + @@ -193,6 +200,21 @@ 勾选后,所有医生都可以查看和使用此处方模板
+ + +
+ +
+ 开启后,导入此模板到处方时将锁定整张处方的药材,不可增删改,只能再次导入覆盖 +
+
+