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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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', '市场专员', 'freight', '运费信息',
  173. '/pages/market/webview/index?entry=specialist-freight',
  174. 'mini:market:specialist:freight', 50
  175. UNION ALL
  176. SELECT 'manager', '地区经理', 'presign', '预签约订单',
  177. '/pages/market/webview/index?entry=manager-presign',
  178. 'mini:market:manager:presign', 10
  179. UNION ALL
  180. SELECT 'manager', '地区经理', 'protocol', '协议单',
  181. '/pages/market/webview/index?entry=manager-protocol',
  182. 'mini:market:manager:protocol', 20
  183. UNION ALL
  184. SELECT 'manager', '地区经理', 'payment-chase', '催缴信息',
  185. '/pages/market/webview/index?entry=manager-payment-chase',
  186. 'mini:market:manager:payment-chase', 30
  187. UNION ALL
  188. SELECT 'manager', '地区经理', 'payment', '缴费信息',
  189. '/pages/market/webview/index?entry=manager-payment',
  190. 'mini:market:manager:payment', 40
  191. UNION ALL
  192. SELECT 'manager', '地区经理', 'freight', '运费信息',
  193. '/pages/market/webview/index?entry=manager-freight',
  194. 'mini:market:manager:freight', 50
  195. ) entry
  196. ON 1 = 1
  197. INNER JOIN sys_menu directory
  198. ON directory.tenant_no = root.tenant_no
  199. AND directory.parent_id = root.id
  200. AND directory.menu_name = entry.role_name
  201. AND directory.menu_type = 'M'
  202. AND directory.path = ''
  203. AND directory.del_flag = 0
  204. WHERE root.parent_id = '0'
  205. AND root.menu_name = '移动端菜单'
  206. AND root.del_flag = 0
  207. AND NOT EXISTS (
  208. SELECT 1
  209. FROM sys_menu existing
  210. WHERE existing.tenant_no = root.tenant_no
  211. AND existing.parent_id = directory.id
  212. AND existing.menu_name = entry.menu_name
  213. AND existing.perms = entry.perms
  214. AND existing.path = entry.path
  215. AND existing.menu_type = 'C'
  216. AND existing.del_flag = 0
  217. )
  218. ON DUPLICATE KEY UPDATE
  219. tenant_no = VALUES(tenant_no),
  220. parent_id = VALUES(parent_id),
  221. menu_name = VALUES(menu_name),
  222. menu_type = VALUES(menu_type),
  223. path = VALUES(path),
  224. component = VALUES(component),
  225. perms = VALUES(perms),
  226. is_frame = VALUES(is_frame),
  227. visible = VALUES(visible),
  228. status = VALUES(status),
  229. order_num = VALUES(order_num),
  230. remark = VALUES(remark),
  231. update_time = VALUES(update_time),
  232. del_flag = VALUES(del_flag);