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/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 }})· 可手动添加、从处方库或粘贴药方批量录入
+
+ 禁用修改
+ 含「禁用修改」处方库模板,药材已锁定,不可增删改,如需调整请重新「从处方库导入」覆盖
+
@@ -171,7 +176,7 @@
:class="{ 'herb-editor-card--dup': isDuplicateHerbName(row.index) }"
>
辅方
-
+
克
-
+
删除
@@ -1028,6 +1034,8 @@ interface Herb {
name: string
dosage: number
formula_type?: FormulaType
+ /** 来自「禁用修改」处方库模板:锁定后不可增删改,只能再次导入覆盖 */
+ locked?: boolean
}
type AuxUsageForm = {
@@ -1044,11 +1052,15 @@ function normalizeFormulaType(v: unknown): FormulaType {
}
function normalizeHerbRow(raw: any): Herb {
- return {
+ const row: Herb = {
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 defaultAuxUsage(prescriptionType = '浓缩水丸'): AuxUsageForm {
@@ -1430,6 +1442,12 @@ const auxHerbRows = computed(() =>
const mainHerbCount = computed(() => mainHerbRows.value.length)
const auxHerbCount = computed(() => auxHerbRows.value.length)
+/**
+ * 整张处方是否被锁定:只要任一药材来自「禁用修改」模板即锁定。
+ * 锁定后:不可增删改任意药材,仅可再次「从处方库导入」覆盖。
+ */
+const herbsLocked = computed(() => formData.herbs.some((h) => (h as Herb).locked === true))
+
const libraryDoctorId = computed(() => {
const uid = Number(userStore.userInfo?.id)
return uid > 0 ? uid : 0
@@ -2029,10 +2047,18 @@ function findDuplicateHerbNames(): string[] {
}
const handleAddHerb = (formulaType: FormulaType = '主方') => {
+ if (herbsLocked.value) {
+ feedback.msgWarning('该处方含「禁用修改」模板,药材已锁定,请重新从处方库导入覆盖')
+ return
+ }
formData.herbs.push({ name: '', dosage: 6, formula_type: formulaType })
}
const handleRemoveHerb = (index: number) => {
+ if (herbsLocked.value) {
+ feedback.msgWarning('该处方含「禁用修改」模板,药材已锁定,不可删除')
+ return
+ }
formData.herbs.splice(index, 1)
}
@@ -2089,10 +2115,18 @@ const handleImportLibrary = (row: any) => {
}
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 = formData.herbs.filter((h) => normalizeFormulaType(h.formula_type) !== formulaType)
formData.herbs = [...kept, ...imported]
@@ -2532,6 +2566,17 @@ defineExpose({
color: var(--el-text-color-regular);
}
+ .rp-toolbar__lock-tip {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ flex-wrap: wrap;
+ margin: 6px 0 0;
+ font-size: 12px;
+ line-height: 1.55;
+ color: var(--el-color-danger);
+ }
+
.rp-toolbar__actions {
display: flex;
flex-wrap: wrap;
diff --git a/admin/src/views/consumer/prescription/index.vue b/admin/src/views/consumer/prescription/index.vue
index c3fe442c..f854a294 100644
--- a/admin/src/views/consumer/prescription/index.vue
+++ b/admin/src/views/consumer/prescription/index.vue
@@ -679,17 +679,21 @@
粘贴文本解析药名与剂量;须与药品库名称完全一致才录入(导入至主方)
+
+ 禁用修改
+ 含「禁用修改」处方库模板,药材已锁定,不可增删改,如需调整请重新「从处方库导入」覆盖
+