shijiplus-web-plugin 0.1.33 → 0.1.35

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shijiplus-web-plugin",
3
- "version": "0.1.33",
3
+ "version": "0.1.35",
4
4
  "files": [
5
5
  "src"
6
6
  ],
@@ -1,4 +1,4 @@
1
- const compFiles = ['plus-tag', 'plus-icon', 'plus-city-cascader', 'plus-count-down', 'plus-city-cascader', 'plus-common-header', 'plus-poptip', 'plus-qr-code', 'plus-drawer', 'plus-tabs', 'plus-remote-selector', 'plus-select', 'plus-form', 'plus-scrollview', 'plus-table', 'plus-modal', 'plus-card', 'permission-component']
1
+ const compFiles = ['plus-tag', 'plus-table-v2', 'plus-icon', 'plus-city-cascader', 'plus-count-down', 'plus-city-cascader', 'plus-common-header', 'plus-poptip', 'plus-qr-code', 'plus-drawer', 'plus-tabs', 'plus-remote-selector', 'plus-select', 'plus-form', 'plus-scrollview', 'plus-table', 'plus-modal', 'plus-card', 'permission-component']
2
2
 
3
3
  const install = (vue, opts = {}) => {
4
4
  console.log('--------install---plus-comp----------')
@@ -167,6 +167,9 @@ export default {
167
167
  // Update progress based on total count
168
168
  this.orderExportModalPercent = (exportedCount / this.totalCount * 100).toFixed(2)
169
169
  instance.updatePercent(this.orderExportModalPercent)
170
+ if (this.orderExportModalPercent >= 100) {
171
+ break
172
+ }
170
173
  }
171
174
 
172
175
  // 5. Export the data (logic omitted here, add your export implementation)
@@ -0,0 +1,78 @@
1
+ import PlusCircleProgressModal from './plus-circle-progress-modal.vue'
2
+ export default {
3
+ data() {
4
+ return {
5
+ totalCount: 0,
6
+ orderExportModalPercent: 0,
7
+ orderExportPageSize: 100
8
+ }
9
+ },
10
+ methods: {
11
+ invokeExportExcel(searchForm, apiFunction) {
12
+ const checkExportDataTotal = (searchForm) => {
13
+ return apiFunction({
14
+ ...searchForm,
15
+ pageNo: 1,
16
+ currentPage: 1,
17
+ pageSize: 1
18
+ })
19
+ .then((res) => {
20
+ if (res && res.meta) {
21
+ this.totalCount = res.meta.totalCount
22
+ } else {
23
+ this.totalCount = (res.data || []).length
24
+ }
25
+ })
26
+ }
27
+ let exportData = []
28
+ const excelExportFun = (pageNo, pageSize, processUpdate) => {
29
+ return apiFunction({
30
+ ...searchForm,
31
+ currentPage: pageNo,
32
+ pageNo: pageNo,
33
+ pageSize: pageSize
34
+ }).then((res) => {
35
+ if (res && res.data) {
36
+ exportData.push(...res.data)
37
+ }
38
+ this.orderExportModalPercent = (exportData.length / (this.totalCount || 1) * 100).toFixed(2)
39
+ if (processUpdate) {
40
+ processUpdate(this.orderExportModalPercent)
41
+ }
42
+ if (exportData.length < this.totalCount) {
43
+ return excelExportFun(pageNo + 1, pageSize, processUpdate)
44
+ }
45
+ return exportData
46
+ }).catch((error) => {
47
+ console.log('--------error---------', error)
48
+ throw Error('导出失败')
49
+ })
50
+ }
51
+ return checkExportDataTotal(searchForm).then((res) => {
52
+ if (this.totalCount === 0) {
53
+ // 宏任务最后执行
54
+ setTimeout(() => {
55
+ this.$Message.error('暂无数据,请搜索后重试', 3)
56
+ }, 0)
57
+ return
58
+ }
59
+ const instance = this.$getComponentInstance(PlusCircleProgressModal)
60
+ instance.$on('on-close', (e) => {
61
+ setTimeout(() => {
62
+ this.$removeVComp(instance)
63
+ }, 500)
64
+ })
65
+ instance.show()
66
+ return excelExportFun(1, this.orderExportPageSize, (process) => {
67
+ instance.updatePercent(process)
68
+ }).catch(() => {
69
+ // 宏任务最后执行
70
+ setTimeout(() => {
71
+ this.$Message.error('导出失败', 3)
72
+ this.$removeVComp(instance)
73
+ }, 0)
74
+ })
75
+ })
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,54 @@
1
+ <template>
2
+ <PlusModal
3
+ :props="modalProps"
4
+ :closable="false"
5
+ @on-close="handlerClose"
6
+ width="500px"
7
+ >
8
+ <div class="i-flex-wrap justify-center align-center" style="height: 200px">
9
+ <i-circle :strokeColor="'var(--primary-color)'" :percent="percent">
10
+ <p class="sub-text">正在导出...</p>
11
+ <p
12
+ class="primary-title"
13
+ style="margin-top: 6px; color: var(--primary-color)"
14
+ >
15
+ {{ percent }}%
16
+ </p>
17
+ </i-circle>
18
+ </div>
19
+ <div slot="footer"></div>
20
+ </PlusModal>
21
+ </template>
22
+ <script>
23
+ export default {
24
+ data() {
25
+ return {
26
+ modalProps: {
27
+ show: false
28
+ },
29
+ percent: 0
30
+ }
31
+ },
32
+ methods: {
33
+ updatePercent(value) {
34
+ this.percent = Number(value)
35
+ if (this.percent >= 100) {
36
+ setTimeout(() => {
37
+ this.handlerClose()
38
+ }, 800)
39
+ }
40
+ },
41
+ handlerClose() {
42
+ this.modalProps.show = false
43
+ this.$emit('on-close')
44
+ },
45
+ show() {
46
+ this.percent = 0
47
+ this.modalProps.show = true
48
+ },
49
+ hide() {}
50
+ }
51
+ }
52
+ </script>
53
+ <style lang="less" scoped>
54
+ </style>
@@ -0,0 +1,584 @@
1
+ /* eslint-disable */
2
+ <template>
3
+ <div
4
+ ref="plusTableInnerRef"
5
+ :class="['plus-table-wrap', fixedHeader ? 'fixed-header' : '']"
6
+ >
7
+ <div
8
+ ref="searchAreaRef"
9
+ :class="[inlineForm && 'i-flex-wrap nowrap inline-wrap', 'p-search-area']"
10
+ v-if="showSearchArea"
11
+ >
12
+ <div :class="[inlineForm && 'f-grow']">
13
+ <PlusForm>
14
+ <Form :inline="inlineForm" :label-width="parseFloat(formLabelWidth)">
15
+ <slot name="searchArea"></slot>
16
+ <div
17
+ v-if="showButtonArea"
18
+ class="btn-area f-no-shrink i-flex-wrap f-grow"
19
+ >
20
+ <Button v-if="showSeachButton" type="primary" @click="onSearch">
21
+ 搜索
22
+ </Button>
23
+ <Button v-if="showResetButton" type="default" @click="onReset">
24
+ 重置
25
+ </Button>
26
+ <div class="operation-area f-grow f-row justify-end">
27
+ <slot name="operation"> </slot>
28
+ </div>
29
+ </div>
30
+ </Form>
31
+ </PlusForm>
32
+ </div>
33
+ </div>
34
+ <slot name="table">
35
+ <Table
36
+ :style="tableStyle"
37
+ :columns="showColumns"
38
+ :data="pageData"
39
+ :loading="loading"
40
+ :size="sizeType"
41
+ :height="height"
42
+ :noDataText="noDataText"
43
+ @on-selection-change="triggerSelectionChange"
44
+ @on-select-all="triggerSelectAll"
45
+ @on-sort-change="onSortChange"
46
+ @on-filter-change="onFilterChange"
47
+ >
48
+ <template
49
+ v-for="item in showColumns"
50
+ :slot="item.slot"
51
+ slot-scope="{ row, column, index }"
52
+ >
53
+ <slot
54
+ v-if="item.slot"
55
+ :name="item.slot"
56
+ :index="localPaging ? beginIndex + index : index"
57
+ :column="column"
58
+ :row="row"
59
+ >
60
+ {{ slotValue(item, row) }}
61
+ </slot>
62
+ <slot v-else-if="!item.render && !item.key">
63
+ {{ item.title }}-未设置渲染方式
64
+ </slot>
65
+ </template>
66
+ </Table>
67
+ </slot>
68
+ <div ref="footerRef">
69
+ <slot name="footer"></slot>
70
+ <div v-if="showPageArea" class="i-flex-wrap">
71
+ <Page
72
+ style="margin: 16px 0 0 auto"
73
+ :total="totalCount"
74
+ :current="currentPage"
75
+ @on-change="onPageChanged"
76
+ :page-size="pageSize"
77
+ :page-size-opts="[10, 20, 30, 50, 100]"
78
+ :show-total="showPageTotal"
79
+ :show-sizer="showPageSizer"
80
+ show-elevator
81
+ @on-page-size-change="onPageSizeChanged"
82
+ />
83
+ </div>
84
+ </div>
85
+ </div>
86
+ </template>
87
+
88
+ <script>
89
+ import exportMixin from './export-mixin'
90
+ import { exportTableExcel } from '../../../libs/util'
91
+ /**
92
+ * 统一了一些基础方法的写法
93
+ * 提供了refresh方法, 需要刷新当前页面时通过 $refs 调用
94
+ * 需要传递的参数 参考props
95
+ *
96
+ * 通过响应 'on-load-data' 事件加载数据, 事件参数包含 3 个属性
97
+ * currentPage: 读取数据的页码
98
+ * pageSize: 单页数据条数
99
+ * clearCondition: 是否需要清空搜索条件
100
+ */
101
+ export default {
102
+ name: 'PlusTable',
103
+ mixins: [exportMixin],
104
+ props: {
105
+ fixedHeader: {
106
+ type: Boolean,
107
+ default: false
108
+ },
109
+ formLabelWidth: {
110
+ type: [Number, String],
111
+ default: 100
112
+ },
113
+ inlineForm: {
114
+ type: Boolean,
115
+ default: false
116
+ },
117
+ // 表格列定义
118
+ columns: {
119
+ type: Array,
120
+ default() {
121
+ return []
122
+ }
123
+ },
124
+ localPaging: {
125
+ type: Boolean,
126
+ default: false
127
+ },
128
+ // 列表数据, 传入res.data即可
129
+ data: {
130
+ type: [Object, Array],
131
+ default() {
132
+ return {}
133
+ }
134
+ },
135
+ // 表格加载状态, 默认false
136
+ loading: {
137
+ type: Boolean,
138
+ default: false
139
+ },
140
+ noDataText: {
141
+ type: String,
142
+ default: '暂无数据'
143
+ },
144
+ // 显示页码按钮
145
+ showPageArea: {
146
+ type: Boolean,
147
+ default: true
148
+ },
149
+ // 显示搜索按钮
150
+ showSeachButton: {
151
+ type: Boolean,
152
+ default: true
153
+ },
154
+ // 显示重置按钮
155
+ showResetButton: {
156
+ type: Boolean,
157
+ default: true
158
+ },
159
+ // 显示按钮区域
160
+ showButtonArea: {
161
+ type: Boolean,
162
+ default: true
163
+ },
164
+ // 是否显示搜索区, 默认显示
165
+ showSearchArea: {
166
+ type: Boolean,
167
+ default: true
168
+ },
169
+ // 每页条数
170
+ defaultPageSize: {
171
+ type: Number,
172
+ default: 10
173
+ },
174
+ sizeType: {
175
+ type: String,
176
+ default: 'default'
177
+ },
178
+ showPageSizer: {
179
+ type: Boolean,
180
+ default: true
181
+ },
182
+ showPageTotal: {
183
+ type: Boolean,
184
+ default: true
185
+ }
186
+ },
187
+ watch: {
188
+ fixedHeader: {
189
+ handler(val) {
190
+ this.$nextTick(() => {
191
+ let tHeight = this.$refs.plusTableInnerRef.clientHeight
192
+ let tableWidth = this.$refs.plusTableInnerRef.clientWidth
193
+
194
+ // 获取元素的所有计算样式
195
+ var styles = window.getComputedStyle(this.$refs.plusTableInnerRef)
196
+
197
+ var styleHeight = parseFloat(styles.getPropertyValue('height'))
198
+ // 如果您只想获取特定方向的padding值,例如padding-top
199
+ var paddingLeft = parseFloat(styles.getPropertyValue('padding-left'))
200
+ var paddingRight = parseFloat(
201
+ styles.getPropertyValue('padding-right')
202
+ )
203
+ var paddingTop = parseFloat(styles.getPropertyValue('padding-top'))
204
+ var paddingBottom = parseFloat(
205
+ styles.getPropertyValue('padding-bottom')
206
+ )
207
+ if (paddingLeft) {
208
+ tableWidth -= paddingLeft
209
+ }
210
+ if (paddingRight) {
211
+ tableWidth -= paddingRight
212
+ }
213
+ if (paddingTop) {
214
+ tHeight -= paddingTop
215
+ }
216
+ if (paddingBottom) {
217
+ tHeight -= paddingBottom
218
+ }
219
+ this.tableWidth = tableWidth
220
+ if (this.$refs.searchAreaRef) {
221
+ tHeight -= this.$refs.searchAreaRef.clientHeight
222
+ }
223
+ if (this.$refs.footerRef) {
224
+ tHeight -= this.$refs.footerRef.clientHeight
225
+ }
226
+ if (val) {
227
+ this.height = tHeight
228
+ } else {
229
+ let tableWrap =
230
+ this.$refs.plusTableInnerRef.getElementsByClassName(
231
+ 'ivu-table-wrapper'
232
+ )[0]
233
+ if (tableWrap) {
234
+ if (!this.data.data || !this.data.data.length) {
235
+ tableWrap.style.minHeight = tHeight + 'px'
236
+ }
237
+ }
238
+ }
239
+ })
240
+ },
241
+ deep: true,
242
+ immediate: true
243
+ },
244
+ defaultPageSize: {
245
+ handler(val) {
246
+ if (val > 0) {
247
+ this.pageSize = val
248
+ }
249
+ },
250
+ deep: true,
251
+ immediate: true
252
+ },
253
+ data: {
254
+ handler(val) {
255
+ if (val) {
256
+ console.log('-----data--------', val)
257
+ let dataArray = []
258
+ if (val instanceof Array) {
259
+ dataArray = val
260
+ this.totalCount = val.length
261
+ } else {
262
+ dataArray = val.data || []
263
+ this.totalCount = 0
264
+ if (val.meta || val.totalCount) {
265
+ this.totalCount = val.totalCount || val.meta.totalCount
266
+ }
267
+ if (this.totalCount < dataArray.length) {
268
+ this.totalCount = dataArray.length
269
+ }
270
+ }
271
+ // if (this.localPaging) {
272
+ // const sortColumn = this.columns.filter((item) => {
273
+ // return item.sortable
274
+ // })[0]
275
+ // if (sortColumn) {
276
+ // dataArray = dataArray
277
+ // .map((item) => {
278
+ // return item
279
+ // })
280
+ // .sort((a, b) => {
281
+ // if (a[sortColumn.key] && b[sortColumn.key]) {
282
+ // if (sortColumn.sortType == 'desc') {
283
+ // return b[sortColumn.key] - a[sortColumn.key]
284
+ // }
285
+ // return a[sortColumn.key] - b[sortColumn.key]
286
+ // }
287
+ // return 0
288
+ // })
289
+ // }
290
+ // }
291
+
292
+ this.dataList = dataArray
293
+ } else {
294
+ this.dataList = []
295
+ this.totalCount = 0
296
+ }
297
+ },
298
+ deep: true,
299
+ immediate: true
300
+ }
301
+ },
302
+ computed: {
303
+ beginIndex() {
304
+ if (this.localPaging) {
305
+ return (this.currentPage - 1) * this.pageSize
306
+ }
307
+ return 0
308
+ },
309
+ pageData() {
310
+ if (this.localPaging) {
311
+ return this.dataList.slice(
312
+ this.beginIndex,
313
+ this.beginIndex + this.pageSize
314
+ )
315
+ }
316
+ return this.dataList
317
+ },
318
+ tableStyle() {
319
+ if (this.tableWidth) {
320
+ return { width: this.tableWidth + 'px' }
321
+ }
322
+ return {}
323
+ },
324
+ showColumns() {
325
+ return this.columns
326
+ .map((item) => {
327
+ if (!item.render && !item.slot) {
328
+ item.slot = `slot` + item.title
329
+ }
330
+ return item
331
+ })
332
+ .filter((item) => {
333
+ if (item.render) {
334
+ const oldRender = item.render
335
+ item.render = (h, params) => {
336
+ if (this.localPaging) {
337
+ params.index = this.beginIndex + params.index
338
+ }
339
+ return oldRender(h, params)
340
+ }
341
+ } else {
342
+ let realValue = ''
343
+ if (typeof item.defaultValue == 'function') {
344
+ realValue = item.defaultValue()
345
+ } else if (typeof item.defaultValue == 'number') {
346
+ realValue = `${item.defaultValue}`
347
+ } else {
348
+ realValue = item.defaultValue
349
+ }
350
+ if (realValue) {
351
+ item.render = (h, params) => {
352
+ if (!params.row[item.key]) {
353
+ return h('span', realValue)
354
+ }
355
+ return h('span', params.row[item.key])
356
+ }
357
+ }
358
+ }
359
+ if (item.filters) {
360
+ if (typeof item.filterMultiple != 'boolean') {
361
+ item.filterMultiple = false
362
+ }
363
+ if (!item.filterKey) {
364
+ item.filterKey = item.key
365
+ }
366
+ if (!item.filterRemote) {
367
+ item.filterRemote = (value, key, column) => {}
368
+ }
369
+ }
370
+ return !item.hide
371
+ })
372
+ }
373
+ },
374
+ data() {
375
+ return {
376
+ tableWidth: 0,
377
+ height: '',
378
+ dataList: [],
379
+ totalCount: 0,
380
+ currentPage: 1,
381
+ pageSize: 10
382
+ }
383
+ },
384
+ methods: {
385
+ slotValue(col, row) {
386
+ return (col.computeValue && col.computeValue(row)) || row[col.key]
387
+ },
388
+ onReset() {
389
+ this.currentPage = 1
390
+ this.triggerLoadEvent(true)
391
+ },
392
+ onSearch() {
393
+ this.currentPage = 1
394
+ this.triggerLoadEvent(false)
395
+ },
396
+ triggerSelectionChange(selection) {
397
+ this.$emit('on-selection-change', selection)
398
+ },
399
+ triggerSelectAll() {
400
+ this.$emit('on-select-all')
401
+ },
402
+ onSortChange(e) {
403
+ this.$emit('on-sort-change', e)
404
+ },
405
+ onFilterChange(e) {
406
+ this.$emit('on-filter-change', { ...e, value: e._filterChecked })
407
+ },
408
+ onPageSizeChanged(size) {
409
+ this.pageSize = size
410
+ this.triggerLoadEvent(false)
411
+ },
412
+ onPageChanged(idx) {
413
+ this.currentPage = idx
414
+ this.triggerLoadEvent(false)
415
+ },
416
+ refresh() {
417
+ this.triggerLoadEvent(false)
418
+ },
419
+ triggerLoadEvent(clearCondition) {
420
+ let e = {
421
+ currentPage: this.currentPage,
422
+ pageSize: this.pageSize,
423
+ clearCondition: clearCondition
424
+ }
425
+ this.$emit('on-load-data', e)
426
+ },
427
+ tableToExcel(p = { params: {}, apiFun: null, fileName: '' }) {
428
+ return new Promise((resolve, reject) => {
429
+ const { params, apiFun, fileName } = Object.assign({}, p)
430
+ if (!apiFun) {
431
+ // 防止被 外部 destory
432
+ setTimeout(() => {
433
+ this.$Message.error({
434
+ content: '需要指定导出的API'
435
+ })
436
+ }, 100)
437
+ resolve()
438
+ return
439
+ }
440
+ this.invokeExportExcel(
441
+ {
442
+ ...params
443
+ },
444
+ apiFun
445
+ )
446
+ .then((data) => {
447
+ if (data) {
448
+ return exportTableExcel(data, this.columns, fileName)
449
+ }
450
+ })
451
+ .finally(() => {
452
+ resolve()
453
+ })
454
+ })
455
+ }
456
+ },
457
+ mounted() {
458
+ this.onSearch()
459
+ }
460
+ }
461
+ </script>
462
+
463
+ <style lang="less" scoped>
464
+ .plus-table-wrap {
465
+ --sibling-nodes-height: 0px;
466
+ --table-th-bg-color: #f8f8f9;
467
+ background-color: #ffffff;
468
+ padding: 0px;
469
+ box-sizing: border-box;
470
+ &.fixed-header {
471
+ height: calc(~'100% - var(--sibling-nodes-height)');
472
+ }
473
+ .p-search-area {
474
+ position: relative;
475
+ padding-bottom: 16px;
476
+ &.inline-wrap {
477
+ padding-bottom: 0px;
478
+ }
479
+ /deep/.plus-form-wrap {
480
+ .ivu-form-item {
481
+ margin-bottom: 16px;
482
+ margin-right: 44px;
483
+ }
484
+ }
485
+ }
486
+ .btn-area {
487
+ // margin-top: auto;
488
+ button {
489
+ margin-left: 8px;
490
+ height: 32px;
491
+ &:first-child {
492
+ margin-left: 0px;
493
+ }
494
+ }
495
+ }
496
+ .operation-area {
497
+ & > * {
498
+ &:first-child {
499
+ margin-left: 48px !important;
500
+ }
501
+ }
502
+ }
503
+ .ivu-table-wrapper {
504
+ border: none;
505
+ /deep/.ivu-table {
506
+ &::before {
507
+ background-color: transparent;
508
+ }
509
+
510
+ &::after {
511
+ background-color: transparent;
512
+ }
513
+ th {
514
+ height: 54px;
515
+ border-bottom: none;
516
+ background-color: var(--table-th-bg-color);
517
+ .ivu-table-cell {
518
+ font-family: PingFangSC-SNaNpxibold;
519
+ font-weight: 600;
520
+ font-size: 14px;
521
+ color: #515a6e;
522
+ letter-spacing: 0.7px;
523
+ }
524
+ }
525
+ // td {
526
+ // height: 64px;
527
+ // }
528
+ .ivu-table-tip {
529
+ height: ~'calc(100% - 54px)'; // 54 header的高
530
+ table {
531
+ height: 100%;
532
+ }
533
+ }
534
+ .ivu-table-tbody {
535
+ .ivu-table-cell {
536
+ padding-top: 16px;
537
+ padding-bottom: 16px;
538
+ line-height: 1.4;
539
+ }
540
+ }
541
+ }
542
+ /deep/.ivu-table-cell {
543
+ padding-left: 12px;
544
+ padding-right: 12px;
545
+ }
546
+ /deep/.ivu-table-row {
547
+ .ivu-table-cell {
548
+ font-weight: 400;
549
+ font-size: 14px;
550
+ color: #515a6e;
551
+ letter-spacing: 0.7px;
552
+ .ivu-btn {
553
+ margin-right: 4px;
554
+ margin-bottom: 2px;
555
+ margin-top: 2px;
556
+ &:last-child {
557
+ margin-right: 0;
558
+ &:first-child {
559
+ margin-bottom: 0;
560
+ margin-top: 0px;
561
+ }
562
+ }
563
+ }
564
+ }
565
+ }
566
+ }
567
+ /deep/.ivu-page {
568
+ .ivu-page-options-sizer {
569
+ margin-right: 0px;
570
+ }
571
+ }
572
+ }
573
+ .ivu-form-item-error .plus-table-wrap {
574
+ border: #ff0000 1px solid;
575
+ border-radius: var(--border-radius);
576
+ overflow: hidden;
577
+ /deep/.ivu-select-selection {
578
+ border-color: var(--border-color) !important;
579
+ .ivu-select-arrow {
580
+ color: var(--subsidiary-color);
581
+ }
582
+ }
583
+ }
584
+ </style>
@@ -17,6 +17,7 @@ const install = (vue, opts = {}) => {
17
17
  vue.prototype.$addYears = addYears
18
18
  vue.prototype.$getDateFromString = getDateFromString
19
19
  vue.prototype.$formatterDateString = formatterDateString
20
+ vue.prototype.$dealDate = dealDate
20
21
  vue.prototype.$dateDiff = dateDiff
21
22
  vue.prototype.$beautyWeekDay = beautyWeekDay
22
23
  Date.prototype.addDays = function (days) {
@@ -34,6 +35,18 @@ const install = (vue, opts = {}) => {
34
35
  }
35
36
  }
36
37
 
38
+ function dealDate(fromtime) {
39
+ const myDate = new Date(fromtime)
40
+ const year = myDate.getFullYear() // 获取完整的年份(4位,1970-????)
41
+ let month = myDate.getMonth() // 获取当前月份(0-11,0代表1月) // 所以获取当前月份是myDate.getMonth()+1;
42
+ let date = myDate.getDate() // 获取当前日(1-31)
43
+ month = prefixZero(month + 1)
44
+ date = prefixZero(date)
45
+ return `${year}-${month}-${(date)}`
46
+ }
47
+ const prefixZero = (num) => {
48
+ return (Array(2).join(0) + num).slice(-2)
49
+ }
37
50
  function formatterDateString(dateStr, fmt = 'yyyy-MM-dd') {
38
51
  if (!dateStr) {
39
52
  return '--'
@@ -43,6 +43,7 @@ const install = (vue, opts = {}) => {
43
43
  })
44
44
  return result
45
45
  }
46
+ vue.prototype.$isEqual = isEqual
46
47
  }
47
48
 
48
49
  function convertNumberToString(obj) {
@@ -57,6 +58,30 @@ function convertNumberToString(obj) {
57
58
  })
58
59
  return obj
59
60
  }
61
+ function isEqual(obj1, obj2) {
62
+ // 判断类型是否相等
63
+ if (typeof obj1 !== typeof obj2) {
64
+ return false
65
+ }
66
+ // 如果是基本类型直接比较值
67
+ if (typeof obj1 !== 'object' || obj1 === null || obj2 === null) {
68
+ return obj1 === obj2
69
+ }
70
+ // 获取两个对象的属性名数组
71
+ const keys1 = Object.keys(obj1)
72
+ const keys2 = Object.keys(obj2)
73
+ // 属性数量不相等,返回false
74
+ if (keys1.length !== keys2.length) {
75
+ return false
76
+ }
77
+ // 比较每个属性的值
78
+ for (let key of keys1) {
79
+ if (!isEqual(obj1[key], obj2[key])) {
80
+ return false
81
+ }
82
+ }
83
+ return true
84
+ }
60
85
  function objValueFromArr(arr, key) {
61
86
  let tempValues = []
62
87
  arr.forEach(item => {
@@ -23,9 +23,19 @@ const install = (vue, opts = {}) => {
23
23
  vComp.$el.parentNode.removeChild(vComp.$el)
24
24
  }
25
25
  }
26
- vue.prototype.$getComponentInstance = (component) => {
26
+ vue.prototype.$getComponentInstance = (component, options) => {
27
+ const defaultConfig = {
28
+ props: {}
29
+ }
30
+ const { props } = Object.assign(Object.assign({}, defaultConfig), options)
27
31
  const ComponentClass = Vue.extend(component)
28
- const instance = new ComponentClass({ store: opts.store })
32
+ const instance = new ComponentClass({
33
+ store: opts.store,
34
+ props,
35
+ propsData: {
36
+ props: props
37
+ }
38
+ })
29
39
  instance.$mount()
30
40
  document.body.appendChild(instance.$el)
31
41
  return instance