lobster_store_operation_menu.sql 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. -- ============================================================================
  2. -- 门店运营与医药工作台菜单优化脚本
  3. --
  4. -- 目标:
  5. -- 1. 管理端(saasmgnui)新增门店运营管理子菜单(业绩/交接班/接待/考勤)
  6. -- 2. 药师端(saaspharmacistui)新增"用药咨询工作台"菜单
  7. -- 3. 医生端(saasdoctorui)新增"在线问诊工作台"菜单
  8. -- 4. 精简药师/医生端可见菜单,隐藏管理类功能
  9. --
  10. -- 使用说明:
  11. -- 主库执行 PART A(sys_menu)
  12. -- 租户库逐租户执行 PART B(tenant_sys_menu)
  13. -- menu_id 使用 31000~31020 区段,不与现有 29xxx 冲突
  14. -- ============================================================================
  15. -- ######################################################################
  16. -- PART A:主库 sys_menu
  17. -- ######################################################################
  18. -- A.1 门店运营管理父菜单
  19. REPLACE INTO sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, perms, create_by, create_time, remark) VALUES
  20. (31000, '门店运营', 0, 90, '/storeOperation', '', 'M', 'el-icon-s-shop', '0', '0', 0, 0, NULL, 'admin', NOW(), 'Store Operation Hub'),
  21. -- A.2 门店运营子菜单
  22. (31001, '员工业绩', 31000, 1, 'staffPerformance', 'store/storeStaffPerformance/index', 'C', 'el-icon-s-marketing', '0', '0', 0, 0, 'store:operation:performance', 'admin', NOW(), NULL),
  23. (31002, '交接班管理', 31000, 2, 'shiftManage', 'store/storeShiftManage/index', 'C', 'el-icon-sort', '0', '0', 0, 0, 'store:operation:shift', 'admin', NOW(), NULL),
  24. (31003, '到店接待', 31000, 3, 'receptionManage', 'store/storeReceptionManage/index', 'C', 'el-icon-bell', '0', '0', 0, 0, 'store:operation:reception', 'admin', NOW(), NULL),
  25. (31004, '考勤打卡', 31000, 4, 'attendanceManage', 'store/storeAttendanceManage/index', 'C', 'el-icon-time', '0', '0', 0, 0, 'store:operation:attendance', 'admin', NOW(), NULL),
  26. (31005, '企微客户', 31000, 5, 'qwCustomer', 'store/storeQwCustomer/index', 'C', 'el-icon-chat-line-round', '0', '0', 0, 0, 'store:operation:qwCustomer', 'admin', NOW(), 'Store QW Customer'),
  27. (31006, '采购建议', 31000, 6, 'purchaseSuggestion', 'store/purchaseSuggestion/index', 'C', 'el-icon-shopping-bag-2', '0', '0', 0, 0, 'store:operation:purchase', 'admin', NOW(), 'Purchase Suggestion'),
  28. (31007, '挂号分诊', 31000, 7, 'clinicRegistration', 'store/clinicRegistration/index', 'C', 'el-icon-document-add', '0', '0', 0, 0, 'store:clinic:registration', 'admin', NOW(), 'Clinic Registration'),
  29. (31008, '就诊叫号', 31000, 8, 'clinicQueue', 'store/clinicQueue/index', 'C', 'el-icon-bell', '0', '0', 0, 0, 'store:clinic:queue', 'admin', NOW(), 'Clinic Queue'),
  30. (31009, '医生排班', 31000, 9, 'doctorSchedule', 'store/doctorSchedule/index', 'C', 'el-icon-date', '0', '0', 0, 0, 'store:clinic:schedule', 'admin', NOW(), 'Doctor Schedule'),
  31. -- A.3 药师工作台菜单
  32. (31010, '用药咨询工作台', 0, 50, '/imWorkbench', 'pharmacist/imWorkbench/index', 'C', 'el-icon-chat-dot-round', '0', '0', 0, 0, 'pharmacist:imworkbench', 'admin', NOW(), 'Pharmacist IM Workbench'),
  33. (31011, '药品销售统计', 0, 51, '/drugStatistics', 'pharmacist/drugStatistics/index', 'C', 'el-icon-pie-chart', '0', '0', 0, 0, 'pharmacist:drugstats', 'admin', NOW(), 'Drug Sales Statistics'),
  34. (31012, '慢病用药周期', 0, 52, '/drugCycle', 'pharmacist/drugCycle/index', 'C', 'el-icon-alarm-clock', '0', '0', 0, 0, 'pharmacist:drugcycle', 'admin', NOW(), 'Drug Cycle Dashboard'),
  35. -- A.4 医生工作台菜单
  36. (31015, '在线问诊工作台', 0, 50, '/consultWorkbench', 'doctor/consultWorkbench/index', 'C', 'el-icon-video-camera', '0', '0', 0, 0, 'doctor:consultworkbench', 'admin', NOW(), 'Doctor Consult Workbench'),
  37. (31016, '患者健康档案', 0, 51, '/patientRecord', 'doctor/patientRecord/index', 'C', 'el-icon-document', '0', '0', 0, 0, 'doctor:patientrecord', 'admin', NOW(), 'Patient Health Record'),
  38. (31017, '随访管理', 0, 52, '/followUp', 'doctor/followUp/index', 'C', 'el-icon-calendar', '0', '0', 0, 0, 'doctor:followup', 'admin', NOW(), 'Follow-up Management'),
  39. (31018, '病历管理', 0, 53, '/medicalRecord', 'doctor/medicalRecord/index', 'C', 'el-icon-tickets', '0', '0', 0, 0, 'doctor:medicalrecord', 'admin', NOW(), 'Medical Record Management');
  40. -- A.4b 企微客户菜单授权
  41. INSERT IGNORE INTO sys_role_menu (role_id, menu_id)
  42. SELECT r.role_id, 31005 FROM sys_role_menu r WHERE r.menu_id = 31000
  43. AND NOT EXISTS (SELECT 1 FROM sys_role_menu x WHERE x.role_id = r.role_id AND x.menu_id = 31005);
  44. -- A.5 同步到 company_menu(销售端子集)
  45. INSERT IGNORE INTO company_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, company_id, remark)
  46. SELECT s.menu_id, s.menu_name, s.parent_id, s.order_num, s.path, s.component, s.is_frame, s.is_cache, s.menu_type, s.visible, s.status, s.perms, s.icon, s.create_by, s.create_time, c.company_id, s.remark
  47. FROM sys_menu s
  48. CROSS JOIN (SELECT DISTINCT company_id FROM company_menu WHERE company_id IS NOT NULL) c
  49. WHERE s.menu_id IN (31000, 31001, 31002, 31003, 31004, 31005, 31006, 31007, 31008, 31009)
  50. AND NOT EXISTS (SELECT 1 FROM company_menu x WHERE x.menu_id = s.menu_id AND x.company_id = c.company_id);
  51. -- A.6 补全角色授权(门店运营菜单授权给门店管理员角色)
  52. INSERT IGNORE INTO sys_role_menu (role_id, menu_id)
  53. SELECT r.role_id, s.menu_id FROM sys_role_menu r CROSS JOIN sys_menu s
  54. WHERE r.menu_id = 31000 AND s.parent_id = 31000 AND s.menu_type = 'C' AND s.visible = '0'
  55. AND NOT EXISTS (SELECT 1 FROM sys_role_menu x WHERE x.role_id = r.role_id AND x.menu_id = s.menu_id);
  56. -- A.7 药师端菜单精简:隐藏管理类菜单(设置 visible=1 隐藏)
  57. -- 以下菜单对药师角色隐藏(billing/saas/system/monitor/lobster管理功能等)
  58. -- 通过 sys_role_menu 删除药师角色对这些菜单的关联
  59. -- 注意:此操作不影响管理端角色,仅清理药师/医生角色不需要的菜单关联
  60. -- 如需执行,请取消注释并替换 :pharmacistRoleId / :doctorRoleId 为实际角色ID
  61. -- DELETE FROM sys_role_menu WHERE role_id = :pharmacistRoleId AND menu_id IN (
  62. -- SELECT menu_id FROM sys_menu WHERE path IN (
  63. -- 'billing','saas','system','monitor','fastGpt','qdrant','sop',
  64. -- 'lobster','tenant','tool','tag','moduleUsage','taskStatistics',
  65. -- 'sensitive','callRecord','aiSipCall','aicall','aiob','aiChatQuality'
  66. -- )
  67. -- );
  68. -- DELETE FROM sys_role_menu WHERE role_id = :doctorRoleId AND menu_id IN (
  69. -- SELECT menu_id FROM sys_menu WHERE path IN (
  70. -- 'billing','saas','system','monitor','fastGpt','qdrant','sop',
  71. -- 'lobster','tenant','tool','tag','moduleUsage','taskStatistics',
  72. -- 'sensitive','callRecord','aiSipCall','aicall','aiob','aiChatQuality',
  73. -- 'shop','store','supplier','supplychain','marketing','adv'
  74. -- )
  75. -- );
  76. -- ######################################################################
  77. -- PART B:租户库 tenant_sys_menu
  78. -- ######################################################################
  79. REPLACE INTO tenant_sys_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, perms, create_by, create_time, remark) VALUES
  80. (31000, '门店运营', 0, 90, '/storeOperation', '', 'M', 'el-icon-s-shop', '0', '0', 0, 0, NULL, 'admin', NOW(), 'Store Operation Hub'),
  81. (31001, '员工业绩', 31000, 1, 'staffPerformance', 'store/storeStaffPerformance/index', 'C', 'el-icon-s-marketing', '0', '0', 0, 0, 'store:operation:performance', 'admin', NOW(), NULL),
  82. (31002, '交接班管理', 31000, 2, 'shiftManage', 'store/storeShiftManage/index', 'C', 'el-icon-sort', '0', '0', 0, 0, 'store:operation:shift', 'admin', NOW(), NULL),
  83. (31003, '到店接待', 31000, 3, 'receptionManage', 'store/storeReceptionManage/index', 'C', 'el-icon-bell', '0', '0', 0, 0, 'store:operation:reception', 'admin', NOW(), NULL),
  84. (31004, '考勤打卡', 31000, 4, 'attendanceManage', 'store/storeAttendanceManage/index', 'C', 'el-icon-time', '0', '0', 0, 0, 'store:operation:attendance', 'admin', NOW(), NULL),
  85. (31005, '企微客户', 31000, 5, 'qwCustomer', 'store/storeQwCustomer/index', 'C', 'el-icon-chat-line-round', '0', '0', 0, 0, 'store:operation:qwCustomer', 'admin', NOW(), 'Store QW Customer'),
  86. (31006, '采购建议', 31000, 6, 'purchaseSuggestion', 'store/purchaseSuggestion/index', 'C', 'el-icon-shopping-bag-2', '0', '0', 0, 0, 'store:operation:purchase', 'admin', NOW(), 'Purchase Suggestion'),
  87. (31007, '挂号分诊', 31000, 7, 'clinicRegistration', 'store/clinicRegistration/index', 'C', 'el-icon-document-add', '0', '0', 0, 0, 'store:clinic:registration', 'admin', NOW(), 'Clinic Registration'),
  88. (31008, '就诊叫号', 31000, 8, 'clinicQueue', 'store/clinicQueue/index', 'C', 'el-icon-bell', '0', '0', 0, 0, 'store:clinic:queue', 'admin', NOW(), 'Clinic Queue'),
  89. (31009, '医生排班', 31000, 9, 'doctorSchedule', 'store/doctorSchedule/index', 'C', 'el-icon-date', '0', '0', 0, 0, 'store:clinic:schedule', 'admin', NOW(), 'Doctor Schedule'),
  90. (31010, '用药咨询工作台', 0, 50, '/imWorkbench', 'pharmacist/imWorkbench/index', 'C', 'el-icon-chat-dot-round', '0', '0', 0, 0, 'pharmacist:imworkbench', 'admin', NOW(), 'Pharmacist IM Workbench'),
  91. (31011, '药品销售统计', 0, 51, '/drugStatistics', 'pharmacist/drugStatistics/index', 'C', 'el-icon-pie-chart', '0', '0', 0, 0, 'pharmacist:drugstats', 'admin', NOW(), 'Drug Sales Statistics'),
  92. (31012, '慢病用药周期', 0, 52, '/drugCycle', 'pharmacist/drugCycle/index', 'C', 'el-icon-alarm-clock', '0', '0', 0, 0, 'pharmacist:drugcycle', 'admin', NOW(), 'Drug Cycle Dashboard'),
  93. (31015, '在线问诊工作台', 0, 50, '/consultWorkbench', 'doctor/consultWorkbench/index', 'C', 'el-icon-video-camera', '0', '0', 0, 0, 'doctor:consultworkbench', 'admin', NOW(), 'Doctor Consult Workbench'),
  94. (31016, '患者健康档案', 0, 51, '/patientRecord', 'doctor/patientRecord/index', 'C', 'el-icon-document', '0', '0', 0, 0, 'doctor:patientrecord', 'admin', NOW(), 'Patient Health Record'),
  95. (31017, '随访管理', 0, 52, '/followUp', 'doctor/followUp/index', 'C', 'el-icon-calendar', '0', '0', 0, 0, 'doctor:followup', 'admin', NOW(), 'Follow-up Management'),
  96. (31018, '病历管理', 0, 53, '/medicalRecord', 'doctor/medicalRecord/index', 'C', 'el-icon-tickets', '0', '0', 0, 0, 'doctor:medicalrecord', 'admin', NOW(), 'Medical Record Management');
  97. -- 同步 tenant_company_menu
  98. REPLACE INTO tenant_company_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, perms, create_by, create_time, remark) VALUES
  99. (31000, '门店运营', 0, 90, '/storeOperation', '', 'M', 'el-icon-s-shop', '0', '0', 0, 0, NULL, 'admin', NOW(), 'Store Operation Hub'),
  100. (31001, '员工业绩', 31000, 1, 'staffPerformance', 'store/storeStaffPerformance/index', 'C', 'el-icon-s-marketing', '0', '0', 0, 0, 'store:operation:performance', 'admin', NOW(), NULL),
  101. (31002, '交接班管理', 31000, 2, 'shiftManage', 'store/storeShiftManage/index', 'C', 'el-icon-sort', '0', '0', 0, 0, 'store:operation:shift', 'admin', NOW(), NULL),
  102. (31003, '到店接待', 31000, 3, 'receptionManage', 'store/storeReceptionManage/index', 'C', 'el-icon-bell', '0', '0', 0, 0, 'store:operation:reception', 'admin', NOW(), NULL),
  103. (31004, '考勤打卡', 31000, 4, 'attendanceManage', 'store/storeAttendanceManage/index', 'C', 'el-icon-time', '0', '0', 0, 0, 'store:operation:attendance', 'admin', NOW(), NULL),
  104. (31005, '企微客户', 31000, 5, 'qwCustomer', 'store/storeQwCustomer/index', 'C', 'el-icon-chat-line-round', '0', '0', 0, 0, 'store:operation:qwCustomer', 'admin', NOW(), 'Store QW Customer'),
  105. (31006, '采购建议', 31000, 6, 'purchaseSuggestion', 'store/purchaseSuggestion/index', 'C', 'el-icon-shopping-bag-2', '0', '0', 0, 0, 'store:operation:purchase', 'admin', NOW(), 'Purchase Suggestion'),
  106. (31007, '挂号分诊', 31000, 7, 'clinicRegistration', 'store/clinicRegistration/index', 'C', 'el-icon-document-add', '0', '0', 0, 0, 'store:clinic:registration', 'admin', NOW(), 'Clinic Registration'),
  107. (31008, '就诊叫号', 31000, 8, 'clinicQueue', 'store/clinicQueue/index', 'C', 'el-icon-bell', '0', '0', 0, 0, 'store:clinic:queue', 'admin', NOW(), 'Clinic Queue'),
  108. (31009, '医生排班', 31000, 9, 'doctorSchedule', 'store/doctorSchedule/index', 'C', 'el-icon-date', '0', '0', 0, 0, 'store:clinic:schedule', 'admin', NOW(), 'Doctor Schedule');
  109. -- 同步 tenant_company_menu 诊所模块
  110. REPLACE INTO tenant_company_menu (menu_id, menu_name, parent_id, order_num, path, component, menu_type, icon, visible, status, is_frame, is_cache, perms, create_by, create_time, remark) VALUES
  111. (31007, '挂号分诊', 31000, 7, 'clinicRegistration', 'store/clinicRegistration/index', 'C', 'el-icon-document-add', '0', '0', 0, 0, 'store:clinic:registration', 'admin', NOW(), 'Clinic Registration'),
  112. (31008, '就诊叫号', 31000, 8, 'clinicQueue', 'store/clinicQueue/index', 'C', 'el-icon-bell', '0', '0', 0, 0, 'store:clinic:queue', 'admin', NOW(), 'Clinic Queue'),
  113. (31009, '医生排班', 31000, 9, 'doctorSchedule', 'store/doctorSchedule/index', 'C', 'el-icon-date', '0', '0', 0, 0, 'store:clinic:schedule', 'admin', NOW(), 'Doctor Schedule');
  114. -- ######################################################################
  115. -- PART C:DDL 用药反馈表
  116. -- ######################################################################
  117. CREATE TABLE IF NOT EXISTS med_feedback (
  118. id BIGINT AUTO_INCREMENT PRIMARY KEY,
  119. patient_id BIGINT NOT NULL COMMENT '患者ID',
  120. drug_name VARCHAR(200) NOT NULL COMMENT '药品名称',
  121. effect_rating TINYINT DEFAULT 3 COMMENT '疗效评价: 3显效 2有效 1无效',
  122. has_adverse_reaction TINYINT DEFAULT 0 COMMENT '是否有不良反应: 0无 1有',
  123. feedback_content TEXT COMMENT '反馈内容',
  124. doctor_id BIGINT COMMENT '记录医生ID',
  125. doctor_name VARCHAR(100) COMMENT '记录医生姓名',
  126. create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
  127. INDEX idx_patient (patient_id),
  128. INDEX idx_doctor (doctor_id)
  129. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用药反馈记录表';
  130. -- ######################################################################
  131. -- PART D:DDL 诊所模块表
  132. -- ######################################################################
  133. CREATE TABLE IF NOT EXISTS clinic_registration (
  134. id BIGINT AUTO_INCREMENT PRIMARY KEY,
  135. store_id BIGINT NOT NULL COMMENT '门店ID',
  136. patient_name VARCHAR(100) NOT NULL COMMENT '患者姓名',
  137. patient_phone VARCHAR(20) COMMENT '患者手机号',
  138. patient_gender TINYINT DEFAULT 1 COMMENT '性别 0女 1男',
  139. patient_age INT COMMENT '年龄',
  140. reg_type TINYINT DEFAULT 0 COMMENT '挂号类型 0普通 1专家 2急诊',
  141. department VARCHAR(100) COMMENT '科室',
  142. doctor_id BIGINT COMMENT '医生ID',
  143. doctor_name VARCHAR(100) COMMENT '医生姓名',
  144. symptom TEXT COMMENT '主诉症状',
  145. reg_fee DECIMAL(10,2) DEFAULT 0 COMMENT '挂号费',
  146. queue_no INT DEFAULT 0 COMMENT '排队号',
  147. status TINYINT DEFAULT 0 COMMENT '状态 0待就诊 1就诊中 2已完成 3已退号',
  148. reg_time DATETIME COMMENT '挂号时间',
  149. visit_time DATETIME COMMENT '就诊时间',
  150. remark VARCHAR(500) COMMENT '备注',
  151. create_by VARCHAR(64) DEFAULT '' COMMENT '创建者',
  152. create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
  153. update_by VARCHAR(64) DEFAULT '' COMMENT '更新者',
  154. update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  155. INDEX idx_store_date (store_id, DATE(reg_time)),
  156. INDEX idx_status (status),
  157. INDEX idx_doctor (doctor_id)
  158. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='诊所挂号表';
  159. CREATE TABLE IF NOT EXISTS doctor_schedule (
  160. id BIGINT AUTO_INCREMENT PRIMARY KEY,
  161. store_id BIGINT NOT NULL COMMENT '门店ID',
  162. doctor_id BIGINT COMMENT '医生ID',
  163. doctor_name VARCHAR(100) NOT NULL COMMENT '医生姓名',
  164. schedule_date DATE NOT NULL COMMENT '排班日期',
  165. shift TINYINT DEFAULT 0 COMMENT '班次 0上午 1下午 2全天',
  166. max_patients INT DEFAULT 20 COMMENT '最大接诊量',
  167. current_patients INT DEFAULT 0 COMMENT '已挂号数',
  168. status TINYINT DEFAULT 0 COMMENT '状态 0可挂号 1已满 2停诊',
  169. department VARCHAR(100) COMMENT '科室',
  170. remark VARCHAR(500) COMMENT '备注',
  171. create_by VARCHAR(64) DEFAULT '',
  172. create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
  173. update_by VARCHAR(64) DEFAULT '',
  174. update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  175. INDEX idx_store_date (store_id, schedule_date),
  176. INDEX idx_doctor (doctor_id)
  177. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='医生排班表';
  178. CREATE TABLE IF NOT EXISTS clinic_billing (
  179. id BIGINT AUTO_INCREMENT PRIMARY KEY,
  180. store_id BIGINT NOT NULL COMMENT '门店ID',
  181. registration_id BIGINT COMMENT '挂号ID',
  182. patient_name VARCHAR(100) NOT NULL COMMENT '患者姓名',
  183. patient_phone VARCHAR(20) COMMENT '患者手机号',
  184. doctor_name VARCHAR(100) COMMENT '接诊医生',
  185. diagnose VARCHAR(500) COMMENT '诊断',
  186. reg_fee DECIMAL(10,2) DEFAULT 0 COMMENT '挂号费',
  187. exam_fee DECIMAL(10,2) DEFAULT 0 COMMENT '检查费',
  188. drug_fee DECIMAL(10,2) DEFAULT 0 COMMENT '药品费',
  189. other_fee DECIMAL(10,2) DEFAULT 0 COMMENT '其他费用',
  190. total_amount DECIMAL(10,2) DEFAULT 0 COMMENT '总金额',
  191. pay_method TINYINT DEFAULT 0 COMMENT '支付方式 0现金 1微信 2支付宝 3医保 4银行卡',
  192. status TINYINT DEFAULT 0 COMMENT '状态 0待支付 1已支付 2已退款',
  193. billing_time DATETIME COMMENT '结算时间',
  194. remark VARCHAR(500) COMMENT '备注',
  195. create_by VARCHAR(64) DEFAULT '',
  196. create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
  197. update_by VARCHAR(64) DEFAULT '',
  198. update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  199. INDEX idx_store (store_id),
  200. INDEX idx_registration (registration_id),
  201. INDEX idx_billing_date (DATE(billing_time))
  202. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='诊所收费结算表';