mooho-base-admin-plus 0.1.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 (283) hide show
  1. package/.env +5 -0
  2. package/.env.development +0 -0
  3. package/.env.production +0 -0
  4. package/.eslintignore +11 -0
  5. package/.eslintrc.js +47 -0
  6. package/.prettierrc +15 -0
  7. package/README.md +18 -0
  8. package/dist/favicon.ico +0 -0
  9. package/dist/mooho-base-admin-plus.min.esm.js +131746 -0
  10. package/dist/mooho-base-admin-plus.min.js +279 -0
  11. package/dist/setting.js +31 -0
  12. package/dist/static/images/app-barcode.png +0 -0
  13. package/dist/static/images/login/bg.png +0 -0
  14. package/dist/static/images/login/logo.png +0 -0
  15. package/dist/static/images/login/password-active.png +0 -0
  16. package/dist/static/images/login/password-default.png +0 -0
  17. package/dist/static/images/login/signIn-img.png +0 -0
  18. package/dist/static/images/login/user-active.png +0 -0
  19. package/dist/static/images/login/user-default.png +0 -0
  20. package/dist/static/images/logo-dark.png +0 -0
  21. package/dist/static/images/logo-small.png +0 -0
  22. package/dist/static/images/logo.png +0 -0
  23. package/dist/static/images/logo.svg +510 -0
  24. package/dist/static/images/no-image.png +0 -0
  25. package/dist/style.css +4 -0
  26. package/index.html +18 -0
  27. package/other/pda.vue +28 -0
  28. package/package.json +59 -0
  29. package/public/favicon.ico +0 -0
  30. package/public/setting.js +31 -0
  31. package/public/static/images/app-barcode.png +0 -0
  32. package/public/static/images/login/bg.png +0 -0
  33. package/public/static/images/login/logo.png +0 -0
  34. package/public/static/images/login/password-active.png +0 -0
  35. package/public/static/images/login/password-default.png +0 -0
  36. package/public/static/images/login/signIn-img.png +0 -0
  37. package/public/static/images/login/user-active.png +0 -0
  38. package/public/static/images/login/user-default.png +0 -0
  39. package/public/static/images/logo-dark.png +0 -0
  40. package/public/static/images/logo-small.png +0 -0
  41. package/public/static/images/logo.png +0 -0
  42. package/public/static/images/logo.svg +510 -0
  43. package/public/static/images/no-image.png +0 -0
  44. package/src/App.vue +60 -0
  45. package/src/api/application.js +35 -0
  46. package/src/api/customModel.js +187 -0
  47. package/src/api/customPage.js +15 -0
  48. package/src/api/customTable.js +24 -0
  49. package/src/api/dataSource.js +93 -0
  50. package/src/api/dataView.js +199 -0
  51. package/src/api/dictType.js +23 -0
  52. package/src/api/entityView.js +13 -0
  53. package/src/api/enum.js +15 -0
  54. package/src/api/filterColumn.js +16 -0
  55. package/src/api/model.js +244 -0
  56. package/src/api/movePlan.js +29 -0
  57. package/src/api/notification.js +28 -0
  58. package/src/api/openApiPermission.js +25 -0
  59. package/src/api/permission.js +51 -0
  60. package/src/api/planJob.js +15 -0
  61. package/src/api/process.js +23 -0
  62. package/src/api/processDef.js +36 -0
  63. package/src/api/processInst.js +16 -0
  64. package/src/api/rolePermission.js +17 -0
  65. package/src/api/roleProperty.js +36 -0
  66. package/src/api/shortcut.js +20 -0
  67. package/src/api/system.js +23 -0
  68. package/src/api/task.js +56 -0
  69. package/src/api/taskQueue.js +24 -0
  70. package/src/api/user.js +45 -0
  71. package/src/api/viewColumn.js +16 -0
  72. package/src/assets/svg/body.svg +17 -0
  73. package/src/assets/svg/header-theme-dark.svg +40 -0
  74. package/src/assets/svg/header-theme-primary.svg +40 -0
  75. package/src/assets/svg/header-top.svg +40 -0
  76. package/src/assets/svg/icon-happy.svg +1 -0
  77. package/src/assets/svg/icon-sad.svg +1 -0
  78. package/src/assets/svg/icon-social-bilibili.svg +1 -0
  79. package/src/assets/svg/icon-social-dingding.svg +1 -0
  80. package/src/assets/svg/icon-social-facebook.svg +1 -0
  81. package/src/assets/svg/icon-social-juejin.svg +1 -0
  82. package/src/assets/svg/icon-social-qq.svg +1 -0
  83. package/src/assets/svg/icon-social-twitter.svg +1 -0
  84. package/src/assets/svg/icon-social-wechat.svg +1 -0
  85. package/src/assets/svg/icon-social-weibo.svg +1 -0
  86. package/src/assets/svg/icon-social-zhihu.svg +1 -0
  87. package/src/assets/svg/nav-theme-dark.svg +40 -0
  88. package/src/assets/svg/nav-theme-light.svg +40 -0
  89. package/src/components/copyright/index.vue +28 -0
  90. package/src/components/home/notice-list.vue +62 -0
  91. package/src/components/home/shortcut.vue +125 -0
  92. package/src/components/input/dialog-select.vue +301 -0
  93. package/src/components/input/item-select.vue +195 -0
  94. package/src/components/link/index.vue +54 -0
  95. package/src/components/richEditor/index.vue +86 -0
  96. package/src/components/upload/file-upload.vue +84 -0
  97. package/src/components/upload/upload-attachment.vue +119 -0
  98. package/src/components/upload/upload-image.vue +212 -0
  99. package/src/components/view/column-check.vue +223 -0
  100. package/src/components/view/column-edit.vue +850 -0
  101. package/src/components/view/column-select.vue +206 -0
  102. package/src/components/view/condition-edit.vue +164 -0
  103. package/src/components/view/filter-edit.vue +633 -0
  104. package/src/components/view/filter-setting.vue +126 -0
  105. package/src/components/view/form-setting-layout.vue +375 -0
  106. package/src/components/view/form-setting.vue +247 -0
  107. package/src/components/view/group-column.vue +104 -0
  108. package/src/components/view/group-method.vue +104 -0
  109. package/src/components/view/mixin.js +72 -0
  110. package/src/components/view/modal-form-filter.vue +319 -0
  111. package/src/components/view/modal-form-sort.vue +248 -0
  112. package/src/components/view/modal-form.vue +453 -0
  113. package/src/components/view/modal-table.vue +471 -0
  114. package/src/components/view/table-filter.vue +702 -0
  115. package/src/components/view/table-setting.vue +533 -0
  116. package/src/components/view/view-chart.vue +423 -0
  117. package/src/components/view/view-form-draggable.vue +837 -0
  118. package/src/components/view/view-form.vue +1444 -0
  119. package/src/components/view/view-table.vue +2261 -0
  120. package/src/components/workflow/flow-chart.vue +846 -0
  121. package/src/directive/focus.js +10 -0
  122. package/src/directive/tabHide.js +9 -0
  123. package/src/i18n/index.js +15 -0
  124. package/src/i18n/locale/en-US.js +1 -0
  125. package/src/i18n/locale/lang.js +1 -0
  126. package/src/i18n/locale/zh-CN.js +1 -0
  127. package/src/i18n/locale.js +102 -0
  128. package/src/index.js +222 -0
  129. package/src/layouts/basic-layout/header-breadcrumb/index.vue +122 -0
  130. package/src/layouts/basic-layout/header-collapse/index.vue +44 -0
  131. package/src/layouts/basic-layout/header-fullscreen/index.vue +19 -0
  132. package/src/layouts/basic-layout/header-i18n/index.vue +45 -0
  133. package/src/layouts/basic-layout/header-log/index.vue +41 -0
  134. package/src/layouts/basic-layout/header-logo/index.vue +23 -0
  135. package/src/layouts/basic-layout/header-notice/index.vue +218 -0
  136. package/src/layouts/basic-layout/header-reload/index.vue +21 -0
  137. package/src/layouts/basic-layout/header-search/index.vue +37 -0
  138. package/src/layouts/basic-layout/header-setting/index.vue +219 -0
  139. package/src/layouts/basic-layout/header-user/index.vue +175 -0
  140. package/src/layouts/basic-layout/i18n.js +50 -0
  141. package/src/layouts/basic-layout/index.vue +280 -0
  142. package/src/layouts/basic-layout/menu-head/index.vue +120 -0
  143. package/src/layouts/basic-layout/menu-head/title.vue +48 -0
  144. package/src/layouts/basic-layout/menu-side/index.vue +113 -0
  145. package/src/layouts/basic-layout/menu-side/menu-collapse.vue +76 -0
  146. package/src/layouts/basic-layout/menu-side/menu-item.vue +31 -0
  147. package/src/layouts/basic-layout/menu-side/menu-title.vue +56 -0
  148. package/src/layouts/basic-layout/menu-side/submenu.vue +31 -0
  149. package/src/layouts/basic-layout/mixins/click-item.js +21 -0
  150. package/src/layouts/basic-layout/mixins/sider-menu-badge.js +13 -0
  151. package/src/layouts/basic-layout/mixins/translate-title.js +11 -0
  152. package/src/layouts/basic-layout/tabs/index.vue +192 -0
  153. package/src/layouts/basic-layout/water-mark/index.vue +29 -0
  154. package/src/libs/lodop/index.js +145 -0
  155. package/src/libs/random_str.js +10 -0
  156. package/src/libs/request/index.js +158 -0
  157. package/src/libs/system/index.js +234 -0
  158. package/src/libs/util.cookies.js +44 -0
  159. package/src/libs/util.db.js +13 -0
  160. package/src/libs/util.js +55 -0
  161. package/src/libs/util.log.js +88 -0
  162. package/src/libs/water-mark.js +44 -0
  163. package/src/menu/header.js +20 -0
  164. package/src/menu/modules/dashboard.js +23 -0
  165. package/src/menu/sider.js +12 -0
  166. package/src/mixins/app.js +9 -0
  167. package/src/mixins/page.js +643 -0
  168. package/src/pages/account/login.vue +101 -0
  169. package/src/pages/common/home.vue +169 -0
  170. package/src/pages/common/task-form.vue +350 -0
  171. package/src/pages/common/todo.vue +31 -0
  172. package/src/pages/system/apiLog.vue +79 -0
  173. package/src/pages/system/applicationType.vue +182 -0
  174. package/src/pages/system/customPage.vue +62 -0
  175. package/src/pages/system/customTable.vue +98 -0
  176. package/src/pages/system/dict.vue +36 -0
  177. package/src/pages/system/dictType.vue +58 -0
  178. package/src/pages/system/entityView.vue +38 -0
  179. package/src/pages/system/error/404.vue +6 -0
  180. package/src/pages/system/extendColumn.vue +99 -0
  181. package/src/pages/system/formView.vue +136 -0
  182. package/src/pages/system/log.vue +55 -0
  183. package/src/pages/system/notice.vue +26 -0
  184. package/src/pages/system/openApi.vue +26 -0
  185. package/src/pages/system/openUser.vue +66 -0
  186. package/src/pages/system/organization.vue +98 -0
  187. package/src/pages/system/organizationType.vue +26 -0
  188. package/src/pages/system/permission.vue +175 -0
  189. package/src/pages/system/planJob.vue +40 -0
  190. package/src/pages/system/printTemplate.vue +48 -0
  191. package/src/pages/system/process.vue +79 -0
  192. package/src/pages/system/processType.vue +26 -0
  193. package/src/pages/system/role.vue +395 -0
  194. package/src/pages/system/rolePropertyEdit.vue +480 -0
  195. package/src/pages/system/sequenceSetting.vue +26 -0
  196. package/src/pages/system/systemData.vue +52 -0
  197. package/src/pages/system/tableView.vue +386 -0
  198. package/src/pages/system/taskQueue.vue +48 -0
  199. package/src/pages/system/user.vue +250 -0
  200. package/src/pages/template/processPage.vue +243 -0
  201. package/src/pages/template/reportPage.vue +66 -0
  202. package/src/pages/template/viewPage.vue +139 -0
  203. package/src/plugins/auth/index.js +21 -0
  204. package/src/plugins/error/index.js +31 -0
  205. package/src/plugins/index.js +24 -0
  206. package/src/plugins/sweetalert2/index.js +20 -0
  207. package/src/router/dynamic.js +183 -0
  208. package/src/router/index.js +84 -0
  209. package/src/setting.js +202 -0
  210. package/src/store/index.js +9 -0
  211. package/src/store/modules/admin/index.js +16 -0
  212. package/src/store/modules/admin/modules/account.js +103 -0
  213. package/src/store/modules/admin/modules/cache.js +119 -0
  214. package/src/store/modules/admin/modules/dataView.js +112 -0
  215. package/src/store/modules/admin/modules/db.js +231 -0
  216. package/src/store/modules/admin/modules/i18n.js +87 -0
  217. package/src/store/modules/admin/modules/layout.js +115 -0
  218. package/src/store/modules/admin/modules/loader.js +44 -0
  219. package/src/store/modules/admin/modules/log.js +77 -0
  220. package/src/store/modules/admin/modules/menu.js +338 -0
  221. package/src/store/modules/admin/modules/page.js +466 -0
  222. package/src/store/modules/admin/modules/user.js +96 -0
  223. package/src/store/modules/admin/modules/viewPage.js +34 -0
  224. package/src/styles/common.less +47 -0
  225. package/src/styles/css/default.css +510 -0
  226. package/src/styles/css/login.css +1217 -0
  227. package/src/styles/default/index.less +6 -0
  228. package/src/styles/font/demo.css +539 -0
  229. package/src/styles/font/demo_index.html +372 -0
  230. package/src/styles/font/icon-demo/demo.css +539 -0
  231. package/src/styles/font/icon-demo/demo_index.html +423 -0
  232. package/src/styles/font/icon-demo/iconfont.css +61 -0
  233. package/src/styles/font/icon-demo/iconfont.eot +0 -0
  234. package/src/styles/font/icon-demo/iconfont.js +1 -0
  235. package/src/styles/font/icon-demo/iconfont.svg +59 -0
  236. package/src/styles/font/icon-demo/iconfont.ttf +0 -0
  237. package/src/styles/font/icon-demo/iconfont.woff +0 -0
  238. package/src/styles/font/icon-demo/iconfont.woff2 +0 -0
  239. package/src/styles/font/iconfont.css +47 -0
  240. package/src/styles/font/iconfont.js +1 -0
  241. package/src/styles/font/iconfont.json +65 -0
  242. package/src/styles/font/iconfont.ttf +0 -0
  243. package/src/styles/font/iconfont.woff +0 -0
  244. package/src/styles/font/iconfont.woff2 +0 -0
  245. package/src/styles/font/ionicons.svg +870 -0
  246. package/src/styles/font/ionicons.ttf +0 -0
  247. package/src/styles/font/ionicons.woff +0 -0
  248. package/src/styles/font/ionicons.woff2 +0 -0
  249. package/src/styles/index.less +7 -0
  250. package/src/styles/layout/basic-layout/layout.less +527 -0
  251. package/src/styles/layout/basic-layout/menu.less +274 -0
  252. package/src/styles/layout/index.less +2 -0
  253. package/src/styles/setting.less +6 -0
  254. package/styleguide.config.js +22 -0
  255. package/test/api/barcode.js +50 -0
  256. package/test/api/inbound.js +47 -0
  257. package/test/api/interfaceLog.js +15 -0
  258. package/test/api/interfaceQueue.js +15 -0
  259. package/test/api/interfaceServer.js +29 -0
  260. package/test/api/movePlan.js +50 -0
  261. package/test/api/movePlanItem.js +13 -0
  262. package/test/api/moveType.js +22 -0
  263. package/test/api/openApiPermission.js +25 -0
  264. package/test/api/outbound.js +40 -0
  265. package/test/api/permission.js +34 -0
  266. package/test/api/rolePermission.js +17 -0
  267. package/test/api/user.js +40 -0
  268. package/test/api/viewColumn.js +16 -0
  269. package/test/api/warehouse.js +13 -0
  270. package/test/api/warehouseMoveType.js +18 -0
  271. package/test/main.js +55 -0
  272. package/test/package.js +33 -0
  273. package/test/pages/home/index.vue +22 -0
  274. package/test/pages/task/test.vue +28 -0
  275. package/test/pages/test/dataViewTest.vue +28 -0
  276. package/test/pages/test/logReport.vue +25 -0
  277. package/test/pages/test/testPage.vue +38 -0
  278. package/test/router/routes.js +88 -0
  279. package/test/setting.env.js +22 -0
  280. package/test/styles/css/custom.css +0 -0
  281. package/test/styles/css/login.css +1217 -0
  282. package/vite.config.js +72 -0
  283. package/vue.config.js +20 -0
@@ -0,0 +1,643 @@
1
+ import util from '../libs/util';
2
+ import router from '../router';
3
+ import { mapState, mapActions } from 'vuex';
4
+ import dateFormat from 'date-fns/format';
5
+ import Setting from '../setting';
6
+
7
+ /**
8
+ * 页面公共混合
9
+ * */
10
+ export default {
11
+ data() {
12
+ return {
13
+ grid4: {
14
+ xxl: 4,
15
+ xl: 4,
16
+ lg: 4,
17
+ md: 6,
18
+ sm: 12,
19
+ xs: 24
20
+ },
21
+ grid6: {
22
+ xxl: 6,
23
+ xl: 6,
24
+ lg: 8,
25
+ md: 12,
26
+ sm: 12,
27
+ xs: 24
28
+ },
29
+ grid8: {
30
+ xxl: 8,
31
+ xl: 8,
32
+ lg: 8,
33
+ md: 12,
34
+ sm: 24,
35
+ xs: 24
36
+ },
37
+ grid12: {
38
+ xxl: 12,
39
+ xl: 12,
40
+ lg: 12,
41
+ md: 12,
42
+ sm: 24,
43
+ xs: 24
44
+ },
45
+ grid16: {
46
+ xxl: 16,
47
+ xl: 16,
48
+ lg: 16,
49
+ md: 24,
50
+ sm: 24,
51
+ xs: 24
52
+ },
53
+ grid18: {
54
+ xxl: 18,
55
+ xl: 18,
56
+ lg: 18,
57
+ md: 24,
58
+ sm: 24,
59
+ xs: 24
60
+ },
61
+ grid24: {
62
+ xxl: 24,
63
+ xl: 24,
64
+ lg: 24,
65
+ md: 24,
66
+ sm: 24,
67
+ xs: 24
68
+ }
69
+ };
70
+ },
71
+ computed: {
72
+ ...mapState('admin/user', ['info']),
73
+ ...mapState('admin/cache', ['userNames', 'enums', 'dicts', 'caches']),
74
+ ...mapState('admin/menu', ['userPermissions']),
75
+ rootPath() {
76
+ return Setting.rootPath;
77
+ },
78
+ sysInfo() {
79
+ return Setting.info;
80
+ },
81
+ layout() {
82
+ return Setting.layout;
83
+ },
84
+ apiBaseURL() {
85
+ return Setting.apiBaseURL;
86
+ },
87
+ uploadURL() {
88
+ return Setting.apiBaseURL + 'api/Attachment/add';
89
+ },
90
+ uploadHeaders() {
91
+ const token = util.cookies.get('token');
92
+ return {
93
+ Authorization: 'Bearer ' + token
94
+ };
95
+ }
96
+ },
97
+ methods: {
98
+ ...mapActions('admin/cache', ['loadEnum', 'loadDict', 'loadUserName', 'loadCache']),
99
+ copy(model) {
100
+ return JSON.parse(JSON.stringify(model));
101
+ },
102
+ allow(key) {
103
+ if (key.startsWith('permission/')) {
104
+ // 全局权限
105
+ return this.userPermissions[key];
106
+ } else {
107
+ // 页面权限点
108
+ //console.log('router.currentRoute', router.currentRoute.value.fullPath);
109
+ let url = router.currentRoute.value.fullPath.substr(1);
110
+
111
+ if (this.userPermissions[url + '$' + key] == true) {
112
+ return true;
113
+ }
114
+
115
+ let count = Object.keys(this.userPermissions).filter(item => item.startsWith(url + '$')).length;
116
+
117
+ // 未分权限点
118
+ if (this.userPermissions[url] == true && count == 0) {
119
+ return true;
120
+ }
121
+
122
+ return false;
123
+ }
124
+ },
125
+ getCache(type, id) {
126
+ this.loadCache(type);
127
+ return this.caches[type].find(x => x.id == id);
128
+ },
129
+ getCacheList(type) {
130
+ this.loadCache(type);
131
+ return this.caches[type];
132
+ },
133
+ getEnum(type, id) {
134
+ this.loadEnum(type);
135
+ return this.enums[type][id];
136
+ },
137
+ getEnumList(type) {
138
+ this.loadEnum(type);
139
+ return Object.keys(this.enums[type]).map(key => {
140
+ return {
141
+ id: key,
142
+ name: this.enums[type][key]
143
+ };
144
+ });
145
+ },
146
+ getDict(type, id) {
147
+ this.loadDict(type);
148
+ return this.dicts[type][id];
149
+ },
150
+ getDictList(type) {
151
+ this.loadDict(type);
152
+ return Object.keys(this.dicts[type]).map(key => {
153
+ return {
154
+ id: key,
155
+ name: this.dicts[type][key]
156
+ };
157
+ });
158
+ },
159
+ getUserName(id) {
160
+ this.loadUserName(id);
161
+ return this.userNames[id];
162
+ },
163
+ // 附件
164
+ getAttachmentUrl(file, name) {
165
+ if (file) {
166
+ return this.apiBaseURL + 'api/Attachment/get?file=' + encodeURI(file) + '&name=' + encodeURI(name);
167
+ } else {
168
+ return null;
169
+ }
170
+ },
171
+ // 文件下载
172
+ fileDownload(file, name) {
173
+ let url = this.getAttachmentUrl(file, name);
174
+
175
+ if (url) {
176
+ window.location.href = url;
177
+ }
178
+ },
179
+ // 图片路径
180
+ getImgUrl(file) {
181
+ if (file) {
182
+ return this.apiBaseURL + 'api/Attachment/getImage?file=' + encodeURI(file);
183
+ } else {
184
+ return this.rootPath + 'images/no-image.png';
185
+ }
186
+ },
187
+ // 显示格式化内容
188
+ showData(model, column) {
189
+ let expression = column.code;
190
+ let dataType = column.dataType;
191
+ let format = column.displayFormat;
192
+ let digit = column.digit;
193
+ let fixedDigit = column.fixedDigit;
194
+
195
+ if (!dataType) {
196
+ return null;
197
+ }
198
+
199
+ if (dataType.indexOf('Enum:') === 0) {
200
+ return this.getEnum(dataType.replace('Enum:', ''), this.parseData(model, expression));
201
+ } else if (dataType === 'BigInteger') {
202
+ return this.getUserName(this.parseData(model, expression));
203
+ }
204
+
205
+ let value = this.parseData(model, expression);
206
+
207
+ if (value == null) {
208
+ return null;
209
+ }
210
+
211
+ if (dataType === 'DateTime') {
212
+ // 日期
213
+ if (!!(format || '').trim()) {
214
+ return dateFormat(new Date(value), format);
215
+ // return $filter('date')(value, format);
216
+ } else {
217
+ return dateFormat(new Date(value), 'yyyy-MM-dd');
218
+ // return $filter('date')(value, 'yyyy-MM-dd');
219
+ }
220
+ } else if (dataType === 'Decimal' || dataType === 'Float' || dataType === 'Double') {
221
+ value = parseFloat(value);
222
+
223
+ // 千分位
224
+ if (format === 'Money') {
225
+ return this.formatThousand(value.toFixed(2));
226
+ } else if (format === 'Thousand') {
227
+ return this.formatThousand(this.keepDecimal(value, digit, fixedDigit));
228
+ } else if (format === 'Percent') {
229
+ return this.keepDecimal(value, digit, fixedDigit) + '%';
230
+ } else {
231
+ return this.keepDecimal(value, digit, fixedDigit);
232
+ }
233
+ } else if (dataType === 'Boolean') {
234
+ if (format === 'Y') {
235
+ return value ? '<i class="fa fa-check info"></i>' : '';
236
+ } else if (format === 'YN') {
237
+ return value ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>';
238
+ } else if (format === 'Disabled') {
239
+ return value ? '<i class="fa fa-ban error"></i>' : '';
240
+ } else if (format === 'Valid') {
241
+ return value ? '<i class="fa fa-check success"></i>' : '';
242
+ } else if (format === 'Attention') {
243
+ return value ? '<i class="fa fa-exclamation error"></i>' : '';
244
+ } else {
245
+ return value ? '<i class="fa fa-check info"></i>' : '';
246
+ }
247
+ } else if (dataType === 'String') {
248
+ return value;
249
+ } else {
250
+ return value;
251
+ }
252
+ },
253
+ // 根据表达式取值
254
+ parseData(model, expression) {
255
+ if (expression == null) {
256
+ return null;
257
+ }
258
+
259
+ let keys = expression.split('.');
260
+ let result = model;
261
+
262
+ for (let i = 0; i < keys.length; i++) {
263
+ if (result == null) {
264
+ return null;
265
+ }
266
+ result = result[keys[i]];
267
+ }
268
+
269
+ return result;
270
+ },
271
+ // 根据表达式赋值
272
+ setData(model, expression, value) {
273
+ if (expression == null) {
274
+ return;
275
+ }
276
+
277
+ let keys = expression.split('.');
278
+ let target = model;
279
+
280
+ for (let i = 0; i < keys.length; i++) {
281
+ if (i === keys.length - 1) {
282
+ target[keys[i]] = value;
283
+ } else {
284
+ if (!(keys[i] in target) || target[keys[i]] == null) {
285
+ target[keys[i]] = {};
286
+ }
287
+
288
+ target = target[keys[i]];
289
+ }
290
+ }
291
+
292
+ //this.$forceUpdate();
293
+ },
294
+ // 根据表达式取值(日期)
295
+ parseDateTimeData(model, expression) {
296
+ let data = this.parseData(model, expression);
297
+
298
+ if (data == null) {
299
+ return '';
300
+ } else {
301
+ return data;
302
+ }
303
+ },
304
+ // 根据表达式取值(数组)
305
+ parseArrayData(model, expression) {
306
+ let data = [];
307
+ let value = this.parseData(model, expression);
308
+
309
+ if (value != null && value != '') {
310
+ data = JSON.parse(value);
311
+ }
312
+
313
+ return data;
314
+ },
315
+ // 根据表达式赋值(数组)
316
+ setArrayData(model, expression, value) {
317
+ let data = '';
318
+ if (value != null) {
319
+ data = JSON.stringify(value);
320
+ }
321
+
322
+ this.setData(model, expression, data);
323
+ },
324
+ // 根据表达式取值(日期段)
325
+ parseDateRangeData(model, expression) {
326
+ let data = [];
327
+ let value = this.parseData(model, expression);
328
+
329
+ if (value != null && value != '') {
330
+ data = JSON.parse(value);
331
+ data[0] = new Date(data[0]);
332
+ data[1] = new Date(data[1]);
333
+ }
334
+
335
+ return data;
336
+ },
337
+ // 根据公式获取触发字段
338
+ getTriggers(text) {
339
+ let triggers = [];
340
+ let expression = '';
341
+
342
+ for (let i = 0; i < text.length; i++) {
343
+ if (
344
+ text[i] == ' ' ||
345
+ text[i] == '+' ||
346
+ text[i] == '-' ||
347
+ text[i] == '*' ||
348
+ text[i] == '/' ||
349
+ text[i] == '(' ||
350
+ text[i] == ')' ||
351
+ text[i] == '>' ||
352
+ text[i] == '<' ||
353
+ text[i] == '!' ||
354
+ text[i] == '&' ||
355
+ text[i] == '|' ||
356
+ text[i] == '='
357
+ ) {
358
+ if (!!(expression || '').trim()) {
359
+ triggers.push(expression);
360
+ expression = '';
361
+ }
362
+ } else {
363
+ expression += text[i];
364
+ }
365
+ }
366
+
367
+ if (!!(expression || '').trim()) {
368
+ triggers.push(expression);
369
+ }
370
+
371
+ return triggers;
372
+ },
373
+ // 计算列
374
+ calculate(text, model) {
375
+ let result = '';
376
+ let expression = '';
377
+
378
+ for (let i = 0; i < text.length; i++) {
379
+ if (
380
+ text[i] == ' ' ||
381
+ text[i] == '+' ||
382
+ text[i] == '-' ||
383
+ text[i] == '*' ||
384
+ text[i] == '/' ||
385
+ text[i] == '(' ||
386
+ text[i] == ')' ||
387
+ text[i] == '>' ||
388
+ text[i] == '<' ||
389
+ text[i] == '!' ||
390
+ text[i] == '|' ||
391
+ text[i] == '&' ||
392
+ text[i] == '='
393
+ ) {
394
+ if (!!(expression || '').trim()) {
395
+ if (!isNaN(expression) || expression.substr(0, 1) == "'" || expression.substr(0, 1) == '"' || expression == 'null') {
396
+ result += expression;
397
+ } else {
398
+ let data = this.parseData(model, expression);
399
+
400
+ if (data == null) {
401
+ result += 'null';
402
+ } else if (isNaN(data)) {
403
+ result += "'" + String(data) + "'";
404
+ } else {
405
+ result += String(data);
406
+ }
407
+ }
408
+
409
+ expression = '';
410
+ }
411
+ result += text[i];
412
+ } else {
413
+ expression += text[i];
414
+ }
415
+ }
416
+
417
+ if (!!(expression || '').trim()) {
418
+ if (!isNaN(expression) || expression.substr(0, 1) == "'" || expression.substr(0, 1) == '"' || expression == 'null') {
419
+ result += expression;
420
+ } else {
421
+ let data = this.parseData(model, expression);
422
+
423
+ if (data == null) {
424
+ result += 'null';
425
+ } else if (isNaN(data)) {
426
+ result += "'" + String(data) + "'";
427
+ } else {
428
+ result += String(data);
429
+ }
430
+ }
431
+ }
432
+
433
+ let data = null;
434
+ try {
435
+ console.log('expression', result);
436
+ data = eval(result);
437
+
438
+ if (data != 'NaN' && String(data) == 'NaN') {
439
+ data = null;
440
+ } else if (typeof data == 'number' && (String(data) == 'Infinity' || String(data) == '-Infinity')) {
441
+ data = null;
442
+ }
443
+ } catch (e) {
444
+ //console.log('表达式计算错误', e);
445
+ }
446
+
447
+ return data;
448
+ },
449
+ // 根据条件判断
450
+ judgeCondition(setting, model) {
451
+ if (!setting) {
452
+ return false;
453
+ }
454
+
455
+ if (setting.type == 'Condition') {
456
+ // 条件
457
+ for (let i = 0; i < setting.condition.length; i++) {
458
+ let data = this.parseData(model, setting.condition[i].code);
459
+ if (data == null) {
460
+ data = '';
461
+ }
462
+ let value = setting.condition[i].value;
463
+ let operator = setting.condition[i].operator;
464
+ let result = false;
465
+
466
+ if (operator == 'Equal') {
467
+ result = value.split(',').some(item => {
468
+ return String(data) == item;
469
+ });
470
+ } else if (operator == 'Contains') {
471
+ result = value.split(',').some(item => {
472
+ return String(data).indexOf(item) != -1;
473
+ });
474
+ } else if (operator == 'GreaterThan') {
475
+ result = data > value;
476
+ } else if (operator == 'LessThan') {
477
+ result = data < value;
478
+ } else if (operator == 'GreaterThanOrEqual') {
479
+ result = data >= value;
480
+ } else if (operator == 'LessThanOrEqual') {
481
+ result = data <= value;
482
+ } else if (operator == 'NotEqual') {
483
+ result = String(data) != value;
484
+ }
485
+
486
+ if (!result) {
487
+ return false;
488
+ }
489
+ }
490
+ return true;
491
+ } else if (setting.type == 'Expression') {
492
+ // 表达式
493
+ return this.calculate(setting.expression, model) == true;
494
+ }
495
+ },
496
+ // 确认框
497
+ confirm(title, onConfirm) {
498
+ let swal = this.$swal.fire({
499
+ title: title,
500
+ icon: 'question',
501
+ showCancelButton: true
502
+ });
503
+
504
+ swal.then(result => {
505
+ if (result.value) {
506
+ if (typeof onConfirm === 'function') {
507
+ onConfirm();
508
+ }
509
+ }
510
+ });
511
+
512
+ return swal;
513
+ },
514
+ // 带输入的确认框
515
+ confirmInput(title, inputLabel, onConfirm, preConfirm) {
516
+ let swal = this.$swal.fire({
517
+ title: title,
518
+ input: 'text',
519
+ inputPlaceholder: inputLabel,
520
+ icon: 'question',
521
+ showCancelButton: true,
522
+ preConfirm: preConfirm
523
+ });
524
+
525
+ swal.then(result => {
526
+ if (result.value) {
527
+ if (typeof onConfirm === 'function') {
528
+ onConfirm();
529
+ }
530
+ }
531
+ });
532
+
533
+ return swal;
534
+ },
535
+ // 成功提示
536
+ success(message, onConfirm) {
537
+ var swal = this.$swal.fire({
538
+ title: message,
539
+ icon: 'success'
540
+ });
541
+
542
+ swal.then(() => {
543
+ if (typeof onConfirm === 'function') {
544
+ onConfirm();
545
+ }
546
+ });
547
+
548
+ return swal;
549
+ },
550
+ // 警告提示
551
+ warning(message, onConfirm) {
552
+ var swal = this.$swal.fire({
553
+ title: message,
554
+ icon: 'warning'
555
+ });
556
+
557
+ swal.then(() => {
558
+ if (typeof onConfirm === 'function') {
559
+ onConfirm();
560
+ }
561
+ });
562
+
563
+ return swal;
564
+ },
565
+ // 失败提示
566
+ error(message, onConfirm) {
567
+ var swal = this.$swal.fire({
568
+ title: message,
569
+ icon: 'error'
570
+ });
571
+
572
+ swal.then(() => {
573
+ if (typeof onConfirm === 'function') {
574
+ onConfirm();
575
+ }
576
+ });
577
+
578
+ return swal;
579
+ },
580
+ // 获取超链接
581
+ getHyperlink(data, hyperlink) {
582
+ while (hyperlink.indexOf('{') >= 0) {
583
+ let start = hyperlink.indexOf('{');
584
+ let end = hyperlink.indexOf('}');
585
+ let expression = hyperlink.substring(start + 1, end);
586
+
587
+ hyperlink = hyperlink.substring(0, start) + this.parseData(data, expression) + hyperlink.substring(end + 1);
588
+ }
589
+
590
+ return hyperlink;
591
+ },
592
+ // 保留小数
593
+ keepDecimal(num, digit, fixedDigit) {
594
+ if (digit == null) {
595
+ return num;
596
+ }
597
+
598
+ let result = parseFloat(num);
599
+ if (isNaN(result) || isNaN(digit)) {
600
+ return null;
601
+ }
602
+
603
+ if (fixedDigit) {
604
+ return result.toFixed(digit);
605
+ } else {
606
+ return Math.round(num * Math.pow(10, digit)) / Math.pow(10, digit);
607
+ }
608
+ },
609
+ // 加千分位
610
+ formatThousand(value) {
611
+ if (value == null) {
612
+ return value;
613
+ }
614
+
615
+ let intPart = Math.trunc(value); // 获取整数部分
616
+
617
+ let intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); // 将整数部分逢三一断
618
+ let value2Array = value.toString().split('.');
619
+ // =2表示数据有小数位
620
+ if (value2Array.length === 2) {
621
+ return intPartFormat + '.' + value2Array[1].toString();
622
+ } else {
623
+ return intPartFormat;
624
+ }
625
+ },
626
+ // 重置通知栏数字
627
+ resetNotice() {
628
+ this.getNotice(this).init();
629
+ },
630
+ // 获取通知栏
631
+ getNotice(node) {
632
+ if (node.$refs.notice != null) {
633
+ return node.$refs.notice;
634
+ }
635
+
636
+ if (node.$parent != null) {
637
+ return this.getNotice(node.$parent);
638
+ }
639
+
640
+ return null;
641
+ }
642
+ }
643
+ };