2026-10-10-market-mobile-menus.sql 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. -- =============================================================================
  2. -- 小程序市场现场菜单:市场专员 / 地区经理两套目录与十二个业务叶子
  3. --
  4. -- 说明:
  5. -- 1. 面向每个租户已有的「移动端菜单」根生成菜单,不写死租户编号。
  6. -- 2. 目录仅用于角色授权分组,path 为空;首页只展示叶子。
  7. -- 3. 不在此处写入 sys_role_menu;由管理员在 Web 角色管理中手工勾选。
  8. -- 4. MySQL 5.7 可执行;所有 INSERT 均以 NOT EXISTS 保证幂等。
  9. -- =============================================================================
  10. -- 市场专员目录
  11. INSERT INTO sys_menu (
  12. id, menu_name, parent_id, menu_type, path, component, perms,
  13. is_frame, visible, status, tenant_no, order_num, remark,
  14. create_by, create_dept_id, create_time, update_by, update_time, del_flag
  15. )
  16. SELECT
  17. MD5(CONCAT(
  18. 'mobile-market-directory|', root.tenant_no, '|', root.id, '|M||市场专员'
  19. )),
  20. '市场专员',
  21. root.id,
  22. 'M',
  23. '',
  24. NULL,
  25. NULL,
  26. 1,
  27. '1',
  28. '1',
  29. root.tenant_no,
  30. 10,
  31. '小程序市场现场:市场专员菜单目录',
  32. NULL,
  33. '',
  34. NOW(),
  35. NULL,
  36. NOW(),
  37. 0
  38. FROM sys_menu root
  39. WHERE root.parent_id = '0'
  40. AND root.menu_name = '移动端菜单'
  41. AND root.del_flag = 0
  42. AND NOT EXISTS (
  43. SELECT 1
  44. FROM sys_menu existing
  45. WHERE existing.tenant_no = root.tenant_no
  46. AND existing.parent_id = root.id
  47. AND existing.menu_name = '市场专员'
  48. AND existing.menu_type = 'M'
  49. AND existing.path = ''
  50. AND existing.del_flag = 0
  51. )
  52. ON DUPLICATE KEY UPDATE
  53. tenant_no = VALUES(tenant_no),
  54. parent_id = VALUES(parent_id),
  55. menu_name = VALUES(menu_name),
  56. menu_type = VALUES(menu_type),
  57. path = VALUES(path),
  58. component = VALUES(component),
  59. perms = VALUES(perms),
  60. is_frame = VALUES(is_frame),
  61. visible = VALUES(visible),
  62. status = VALUES(status),
  63. order_num = VALUES(order_num),
  64. remark = VALUES(remark),
  65. update_time = VALUES(update_time),
  66. del_flag = VALUES(del_flag);
  67. -- 地区经理目录
  68. INSERT INTO sys_menu (
  69. id, menu_name, parent_id, menu_type, path, component, perms,
  70. is_frame, visible, status, tenant_no, order_num, remark,
  71. create_by, create_dept_id, create_time, update_by, update_time, del_flag
  72. )
  73. SELECT
  74. MD5(CONCAT(
  75. 'mobile-market-directory|', root.tenant_no, '|', root.id, '|M||地区经理'
  76. )),
  77. '地区经理',
  78. root.id,
  79. 'M',
  80. '',
  81. NULL,
  82. NULL,
  83. 1,
  84. '1',
  85. '1',
  86. root.tenant_no,
  87. 20,
  88. '小程序市场现场:地区经理菜单目录',
  89. NULL,
  90. '',
  91. NOW(),
  92. NULL,
  93. NOW(),
  94. 0
  95. FROM sys_menu root
  96. WHERE root.parent_id = '0'
  97. AND root.menu_name = '移动端菜单'
  98. AND root.del_flag = 0
  99. AND NOT EXISTS (
  100. SELECT 1
  101. FROM sys_menu existing
  102. WHERE existing.tenant_no = root.tenant_no
  103. AND existing.parent_id = root.id
  104. AND existing.menu_name = '地区经理'
  105. AND existing.menu_type = 'M'
  106. AND existing.path = ''
  107. AND existing.del_flag = 0
  108. )
  109. ON DUPLICATE KEY UPDATE
  110. tenant_no = VALUES(tenant_no),
  111. parent_id = VALUES(parent_id),
  112. menu_name = VALUES(menu_name),
  113. menu_type = VALUES(menu_type),
  114. path = VALUES(path),
  115. component = VALUES(component),
  116. perms = VALUES(perms),
  117. is_frame = VALUES(is_frame),
  118. visible = VALUES(visible),
  119. status = VALUES(status),
  120. order_num = VALUES(order_num),
  121. remark = VALUES(remark),
  122. update_time = VALUES(update_time),
  123. del_flag = VALUES(del_flag);
  124. -- 十二个业务叶子:每个角色目录各六个,均进入小程序受控 web-view。
  125. INSERT INTO sys_menu (
  126. id, menu_name, parent_id, menu_type, path, component, perms,
  127. is_frame, visible, status, tenant_no, order_num, remark,
  128. create_by, create_dept_id, create_time, update_by, update_time, del_flag
  129. )
  130. SELECT
  131. MD5(CONCAT(
  132. 'mobile-market-leaf|', root.tenant_no, '|', root.id, '|', directory.id,
  133. '|', entry.path, '|', entry.perms
  134. )),
  135. entry.menu_name,
  136. directory.id,
  137. 'C',
  138. entry.path,
  139. NULL,
  140. entry.perms,
  141. 1,
  142. '1',
  143. '1',
  144. root.tenant_no,
  145. entry.order_num,
  146. CONCAT('小程序市场现场:', entry.role_name, ' / ', entry.menu_name),
  147. NULL,
  148. '',
  149. NOW(),
  150. NULL,
  151. NOW(),
  152. 0
  153. FROM sys_menu root
  154. INNER JOIN (
  155. SELECT 'specialist' AS role_code, '市场专员' AS role_name,
  156. 'presign' AS module_code, '预签约订单' AS menu_name,
  157. '/pages/market/webview/index?entry=specialist-presign' AS path,
  158. 'mini:market:specialist:presign' AS perms, 10 AS order_num
  159. UNION ALL
  160. SELECT 'specialist', '市场专员', 'protocol', '协议单',
  161. '/pages/market/webview/index?entry=specialist-protocol',
  162. 'mini:market:specialist:protocol', 20
  163. UNION ALL
  164. SELECT 'specialist', '市场专员', 'payment-chase', '催缴信息',
  165. '/pages/market/webview/index?entry=specialist-payment-chase',
  166. 'mini:market:specialist:payment-chase', 30
  167. UNION ALL
  168. SELECT 'specialist', '市场专员', 'payment', '缴费信息',
  169. '/pages/market/webview/index?entry=specialist-payment',
  170. 'mini:market:specialist:payment', 40
  171. UNION ALL
  172. SELECT 'specialist', '市场专员', 'sample', '样本信息',
  173. '/pages/market/webview/index?entry=specialist-sample',
  174. 'mini:market:specialist:sample', 50
  175. UNION ALL
  176. SELECT 'specialist', '市场专员', 'freight', '运费信息',
  177. '/pages/market/webview/index?entry=specialist-freight',
  178. 'mini:market:specialist:freight', 60
  179. UNION ALL
  180. SELECT 'manager', '地区经理', 'presign', '预签约订单',
  181. '/pages/market/webview/index?entry=manager-presign',
  182. 'mini:market:manager:presign', 10
  183. UNION ALL
  184. SELECT 'manager', '地区经理', 'protocol', '协议单',
  185. '/pages/market/webview/index?entry=manager-protocol',
  186. 'mini:market:manager:protocol', 20
  187. UNION ALL
  188. SELECT 'manager', '地区经理', 'payment-chase', '催缴信息',
  189. '/pages/market/webview/index?entry=manager-payment-chase',
  190. 'mini:market:manager:payment-chase', 30
  191. UNION ALL
  192. SELECT 'manager', '地区经理', 'payment', '缴费信息',
  193. '/pages/market/webview/index?entry=manager-payment',
  194. 'mini:market:manager:payment', 40
  195. UNION ALL
  196. SELECT 'manager', '地区经理', 'sample', '样本信息',
  197. '/pages/market/webview/index?entry=manager-sample',
  198. 'mini:market:manager:sample', 50
  199. UNION ALL
  200. SELECT 'manager', '地区经理', 'freight', '运费信息',
  201. '/pages/market/webview/index?entry=manager-freight',
  202. 'mini:market:manager:freight', 60
  203. ) entry
  204. ON 1 = 1
  205. INNER JOIN sys_menu directory
  206. ON directory.tenant_no = root.tenant_no
  207. AND directory.parent_id = root.id
  208. AND directory.menu_name = entry.role_name
  209. AND directory.menu_type = 'M'
  210. AND directory.path = ''
  211. AND directory.del_flag = 0
  212. WHERE root.parent_id = '0'
  213. AND root.menu_name = '移动端菜单'
  214. AND root.del_flag = 0
  215. AND NOT EXISTS (
  216. SELECT 1
  217. FROM sys_menu existing
  218. WHERE existing.tenant_no = root.tenant_no
  219. AND existing.parent_id = directory.id
  220. AND existing.menu_name = entry.menu_name
  221. AND existing.perms = entry.perms
  222. AND existing.path = entry.path
  223. AND existing.menu_type = 'C'
  224. AND existing.del_flag = 0
  225. )
  226. ON DUPLICATE KEY UPDATE
  227. tenant_no = VALUES(tenant_no),
  228. parent_id = VALUES(parent_id),
  229. menu_name = VALUES(menu_name),
  230. menu_type = VALUES(menu_type),
  231. path = VALUES(path),
  232. component = VALUES(component),
  233. perms = VALUES(perms),
  234. is_frame = VALUES(is_frame),
  235. visible = VALUES(visible),
  236. status = VALUES(status),
  237. order_num = VALUES(order_num),
  238. remark = VALUES(remark),
  239. update_time = VALUES(update_time),
  240. del_flag = VALUES(del_flag);