eoss-mobiles 0.1.13

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 (285) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +28 -0
  3. package/lib/action-sheet.js +313 -0
  4. package/lib/button-group.js +421 -0
  5. package/lib/button.js +278 -0
  6. package/lib/calendar.js +301 -0
  7. package/lib/cascader.js +336 -0
  8. package/lib/cell.js +366 -0
  9. package/lib/checkbox.js +2170 -0
  10. package/lib/circle.js +299 -0
  11. package/lib/config/api.js +31 -0
  12. package/lib/count-down.js +299 -0
  13. package/lib/date.js +956 -0
  14. package/lib/empty.js +274 -0
  15. package/lib/eoss-mobile.common.js +15072 -0
  16. package/lib/field.js +440 -0
  17. package/lib/flow.js +5664 -0
  18. package/lib/form.js +714 -0
  19. package/lib/grid-item.js +274 -0
  20. package/lib/grid.js +317 -0
  21. package/lib/image-preview.js +325 -0
  22. package/lib/index.js +1 -0
  23. package/lib/list.js +315 -0
  24. package/lib/loading.js +279 -0
  25. package/lib/nav-bar.js +283 -0
  26. package/lib/pagination.js +323 -0
  27. package/lib/picker.js +2714 -0
  28. package/lib/popover.js +306 -0
  29. package/lib/popup.js +297 -0
  30. package/lib/radio.js +2137 -0
  31. package/lib/rate.js +300 -0
  32. package/lib/search.js +316 -0
  33. package/lib/selector.js +3496 -0
  34. package/lib/skeleton.js +277 -0
  35. package/lib/stepper.js +300 -0
  36. package/lib/switch.js +304 -0
  37. package/lib/tab.js +274 -0
  38. package/lib/table-column.js +2991 -0
  39. package/lib/table.js +2652 -0
  40. package/lib/tabs.js +315 -0
  41. package/lib/tag.js +281 -0
  42. package/lib/theme-chalk/action-sheet.css +0 -0
  43. package/lib/theme-chalk/base.css +1 -0
  44. package/lib/theme-chalk/button-group.css +1 -0
  45. package/lib/theme-chalk/button.css +1 -0
  46. package/lib/theme-chalk/calendar.css +1 -0
  47. package/lib/theme-chalk/cascader.css +1 -0
  48. package/lib/theme-chalk/cell.css +1 -0
  49. package/lib/theme-chalk/checkbox.css +1 -0
  50. package/lib/theme-chalk/circle.css +1 -0
  51. package/lib/theme-chalk/count-down.css +0 -0
  52. package/lib/theme-chalk/date.css +0 -0
  53. package/lib/theme-chalk/empty.css +0 -0
  54. package/lib/theme-chalk/field.css +1 -0
  55. package/lib/theme-chalk/flow.css +1 -0
  56. package/lib/theme-chalk/fonts/iconfont.scss +530 -0
  57. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  58. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  59. package/lib/theme-chalk/form.css +0 -0
  60. package/lib/theme-chalk/grid-item.css +1 -0
  61. package/lib/theme-chalk/grid.css +0 -0
  62. package/lib/theme-chalk/icon.css +1 -0
  63. package/lib/theme-chalk/image-preview.css +0 -0
  64. package/lib/theme-chalk/index.css +1 -0
  65. package/lib/theme-chalk/list.css +0 -0
  66. package/lib/theme-chalk/loading.css +0 -0
  67. package/lib/theme-chalk/nav-bar.css +0 -0
  68. package/lib/theme-chalk/navbar.css +1 -0
  69. package/lib/theme-chalk/pagination.css +1 -0
  70. package/lib/theme-chalk/picker.css +1 -0
  71. package/lib/theme-chalk/popover.css +0 -0
  72. package/lib/theme-chalk/popup.css +0 -0
  73. package/lib/theme-chalk/radio.css +1 -0
  74. package/lib/theme-chalk/rate.css +0 -0
  75. package/lib/theme-chalk/search.css +0 -0
  76. package/lib/theme-chalk/selector.css +1 -0
  77. package/lib/theme-chalk/skeleton.css +0 -0
  78. package/lib/theme-chalk/stepper.css +1 -0
  79. package/lib/theme-chalk/switch.css +1 -0
  80. package/lib/theme-chalk/tab.css +0 -0
  81. package/lib/theme-chalk/table-column.css +0 -0
  82. package/lib/theme-chalk/table.css +1 -0
  83. package/lib/theme-chalk/tabs.css +1 -0
  84. package/lib/theme-chalk/tag.css +1 -0
  85. package/lib/theme-chalk/theme.css +0 -0
  86. package/lib/theme-chalk/tree.css +1 -0
  87. package/lib/theme-chalk/uploader.css +0 -0
  88. package/lib/uploader.js +307 -0
  89. package/lib/utils/axios.js +199 -0
  90. package/lib/utils/date-util.js +320 -0
  91. package/lib/utils/http.js +74 -0
  92. package/lib/utils/rules.js +21 -0
  93. package/lib/utils/store.js +24 -0
  94. package/lib/utils/util.js +1315 -0
  95. package/package.json +153 -0
  96. package/packages/action-sheet/index.js +5 -0
  97. package/packages/action-sheet/src/main.vue +32 -0
  98. package/packages/button/index.js +5 -0
  99. package/packages/button/src/main.vue +15 -0
  100. package/packages/button-group/index.js +5 -0
  101. package/packages/button-group/src/main.vue +80 -0
  102. package/packages/calendar/index.js +5 -0
  103. package/packages/calendar/src/main.vue +34 -0
  104. package/packages/cascader/index.js +5 -0
  105. package/packages/cascader/src/main.vue +40 -0
  106. package/packages/cell/index.js +5 -0
  107. package/packages/cell/src/main.vue +72 -0
  108. package/packages/checkbox/index.js +5 -0
  109. package/packages/checkbox/src/main.vue +149 -0
  110. package/packages/circle/index.js +5 -0
  111. package/packages/circle/src/main.vue +27 -0
  112. package/packages/count-down/index.js +5 -0
  113. package/packages/count-down/src/main.vue +27 -0
  114. package/packages/date/index.js +5 -0
  115. package/packages/date/src/date-time.vue +290 -0
  116. package/packages/date/src/main.vue +319 -0
  117. package/packages/empty/index.js +5 -0
  118. package/packages/empty/src/main.vue +16 -0
  119. package/packages/field/index.js +5 -0
  120. package/packages/field/src/main.vue +130 -0
  121. package/packages/flow/index.js +5 -0
  122. package/packages/flow/src/components/Handle.vue +1031 -0
  123. package/packages/flow/src/components/Message.vue +96 -0
  124. package/packages/flow/src/components/Opinion.vue +112 -0
  125. package/packages/flow/src/components/Reject.vue +202 -0
  126. package/packages/flow/src/components/StartFlow.vue +440 -0
  127. package/packages/flow/src/components/TaskRead.vue +237 -0
  128. package/packages/flow/src/main.vue +43 -0
  129. package/packages/form/index.js +5 -0
  130. package/packages/form/src/main.vue +158 -0
  131. package/packages/grid/index.js +5 -0
  132. package/packages/grid/src/main.vue +28 -0
  133. package/packages/grid-item/index.js +5 -0
  134. package/packages/grid-item/src/main.vue +16 -0
  135. package/packages/image-preview/index.js +5 -0
  136. package/packages/image-preview/src/main.vue +34 -0
  137. package/packages/list/index.js +5 -0
  138. package/packages/list/src/main.vue +32 -0
  139. package/packages/loading/index.js +5 -0
  140. package/packages/loading/src/main.vue +20 -0
  141. package/packages/nav-bar/index.js +5 -0
  142. package/packages/nav-bar/src/main.vue +16 -0
  143. package/packages/pagination/index.js +5 -0
  144. package/packages/pagination/src/main.vue +29 -0
  145. package/packages/picker/index.js +5 -0
  146. package/packages/picker/src/main.vue +500 -0
  147. package/packages/popover/index.js +5 -0
  148. package/packages/popover/src/main.vue +32 -0
  149. package/packages/popup/index.js +5 -0
  150. package/packages/popup/src/main.vue +27 -0
  151. package/packages/radio/index.js +5 -0
  152. package/packages/radio/src/main.vue +147 -0
  153. package/packages/rate/index.js +5 -0
  154. package/packages/rate/src/main.vue +27 -0
  155. package/packages/search/index.js +5 -0
  156. package/packages/search/src/main.vue +39 -0
  157. package/packages/selector/index.js +5 -0
  158. package/packages/selector/src/main.vue +77 -0
  159. package/packages/selector/src/selector-field.vue +225 -0
  160. package/packages/selector/src/selector-tree.vue +472 -0
  161. package/packages/selector/src/tree.vue +179 -0
  162. package/packages/skeleton/index.js +5 -0
  163. package/packages/skeleton/src/main.vue +17 -0
  164. package/packages/stepper/index.js +5 -0
  165. package/packages/stepper/src/main.vue +25 -0
  166. package/packages/switch/index.js +5 -0
  167. package/packages/switch/src/main.vue +29 -0
  168. package/packages/tab/index.js +5 -0
  169. package/packages/tab/src/main.vue +16 -0
  170. package/packages/table/index.js +5 -0
  171. package/packages/table/src/main.vue +830 -0
  172. package/packages/table-column/index.js +5 -0
  173. package/packages/table-column/src/main.vue +742 -0
  174. package/packages/table-column/src/mixins/table.js +12 -0
  175. package/packages/tabs/index.js +5 -0
  176. package/packages/tabs/src/main.vue +34 -0
  177. package/packages/tag/index.js +5 -0
  178. package/packages/tag/src/main.vue +16 -0
  179. package/packages/theme-chalk/README.md +33 -0
  180. package/packages/theme-chalk/lib/action-sheet.css +0 -0
  181. package/packages/theme-chalk/lib/base.css +1 -0
  182. package/packages/theme-chalk/lib/button-group.css +1 -0
  183. package/packages/theme-chalk/lib/button.css +1 -0
  184. package/packages/theme-chalk/lib/calendar.css +1 -0
  185. package/packages/theme-chalk/lib/cascader.css +1 -0
  186. package/packages/theme-chalk/lib/cell.css +1 -0
  187. package/packages/theme-chalk/lib/checkbox.css +1 -0
  188. package/packages/theme-chalk/lib/circle.css +1 -0
  189. package/packages/theme-chalk/lib/count-down.css +0 -0
  190. package/packages/theme-chalk/lib/date.css +0 -0
  191. package/packages/theme-chalk/lib/empty.css +0 -0
  192. package/packages/theme-chalk/lib/field.css +1 -0
  193. package/packages/theme-chalk/lib/flow.css +1 -0
  194. package/packages/theme-chalk/lib/fonts/iconfont.scss +530 -0
  195. package/packages/theme-chalk/lib/fonts/iconfont.ttf +0 -0
  196. package/packages/theme-chalk/lib/fonts/iconfont.woff +0 -0
  197. package/packages/theme-chalk/lib/form.css +0 -0
  198. package/packages/theme-chalk/lib/grid-item.css +1 -0
  199. package/packages/theme-chalk/lib/grid.css +0 -0
  200. package/packages/theme-chalk/lib/icon.css +1 -0
  201. package/packages/theme-chalk/lib/image-preview.css +0 -0
  202. package/packages/theme-chalk/lib/index.css +1 -0
  203. package/packages/theme-chalk/lib/list.css +0 -0
  204. package/packages/theme-chalk/lib/loading.css +0 -0
  205. package/packages/theme-chalk/lib/nav-bar.css +0 -0
  206. package/packages/theme-chalk/lib/navbar.css +1 -0
  207. package/packages/theme-chalk/lib/pagination.css +1 -0
  208. package/packages/theme-chalk/lib/picker.css +1 -0
  209. package/packages/theme-chalk/lib/popover.css +0 -0
  210. package/packages/theme-chalk/lib/popup.css +0 -0
  211. package/packages/theme-chalk/lib/radio.css +1 -0
  212. package/packages/theme-chalk/lib/rate.css +0 -0
  213. package/packages/theme-chalk/lib/search.css +0 -0
  214. package/packages/theme-chalk/lib/selector.css +1 -0
  215. package/packages/theme-chalk/lib/skeleton.css +0 -0
  216. package/packages/theme-chalk/lib/stepper.css +1 -0
  217. package/packages/theme-chalk/lib/switch.css +1 -0
  218. package/packages/theme-chalk/lib/tab.css +0 -0
  219. package/packages/theme-chalk/lib/table-column.css +0 -0
  220. package/packages/theme-chalk/lib/table.css +1 -0
  221. package/packages/theme-chalk/lib/tabs.css +1 -0
  222. package/packages/theme-chalk/lib/tag.css +1 -0
  223. package/packages/theme-chalk/lib/theme.css +0 -0
  224. package/packages/theme-chalk/lib/tree.css +1 -0
  225. package/packages/theme-chalk/lib/uploader.css +0 -0
  226. package/packages/theme-chalk/package.json +35 -0
  227. package/packages/theme-chalk/src/action-sheet.scss +0 -0
  228. package/packages/theme-chalk/src/base.scss +182 -0
  229. package/packages/theme-chalk/src/button-group.scss +26 -0
  230. package/packages/theme-chalk/src/button.scss +3 -0
  231. package/packages/theme-chalk/src/calendar.scss +12 -0
  232. package/packages/theme-chalk/src/cascader.scss +12 -0
  233. package/packages/theme-chalk/src/cell.scss +14 -0
  234. package/packages/theme-chalk/src/checkbox.scss +10 -0
  235. package/packages/theme-chalk/src/circle.scss +7 -0
  236. package/packages/theme-chalk/src/common/var.scss +1525 -0
  237. package/packages/theme-chalk/src/count-down.scss +0 -0
  238. package/packages/theme-chalk/src/date.scss +0 -0
  239. package/packages/theme-chalk/src/empty.scss +0 -0
  240. package/packages/theme-chalk/src/field.scss +28 -0
  241. package/packages/theme-chalk/src/flow.scss +542 -0
  242. package/packages/theme-chalk/src/fonts/iconfont.scss +530 -0
  243. package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
  244. package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
  245. package/packages/theme-chalk/src/form.scss +15 -0
  246. package/packages/theme-chalk/src/grid-item.scss +8 -0
  247. package/packages/theme-chalk/src/grid.scss +0 -0
  248. package/packages/theme-chalk/src/icon.scss +1661 -0
  249. package/packages/theme-chalk/src/image-preview.scss +0 -0
  250. package/packages/theme-chalk/src/index.scss +38 -0
  251. package/packages/theme-chalk/src/list.scss +0 -0
  252. package/packages/theme-chalk/src/loading.scss +0 -0
  253. package/packages/theme-chalk/src/mixins/color.scss +117 -0
  254. package/packages/theme-chalk/src/mixins/mixins.scss +25 -0
  255. package/packages/theme-chalk/src/nav-bar.scss +0 -0
  256. package/packages/theme-chalk/src/navbar.scss +6 -0
  257. package/packages/theme-chalk/src/pagination.scss +10 -0
  258. package/packages/theme-chalk/src/picker.scss +27 -0
  259. package/packages/theme-chalk/src/popover.scss +0 -0
  260. package/packages/theme-chalk/src/popup.scss +0 -0
  261. package/packages/theme-chalk/src/radio.scss +7 -0
  262. package/packages/theme-chalk/src/rate.scss +0 -0
  263. package/packages/theme-chalk/src/search.scss +0 -0
  264. package/packages/theme-chalk/src/selector.scss +218 -0
  265. package/packages/theme-chalk/src/skeleton.scss +0 -0
  266. package/packages/theme-chalk/src/stepper.scss +10 -0
  267. package/packages/theme-chalk/src/switch.scss +6 -0
  268. package/packages/theme-chalk/src/tab.scss +0 -0
  269. package/packages/theme-chalk/src/table-column.scss +0 -0
  270. package/packages/theme-chalk/src/table.scss +42 -0
  271. package/packages/theme-chalk/src/tabs.scss +21 -0
  272. package/packages/theme-chalk/src/tag.scss +13 -0
  273. package/packages/theme-chalk/src/theme.scss +2 -0
  274. package/packages/theme-chalk/src/tree.scss +115 -0
  275. package/packages/theme-chalk/src/uploader.scss +0 -0
  276. package/packages/uploader/index.js +5 -0
  277. package/packages/uploader/src/main.vue +31 -0
  278. package/src/config/api.js +29 -0
  279. package/src/index.js +130 -0
  280. package/src/utils/axios.js +198 -0
  281. package/src/utils/date-util.js +312 -0
  282. package/src/utils/http.js +66 -0
  283. package/src/utils/rules.js +18 -0
  284. package/src/utils/store.js +21 -0
  285. package/src/utils/util.js +1346 -0
@@ -0,0 +1,830 @@
1
+ <script>
2
+ import { Table } from 'element-ui';
3
+ import 'element-ui/lib/theme-chalk/table.css';
4
+ import request from 'eoss-mobile/src/utils/http';
5
+ import util from 'eoss-mobile/src/utils/util';
6
+ export default {
7
+ name: 'EmTable',
8
+ components: { Table },
9
+ inheritAttrs: false,
10
+ props: {
11
+ thead: {
12
+ type: Array,
13
+ default: () => []
14
+ },
15
+ data: {
16
+ type: Array,
17
+ default: () => []
18
+ },
19
+ checkbox: {
20
+ type: Boolean,
21
+ default: false
22
+ },
23
+ // 开启分页
24
+ page: {
25
+ type: [Boolean, Object],
26
+ default() {
27
+ return false;
28
+ }
29
+ },
30
+ numbers: {
31
+ type: Boolean,
32
+ default: false
33
+ },
34
+ selectable: Function,
35
+ reserveSelection: Boolean,
36
+ full: {
37
+ type: Boolean,
38
+ default: true
39
+ },
40
+ height: [Number, String],
41
+ maxHeight: [Number, String],
42
+ form: {
43
+ type: Boolean,
44
+ default: false
45
+ },
46
+ optionData: Object,
47
+ //本地数据总条数差值
48
+ lose: {
49
+ type: Number,
50
+ default: 0
51
+ },
52
+ param: {
53
+ type: Object,
54
+ default() {
55
+ return {};
56
+ }
57
+ },
58
+ method: {
59
+ type: String,
60
+ default: 'get'
61
+ },
62
+ format: {
63
+ type: Boolean,
64
+ default: true
65
+ },
66
+ url: {
67
+ type: String,
68
+ default: ''
69
+ },
70
+ // 默认选中,类型为Boolean时默认全(不)选
71
+ checked: {
72
+ type: [Boolean, Array],
73
+ default: false
74
+ }
75
+ },
76
+ data() {
77
+ return {
78
+ selected: null,
79
+ pageChange: false,
80
+ tableHeight: 'auto',
81
+ options: {},
82
+ theadData: [],
83
+ list: null,
84
+ wheres: {},
85
+ config: {
86
+ pageNum: 1,
87
+ pageSize: 20,
88
+ totalCount: 0
89
+ },
90
+ isFirsetCheck: false
91
+ };
92
+ },
93
+ watch: {
94
+ checked(newVal) {
95
+ this.checkSelect(newVal);
96
+ },
97
+ page: {
98
+ immediate: true,
99
+ deep: true,
100
+ handler(val) {
101
+ this.config = util.extend({}, this.config, this.page);
102
+ }
103
+ },
104
+ thead: {
105
+ immediate: true,
106
+ handler(val) {
107
+ if (typeof val === 'string') {
108
+ this.getTheads();
109
+ }
110
+ }
111
+ },
112
+ height: {
113
+ immediate: true,
114
+ handler(val) {
115
+ if (val) {
116
+ this.tableHeight = val;
117
+ }
118
+ }
119
+ },
120
+ maxHeight: {
121
+ immediate: true,
122
+ handler(val) {
123
+ if (val && this.height === undefined) {
124
+ this.tableHeight = val;
125
+ }
126
+ }
127
+ }
128
+ },
129
+ mounted() {
130
+ // this.resetHeight();
131
+ this.getTableData();
132
+ this.checkSelect(this.checked);
133
+ },
134
+ computed: {
135
+ theads() {
136
+ return typeof this.thead === 'string' ? this.theadData : this.thead;
137
+ },
138
+ optionDatas() {
139
+ return this.optionData ? this.optionData : this.options;
140
+ },
141
+ datas: {
142
+ get() {
143
+ if (this.list) {
144
+ return this.list;
145
+ }
146
+ if (
147
+ this.page &&
148
+ this.data &&
149
+ this.data.length &&
150
+ this.config.totalCount < this.data.length + 1
151
+ ) {
152
+ this.config.totalCount = this.data.length - this.lose;
153
+ return this.data.filter((item, index) => {
154
+ return (
155
+ index > (this.config.pageNum - 1) * this.config.pageSize - 1 &&
156
+ index < this.config.pageNum * this.config.pageSize
157
+ );
158
+ });
159
+ }
160
+
161
+ return this.data;
162
+ },
163
+ set(val) {
164
+ return val;
165
+ }
166
+ }
167
+ },
168
+ methods: {
169
+ toggleAllSelection() {
170
+ this.$refs.oaTable.toggleAllSelection();
171
+ },
172
+ checkSelect(newVal) {
173
+ if (!this.isFirsetCheck && newVal) {
174
+ if (util.getObjectType(newVal) === 'array') {
175
+ newVal.forEach(row => {
176
+ this.$refs.oaTable.toggleRowSelection(row, true);
177
+ });
178
+ } else if (newVal === true) {
179
+ this.toggleAllSelection();
180
+ }
181
+ this.isFirsetCheck = true;
182
+ }
183
+ },
184
+ getTableData(res) {
185
+ let where;
186
+ let first;
187
+ if (res) {
188
+ where = res.where;
189
+ first = res.first;
190
+ }
191
+ if (!this.url) {
192
+ return;
193
+ }
194
+ if (first !== false) {
195
+ this.config.pageNum = 1;
196
+ }
197
+ this.$toast.loading({
198
+ message: '加载中...',
199
+ forbidClick: true,
200
+ loadingType: 'spinner',
201
+ overlay: true,
202
+ duration: 0
203
+ });
204
+ let reqData = util.extend({}, this.param, {
205
+ pageNum: this.config.pageNum,
206
+ pageSize: this.config.pageSize
207
+ });
208
+ if (where) {
209
+ reqData = util.extend({}, reqData, where);
210
+ }
211
+ util
212
+ .ajax({
213
+ url: this.url,
214
+ method: this.method,
215
+ format: this.format,
216
+ params: reqData,
217
+ data: reqData
218
+ })
219
+ .then(res => {
220
+ if (res.rCode === 0 || res.status === 'success') {
221
+ let results =
222
+ this.parseData !== undefined
223
+ ? this.parseData(res.results || res.data || res)
224
+ : res.results || res.data;
225
+ this.list = results.data || results.records || results.list || [];
226
+ this.config.totalCount =
227
+ results.count || results.total || results.totalCount;
228
+ } else {
229
+ this.list = [];
230
+ }
231
+ this.$toast.clear();
232
+ this.$emit('success', res);
233
+ })
234
+ .catch(err => {
235
+ this.$toast.clear();
236
+ if (err && err.code && [64, 65, 67].indexOf(err.code) > -1) {
237
+ return;
238
+ }
239
+ if (util.getObjectType(err) === 'string') {
240
+ this.$toast(err);
241
+ } else {
242
+ this.$toast(err.message || '数据加载失败,请联系管理员!');
243
+ }
244
+ });
245
+ },
246
+ currentChange(res) {
247
+ this.pageChange = true;
248
+ setTimeout(() => {
249
+ this.pageChange = false;
250
+ }, 10);
251
+ this.config.pageNum = res;
252
+ this.$emit('page-current-change', res);
253
+ if (this.url) {
254
+ this.getTableData({ where: this.wheres, first: false });
255
+ }
256
+ },
257
+ getTheads() {
258
+ util
259
+ .ajax({
260
+ url: this.thead,
261
+ method: this.method,
262
+ format: this.format,
263
+ params: this.param,
264
+ data: this.param
265
+ })
266
+ .then(res => {
267
+ if (res.rCode === 0) {
268
+ let results = res.results;
269
+ if (Array.isArray(results)) {
270
+ this.theadData = results;
271
+ } else {
272
+ this.theadData = results.theadData || [];
273
+ this.list = results.data || results.records || [];
274
+ this.config.totalCount =
275
+ results.count || results.total || results.totalCount;
276
+ }
277
+ } else {
278
+ this.theadData = [];
279
+ }
280
+ this.$emit('success', res);
281
+ })
282
+ .catch(err => {
283
+ if (err && err.code && [64, 65, 67].indexOf(err.code) > -1) {
284
+ return;
285
+ }
286
+ if (util.getObjectType(err) === 'string') {
287
+ this.$message.error(err);
288
+ } else {
289
+ this.$message.error(err.message || '数据加载失败,请联系管理员!');
290
+ }
291
+ });
292
+ },
293
+ getTableColumns(data, name) {
294
+ this.optionDatas[name] = data;
295
+ },
296
+ formBlur(data) {
297
+ this.$emit('blur', data, this.datas);
298
+ },
299
+ formFocus(data) {
300
+ this.$emit('focus', data, this.datas);
301
+ },
302
+ formChange(data) {
303
+ if (this.pageChange) return;
304
+ if (data.type) {
305
+ this.pageChange = true;
306
+ setTimeout(() => {
307
+ this.pageChange = false;
308
+ }, 20);
309
+ }
310
+ this.$emit('edit', data, this.datas);
311
+ },
312
+ resetHeight() {
313
+ this.$nextTick(() => {
314
+ if (this.full && !this.height && !this.maxHeight) {
315
+ let height =
316
+ this.$el.parentNode.offsetHeight -
317
+ parseInt(util.getStyle(this.$el.parentNode, 'paddingTop'), 10) -
318
+ parseInt(util.getStyle(this.$el.parentNode, 'paddingBottom'), 10);
319
+ for (let i = 0; i < this.$el.parentNode.childNodes.length; i++) {
320
+ let ele = this.$el.parentNode.childNodes[i];
321
+ if (ele !== this.$el) {
322
+ height -= ele.offsetHeight === undefined ? 0 : ele.offsetHeight;
323
+ }
324
+ }
325
+ for (let i = 0; i < this.$el.childNodes.length; i++) {
326
+ let ele = this.$el.childNodes[i];
327
+ if (ele !== this.$refs.esTableContent) {
328
+ height -= ele.offsetHeight === undefined ? 0 : ele.offsetHeight;
329
+ }
330
+ }
331
+ this.styles = { height: height + 'px' };
332
+ const loadingDom = this.$refs.esTableContent.querySelector(
333
+ '.el-loading-mask'
334
+ );
335
+ for (
336
+ let i = 0;
337
+ i < this.$refs.esTableContent.childNodes.length;
338
+ i++
339
+ ) {
340
+ let ele = this.$refs.esTableContent.childNodes[i];
341
+ if (
342
+ ele !== this.$refs.oaTable.$el &&
343
+ (!loadingDom || ele !== loadingDom)
344
+ ) {
345
+ height -= ele.offsetHeight === undefined ? 0 : ele.offsetHeight;
346
+ }
347
+ }
348
+ let pt = parseInt(
349
+ util.getStyle(this.$refs.esTableContent, 'paddingTop'),
350
+ 10
351
+ );
352
+ let pb = parseInt(
353
+ util.getStyle(this.$refs.esTableContent, 'paddingBottom'),
354
+ 10
355
+ );
356
+ this.tableHeight = height - pt - pb + (this.page ? 2 : 1) + 'px';
357
+ }
358
+ });
359
+ },
360
+ handleAjax(handle, row) {
361
+ this.$toast.loading({
362
+ message: '加载中...',
363
+ forbidClick: true,
364
+ loadingType: 'spinner',
365
+ overlay: true,
366
+ duration: 0
367
+ });
368
+ let params = handle.param || {};
369
+ if (handle.syncKeys) {
370
+ if (typeof handle.syncKeys === 'string') {
371
+ params[handle.syncKeys] = row[handle.syncKeys];
372
+ } else if (Array.isArray(handle.syncKeys)) {
373
+ for (let i in handle.syncKeys) {
374
+ if (Array.isArray(row)) {
375
+ let param = row.map(item => {
376
+ return item[handle.syncKeys[i]];
377
+ });
378
+ params[handle.syncKeys[i]] = param.join(',');
379
+ } else {
380
+ params[handle.syncKeys[i]] = row[handle.syncKeys[i]];
381
+ }
382
+ }
383
+ } else {
384
+ for (let i in handle.syncKeys) {
385
+ if (Array.isArray(row)) {
386
+ let param = row.map(item => {
387
+ return item[handle.syncKeys[i]];
388
+ });
389
+ params[i] = param.join(',');
390
+ } else {
391
+ params[i] = row[handle.syncKeys[i]];
392
+ }
393
+ }
394
+ }
395
+ } else {
396
+ if (Array.isArray(row)) {
397
+ let param = row.map(item => {
398
+ return item.id;
399
+ });
400
+ params.id = param.join(',');
401
+ } else {
402
+ params.id = row.id;
403
+ }
404
+ }
405
+ let keys = Object.keys(params);
406
+ request({
407
+ url: handle.action,
408
+ data:
409
+ keys.length == 1 && handle.format === false
410
+ ? params[keys[0]].split(',')
411
+ : params,
412
+ params:
413
+ keys.length == 1 && handle.format === false
414
+ ? params[keys[0]].split(',')
415
+ : params,
416
+ method: handle.method,
417
+ format: handle.format
418
+ })
419
+ .then(res => {
420
+ this.$toast.clear();
421
+ if (res.rCode === 0) {
422
+ this.$message({
423
+ message: `${handle.text}成功`,
424
+ duration: 2000,
425
+ type: 'success',
426
+ onClose: () => {
427
+ let first = Object.prototype.hasOwnProperty.call(
428
+ handle,
429
+ 'first'
430
+ )
431
+ ? handle.first
432
+ : false;
433
+ let reload = handle.reload || true;
434
+ if (reload) {
435
+ this.reload({}, first);
436
+ }
437
+ }
438
+ });
439
+ } else {
440
+ this.$toast(res.msg || `${handle.text}失败,请联系管理员!`);
441
+ }
442
+ })
443
+ .catch(() => {});
444
+ },
445
+ handleClick(res) {
446
+ let { row, handle } = res;
447
+ let rows;
448
+ if (handle.checkbox) {
449
+ if (!this.selected || !this.selected.length) {
450
+ this.$alert('请选择数据', '提示', { type: 'warning' });
451
+ return;
452
+ } else {
453
+ row = this.selected;
454
+ }
455
+ }
456
+ if (this.checkboxParseData) {
457
+ rows = this.checkboxParseData(JSON.parse(JSON.stringify(row)));
458
+ } else if (this.checkboxParse) {
459
+ rows = this.checkParse(row, this.checkboxParse);
460
+ } else if (handle.checkboxParse) {
461
+ rows = this.checkParse(row, handle.checkboxParse);
462
+ } else if (row) {
463
+ rows = JSON.parse(JSON.stringify(row));
464
+ }
465
+ let thead = this.thead;
466
+ if (this.$refs.oaTable) {
467
+ thead = this.$refs.oaTable.getThead();
468
+ }
469
+ if (handle.action) {
470
+ let isConfirm = handle.confirm || true;
471
+ if (isConfirm) {
472
+ let msg = handle.field ? row[handle.field] : '';
473
+ this.$dialog
474
+ .confirm({
475
+ message: `确定要${handle.text}${msg}吗`,
476
+ title: '提示',
477
+ confirmButtonText: '确定',
478
+ cancelButtonText: '取消',
479
+ type: 'warning'
480
+ })
481
+ .then(() => {
482
+ this.handleAjax(handle, rows);
483
+ })
484
+ .catch(() => {});
485
+ } else {
486
+ this.handleAjax(handle, rows);
487
+ }
488
+ } else if (handle.event) {
489
+ if (typeof handle.event === 'function') {
490
+ handle.event({
491
+ ele: this,
492
+ thead: thead,
493
+ data: this.datas,
494
+ ...res
495
+ });
496
+ } else if (
497
+ handle.event === 'add' ||
498
+ handle.event === 'edit' ||
499
+ handle.event === 'look'
500
+ ) {
501
+ let changes = {
502
+ event: handle.event,
503
+ title: handle.title || handle.text,
504
+ values: handle.event === 'add' ? {} : rows,
505
+ readonly: handle.event === 'look',
506
+ actionType: handle.actionType
507
+ ? handle.actionType
508
+ : handle.event === 'add'
509
+ ? 'save'
510
+ : 'update'
511
+ };
512
+ if (handle.dialog && this.$parent.$attrs[handle.dialog]) {
513
+ this.$parent.$attrs[handle.dialog].handleShow();
514
+ } else {
515
+ changes['visible'] = true;
516
+ }
517
+ if (handle.tabs) {
518
+ this.esTabs && this.esTabs.handleChangeData(changes);
519
+ } else if (handle.flowGroup) {
520
+ this.esFlowGroup && this.esFlowGroup.handleChangeData(changes);
521
+ } else {
522
+ this.esPage && this.esPage.handleChangeData(changes);
523
+ }
524
+ }
525
+ } else if (handle.changeData) {
526
+ let changeData = {};
527
+ if (Array.isArray(handle.changeData)) {
528
+ handle.changeData.forEach(item => {
529
+ if (util.isObject(item)) {
530
+ for (let i in item) {
531
+ if (typeof item[i] === 'boolean') {
532
+ changeData[i] = item[i];
533
+ } else {
534
+ changeData[i] = handle[item[i]] || item[i];
535
+ }
536
+ }
537
+ } else {
538
+ changeData[item] =
539
+ handle[item] || (Array.isArray(rows) ? rows : rows[item]);
540
+ }
541
+ });
542
+ } else {
543
+ for (let i in handle.changeData) {
544
+ let item = handle.changeData[i];
545
+ if (util.isObject(item)) {
546
+ let obj = {};
547
+ for (let e in item) {
548
+ obj[e] =
549
+ handle[item[e]] ||
550
+ (Array.isArray(rows) ? rows : rows[item[e]]);
551
+ }
552
+ changeData[i] = obj;
553
+ } else {
554
+ if (typeof item === 'boolean') {
555
+ changeData[i] = item;
556
+ } else {
557
+ changeData[i] =
558
+ handle[item] || (Array.isArray(rows) ? rows : rows[item]);
559
+ }
560
+ }
561
+ }
562
+ }
563
+ if (handle.actionType) {
564
+ changeData['actionType'] = handle.actionType;
565
+ }
566
+ if (handle.tabs) {
567
+ this.esTabs && this.esTabs.handleChangeData(changeData);
568
+ } else if (handle.flowGroup) {
569
+ this.esFlowGroup && this.esFlowGroup.handleChangeData(changeData);
570
+ } else {
571
+ this.esPage && this.esPage.handleChangeData(changeData);
572
+ }
573
+ } else {
574
+ if (handle.exportXls) {
575
+ let text = '操作';
576
+ if (
577
+ this.thead[this.thead.length - 1] &&
578
+ this.thead[this.thead.length - 1].type === 'handle'
579
+ ) {
580
+ text = this.thead[this.thead.length - 1].title;
581
+ }
582
+ thead = thead.map(item => {
583
+ return item.filter(ele => {
584
+ return ele.label !== text && ele.label;
585
+ });
586
+ });
587
+ util.exportXls({
588
+ thead: thead,
589
+ data: this.datas,
590
+ name: this.fileName
591
+ });
592
+ }
593
+ this.$emit('btnClick', res, this.datas, thead);
594
+ this.$emit('btn-click', res, this.datas, thead);
595
+ }
596
+ },
597
+ selectionChange(data) {
598
+ this.selected = JSON.parse(JSON.stringify(data));
599
+ this.$emit('selection-change', data);
600
+ },
601
+ rowClick(row, column, event) {
602
+ this.$emit('click', row, column, event);
603
+ this.$emit('row-click', row, column, event);
604
+ },
605
+ getChildrens(h, items) {
606
+ let doms = [];
607
+ items.childHead.forEach((item, index) => {
608
+ if (!item.hide) {
609
+ let childs = [];
610
+ if (item.childHead && item.childHead.length) {
611
+ childs = this.getChildrens(h, item);
612
+ }
613
+ doms.push(
614
+ h(
615
+ 'em-table-column',
616
+ {
617
+ props: {
618
+ name: this.name,
619
+ item: item,
620
+ prop: item.field,
621
+ label: item.title,
622
+ width: item.width,
623
+ index: index + 1000,
624
+ readonly: this.readonly,
625
+ optionData: this.optionDatas,
626
+ form: this.form,
627
+ minWidth: this.minWidth
628
+ },
629
+ on: {
630
+ handleClick: this.handleClick,
631
+ formBlur: this.formBlur,
632
+ formFocus: this.formFocus,
633
+ tableColumns: this.getTableColumns,
634
+ formChange: this.formChange
635
+ }
636
+ },
637
+ childs
638
+ )
639
+ );
640
+ }
641
+ });
642
+ return doms;
643
+ },
644
+ tableRowClassName({ row, rowIndex }) {
645
+ if (rowIndex % 2 === 0) {
646
+ return 'em-row';
647
+ }
648
+ return '';
649
+ },
650
+ tableHeader() {
651
+ return 'em-table-header';
652
+ }
653
+ },
654
+ render(h) {
655
+ let tag = 'div';
656
+ let dom = [];
657
+ if (this.$slots.prepend) {
658
+ dom.push(this.$slots.prepend);
659
+ }
660
+ if (this.$slots.default) {
661
+ dom.push(this.$slots.default);
662
+ }
663
+ // 开启多选
664
+ if (this.checkbox) {
665
+ dom.push(
666
+ h('el-table-column', {
667
+ props: {
668
+ type: 'selection',
669
+ width: '55',
670
+ align: 'center',
671
+ fixed: 'left',
672
+ selectable: this.selectable,
673
+ reserveSelection: this.reserveSelection
674
+ }
675
+ })
676
+ );
677
+ }
678
+ // 开启索引
679
+ if (this.numbers) {
680
+ dom.push(
681
+ h('el-table-column', {
682
+ props: {
683
+ type: 'index',
684
+ label: '序号',
685
+ width: '60',
686
+ align: 'center',
687
+ fixed: 'left'
688
+ }
689
+ })
690
+ );
691
+ }
692
+ this.theads.forEach((items, indexs) => {
693
+ if (
694
+ items.type &&
695
+ (items.type === 'selection' || items.type === 'index')
696
+ ) {
697
+ if (items.type === 'index') {
698
+ dom.push(
699
+ h('em-table-column', {
700
+ props: util.extend(
701
+ {},
702
+ {
703
+ type: 'index',
704
+ label: '序号',
705
+ width: '60',
706
+ align: 'center',
707
+ fixed: 'left'
708
+ },
709
+ items
710
+ ),
711
+
712
+ key: indexs
713
+ })
714
+ );
715
+ } else {
716
+ dom.push(
717
+ h('em-table-column', {
718
+ props: util.extend(
719
+ {},
720
+ {
721
+ type: 'selection',
722
+ width: '55',
723
+ align: 'center',
724
+ fixed: 'left'
725
+ },
726
+ items
727
+ ),
728
+
729
+ key: indexs
730
+ })
731
+ );
732
+ }
733
+ } else if (!items.hide) {
734
+ let tds = [];
735
+ if (items.childHead && items.childHead.length) {
736
+ tds = this.getChildrens(h, items);
737
+ }
738
+ dom.push(
739
+ h(
740
+ 'em-table-column',
741
+ {
742
+ props: {
743
+ name: this.name,
744
+ prop: items.field,
745
+ label: items.title,
746
+ item: items,
747
+ width: items.width,
748
+ index: indexs,
749
+ readonly: this.readonly,
750
+ optionData: this.optionDatas,
751
+ form: this.form,
752
+ minWidth: this.minWidth
753
+ },
754
+ on: {
755
+ handleClick: this.handleClick,
756
+ formBlur: this.formBlur,
757
+ formFocus: this.formFocus,
758
+ tableColumns: this.getTableColumns,
759
+ formChange: this.formChange
760
+ },
761
+ key: indexs
762
+ },
763
+ tds
764
+ )
765
+ );
766
+ }
767
+ });
768
+ let tableContents = [];
769
+ tableContents.push(
770
+ h(
771
+ 'el-table',
772
+ {
773
+ // ref: ref,
774
+ class: 'em-table',
775
+ attrs: {
776
+ 'row-class-name': this.tableRowClassName,
777
+ 'header-row-class-name': this.tableHeader,
778
+ data: this.datas,
779
+ ...this.$attrs,
780
+ height: this.tableHeight !== 'auto' ? this.tableHeight : undefined
781
+ },
782
+ on: {
783
+ ...this.$listeners,
784
+ 'row-click': this.rowClick,
785
+ 'selection-change': this.selectionChange
786
+ },
787
+ ref: 'oaTable'
788
+ },
789
+ dom
790
+ )
791
+ );
792
+ if (this.page) {
793
+ tableContents.push(
794
+ h('em-pagination', {
795
+ attrs: {
796
+ // ...this.config,
797
+ value: this.config.pageNum,
798
+ 'items-per-page': this.config.pageSize,
799
+ 'total-items': this.config.totalCount
800
+ },
801
+ class: 'em-table-page',
802
+ style: { 'text-align': this.page.position || 'center' },
803
+ on: {
804
+ change: this.currentChange
805
+ }
806
+ })
807
+ );
808
+ }
809
+ return h(
810
+ 'div',
811
+ {
812
+ // ref: ref,
813
+ // attrs: {
814
+ // 'row-class-name': this.tableRowClassName,
815
+ // 'header-row-class-name': this.tableHeader,
816
+ // data: this.data,
817
+ // ...this.$attrs,
818
+ // height: this.tableHeight !== 'auto' ? this.tableHeight : undefined
819
+ // },
820
+ // on: {
821
+ // ...this.$listeners,
822
+ // 'row-click': this.rowClick,
823
+ // 'selection-change': this.selectionChange
824
+ // }
825
+ },
826
+ tableContents
827
+ );
828
+ }
829
+ };
830
+ </script>