ylyx-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (402) hide show
  1. package/README.md +184 -0
  2. package/bin/ylyx.js +95 -0
  3. package/lib/generator.js +192 -0
  4. package/lib/index.js +113 -0
  5. package/lib/interactive.js +87 -0
  6. package/lib/remote.js +179 -0
  7. package/lib/template.js +174 -0
  8. package/lib/utils.js +134 -0
  9. package/package.json +56 -0
  10. package/templates/react-app/files/README.md +23 -0
  11. package/templates/react-app/files/package.json +29 -0
  12. package/templates/react-app/files/public/index.html +11 -0
  13. package/templates/react-app/files/src/App.css +15 -0
  14. package/templates/react-app/files/src/App.js +15 -0
  15. package/templates/react-app/files/src/index.css +10 -0
  16. package/templates/react-app/files/src/index.js +11 -0
  17. package/templates/react-app/template.json +12 -0
  18. package/templates/react-component/files/Component.module.css +5 -0
  19. package/templates/react-component/files/Component.tsx +31 -0
  20. package/templates/react-component/files/index.ts +2 -0
  21. package/templates/react-component/template.json +49 -0
  22. package/templates/vue-app/files/.editorconfig +14 -0
  23. package/templates/vue-app/files/.env.development +21 -0
  24. package/templates/vue-app/files/.env.production +18 -0
  25. package/templates/vue-app/files/.eslintignore +5 -0
  26. package/templates/vue-app/files/.eslintrc.js +267 -0
  27. package/templates/vue-app/files/.prettierignore +12 -0
  28. package/templates/vue-app/files/.travis.yml +5 -0
  29. package/templates/vue-app/files/.vscode/extensions.json +7 -0
  30. package/templates/vue-app/files/.vscode/settings.json +39 -0
  31. package/templates/vue-app/files/LICENSE +191 -0
  32. package/templates/vue-app/files/README.md +87 -0
  33. package/templates/vue-app/files/babel.config.js +11 -0
  34. package/templates/vue-app/files/jest.config.js +24 -0
  35. package/templates/vue-app/files/package.json +136 -0
  36. package/templates/vue-app/files/plopfile.js +7 -0
  37. package/templates/vue-app/files/postcss.config.js +5 -0
  38. package/templates/vue-app/files/prettier.config.js +36 -0
  39. package/templates/vue-app/files/public/default.js +26 -0
  40. package/templates/vue-app/files/public/favicon.ico +0 -0
  41. package/templates/vue-app/files/public/index.html +26 -0
  42. package/templates/vue-app/files/src/App.vue +54 -0
  43. package/templates/vue-app/files/src/api/bigDataV/index.js +198 -0
  44. package/templates/vue-app/files/src/api/data.js +42 -0
  45. package/templates/vue-app/files/src/api/dataArchive/index.js +186 -0
  46. package/templates/vue-app/files/src/api/generator/genConfig.js +16 -0
  47. package/templates/vue-app/files/src/api/generator/generator.js +32 -0
  48. package/templates/vue-app/files/src/api/indexManagement/index.js +39 -0
  49. package/templates/vue-app/files/src/api/institutionMonitor/index.js +396 -0
  50. package/templates/vue-app/files/src/api/institutionSet/index.js +120 -0
  51. package/templates/vue-app/files/src/api/login.js +44 -0
  52. package/templates/vue-app/files/src/api/selfStatistics/index.js +50 -0
  53. package/templates/vue-app/files/src/api/system/code.js +15 -0
  54. package/templates/vue-app/files/src/api/system/dict.js +34 -0
  55. package/templates/vue-app/files/src/api/system/dictDetail.js +52 -0
  56. package/templates/vue-app/files/src/api/system/equipment.js +35 -0
  57. package/templates/vue-app/files/src/api/system/examManage.js +49 -0
  58. package/templates/vue-app/files/src/api/system/examProject.js +48 -0
  59. package/templates/vue-app/files/src/api/system/hosModel.js +35 -0
  60. package/templates/vue-app/files/src/api/system/hospital.js +88 -0
  61. package/templates/vue-app/files/src/api/system/job.js +40 -0
  62. package/templates/vue-app/files/src/api/system/menu.js +67 -0
  63. package/templates/vue-app/files/src/api/system/model.js +42 -0
  64. package/templates/vue-app/files/src/api/system/risConfig.js +9 -0
  65. package/templates/vue-app/files/src/api/system/role.js +64 -0
  66. package/templates/vue-app/files/src/api/system/sysSet.js +19 -0
  67. package/templates/vue-app/files/src/api/system/timing.js +41 -0
  68. package/templates/vue-app/files/src/api/system/user.js +121 -0
  69. package/templates/vue-app/files/src/api/tools/alipay.js +25 -0
  70. package/templates/vue-app/files/src/api/tools/email.js +24 -0
  71. package/templates/vue-app/files/src/api/tools/localStorage.js +27 -0
  72. package/templates/vue-app/files/src/api/tools/qiniu.js +40 -0
  73. package/templates/vue-app/files/src/assets/401_images/401.gif +0 -0
  74. package/templates/vue-app/files/src/assets/404_images/404.png +0 -0
  75. package/templates/vue-app/files/src/assets/404_images/404_cloud.png +0 -0
  76. package/templates/vue-app/files/src/assets/css/font-awesome.css +2342 -0
  77. package/templates/vue-app/files/src/assets/css/font-awesome.min.css +2336 -0
  78. package/templates/vue-app/files/src/assets/fonts/FontAwesome.otf +0 -0
  79. package/templates/vue-app/files/src/assets/fonts/fontawesome-webfont.eot +0 -0
  80. package/templates/vue-app/files/src/assets/fonts/fontawesome-webfont.svg +2671 -0
  81. package/templates/vue-app/files/src/assets/fonts/fontawesome-webfont.ttf +0 -0
  82. package/templates/vue-app/files/src/assets/fonts/fontawesome-webfont.woff +0 -0
  83. package/templates/vue-app/files/src/assets/fonts/fontawesome-webfont.woff2 +0 -0
  84. package/templates/vue-app/files/src/assets/icons/index.js +9 -0
  85. package/templates/vue-app/files/src/assets/icons/svg/Steve-Jobs.svg +1 -0
  86. package/templates/vue-app/files/src/assets/icons/svg/achive.svg +1 -0
  87. package/templates/vue-app/files/src/assets/icons/svg/alipay.svg +1 -0
  88. package/templates/vue-app/files/src/assets/icons/svg/anq.svg +1 -0
  89. package/templates/vue-app/files/src/assets/icons/svg/app.svg +1 -0
  90. package/templates/vue-app/files/src/assets/icons/svg/archive.svg +1 -0
  91. package/templates/vue-app/files/src/assets/icons/svg/backup.svg +1 -0
  92. package/templates/vue-app/files/src/assets/icons/svg/chain.svg +1 -0
  93. package/templates/vue-app/files/src/assets/icons/svg/chart.svg +1 -0
  94. package/templates/vue-app/files/src/assets/icons/svg/codeConsole.svg +1 -0
  95. package/templates/vue-app/files/src/assets/icons/svg/dashboard.svg +1 -0
  96. package/templates/vue-app/files/src/assets/icons/svg/database.svg +1 -0
  97. package/templates/vue-app/files/src/assets/icons/svg/date.svg +1 -0
  98. package/templates/vue-app/files/src/assets/icons/svg/deploy.svg +1 -0
  99. package/templates/vue-app/files/src/assets/icons/svg/dept.svg +1 -0
  100. package/templates/vue-app/files/src/assets/icons/svg/dev.svg +1 -0
  101. package/templates/vue-app/files/src/assets/icons/svg/develop.svg +1 -0
  102. package/templates/vue-app/files/src/assets/icons/svg/dictionary.svg +1 -0
  103. package/templates/vue-app/files/src/assets/icons/svg/doc.svg +1 -0
  104. package/templates/vue-app/files/src/assets/icons/svg/download.svg +1 -0
  105. package/templates/vue-app/files/src/assets/icons/svg/edit.svg +1 -0
  106. package/templates/vue-app/files/src/assets/icons/svg/education.svg +1 -0
  107. package/templates/vue-app/files/src/assets/icons/svg/email.svg +1 -0
  108. package/templates/vue-app/files/src/assets/icons/svg/equSet.svg +1 -0
  109. package/templates/vue-app/files/src/assets/icons/svg/error.svg +1 -0
  110. package/templates/vue-app/files/src/assets/icons/svg/exit-fullscreen.svg +1 -0
  111. package/templates/vue-app/files/src/assets/icons/svg/fullscreen.svg +1 -0
  112. package/templates/vue-app/files/src/assets/icons/svg/fwb.svg +1 -0
  113. package/templates/vue-app/files/src/assets/icons/svg/github.svg +1 -0
  114. package/templates/vue-app/files/src/assets/icons/svg/goBack.svg +1 -0
  115. package/templates/vue-app/files/src/assets/icons/svg/gonggao.svg +1 -0
  116. package/templates/vue-app/files/src/assets/icons/svg/hospital.svg +2 -0
  117. package/templates/vue-app/files/src/assets/icons/svg/hospital1.svg +2 -0
  118. package/templates/vue-app/files/src/assets/icons/svg/hospitalTotal.svg +1 -0
  119. package/templates/vue-app/files/src/assets/icons/svg/icon.svg +1 -0
  120. package/templates/vue-app/files/src/assets/icons/svg/image.svg +1 -0
  121. package/templates/vue-app/files/src/assets/icons/svg/index.svg +1 -0
  122. package/templates/vue-app/files/src/assets/icons/svg/international.svg +1 -0
  123. package/templates/vue-app/files/src/assets/icons/svg/ipvisits.svg +1 -0
  124. package/templates/vue-app/files/src/assets/icons/svg/java.svg +1 -0
  125. package/templates/vue-app/files/src/assets/icons/svg/link.svg +1 -0
  126. package/templates/vue-app/files/src/assets/icons/svg/list.svg +1 -0
  127. package/templates/vue-app/files/src/assets/icons/svg/lock.svg +1 -0
  128. package/templates/vue-app/files/src/assets/icons/svg/log.svg +1 -0
  129. package/templates/vue-app/files/src/assets/icons/svg/login.svg +1 -0
  130. package/templates/vue-app/files/src/assets/icons/svg/loginOne.svg +35 -0
  131. package/templates/vue-app/files/src/assets/icons/svg/loginOneWhite.svg +19 -0
  132. package/templates/vue-app/files/src/assets/icons/svg/loginOr.svg +93 -0
  133. package/templates/vue-app/files/src/assets/icons/svg/loginUp.svg +96 -0
  134. package/templates/vue-app/files/src/assets/icons/svg/markdown.svg +1 -0
  135. package/templates/vue-app/files/src/assets/icons/svg/menu.svg +1 -0
  136. package/templates/vue-app/files/src/assets/icons/svg/message.svg +1 -0
  137. package/templates/vue-app/files/src/assets/icons/svg/mnt.svg +1 -0
  138. package/templates/vue-app/files/src/assets/icons/svg/money.svg +1 -0
  139. package/templates/vue-app/files/src/assets/icons/svg/monitor.svg +1 -0
  140. package/templates/vue-app/files/src/assets/icons/svg/nested.svg +1 -0
  141. package/templates/vue-app/files/src/assets/icons/svg/network.svg +1 -0
  142. package/templates/vue-app/files/src/assets/icons/svg/offline.svg +1 -0
  143. package/templates/vue-app/files/src/assets/icons/svg/online.svg +1 -0
  144. package/templates/vue-app/files/src/assets/icons/svg/password.svg +1 -0
  145. package/templates/vue-app/files/src/assets/icons/svg/people.svg +1 -0
  146. package/templates/vue-app/files/src/assets/icons/svg/peoples.svg +1 -0
  147. package/templates/vue-app/files/src/assets/icons/svg/perSet.svg +1 -0
  148. package/templates/vue-app/files/src/assets/icons/svg/permission.svg +1 -0
  149. package/templates/vue-app/files/src/assets/icons/svg/phone.svg +1 -0
  150. package/templates/vue-app/files/src/assets/icons/svg/piechart.svg +1 -0
  151. package/templates/vue-app/files/src/assets/icons/svg/qiniu.svg +1 -0
  152. package/templates/vue-app/files/src/assets/icons/svg/redis.svg +1 -0
  153. package/templates/vue-app/files/src/assets/icons/svg/resetpassword.svg +1 -0
  154. package/templates/vue-app/files/src/assets/icons/svg/resetpassword1.svg +1 -0
  155. package/templates/vue-app/files/src/assets/icons/svg/role.svg +1 -0
  156. package/templates/vue-app/files/src/assets/icons/svg/search.svg +1 -0
  157. package/templates/vue-app/files/src/assets/icons/svg/server.svg +1 -0
  158. package/templates/vue-app/files/src/assets/icons/svg/shopping.svg +1 -0
  159. package/templates/vue-app/files/src/assets/icons/svg/size.svg +1 -0
  160. package/templates/vue-app/files/src/assets/icons/svg/skill.svg +1 -0
  161. package/templates/vue-app/files/src/assets/icons/svg/source.svg +1 -0
  162. package/templates/vue-app/files/src/assets/icons/svg/sqlMonitor.svg +1 -0
  163. package/templates/vue-app/files/src/assets/icons/svg/statistical.svg +1 -0
  164. package/templates/vue-app/files/src/assets/icons/svg/swagger.svg +1 -0
  165. package/templates/vue-app/files/src/assets/icons/svg/sys-tools.svg +1 -0
  166. package/templates/vue-app/files/src/assets/icons/svg/system.svg +1 -0
  167. package/templates/vue-app/files/src/assets/icons/svg/system1.svg +1 -0
  168. package/templates/vue-app/files/src/assets/icons/svg/tab.svg +1 -0
  169. package/templates/vue-app/files/src/assets/icons/svg/teams.svg +1 -0
  170. package/templates/vue-app/files/src/assets/icons/svg/theme.svg +1 -0
  171. package/templates/vue-app/files/src/assets/icons/svg/timing.svg +1 -0
  172. package/templates/vue-app/files/src/assets/icons/svg/tools.svg +1 -0
  173. package/templates/vue-app/files/src/assets/icons/svg/tree-table.svg +1 -0
  174. package/templates/vue-app/files/src/assets/icons/svg/tree.svg +1 -0
  175. package/templates/vue-app/files/src/assets/icons/svg/unlock.svg +1 -0
  176. package/templates/vue-app/files/src/assets/icons/svg/user.svg +1 -0
  177. package/templates/vue-app/files/src/assets/icons/svg/user1.svg +1 -0
  178. package/templates/vue-app/files/src/assets/icons/svg/validCode.svg +1 -0
  179. package/templates/vue-app/files/src/assets/icons/svg/visits.svg +1 -0
  180. package/templates/vue-app/files/src/assets/icons/svg/web.svg +1 -0
  181. package/templates/vue-app/files/src/assets/icons/svg/wechat.svg +1 -0
  182. package/templates/vue-app/files/src/assets/icons/svg/weixin.svg +1 -0
  183. package/templates/vue-app/files/src/assets/icons/svg/zujian.svg +1 -0
  184. package/templates/vue-app/files/src/assets/icons/svgo.yml +21 -0
  185. package/templates/vue-app/files/src/assets/images/archive.png +0 -0
  186. package/templates/vue-app/files/src/assets/images/archive_icon.png +0 -0
  187. package/templates/vue-app/files/src/assets/images/avatar.png +0 -0
  188. package/templates/vue-app/files/src/assets/images/background.jpg +0 -0
  189. package/templates/vue-app/files/src/assets/images/bg.png +0 -0
  190. package/templates/vue-app/files/src/assets/images/gongan.png +0 -0
  191. package/templates/vue-app/files/src/assets/images/hospital_icon.png +0 -0
  192. package/templates/vue-app/files/src/assets/images/location.png +0 -0
  193. package/templates/vue-app/files/src/assets/images/logintitle.jpg +0 -0
  194. package/templates/vue-app/files/src/assets/images/logo-copy1.png +0 -0
  195. package/templates/vue-app/files/src/assets/images/logo.png +0 -0
  196. package/templates/vue-app/files/src/assets/images/logoBg.png +0 -0
  197. package/templates/vue-app/files/src/assets/images/offline-bg.png +0 -0
  198. package/templates/vue-app/files/src/assets/images/position.png +0 -0
  199. package/templates/vue-app/files/src/assets/images/qualityBg.jpg +0 -0
  200. package/templates/vue-app/files/src/assets/images/self-bg.png +0 -0
  201. package/templates/vue-app/files/src/assets/images/self-bg2.png +0 -0
  202. package/templates/vue-app/files/src/assets/images/triAngel.png +0 -0
  203. package/templates/vue-app/files/src/assets/images/triAngelNormal.png +0 -0
  204. package/templates/vue-app/files/src/assets/styles/btn.scss +103 -0
  205. package/templates/vue-app/files/src/assets/styles/eladmin.scss +124 -0
  206. package/templates/vue-app/files/src/assets/styles/element-ui.scss +217 -0
  207. package/templates/vue-app/files/src/assets/styles/element-variables.scss +31 -0
  208. package/templates/vue-app/files/src/assets/styles/global.scss +73 -0
  209. package/templates/vue-app/files/src/assets/styles/index.scss +220 -0
  210. package/templates/vue-app/files/src/assets/styles/mixin.scss +60 -0
  211. package/templates/vue-app/files/src/assets/styles/publicStyle.scss +224 -0
  212. package/templates/vue-app/files/src/assets/styles/sidebar.scss +239 -0
  213. package/templates/vue-app/files/src/assets/styles/transition.scss +48 -0
  214. package/templates/vue-app/files/src/assets/styles/variables.scss +44 -0
  215. package/templates/vue-app/files/src/common/flexible.js +145 -0
  216. package/templates/vue-app/files/src/components/Breadcrumb/index.vue +87 -0
  217. package/templates/vue-app/files/src/components/Crud/CRUD.operation.vue +248 -0
  218. package/templates/vue-app/files/src/components/Crud/Pagination.vue +20 -0
  219. package/templates/vue-app/files/src/components/Crud/RR.operation.vue +39 -0
  220. package/templates/vue-app/files/src/components/Crud/UD.operation.vue +106 -0
  221. package/templates/vue-app/files/src/components/Crud/crud.js +907 -0
  222. package/templates/vue-app/files/src/components/Crud/user/UR.operation.vue +154 -0
  223. package/templates/vue-app/files/src/components/DateRangePicker/index.vue +42 -0
  224. package/templates/vue-app/files/src/components/DateRangePickerProhibitNext/index.vue +42 -0
  225. package/templates/vue-app/files/src/components/DateRangePickerProhibitTodayNext/index.vue +48 -0
  226. package/templates/vue-app/files/src/components/Dict/Dict.js +31 -0
  227. package/templates/vue-app/files/src/components/Dict/index.js +29 -0
  228. package/templates/vue-app/files/src/components/Doc/index.vue +16 -0
  229. package/templates/vue-app/files/src/components/Echarts/BarChart.vue +115 -0
  230. package/templates/vue-app/files/src/components/Echarts/Category.vue +768 -0
  231. package/templates/vue-app/files/src/components/Echarts/Funnel.vue +120 -0
  232. package/templates/vue-app/files/src/components/Echarts/Gauge.vue +74 -0
  233. package/templates/vue-app/files/src/components/Echarts/Graph.vue +101 -0
  234. package/templates/vue-app/files/src/components/Echarts/HeatMap.vue +301 -0
  235. package/templates/vue-app/files/src/components/Echarts/Line3D.vue +110 -0
  236. package/templates/vue-app/files/src/components/Echarts/PieChart.vue +84 -0
  237. package/templates/vue-app/files/src/components/Echarts/Point.vue +161 -0
  238. package/templates/vue-app/files/src/components/Echarts/RadarChart.vue +123 -0
  239. package/templates/vue-app/files/src/components/Echarts/Rich.vue +160 -0
  240. package/templates/vue-app/files/src/components/Echarts/Sankey.vue +114 -0
  241. package/templates/vue-app/files/src/components/Echarts/Scatter.vue +192 -0
  242. package/templates/vue-app/files/src/components/Echarts/Sunburst.vue +127 -0
  243. package/templates/vue-app/files/src/components/Echarts/ThemeRiver.vue +233 -0
  244. package/templates/vue-app/files/src/components/Echarts/WordCloud.vue +201 -0
  245. package/templates/vue-app/files/src/components/GithubCorner/index.vue +55 -0
  246. package/templates/vue-app/files/src/components/Hamburger/index.vue +44 -0
  247. package/templates/vue-app/files/src/components/HeaderSearch/index.vue +196 -0
  248. package/templates/vue-app/files/src/components/IconSelect/index.vue +74 -0
  249. package/templates/vue-app/files/src/components/IconSelect/requireIcons.js +10 -0
  250. package/templates/vue-app/files/src/components/Iframe/index.vue +30 -0
  251. package/templates/vue-app/files/src/components/JavaEdit/index.vue +78 -0
  252. package/templates/vue-app/files/src/components/Pagination/index.vue +100 -0
  253. package/templates/vue-app/files/src/components/PanThumb/index.vue +149 -0
  254. package/templates/vue-app/files/src/components/ParentView/index.vue +3 -0
  255. package/templates/vue-app/files/src/components/Permission/index.js +13 -0
  256. package/templates/vue-app/files/src/components/Permission/permission.js +21 -0
  257. package/templates/vue-app/files/src/components/RightPanel/index.vue +149 -0
  258. package/templates/vue-app/files/src/components/Screenfull/index.vue +60 -0
  259. package/templates/vue-app/files/src/components/SizeSelect/index.vue +60 -0
  260. package/templates/vue-app/files/src/components/SvgIcon/index.vue +66 -0
  261. package/templates/vue-app/files/src/components/ThemePicker/index.vue +177 -0
  262. package/templates/vue-app/files/src/components/UploadExcel/index.vue +149 -0
  263. package/templates/vue-app/files/src/components/WaterMark/setWaterMark.js +68 -0
  264. package/templates/vue-app/files/src/components/WaterMark/waterMark.vue +69 -0
  265. package/templates/vue-app/files/src/components/Xgplayer/index.vue +49 -0
  266. package/templates/vue-app/files/src/components/YamlEdit/index.vue +81 -0
  267. package/templates/vue-app/files/src/layout/components/AppMain.vue +67 -0
  268. package/templates/vue-app/files/src/layout/components/Navbar.vue +209 -0
  269. package/templates/vue-app/files/src/layout/components/Settings/index.vue +125 -0
  270. package/templates/vue-app/files/src/layout/components/Sidebar/FixiOSBug.js +26 -0
  271. package/templates/vue-app/files/src/layout/components/Sidebar/Item.vue +29 -0
  272. package/templates/vue-app/files/src/layout/components/Sidebar/Link.vue +35 -0
  273. package/templates/vue-app/files/src/layout/components/Sidebar/Logo.vue +93 -0
  274. package/templates/vue-app/files/src/layout/components/Sidebar/SidebarItem.vue +104 -0
  275. package/templates/vue-app/files/src/layout/components/Sidebar/index.vue +79 -0
  276. package/templates/vue-app/files/src/layout/components/TagsView/ScrollPane.vue +90 -0
  277. package/templates/vue-app/files/src/layout/components/TagsView/index.vue +299 -0
  278. package/templates/vue-app/files/src/layout/components/index.js +5 -0
  279. package/templates/vue-app/files/src/layout/index.vue +119 -0
  280. package/templates/vue-app/files/src/layout/mixin/ResizeHandler.js +45 -0
  281. package/templates/vue-app/files/src/main.js +89 -0
  282. package/templates/vue-app/files/src/mixins/crud.js +348 -0
  283. package/templates/vue-app/files/src/router/index.js +156 -0
  284. package/templates/vue-app/files/src/router/routers.js +203 -0
  285. package/templates/vue-app/files/src/settings.js +57 -0
  286. package/templates/vue-app/files/src/store/getters.js +29 -0
  287. package/templates/vue-app/files/src/store/index.js +25 -0
  288. package/templates/vue-app/files/src/store/modules/api.js +33 -0
  289. package/templates/vue-app/files/src/store/modules/app.js +55 -0
  290. package/templates/vue-app/files/src/store/modules/permission.js +79 -0
  291. package/templates/vue-app/files/src/store/modules/register.js +17 -0
  292. package/templates/vue-app/files/src/store/modules/settings.js +46 -0
  293. package/templates/vue-app/files/src/store/modules/tagsView.js +168 -0
  294. package/templates/vue-app/files/src/store/modules/user.js +119 -0
  295. package/templates/vue-app/files/src/utils/auth.js +18 -0
  296. package/templates/vue-app/files/src/utils/base64ToFile.js +27 -0
  297. package/templates/vue-app/files/src/utils/clipboard.js +36 -0
  298. package/templates/vue-app/files/src/utils/datetime.js +289 -0
  299. package/templates/vue-app/files/src/utils/getBlobFile.js +10 -0
  300. package/templates/vue-app/files/src/utils/getTime.js +29 -0
  301. package/templates/vue-app/files/src/utils/index.js +520 -0
  302. package/templates/vue-app/files/src/utils/permission.js +29 -0
  303. package/templates/vue-app/files/src/utils/pinyin.js +450 -0
  304. package/templates/vue-app/files/src/utils/request.js +139 -0
  305. package/templates/vue-app/files/src/utils/rsaEncrypt.js +37 -0
  306. package/templates/vue-app/files/src/utils/shortcuts.js +210 -0
  307. package/templates/vue-app/files/src/utils/upload.js +12 -0
  308. package/templates/vue-app/files/src/utils/validate.js +262 -0
  309. package/templates/vue-app/files/src/views/components/Echarts.vue +124 -0
  310. package/templates/vue-app/files/src/views/components/Editor.vue +75 -0
  311. package/templates/vue-app/files/src/views/components/MarkDown.vue +44 -0
  312. package/templates/vue-app/files/src/views/components/UVideo.vue +37 -0
  313. package/templates/vue-app/files/src/views/components/YamlEdit.vue +206 -0
  314. package/templates/vue-app/files/src/views/components/camera/camera.vue +115 -0
  315. package/templates/vue-app/files/src/views/components/camera/cameraTest.vue +158 -0
  316. package/templates/vue-app/files/src/views/components/excel/upload-excel.vue +41 -0
  317. package/templates/vue-app/files/src/views/components/icons/element-icons.js +74 -0
  318. package/templates/vue-app/files/src/views/components/icons/index.vue +106 -0
  319. package/templates/vue-app/files/src/views/components/icons/svg-icons.js +10 -0
  320. package/templates/vue-app/files/src/views/components/scroll/index.vue +107 -0
  321. package/templates/vue-app/files/src/views/components/scrollFull/index.vue +99 -0
  322. package/templates/vue-app/files/src/views/dashboard/LineChart.vue +138 -0
  323. package/templates/vue-app/files/src/views/dashboard/PanelGroup.vue +173 -0
  324. package/templates/vue-app/files/src/views/dashboard/mixins/resize.js +57 -0
  325. package/templates/vue-app/files/src/views/dataArchive/delTable.vue +354 -0
  326. package/templates/vue-app/files/src/views/dataArchive/exportDetail.vue +121 -0
  327. package/templates/vue-app/files/src/views/dataArchive/exportList.vue +160 -0
  328. package/templates/vue-app/files/src/views/dataArchive/index.vue +2104 -0
  329. package/templates/vue-app/files/src/views/features/401.vue +83 -0
  330. package/templates/vue-app/files/src/views/features/404.vue +226 -0
  331. package/templates/vue-app/files/src/views/features/redirect.vue +12 -0
  332. package/templates/vue-app/files/src/views/generator/config.vue +348 -0
  333. package/templates/vue-app/files/src/views/generator/index.vue +143 -0
  334. package/templates/vue-app/files/src/views/generator/preview.vue +39 -0
  335. package/templates/vue-app/files/src/views/home.vue +80 -0
  336. package/templates/vue-app/files/src/views/indexManagement/index.vue +422 -0
  337. package/templates/vue-app/files/src/views/indexManagement/other.vue +286 -0
  338. package/templates/vue-app/files/src/views/institutionMonitor/components/LineChart.vue +191 -0
  339. package/templates/vue-app/files/src/views/institutionMonitor/index.scss +339 -0
  340. package/templates/vue-app/files/src/views/institutionMonitor/index.vue +1385 -0
  341. package/templates/vue-app/files/src/views/institutionMonitor/mixins/resize.js +57 -0
  342. package/templates/vue-app/files/src/views/institutionMonitor/monitorDetail/checkProjectCode.vue +267 -0
  343. package/templates/vue-app/files/src/views/institutionMonitor/monitorDetail/imageAbnormalMonitor.vue +361 -0
  344. package/templates/vue-app/files/src/views/institutionMonitor/monitorDetail/index.vue +686 -0
  345. package/templates/vue-app/files/src/views/institutionMonitor/monitorDetail/leakageAnomaly.vue +270 -0
  346. package/templates/vue-app/files/src/views/institutionMonitor/monitorDetail/moveMonitore.vue +114 -0
  347. package/templates/vue-app/files/src/views/institutionMonitor/monitorDetail/qualityMonitore.vue +338 -0
  348. package/templates/vue-app/files/src/views/institutionSet/cloudSet.vue +534 -0
  349. package/templates/vue-app/files/src/views/institutionSet/index.vue +2550 -0
  350. package/templates/vue-app/files/src/views/login.vue +243 -0
  351. package/templates/vue-app/files/src/views/qualityLogin.vue +280 -0
  352. package/templates/vue-app/files/src/views/selfStatistics/components/LineChart.vue +296 -0
  353. package/templates/vue-app/files/src/views/selfStatistics/hospitalDetail/index.vue +533 -0
  354. package/templates/vue-app/files/src/views/selfStatistics/index.scss +447 -0
  355. package/templates/vue-app/files/src/views/selfStatistics/index.vue +903 -0
  356. package/templates/vue-app/files/src/views/selfStatistics/mixins/resize.js +57 -0
  357. package/templates/vue-app/files/src/views/selfStatistics/monitorDetail/index.vue +285 -0
  358. package/templates/vue-app/files/src/views/selfStatistics/offlineDetail/index.vue +104 -0
  359. package/templates/vue-app/files/src/views/selfStatistics/selfActiveDetail/index.vue +104 -0
  360. package/templates/vue-app/files/src/views/selfStatistics/selfMonitorDetail/index.vue +420 -0
  361. package/templates/vue-app/files/src/views/selfStatistics/setWaterMark/setWaterMark.js +68 -0
  362. package/templates/vue-app/files/src/views/selfStatistics/setWaterMark/waterMark.vue +69 -0
  363. package/templates/vue-app/files/src/views/system/dept/index.vue +144 -0
  364. package/templates/vue-app/files/src/views/system/dict/dictDetail.vue +146 -0
  365. package/templates/vue-app/files/src/views/system/dict/index.vue +159 -0
  366. package/templates/vue-app/files/src/views/system/examModality/index.vue +174 -0
  367. package/templates/vue-app/files/src/views/system/examPart/index.vue +184 -0
  368. package/templates/vue-app/files/src/views/system/examProject/index.vue +321 -0
  369. package/templates/vue-app/files/src/views/system/examine/index.vue +66 -0
  370. package/templates/vue-app/files/src/views/system/job/index.vue +119 -0
  371. package/templates/vue-app/files/src/views/system/job/module/form.vue +72 -0
  372. package/templates/vue-app/files/src/views/system/job/module/header.vue +48 -0
  373. package/templates/vue-app/files/src/views/system/menu/index.vue +327 -0
  374. package/templates/vue-app/files/src/views/system/model/index.vue +285 -0
  375. package/templates/vue-app/files/src/views/system/role/index.vue +434 -0
  376. package/templates/vue-app/files/src/views/system/sysSet/index.vue +84 -0
  377. package/templates/vue-app/files/src/views/system/timing/index.vue +289 -0
  378. package/templates/vue-app/files/src/views/system/timing/log.vue +143 -0
  379. package/templates/vue-app/files/src/views/system/user/admin.vue +414 -0
  380. package/templates/vue-app/files/src/views/system/user/center/updateEmail.vue +146 -0
  381. package/templates/vue-app/files/src/views/system/user/center/updatePass.vue +168 -0
  382. package/templates/vue-app/files/src/views/system/user/center.vue +140 -0
  383. package/templates/vue-app/files/src/views/system/user/index.vue +972 -0
  384. package/templates/vue-app/files/src/views/systemSet/role/index.vue +314 -0
  385. package/templates/vue-app/files/src/views/systemSet/user/admin.vue +414 -0
  386. package/templates/vue-app/files/src/views/systemSet/user/center/updateEmail.vue +146 -0
  387. package/templates/vue-app/files/src/views/systemSet/user/center/updatePass.vue +115 -0
  388. package/templates/vue-app/files/src/views/systemSet/user/center.vue +351 -0
  389. package/templates/vue-app/files/src/views/systemSet/user/index.vue +928 -0
  390. package/templates/vue-app/files/src/views/tools/aliPay/config.vue +102 -0
  391. package/templates/vue-app/files/src/views/tools/aliPay/index.vue +48 -0
  392. package/templates/vue-app/files/src/views/tools/aliPay/toPay.vue +91 -0
  393. package/templates/vue-app/files/src/views/tools/email/config.vue +91 -0
  394. package/templates/vue-app/files/src/views/tools/email/index.vue +42 -0
  395. package/templates/vue-app/files/src/views/tools/email/send.vue +159 -0
  396. package/templates/vue-app/files/src/views/tools/storage/index.vue +35 -0
  397. package/templates/vue-app/files/src/views/tools/storage/local/index.vue +207 -0
  398. package/templates/vue-app/files/src/views/tools/storage/qiniu/form.vue +108 -0
  399. package/templates/vue-app/files/src/views/tools/storage/qiniu/index.vue +241 -0
  400. package/templates/vue-app/files/src/views/tools/swagger/index.vue +14 -0
  401. package/templates/vue-app/files/vue.config.js +173 -0
  402. package/templates/vue-app/template.json +30 -0
@@ -0,0 +1,907 @@
1
+ import { initData, initDataPost, download } from '@/api/data';
2
+ import { parseTime, downloadFile } from '@/utils/index';
3
+ import Vue from 'vue';
4
+
5
+ /**
6
+ * CRUD配置
7
+ * @author moxun
8
+ * @param {*} options <br>
9
+ * @return crud instance.
10
+ * @example
11
+ * 要使用多crud时,请在关联crud的组件处使用crud-tag进行标记,如:<jobForm :job-status="dict.job_status" crud-tag="job" />
12
+ */
13
+ function CRUD(options) {
14
+ const defaultOptions = {
15
+ tag: 'default',
16
+ // id字段名
17
+ idField: 'id',
18
+ // 标题
19
+ title: '',
20
+ // 请求数据的url
21
+ url: '',
22
+ // 表格数据
23
+ data: [],
24
+ // 选择项
25
+ selections: [],
26
+ // 待查询的对象
27
+ query: {},
28
+ // 查询数据的参数
29
+ params: {},
30
+ // Form 表单
31
+ form: {},
32
+ // 重置表单
33
+ defaultForm: () => {},
34
+ // 排序规则,默认 id 降序, 支持多字段排序 ['id,desc', 'createTime,asc']
35
+ sort: ['id,desc'],
36
+ // 等待时间
37
+ time: 50,
38
+ // CRUD Method
39
+ crudMethod: {
40
+ add: form => {},
41
+ del: id => {},
42
+ edit: form => {},
43
+ get: id => {},
44
+ },
45
+ // 主页操作栏显示哪些按钮
46
+ optShow: {
47
+ add: true,
48
+ edit: false,
49
+ del: false,
50
+ download: false,
51
+ reset: false,
52
+ },
53
+ // 自定义一些扩展属性
54
+ props: {},
55
+ // 在主页准备
56
+ queryOnPresenterCreated: true,
57
+ // 调试开关
58
+ debug: false,
59
+ type: '',
60
+ };
61
+ options = mergeOptions(defaultOptions, options);
62
+ const data = {
63
+ ...options,
64
+ // 记录数据状态
65
+ dataStatus: {},
66
+ status: {
67
+ add: CRUD.STATUS.NORMAL,
68
+ edit: CRUD.STATUS.NORMAL,
69
+ // 添加或编辑状态
70
+ get cu() {
71
+ if (this.add === CRUD.STATUS.NORMAL && this.edit === CRUD.STATUS.NORMAL) {
72
+ return CRUD.STATUS.NORMAL;
73
+ } else if (this.add === CRUD.STATUS.PREPARED || this.edit === CRUD.STATUS.PREPARED) {
74
+ return CRUD.STATUS.PREPARED;
75
+ } else if (this.add === CRUD.STATUS.PROCESSING || this.edit === CRUD.STATUS.PROCESSING) {
76
+ return CRUD.STATUS.PROCESSING;
77
+ }
78
+ throw new Error("wrong crud's cu status");
79
+ },
80
+ // 标题
81
+ get title() {
82
+ return this.add > CRUD.STATUS.NORMAL
83
+ ? `新增${crud.title}`
84
+ : this.edit > CRUD.STATUS.NORMAL
85
+ ? `编辑${crud.title}`
86
+ : crud.title;
87
+ },
88
+ },
89
+ msg: {
90
+ submit: '提交成功',
91
+ add: '新增成功',
92
+ edit: '编辑成功',
93
+ del: '删除成功',
94
+ },
95
+ page: {
96
+ // 页码
97
+ page: 0,
98
+ // 每页数据条数
99
+ size: 10,
100
+ // 总数据条数
101
+ total: 0,
102
+ },
103
+ // 整体loading
104
+ loading: false,
105
+ // 导出的 Loading
106
+ downloadLoading: false,
107
+ // 删除的 Loading
108
+ delAllLoading: false,
109
+ };
110
+ const methods = {
111
+ /**
112
+ * 通用的提示
113
+ */
114
+ submitSuccessNotify() {
115
+ crud.notify(crud.msg.submit, CRUD.NOTIFICATION_TYPE.SUCCESS);
116
+ },
117
+ addSuccessNotify() {
118
+ crud.notify(crud.msg.add, CRUD.NOTIFICATION_TYPE.SUCCESS);
119
+ },
120
+ editSuccessNotify() {
121
+ crud.notify(crud.msg.edit, CRUD.NOTIFICATION_TYPE.SUCCESS);
122
+ },
123
+ delSuccessNotify() {
124
+ crud.notify(crud.msg.del, CRUD.NOTIFICATION_TYPE.SUCCESS);
125
+ },
126
+ // 搜索
127
+ toQuery() {
128
+ crud.page.page = 1;
129
+ crud.refresh();
130
+ },
131
+ // 刷新
132
+ refresh() {
133
+ if (!callVmHook(crud, CRUD.HOOK.beforeRefresh)) {
134
+ return;
135
+ }
136
+ // 没有地址的时候 阻止进行下一步
137
+ if (!crud.url) return;
138
+ return new Promise((resolve, reject) => {
139
+ crud.loading = true;
140
+ // 请求数据
141
+ let initDataType = crud.type == 'post' ? initDataPost : initData;
142
+ initDataType(crud.url, crud.getQueryParams())
143
+ .then(data => {
144
+ const table = crud.getTable();
145
+ if (table && table.lazy) {
146
+ // 懒加载子节点数据,清掉已加载的数据
147
+ table.store.states.treeData = {};
148
+ table.store.states.lazyTreeNodeMap = {};
149
+ }
150
+ crud.page.total = data.totalElements;
151
+ crud.data = data.content;
152
+ crud.resetDataStatus();
153
+ // time 毫秒后显示表格
154
+ setTimeout(() => {
155
+ crud.loading = false;
156
+ callVmHook(crud, CRUD.HOOK.afterRefresh);
157
+ }, crud.time);
158
+ resolve(data);
159
+ })
160
+ .catch(err => {
161
+ crud.loading = false;
162
+ reject(err);
163
+ });
164
+ });
165
+ },
166
+ /**
167
+ * 启动添加
168
+ */
169
+ toAdd() {
170
+ crud.resetForm();
171
+ if (
172
+ !(
173
+ callVmHook(crud, CRUD.HOOK.beforeToAdd, crud.form) &&
174
+ callVmHook(crud, CRUD.HOOK.beforeToCU, crud.form)
175
+ )
176
+ ) {
177
+ return;
178
+ }
179
+ crud.status.add = CRUD.STATUS.PREPARED;
180
+ callVmHook(crud, CRUD.HOOK.afterToAdd, crud.form);
181
+ callVmHook(crud, CRUD.HOOK.afterToCU, crud.form);
182
+ },
183
+ /**
184
+ * 启动编辑
185
+ * @param {*} data 数据项
186
+ */
187
+ toEdit(data) {
188
+ crud.resetForm(JSON.parse(JSON.stringify(data)));
189
+ if (
190
+ !(
191
+ callVmHook(crud, CRUD.HOOK.beforeToEdit, crud.form) &&
192
+ callVmHook(crud, CRUD.HOOK.beforeToCU, crud.form)
193
+ )
194
+ ) {
195
+ return;
196
+ }
197
+ crud.status.edit = CRUD.STATUS.PREPARED;
198
+ crud.getDataStatus(crud.getDataId(data)).edit = CRUD.STATUS.PREPARED;
199
+ callVmHook(crud, CRUD.HOOK.afterToEdit, crud.form);
200
+ callVmHook(crud, CRUD.HOOK.afterToCU, crud.form);
201
+ },
202
+ /**
203
+ * 启动删除
204
+ * @param {*} data 数据项
205
+ */
206
+ toDelete(data) {
207
+ crud.getDataStatus(crud.getDataId(data)).delete = CRUD.STATUS.PREPARED;
208
+ },
209
+ /**
210
+ * 取消删除
211
+ * @param {*} data 数据项
212
+ */
213
+ cancelDelete(data) {
214
+ if (!callVmHook(crud, CRUD.HOOK.beforeDeleteCancel, data)) {
215
+ return;
216
+ }
217
+ crud.getDataStatus(crud.getDataId(data)).delete = CRUD.STATUS.NORMAL;
218
+ callVmHook(crud, CRUD.HOOK.afterDeleteCancel, data);
219
+ },
220
+ /**
221
+ * 取消新增/编辑
222
+ */
223
+ cancelCU() {
224
+ const addStatus = crud.status.add;
225
+ const editStatus = crud.status.edit;
226
+ if (addStatus === CRUD.STATUS.PREPARED) {
227
+ if (!callVmHook(crud, CRUD.HOOK.beforeAddCancel, crud.form)) {
228
+ return;
229
+ }
230
+ crud.status.add = CRUD.STATUS.NORMAL;
231
+ }
232
+ if (editStatus === CRUD.STATUS.PREPARED) {
233
+ if (!callVmHook(crud, CRUD.HOOK.beforeEditCancel, crud.form)) {
234
+ return;
235
+ }
236
+ crud.status.edit = CRUD.STATUS.NORMAL;
237
+ crud.getDataStatus(crud.getDataId(crud.form)).edit = CRUD.STATUS.NORMAL;
238
+ }
239
+ crud.resetForm();
240
+ if (addStatus === CRUD.STATUS.PREPARED) {
241
+ callVmHook(crud, CRUD.HOOK.afterAddCancel, crud.form);
242
+ }
243
+ if (editStatus === CRUD.STATUS.PREPARED) {
244
+ callVmHook(crud, CRUD.HOOK.afterEditCancel, crud.form);
245
+ }
246
+ // 清除表单验证
247
+ if (crud.findVM('form').$refs['form']) {
248
+ crud.findVM('form').$refs['form'].clearValidate();
249
+ }
250
+ },
251
+ /**
252
+ * 提交新增/编辑
253
+ */
254
+ submitCU() {
255
+ if (!callVmHook(crud, CRUD.HOOK.beforeValidateCU)) {
256
+ return;
257
+ }
258
+ crud.findVM('form').$refs['form'].validate(valid => {
259
+ if (!valid) {
260
+ return;
261
+ }
262
+ if (!callVmHook(crud, CRUD.HOOK.afterValidateCU)) {
263
+ return;
264
+ }
265
+ if (crud.status.add === CRUD.STATUS.PREPARED) {
266
+ crud.doAdd();
267
+ } else if (crud.status.edit === CRUD.STATUS.PREPARED) {
268
+ crud.doEdit();
269
+ }
270
+ });
271
+ },
272
+ /**
273
+ * 执行添加
274
+ */
275
+ doAdd() {
276
+ if (!callVmHook(crud, CRUD.HOOK.beforeSubmit)) {
277
+ return;
278
+ }
279
+ crud.status.add = CRUD.STATUS.PROCESSING;
280
+ crud.crudMethod
281
+ .add(crud.form)
282
+ .then(() => {
283
+ crud.status.add = CRUD.STATUS.NORMAL;
284
+ crud.resetForm();
285
+ crud.addSuccessNotify();
286
+ callVmHook(crud, CRUD.HOOK.afterSubmit);
287
+ crud.toQuery();
288
+ })
289
+ .catch(() => {
290
+ crud.status.add = CRUD.STATUS.PREPARED;
291
+ callVmHook(crud, CRUD.HOOK.afterAddError);
292
+ });
293
+ },
294
+ /**
295
+ * 执行编辑
296
+ */
297
+ doEdit() {
298
+ if (!callVmHook(crud, CRUD.HOOK.beforeSubmit)) {
299
+ return;
300
+ }
301
+ crud.status.edit = CRUD.STATUS.PROCESSING;
302
+ crud.crudMethod
303
+ .edit(crud.form)
304
+ .then(() => {
305
+ crud.status.edit = CRUD.STATUS.NORMAL;
306
+ crud.getDataStatus(crud.getDataId(crud.form)).edit = CRUD.STATUS.NORMAL;
307
+ crud.editSuccessNotify();
308
+ crud.resetForm();
309
+ callVmHook(crud, CRUD.HOOK.afterSubmit);
310
+ crud.refresh();
311
+ })
312
+ .catch(() => {
313
+ crud.status.edit = CRUD.STATUS.PREPARED;
314
+ callVmHook(crud, CRUD.HOOK.afterEditError);
315
+ });
316
+ },
317
+ /**
318
+ * 执行删除
319
+ * @param {*} data 数据项
320
+ */
321
+ doDelete(data) {
322
+ let delAll = false;
323
+ let dataStatus;
324
+ const ids = [];
325
+ if (data instanceof Array) {
326
+ delAll = true;
327
+ data.forEach(val => {
328
+ ids.push(this.getDataId(val));
329
+ });
330
+ } else {
331
+ ids.push(this.getDataId(data));
332
+ dataStatus = crud.getDataStatus(this.getDataId(data));
333
+ }
334
+ if (!callVmHook(crud, CRUD.HOOK.beforeDelete, data)) {
335
+ return;
336
+ }
337
+ if (!delAll) {
338
+ dataStatus.delete = CRUD.STATUS.PROCESSING;
339
+ }
340
+ return crud.crudMethod
341
+ .del(ids)
342
+ .then(() => {
343
+ if (delAll) {
344
+ crud.delAllLoading = false;
345
+ } else dataStatus.delete = CRUD.STATUS.PREPARED;
346
+ crud.dleChangePage(1);
347
+ crud.delSuccessNotify();
348
+ callVmHook(crud, CRUD.HOOK.afterDelete, data);
349
+ crud.refresh();
350
+ })
351
+ .catch(() => {
352
+ if (delAll) {
353
+ crud.delAllLoading = false;
354
+ } else dataStatus.delete = CRUD.STATUS.PREPARED;
355
+ });
356
+ },
357
+ /**
358
+ * 通用导出
359
+ */
360
+ doExport() {
361
+ crud.downloadLoading = true;
362
+ download(crud.url + '/download', crud.getQueryParams())
363
+ .then(result => {
364
+ crud.downloadLoading = false;
365
+ })
366
+ .catch(result => {
367
+ downloadFile(result, crud.title + '数据', 'xlsx');
368
+ crud.downloadLoading = false;
369
+ });
370
+ },
371
+ /**
372
+ * 获取查询参数
373
+ */
374
+ getQueryParams: function () {
375
+ //字符串清空前后空格
376
+ Object.keys(crud.query).map(key => {
377
+ if (typeof crud.query[key] == 'string') {
378
+ crud.query[key] = crud.query[key].trim();
379
+ }
380
+ });
381
+ // 清除参数无值的情况
382
+ Object.keys(crud.query).length !== 0 &&
383
+ Object.keys(crud.query).forEach(item => {
384
+ if (crud.query[item] === null || crud.query[item] === '') crud.query[item] = undefined;
385
+ });
386
+ Object.keys(crud.params).length !== 0 &&
387
+ Object.keys(crud.params).forEach(item => {
388
+ if (crud.params[item] === null || crud.params[item] === '') crud.params[item] = undefined;
389
+ });
390
+ return {
391
+ page: crud.page.page - 1,
392
+ size: crud.page.size,
393
+ sort: crud.sort,
394
+ ...crud.query,
395
+ ...crud.params,
396
+ };
397
+ },
398
+ // 当前页改变
399
+ pageChangeHandler(e) {
400
+ crud.page.page = e;
401
+ crud.refresh();
402
+ },
403
+ // 每页条数改变
404
+ sizeChangeHandler(e) {
405
+ crud.page.size = e;
406
+ crud.page.page = 1;
407
+ crud.refresh();
408
+ },
409
+ // 预防删除第二页最后一条数据时,或者多选删除第二页的数据时,页码错误导致请求无数据
410
+ dleChangePage(size) {
411
+ if (crud.data.length === size && crud.page.page !== 1) {
412
+ crud.page.page -= 1;
413
+ }
414
+ },
415
+ // 选择改变
416
+ selectionChangeHandler(val) {
417
+ crud.selections = val;
418
+ },
419
+ /**
420
+ * 重置查询参数
421
+ * @param {Boolean} toQuery 重置后进行查询操作
422
+ */
423
+ resetQuery(toQuery = true) {
424
+ const defaultQuery = JSON.parse(JSON.stringify(crud.defaultQuery));
425
+ const query = crud.query;
426
+ Object.keys(query).forEach(key => {
427
+ query[key] = defaultQuery[key];
428
+ });
429
+ // 重置参数
430
+ this.params = {};
431
+ if (toQuery) {
432
+ crud.toQuery();
433
+ }
434
+ },
435
+ /**
436
+ * 重置表单
437
+ * @param {Array} data 数据
438
+ */
439
+ resetForm(data) {
440
+ const form =
441
+ data ||
442
+ (typeof crud.defaultForm === 'object'
443
+ ? JSON.parse(JSON.stringify(crud.defaultForm))
444
+ : crud.defaultForm.apply(crud.findVM('form')));
445
+ const crudFrom = crud.form;
446
+ for (const key in form) {
447
+ if (crudFrom.hasOwnProperty(key)) {
448
+ crudFrom[key] = form[key];
449
+ } else {
450
+ Vue.set(crudFrom, key, form[key]);
451
+ }
452
+ }
453
+ // add by ghl 2020-10-04 页面重复添加信息时,下拉框的校验会存在,需要找工取消
454
+ if (crud.findVM('form').$refs['form']) {
455
+ crud.findVM('form').$refs['form'].clearValidate();
456
+ }
457
+ },
458
+ /**
459
+ * 重置数据状态
460
+ */
461
+ resetDataStatus() {
462
+ const dataStatus = {};
463
+ function resetStatus(datas) {
464
+ datas = datas || [];
465
+ datas.forEach(e => {
466
+ dataStatus[crud.getDataId(e)] = {
467
+ delete: 0,
468
+ edit: 0,
469
+ };
470
+ if (e.children) {
471
+ resetStatus(e.children);
472
+ }
473
+ });
474
+ }
475
+ resetStatus(crud.data);
476
+ crud.dataStatus = dataStatus;
477
+ },
478
+ /**
479
+ * 获取数据状态
480
+ * @param {Number | String} id 数据项id
481
+ */
482
+ getDataStatus(id) {
483
+ return crud.dataStatus[id];
484
+ },
485
+ /**
486
+ * 用于树形表格多选, 选中所有
487
+ * @param selection
488
+ */
489
+ selectAllChange(selection) {
490
+ // 如果选中的数目与请求到的数目相同就选中子节点,否则就清空选中
491
+ if (selection && selection.length === crud.data.length) {
492
+ selection.forEach(val => {
493
+ crud.selectChange(selection, val);
494
+ });
495
+ } else {
496
+ crud.getTable().clearSelection();
497
+ }
498
+ },
499
+ /**
500
+ * 用于树形表格多选,单选的封装
501
+ * @param selection
502
+ * @param row
503
+ */
504
+ selectChange(selection, row) {
505
+ // 如果selection中存在row代表是选中,否则是取消选中
506
+ if (
507
+ selection.find(val => {
508
+ return crud.getDataId(val) === crud.getDataId(row);
509
+ })
510
+ ) {
511
+ if (row.children) {
512
+ row.children.forEach(val => {
513
+ crud.getTable().toggleRowSelection(val, true);
514
+ selection.push(val);
515
+ if (val.children) {
516
+ crud.selectChange(selection, val);
517
+ }
518
+ });
519
+ }
520
+ } else {
521
+ crud.toggleRowSelection(selection, row);
522
+ }
523
+ },
524
+ /**
525
+ * 切换选中状态
526
+ * @param selection
527
+ * @param data
528
+ */
529
+ toggleRowSelection(selection, data) {
530
+ if (data.children) {
531
+ data.children.forEach(val => {
532
+ crud.getTable().toggleRowSelection(val, false);
533
+ if (val.children) {
534
+ crud.toggleRowSelection(selection, val);
535
+ }
536
+ });
537
+ }
538
+ },
539
+ findVM(type) {
540
+ return crud.vms.find(vm => vm && vm.type === type).vm;
541
+ },
542
+ notify(title, type = CRUD.NOTIFICATION_TYPE.INFO) {
543
+ crud.vms[0].vm.$notify({
544
+ title,
545
+ type,
546
+ duration: 2500,
547
+ });
548
+ },
549
+ updateProp(name, value) {
550
+ Vue.set(crud.props, name, value);
551
+ },
552
+ getDataId(data) {
553
+ return data[this.idField];
554
+ },
555
+ getTable() {
556
+ return this.findVM('presenter').$refs.table;
557
+ },
558
+ attchTable() {
559
+ const table = this.getTable();
560
+ this.updateProp('table', table);
561
+ const that = this;
562
+ table.$on('expand-change', (row, expanded) => {
563
+ if (!expanded) {
564
+ return;
565
+ }
566
+ const lazyTreeNodeMap = table.store.states.lazyTreeNodeMap;
567
+ row.children = lazyTreeNodeMap[crud.getDataId(row)];
568
+ if (row.children) {
569
+ row.children.forEach(ele => {
570
+ const id = crud.getDataId(ele);
571
+ if (that.dataStatus[id] === undefined) {
572
+ that.dataStatus[id] = {
573
+ delete: 0,
574
+ edit: 0,
575
+ };
576
+ }
577
+ });
578
+ }
579
+ });
580
+ },
581
+ };
582
+ const crud = Object.assign({}, data);
583
+ // 可观测化
584
+ Vue.observable(crud);
585
+ // 附加方法
586
+ Object.assign(crud, methods);
587
+ // 记录初始默认的查询参数,后续重置查询时使用
588
+ Object.assign(crud, {
589
+ defaultQuery: JSON.parse(JSON.stringify(data.query)),
590
+ // 预留4位存储:组件 主页、头部、分页、表单,调试查看也方便找
591
+ vms: Array(4),
592
+ /**
593
+ * 注册组件实例
594
+ * @param {String} type 类型
595
+ * @param {*} vm 组件实例
596
+ * @param {Number} index 该参数内部使用
597
+ */
598
+ registerVM(type, vm, index = -1) {
599
+ const vmObj = {
600
+ type,
601
+ vm: vm,
602
+ };
603
+ if (index < 0) {
604
+ this.vms.push(vmObj);
605
+ return;
606
+ }
607
+ if (index < 4) {
608
+ // 内置预留vm数
609
+ this.vms[index] = vmObj;
610
+ return;
611
+ }
612
+ this.vms.length = Math.max(this.vms.length, index);
613
+ this.vms.splice(index, 1, vmObj);
614
+ },
615
+ /**
616
+ * 取消注册组件实例
617
+ * @param {*} vm 组件实例
618
+ */
619
+ unregisterVM(type, vm) {
620
+ for (let i = this.vms.length - 1; i >= 0; i--) {
621
+ if (this.vms[i] === undefined) {
622
+ continue;
623
+ }
624
+ if (this.vms[i].type === type && this.vms[i].vm === vm) {
625
+ if (i < 4) {
626
+ // 内置预留vm数
627
+ this.vms[i] = undefined;
628
+ } else {
629
+ this.vms.splice(i, 1);
630
+ }
631
+ break;
632
+ }
633
+ }
634
+ },
635
+ });
636
+ // 冻结处理,需要扩展数据的话,使用crud.updateProp(name, value),以crud.props.name形式访问,这个是响应式的,可以做数据绑定
637
+ Object.freeze(crud);
638
+ return crud;
639
+ }
640
+
641
+ // hook VM
642
+ function callVmHook(crud, hook) {
643
+ const tagHook = crud.tag ? hook + '$' + crud.tag : null;
644
+ let ret = true;
645
+ const nargs = [crud];
646
+ for (let i = 2; i < arguments.length; ++i) {
647
+ nargs.push(arguments[i]);
648
+ }
649
+ // 有些组件扮演了多个角色,调用钩子时,需要去重
650
+ const vmSet = new Set();
651
+ crud.vms.forEach(vm => vm && vmSet.add(vm.vm));
652
+ vmSet.forEach(vm => {
653
+ if (vm[hook]) {
654
+ ret = vm[hook].apply(vm, nargs) !== false && ret;
655
+ }
656
+ if (tagHook && vm[tagHook]) {
657
+ ret = vm[tagHook].apply(vm, nargs) !== false && ret;
658
+ }
659
+ });
660
+ return ret;
661
+ }
662
+
663
+ function mergeOptions(src, opts) {
664
+ const optsRet = {
665
+ ...src,
666
+ };
667
+ for (const key in src) {
668
+ if (opts.hasOwnProperty(key)) {
669
+ optsRet[key] = opts[key];
670
+ }
671
+ }
672
+ return optsRet;
673
+ }
674
+
675
+ /**
676
+ * 查找crud
677
+ * @param {*} vm
678
+ * @param {string} tag
679
+ */
680
+ function lookupCrud(vm, tag) {
681
+ tag = tag || vm.$attrs['crud-tag'] || 'default';
682
+ // function lookupCrud(vm, tag) {
683
+ if (vm.$crud) {
684
+ const ret = vm.$crud[tag];
685
+ if (ret) {
686
+ return ret;
687
+ }
688
+ }
689
+ return vm.$parent ? lookupCrud(vm.$parent, tag) : undefined;
690
+ }
691
+
692
+ /**
693
+ * crud主页
694
+ */
695
+ function presenter(crud) {
696
+ if (crud) {
697
+ console.warn(
698
+ '[CRUD warn]: ' + 'please use $options.cruds() { return CRUD(...) or [CRUD(...), ...] }'
699
+ );
700
+ }
701
+ return {
702
+ data() {
703
+ // 在data中返回crud,是为了将crud与当前实例关联,组件观测crud相关属性变化
704
+ return {
705
+ crud: this.crud,
706
+ };
707
+ },
708
+ beforeCreate() {
709
+ this.$crud = this.$crud || {};
710
+ let cruds = this.$options.cruds instanceof Function ? this.$options.cruds() : crud;
711
+ if (!(cruds instanceof Array)) {
712
+ cruds = [cruds];
713
+ }
714
+ cruds.forEach(ele => {
715
+ if (this.$crud[ele.tag]) {
716
+ console.error('[CRUD error]: ' + 'crud with tag [' + ele.tag + ' is already exist');
717
+ }
718
+ this.$crud[ele.tag] = ele;
719
+ ele.registerVM('presenter', this, 0);
720
+ });
721
+ this.crud = this.$crud['defalut'] || cruds[0];
722
+ },
723
+ methods: {
724
+ parseTime,
725
+ },
726
+ created() {
727
+ for (const k in this.$crud) {
728
+ if (this.$crud[k].queryOnPresenterCreated) {
729
+ this.$crud[k].toQuery();
730
+ }
731
+ }
732
+ },
733
+ destroyed() {
734
+ for (const k in this.$crud) {
735
+ this.$crud[k].unregisterVM('presenter', this);
736
+ }
737
+ },
738
+ mounted() {
739
+ // 如果table未实例化(例如使用了v-if),请稍后在适当时机crud.attchTable刷新table信息
740
+ if (this.$refs.table !== undefined) {
741
+ this.crud.attchTable();
742
+ }
743
+ },
744
+ };
745
+ }
746
+
747
+ /**
748
+ * 头部
749
+ */
750
+ function header() {
751
+ return {
752
+ data() {
753
+ return {
754
+ crud: this.crud,
755
+ query: this.crud.query,
756
+ };
757
+ },
758
+ beforeCreate() {
759
+ this.crud = lookupCrud(this);
760
+ this.crud.registerVM('header', this, 1);
761
+ },
762
+ destroyed() {
763
+ this.crud.unregisterVM('header', this);
764
+ },
765
+ };
766
+ }
767
+
768
+ /**
769
+ * 分页
770
+ */
771
+ function pagination() {
772
+ return {
773
+ data() {
774
+ return {
775
+ crud: this.crud,
776
+ page: this.crud.page,
777
+ };
778
+ },
779
+ beforeCreate() {
780
+ this.crud = lookupCrud(this);
781
+ this.crud.registerVM('pagination', this, 2);
782
+ },
783
+ destroyed() {
784
+ this.crud.unregisterVM('pagination', this);
785
+ },
786
+ };
787
+ }
788
+
789
+ /**
790
+ * 表单
791
+ */
792
+ function form(defaultForm) {
793
+ return {
794
+ data() {
795
+ return {
796
+ crud: this.crud,
797
+ form: this.crud.form,
798
+ };
799
+ },
800
+ beforeCreate() {
801
+ this.crud = lookupCrud(this);
802
+ this.crud.registerVM('form', this, 3);
803
+ },
804
+ created() {
805
+ this.crud.defaultForm = defaultForm;
806
+ this.crud.resetForm();
807
+ },
808
+ destroyed() {
809
+ this.crud.unregisterVM('form', this);
810
+ },
811
+ };
812
+ }
813
+
814
+ /**
815
+ * crud
816
+ */
817
+ function crud(options = {}) {
818
+ const defaultOptions = {
819
+ type: undefined,
820
+ };
821
+ options = mergeOptions(defaultOptions, options);
822
+ return {
823
+ data() {
824
+ return {
825
+ crud: this.crud,
826
+ };
827
+ },
828
+ beforeCreate() {
829
+ this.crud = lookupCrud(this);
830
+ this.crud.registerVM(options.type, this);
831
+ },
832
+ destroyed() {
833
+ this.crud.unregisterVM(options.type, this);
834
+ },
835
+ };
836
+ }
837
+
838
+ /**
839
+ * CRUD钩子
840
+ */
841
+ CRUD.HOOK = {
842
+ /** 刷新 - 之前 */
843
+ beforeRefresh: 'beforeCrudRefresh',
844
+ /** 刷新 - 之后 */
845
+ afterRefresh: 'afterCrudRefresh',
846
+ /** 删除 - 之前 */
847
+ beforeDelete: 'beforeCrudDelete',
848
+ /** 删除 - 之后 */
849
+ afterDelete: 'afterCrudDelete',
850
+ /** 删除取消 - 之前 */
851
+ beforeDeleteCancel: 'beforeCrudDeleteCancel',
852
+ /** 删除取消 - 之后 */
853
+ afterDeleteCancel: 'afterCrudDeleteCancel',
854
+ /** 新建 - 之前 */
855
+ beforeToAdd: 'beforeCrudToAdd',
856
+ /** 新建 - 之后 */
857
+ afterToAdd: 'afterCrudToAdd',
858
+ /** 编辑 - 之前 */
859
+ beforeToEdit: 'beforeCrudToEdit',
860
+ /** 编辑 - 之后 */
861
+ afterToEdit: 'afterCrudToEdit',
862
+ /** 开始 "新建/编辑" - 之前 */
863
+ beforeToCU: 'beforeCrudToCU',
864
+ /** 开始 "新建/编辑" - 之后 */
865
+ afterToCU: 'afterCrudToCU',
866
+ /** "新建/编辑" 验证 - 之前 */
867
+ beforeValidateCU: 'beforeCrudValidateCU',
868
+ /** "新建/编辑" 验证 - 之后 */
869
+ afterValidateCU: 'afterCrudValidateCU',
870
+ /** 添加取消 - 之前 */
871
+ beforeAddCancel: 'beforeCrudAddCancel',
872
+ /** 添加取消 - 之后 */
873
+ afterAddCancel: 'afterCrudAddCancel',
874
+ /** 编辑取消 - 之前 */
875
+ beforeEditCancel: 'beforeCrudEditCancel',
876
+ /** 编辑取消 - 之后 */
877
+ afterEditCancel: 'afterCrudEditCancel',
878
+ /** 提交 - 之前 */
879
+ beforeSubmit: 'beforeCrudSubmitCU',
880
+ /** 提交 - 之后 */
881
+ afterSubmit: 'afterCrudSubmitCU',
882
+ afterAddError: 'afterCrudAddError',
883
+ afterEditError: 'afterCrudEditError',
884
+ };
885
+
886
+ /**
887
+ * CRUD状态
888
+ */
889
+ CRUD.STATUS = {
890
+ NORMAL: 0,
891
+ PREPARED: 1,
892
+ PROCESSING: 2,
893
+ };
894
+
895
+ /**
896
+ * CRUD通知类型
897
+ */
898
+ CRUD.NOTIFICATION_TYPE = {
899
+ SUCCESS: 'success',
900
+ WARNING: 'warning',
901
+ INFO: 'info',
902
+ ERROR: 'error',
903
+ };
904
+
905
+ export default CRUD;
906
+
907
+ export { presenter, header, form, pagination, crud };