hd-idevvue3 3.0.2 → 3.0.4

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 (147) hide show
  1. package/dist/assets/index.9c127719.css +1 -0
  2. package/dist/hd-idevvue3.mjs +3521 -3305
  3. package/dist/hd-idevvue3.umd.js +29 -29
  4. package/npminstall-debug.log +2 -10
  5. package/package.json +4 -2
  6. package/pnpm-lock.yaml +37 -4
  7. package/src/App.vue +11 -15
  8. package/src/assets/sound/notify.wav +0 -0
  9. package/src/demo/demo.vue +9 -10
  10. package/src/demo/dropdemo.vue +42 -43
  11. package/src/demo/extsets.vue +140 -39
  12. package/src/demo/formedit.vue +157 -145
  13. package/src/demo/hightquery.vue +263 -66
  14. package/src/demo/inlineedit.vue +129 -35
  15. package/src/demo/selfdrop.vue +32 -15
  16. package/src/directive/el-dragDialog/drag.js +13 -13
  17. package/src/directive/el-dragDialog/index.js +13 -13
  18. package/src/errorLog.js +3 -3
  19. package/src/hdcom/BigGrid.js +54 -48
  20. package/src/hdcom/BillShow.vue +84 -63
  21. package/src/hdcom/BillUpload.vue +144 -86
  22. package/src/hdcom/BtnRight.vue +26 -23
  23. package/src/hdcom/ErrHint.vue +36 -24
  24. package/src/hdcom/ExtendColumn.vue +97 -90
  25. package/src/hdcom/ExtendCommon.js +24 -13
  26. package/src/hdcom/ExtendForm.vue +107 -80
  27. package/src/hdcom/FacePicUpload.vue +59 -50
  28. package/src/hdcom/FaceRecTest.vue +87 -77
  29. package/src/hdcom/GridChart.vue +175 -162
  30. package/src/hdcom/GridExField.vue +328 -234
  31. package/src/hdcom/GridShow.vue +89 -39
  32. package/src/hdcom/HdAside.vue +192 -145
  33. package/src/hdcom/HdBtn.vue +44 -32
  34. package/src/hdcom/HdButton.vue +141 -117
  35. package/src/hdcom/HdComFaceRec.vue +80 -32
  36. package/src/hdcom/HdComGrid.vue +329 -229
  37. package/src/hdcom/HdComQuery.vue +179 -90
  38. package/src/hdcom/HdComQueryDetail.vue +159 -115
  39. package/src/hdcom/HdComSortDetail.vue +136 -130
  40. package/src/hdcom/HdDatePicker.vue +32 -16
  41. package/src/hdcom/HdDialog.vue +62 -44
  42. package/src/hdcom/HdDrop.vue +163 -138
  43. package/src/hdcom/HdFileUpload.vue +138 -119
  44. package/src/hdcom/HdFilterBox.vue +62 -62
  45. package/src/hdcom/HdFooter.vue +152 -119
  46. package/src/hdcom/HdForm.vue +276 -203
  47. package/src/hdcom/HdFormBtn.vue +81 -39
  48. package/src/hdcom/HdFormItem.vue +14 -10
  49. package/src/hdcom/HdGrid.vue +353 -156
  50. package/src/hdcom/HdGridEditBtn.vue +34 -20
  51. package/src/hdcom/HdGridExt.js +78 -47
  52. package/src/hdcom/HdGridSel.vue +227 -193
  53. package/src/hdcom/HdHeader.vue +149 -117
  54. package/src/hdcom/HdHotKey.vue +70 -67
  55. package/src/hdcom/HdInputHint.vue +40 -36
  56. package/src/hdcom/HdMain.vue +25 -27
  57. package/src/hdcom/HdMessage.vue +180 -171
  58. package/src/hdcom/HdNum.vue +67 -57
  59. package/src/hdcom/HdPopSel.vue +46 -24
  60. package/src/hdcom/HdRightMenu.vue +63 -61
  61. package/src/hdcom/HdSel/SelGridFieldcod.vue +46 -28
  62. package/src/hdcom/HdTableColumn.vue +156 -109
  63. package/src/hdcom/HdTempSave.vue +138 -116
  64. package/src/hdcom/HdTree.vue +89 -72
  65. package/src/hdcom/HdTreeTable/eval.js +8 -3
  66. package/src/hdcom/HdTreeTable/index.vue +229 -174
  67. package/src/hdcom/ImportExcel.vue +69 -34
  68. package/src/hdcom/index.js +39 -44
  69. package/src/idev.common.js +54 -47
  70. package/src/index.js +3 -6
  71. package/src/utils/HdQuery.js +25 -14
  72. package/src/utils/comutils.js +50 -28
  73. package/src/utils/gogocodeTransfer.js +59 -0
  74. package/src/utils/utils.js +30 -19
  75. package/src/vendor/Blob.js +187 -179
  76. package/src/vendor/Export2Excel.js +231 -220
  77. package/src/vendor/Export2Zip.js +25 -22
  78. package/src/views/layout/AppMain.vue +34 -32
  79. package/src/views/layout/HdLayout.vue +64 -52
  80. package/src/views/layout/header/ElasticSearch.vue +196 -159
  81. package/src/views/layout/header/HZRecorder.js +163 -135
  82. package/src/views/layout/header/HeaderSearch.vue +165 -145
  83. package/src/views/layout/header/Levelbar.vue +55 -49
  84. package/src/views/layout/header/MainHeader.vue +233 -189
  85. package/src/views/layout/header/Navbar.vue +74 -78
  86. package/src/views/layout/header/ScrollPane.vue +103 -81
  87. package/src/views/layout/header/TagsView.vue +169 -164
  88. package/src/views/layout/header/VocRec.vue +86 -78
  89. package/src/views/layout/header/changepswform.vue +98 -64
  90. package/src/views/layout/index.js +5 -7
  91. package/src/views/layout/menu/Hamburger.vue +63 -45
  92. package/src/views/layout/menu/HdMenu.vue +155 -118
  93. package/src/views/layout/menu/index.vue +21 -19
  94. package/src/views/privilege/commsg/commsg.vue +115 -41
  95. package/src/views/privilege/commsg/commsgOrgn.vue +40 -31
  96. package/src/views/privilege/commsg/commsgRole.vue +180 -109
  97. package/src/views/privilege/commsg/commsgform.vue +125 -101
  98. package/src/views/privilege/commsg/commsgiframe.vue +30 -23
  99. package/src/views/privilege/commsg/commsgto.vue +163 -84
  100. package/src/views/privilege/commsg/commsgtoform.vue +64 -58
  101. package/src/views/privilege/commsg/commsgtrans.vue +187 -115
  102. package/src/views/privilege/exfield/comexcolumn.vue +133 -43
  103. package/src/views/privilege/exfield/comexcolumnform.vue +85 -58
  104. package/src/views/privilege/exfield/comexfield.vue +15 -17
  105. package/src/views/privilege/exfield/comexfieldform.vue +71 -53
  106. package/src/views/privilege/exfield/comexfieldsub.vue +137 -46
  107. package/src/views/privilege/index.js +19 -20
  108. package/src/views/privilege/menu/comMenu.vue +49 -41
  109. package/src/views/privilege/menu/menu.vue +166 -49
  110. package/src/views/privilege/menu/menuinfo.vue +41 -34
  111. package/src/views/privilege/menu/rolelist.vue +78 -33
  112. package/src/views/privilege/menu/userlist.vue +76 -33
  113. package/src/views/privilege/mobile/authmobileupdate.vue +119 -43
  114. package/src/views/privilege/mobile/authmobileupdateform.vue +76 -46
  115. package/src/views/privilege/orgDept/authOrgn.vue +157 -65
  116. package/src/views/privilege/orgDept/authorgnform.vue +50 -38
  117. package/src/views/privilege/orgDept/orgDept.vue +38 -37
  118. package/src/views/privilege/orgDept/orgTree.vue +99 -88
  119. package/src/views/privilege/orgDept/orgnselect.vue +132 -111
  120. package/src/views/privilege/personDept/authuser.vue +197 -91
  121. package/src/views/privilege/personDept/authuserform.vue +123 -71
  122. package/src/views/privilege/personDept/facerec.vue +128 -83
  123. package/src/views/privilege/personDept/orgncascader.vue +134 -115
  124. package/src/views/privilege/personDept/personDept.vue +9 -7
  125. package/src/views/privilege/quartz/comquartzjob.vue +123 -38
  126. package/src/views/privilege/quartz/comquartzjobform.vue +67 -51
  127. package/src/views/privilege/quartz/comquartzlog.vue +116 -32
  128. package/src/views/privilege/role/btnRole.vue +123 -67
  129. package/src/views/privilege/role/menuRole.vue +65 -45
  130. package/src/views/privilege/role/orgnRole.vue +63 -41
  131. package/src/views/privilege/role/role.vue +26 -9
  132. package/src/views/privilege/role/rolelist.vue +114 -45
  133. package/src/views/privilege/role/roleselect.vue +34 -17
  134. package/src/views/privilege/search/comsearch.vue +164 -73
  135. package/src/views/privilege/search/menu.vue +38 -22
  136. package/src/views/privilege/syscode/syscode.vue +157 -69
  137. package/src/views/privilege/syscode/sysfield.vue +96 -43
  138. package/src/views/privilege/syscode/sysfieldframe.vue +30 -30
  139. package/src/views/privilege/syslog/menulog.vue +38 -22
  140. package/src/views/privilege/syslog/syslog.vue +145 -78
  141. package/src/views/privilege/syslog/syslogconfig.vue +91 -24
  142. package/src/views/privilege/syslog/syslogform.vue +45 -43
  143. package/src/views/privilege/syslog/syslogframe.vue +26 -26
  144. package/src/views/privilege/userRole/userRole.vue +187 -89
  145. package/vite.config.js +7 -0
  146. package/dist/assets/index.774ef40e.css +0 -1
  147. package/src/views/privilege.zip +0 -0
@@ -2,59 +2,65 @@ import hdcom from './hdcom'
2
2
  import comutils from './utils/comutils'
3
3
 
4
4
  export default {
5
-
6
5
  install(Vue, options, inElement) {
7
-
8
6
  try {
9
7
  let ver = require('../package.json').version
10
8
  console.info('您现在使用的是hd-idevvue2:' + ver)
11
- } catch (e) {
12
- }
9
+ } catch (e) {}
13
10
 
14
11
  //滚动去掉高亮事件,提升虚拟滚动条性能
15
- inElement.Table.components.TableBody.methods.handleMouseEnter = function handleMouseEnter(index) {//去掉eltable的hover事件
16
- if(this.store.states.hoverRow != 'locked') {
17
- this.store.commit('setHoverRow', index);
18
- }
19
- },
20
- inElement.Table.components.TableBody.methods.handleMouseLeave = function handleMouseLeave(index) {//去掉eltable的hover事件
21
- if(this.store.states.hoverRow != 'locked') {
22
- this.store.commit('setHoverRow', null);
23
- }
24
- },
25
- inElement.Table.components.TableBody.methods.getColspanRealWidth = function getColspanRealWidth(columns, colspan, index) {
26
- if (colspan < 1) {
27
- return columns[index].realWidth;
28
- }
29
- const widthArr = columns.map(({ realWidth }) => realWidth).slice(index, index + colspan);
30
- return widthArr.reduce((acc, width) => acc + width, 0);
31
- },
32
-
33
- inElement.Input.props.clearable = {// clearable默认生效
34
- type: Boolean,
35
- default: true
36
- }
37
- inElement.Input.props.value = {// 不写会出现undefined
12
+ ;(inElement.Table.components.TableBody.methods.handleMouseEnter =
13
+ function handleMouseEnter(index) {
14
+ //去掉eltable的hover事件
15
+ if (this.store.states.hoverRow != 'locked') {
16
+ this.store.commit('setHoverRow', index)
17
+ }
18
+ }),
19
+ (inElement.Table.components.TableBody.methods.handleMouseLeave =
20
+ function handleMouseLeave(index) {
21
+ //去掉eltable的hover事件
22
+ if (this.store.states.hoverRow != 'locked') {
23
+ this.store.commit('setHoverRow', null)
24
+ }
25
+ }),
26
+ (inElement.Table.components.TableBody.methods.getColspanRealWidth =
27
+ function getColspanRealWidth(columns, colspan, index) {
28
+ if (colspan < 1) {
29
+ return columns[index].realWidth
30
+ }
31
+ const widthArr = columns
32
+ .map(({ realWidth }) => realWidth)
33
+ .slice(index, index + colspan)
34
+ return widthArr.reduce((acc, width) => acc + width, 0)
35
+ }),
36
+ (inElement.Input.props.clearable = {
37
+ // clearable默认生效
38
+ type: Boolean,
39
+ default: true,
40
+ })
41
+ inElement.Input.props.value = {
42
+ // 不写会出现undefined
38
43
  type: [String, Number],
39
- default: ''
44
+ default: '',
40
45
  }
41
46
  //element ui自身组件进行了扩展,如果使用纯原生的可以使用Ex***,或者自己import
42
- Vue.component('ExFooter', inElement.Footer)
43
- Vue.component('ExMain', inElement.Main)
44
- Vue.component('ExAside', inElement.Aside)
45
- Vue.component('ExHeader', inElement.Header)
46
- Vue.component('ExDialog', inElement.Dialog) //这里引入,然后HdDialog调用,保证了一个vue对象,zIndex才能正常
47
- Vue.component('ExFormItem', inElement.FormItem)
48
- Vue.component('ExFormItem', inElement.FormItem)
49
- Vue.component('ExButton', inElement.Button)
50
- Vue.component('ExTableColumn', inElement.TableColumn)
51
- Vue.component('ExDatePicker', inElement.DatePicker)
52
- Vue.use(inElement, options)
53
- Vue.use(comutils)
54
- Vue.use(hdcom)
55
- Vue.prototype.$message = function (options) { // 消息默认值
47
+ window.$vueApp.component('ExFooter', inElement.Footer)
48
+ window.$vueApp.component('ExMain', inElement.Main)
49
+ window.$vueApp.component('ExAside', inElement.Aside)
50
+ window.$vueApp.component('ExHeader', inElement.Header)
51
+ window.$vueApp.component('ExDialog', inElement.Dialog) //这里引入,然后HdDialog调用,保证了一个vue对象,zIndex才能正常
52
+ window.$vueApp.component('ExFormItem', inElement.FormItem)
53
+ window.$vueApp.component('ExFormItem', inElement.FormItem)
54
+ window.$vueApp.component('ExButton', inElement.Button)
55
+ window.$vueApp.component('ExTableColumn', inElement.TableColumn)
56
+ window.$vueApp.component('ExDatePicker', inElement.DatePicker)
57
+ window.$vueApp.use(inElement, options)
58
+ window.$vueApp.use(comutils)
59
+ window.$vueApp.use(hdcom)
60
+ window.$vueApp.config.globalProperties.$message = function (options) {
61
+ // 消息默认值
56
62
  if (!options.duration) {
57
- if(options.type=="error") {
63
+ if (options.type == 'error') {
58
64
  options.duration = 3000
59
65
  } else {
60
66
  options.duration = 5000
@@ -65,8 +71,9 @@ export default {
65
71
  }
66
72
  inElement.Message(options)
67
73
  }
68
- Vue.prototype.$message.closeAll = inElement.Message.closeAll
69
- Vue.prototype.$message.close = inElement.Message.close
70
- }
74
+ window.$vueApp.config.globalProperties.$message.closeAll =
75
+ inElement.Message.closeAll
76
+ window.$vueApp.config.globalProperties.$message.close =
77
+ inElement.Message.close
78
+ },
71
79
  }
72
-
package/src/index.js CHANGED
@@ -1,14 +1,11 @@
1
-
2
1
  import common from './idev.common'
3
2
  import privilege from './views/privilege'
4
3
  import layout from './views/layout'
5
4
 
6
5
  export default {
7
-
8
6
  install(Vue, options, inElement) {
9
7
  common.install(Vue, options, inElement)
10
- Vue.use(privilege)
11
- Vue.use(layout)
12
- }
8
+ window.$vueApp.use(privilege)
9
+ window.$vueApp.use(layout)
10
+ },
13
11
  }
14
-
@@ -1,4 +1,5 @@
1
- export default (st, pageRows, queryMethod) => {//st页面this对象,pageRows,每页显示行数,queryMethod如果默认查询不是doQuery需要指定字符串
1
+ export default (st, pageRows, queryMethod) => {
2
+ //st页面this对象,pageRows,每页显示行数,queryMethod如果默认查询不是doQuery需要指定字符串
2
3
  let _thisst = st
3
4
  let query = {}
4
5
  let page = 1
@@ -9,27 +10,37 @@ export default (st, pageRows, queryMethod) => {//st页面this对象,pageRows,每
9
10
  let q = ''
10
11
  let sort = ''
11
12
  let order = 'desc'
12
- let selObj = []//checkbox勾选的对象
13
- let doQueryMethod = queryMethod ? '_thisst.' + queryMethod + '()' : '_thisst.doQuery()'
13
+ let selObj = [] //checkbox勾选的对象
14
+ let doQueryMethod = queryMethod
15
+ ? '_thisst.' + queryMethod + '()'
16
+ : '_thisst.doQuery()'
14
17
 
15
18
  let outObj = {
19
+ query,
20
+ page,
21
+ rows,
22
+ q,
23
+ sort,
24
+ order,
25
+ selObj,
26
+ doQueryMethod,
16
27
 
17
- query, page, rows, q, sort, order, selObj, doQueryMethod,
18
-
19
- add:
20
- (key, value) => {//没啥用
21
- query[key] = value
22
- },
28
+ add: (key, value) => {
29
+ //没啥用
30
+ query[key] = value
31
+ },
23
32
  setThis(st) {
24
33
  _thisst = st
25
34
  },
26
- doSizeChg(val) {//显示行数切换
35
+ doSizeChg(val) {
36
+ //显示行数切换
27
37
  outObj.rows = val
28
38
  return eval(doQueryMethod)
29
39
 
30
40
  //st.doQuery()
31
41
  },
32
- doCurPageChange(val) {//页码切换
42
+ doCurPageChange(val) {
43
+ //页码切换
33
44
  outObj.page = val
34
45
 
35
46
  return eval(doQueryMethod)
@@ -44,11 +55,11 @@ export default (st, pageRows, queryMethod) => {//st页面this对象,pageRows,每
44
55
  outObj.sort = ''
45
56
  outObj.order = ''
46
57
  }
47
- if (!noQuery) {//true 不查询,适合列表一加载时
58
+ if (!noQuery) {
59
+ //true 不查询,适合列表一加载时
48
60
  return eval(doQueryMethod)
49
61
  }
50
- }
62
+ },
51
63
  }
52
64
  return outObj
53
65
  }
54
-
@@ -1,40 +1,64 @@
1
- function genRules(isRequired, minLength, maxLength, type = 'string', decimalNum) { // decimalNum=0是整数
1
+ function genRules(
2
+ isRequired,
3
+ minLength,
4
+ maxLength,
5
+ type = 'string',
6
+ decimalNum
7
+ ) {
8
+ // decimalNum=0是整数
2
9
  const result = []
3
10
  if (isRequired) {
4
- const msg = {message: this.$t('此处必填'), required: true}
11
+ const msg = { message: this.$t('此处必填'), required: true }
5
12
  result.push(msg)
6
13
  }
7
14
  if (type == 'string') {
8
15
  if (minLength) {
9
- result.push({min: minLength, message: this.$t('字符长度不能小于x个字符', [minLength])})
16
+ result.push({
17
+ min: minLength,
18
+ message: this.$t('字符长度不能小于x个字符', [minLength]),
19
+ })
10
20
  }
11
21
  if (maxLength) {
12
- result.push({max: maxLength, message: this.$t('字符长度不能大于x个字符', [maxLength])})
22
+ result.push({
23
+ max: maxLength,
24
+ message: this.$t('字符长度不能大于x个字符', [maxLength]),
25
+ })
13
26
  }
14
27
  } else if (type == 'number') {
15
- result.push({type: 'number', message: this.$t('必须为数字')})
28
+ result.push({ type: 'number', message: this.$t('必须为数字') })
16
29
  if (minLength != null) {
17
- result.push({type: 'number', min: minLength, message: this.$t('数字不能小于') + minLength})
30
+ result.push({
31
+ type: 'number',
32
+ min: minLength,
33
+ message: this.$t('数字不能小于') + minLength,
34
+ })
18
35
  }
19
36
  if (maxLength) {
20
- result.push({type: 'number', max: maxLength, message: this.$t('数字不能大于') + maxLength})
37
+ result.push({
38
+ type: 'number',
39
+ max: maxLength,
40
+ message: this.$t('数字不能大于') + maxLength,
41
+ })
21
42
  }
22
- if (decimalNum) { // 非0时,有小数
43
+ if (decimalNum) {
44
+ // 非0时,有小数
23
45
  const reg = new RegExp('^(\\-|\\+?)\\d+(\\.\\d{0,' + decimalNum + '})?$')
24
- result.push({pattern: reg, message: this.$t('小数最多x位', [decimalNum])}
25
- )
46
+ result.push({
47
+ pattern: reg,
48
+ message: this.$t('小数最多x位', [decimalNum]),
49
+ })
26
50
  }
27
51
  if (decimalNum === 0) {
28
52
  const reg = new RegExp('(^-?\\d+$)')
29
- result.push({pattern: reg, message: this.$t('请输入整数')}
30
- )
53
+ result.push({ pattern: reg, message: this.$t('请输入整数') })
31
54
  }
32
55
  }
33
56
 
34
57
  return result
35
58
  }
36
59
 
37
- function ckFt(value) { // checkbox展示用
60
+ function ckFt(value) {
61
+ // checkbox展示用
38
62
  if (value == '1') {
39
63
  return '√'
40
64
  } else {
@@ -42,57 +66,55 @@ function ckFt(value) { // checkbox展示用
42
66
  }
43
67
  }
44
68
 
45
-
46
69
  function date() {
47
70
  return
48
71
  }
49
72
 
50
73
  export default {
51
-
52
74
  install(Vue) {
53
- Vue.prototype.$r = genRules
54
- Vue.prototype.$ckFt = ckFt
55
- Vue.prototype.$date = {
75
+ window.$vueApp.config.globalProperties.$r = genRules
76
+ window.$vueApp.config.globalProperties.$ckFt = ckFt
77
+ window.$vueApp.config.globalProperties.$date = {
56
78
  type: 'date',
57
79
  placeholder: '选择日期',
58
80
  format: 'yyyy-MM-dd',
59
81
  valueFormat: 'yyyy-MM-dd',
60
- style: {width: '100%'}
82
+ style: { width: '100%' },
61
83
  }
62
- Vue.prototype.$time = {
84
+ window.$vueApp.config.globalProperties.$time = {
63
85
  type: 'datetime',
64
86
  placeholder: '选择时间',
65
87
  format: 'yyyy-MM-dd HH:mm',
66
88
  valueFormat: 'yyyy-MM-dd HH:mm',
67
- style: {width: '100%'}
89
+ style: { width: '100%' },
68
90
  }
69
- Vue.prototype.$simdate = {
91
+ window.$vueApp.config.globalProperties.$simdate = {
70
92
  type: 'date',
71
93
  placeholder: '选择日期',
72
94
  format: 'yy-MM-dd',
73
95
  valueFormat: 'yyyy-MM-dd',
74
- style: {width: '100%'}
96
+ style: { width: '100%' },
75
97
  }
76
- Vue.prototype.$simtime = {
98
+ window.$vueApp.config.globalProperties.$simtime = {
77
99
  type: 'datetime',
78
100
  placeholder: '选择时间',
79
101
  format: 'yy-MM-dd HH:mm',
80
102
  valueFormat: 'yyyy-MM-dd HH:mm',
81
- style: {width: '100%'}
103
+ style: { width: '100%' },
82
104
  }
83
- Vue.prototype.$simdateshow = (v) => {
105
+ window.$vueApp.config.globalProperties.$simdateshow = (v) => {
84
106
  if (v) {
85
107
  return v.substring(2, 10)
86
108
  } else {
87
109
  return ''
88
110
  }
89
111
  }
90
- Vue.prototype.$simtimeshow = (v) => {
112
+ window.$vueApp.config.globalProperties.$simtimeshow = (v) => {
91
113
  if (v) {
92
114
  return v.substring(2)
93
115
  } else {
94
116
  return ''
95
117
  }
96
118
  }
97
- }
119
+ },
98
120
  }
@@ -0,0 +1,59 @@
1
+ const eventRegistryMap = new WeakMap()
2
+ function getRegistry(instance) {
3
+ let events = eventRegistryMap.get(instance)
4
+ if (!events) {
5
+ eventRegistryMap.set(instance, (events = Object.create(null)))
6
+ }
7
+ return events
8
+ }
9
+ export function $on(instance, event, fn) {
10
+ if (Array.isArray(event)) {
11
+ event.forEach((e) => $on(instance, e, fn))
12
+ } else {
13
+ const events = getRegistry(instance)
14
+ ;(events[event] || (events[event] = [])).push(fn)
15
+ }
16
+ return instance
17
+ }
18
+ export function $once(instance, event, fn) {
19
+ const wrapped = (...args) => {
20
+ $off(instance, event, wrapped)
21
+ fn.call(instance, ...args)
22
+ }
23
+ wrapped.fn = fn
24
+ $on(instance, event, wrapped)
25
+ return instance
26
+ }
27
+ export function $off(instance, event, fn) {
28
+ const vm = instance
29
+ // all
30
+ if (!event) {
31
+ eventRegistryMap.set(instance, Object.create(null))
32
+ return vm
33
+ }
34
+ // array of events
35
+ if (Array.isArray(event)) {
36
+ event.forEach((e) => $off(instance, e, fn))
37
+ return vm
38
+ }
39
+ // specific event
40
+ const events = getRegistry(instance)
41
+ const cbs = events[event]
42
+ if (!cbs) {
43
+ return vm
44
+ }
45
+ if (!fn) {
46
+ events[event] = undefined
47
+ return vm
48
+ }
49
+ events[event] = cbs.filter((cb) => !(cb === fn || cb.fn === fn))
50
+ return vm
51
+ }
52
+ export function $emit(instance, event, ...args) {
53
+ instance && instance.$emit && instance.$emit(event, ...args)
54
+ const cbs = getRegistry(instance)[event]
55
+ if (cbs) {
56
+ cbs.map((cb) => cb.apply(instance, args))
57
+ }
58
+ return instance
59
+ }
@@ -6,15 +6,21 @@ Date.prototype.format = function (format) {
6
6
  'm+': this.getMinutes(),
7
7
  's+': this.getSeconds(),
8
8
  'q+': Math.floor((this.getMonth() + 3) / 3), // quarter
9
- 'S': this.getMilliseconds()
9
+ S: this.getMilliseconds(),
10
10
  }
11
11
  if (/(y+)/.test(format)) {
12
- format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
12
+ format = format.replace(
13
+ RegExp.$1,
14
+ (this.getFullYear() + '').substr(4 - RegExp.$1.length)
15
+ )
13
16
  }
14
17
  for (var i in args) {
15
18
  var n = args[i]
16
19
  if (new RegExp('(' + i + ')').test(format)) {
17
- format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ('00' + n).substr(('' + n).length))
20
+ format = format.replace(
21
+ RegExp.$1,
22
+ RegExp.$1.length == 1 ? n : ('00' + n).substr(('' + n).length)
23
+ )
18
24
  }
19
25
  }
20
26
  return format
@@ -36,17 +42,17 @@ String.prototype.formatStr = function (format) {
36
42
  }
37
43
  if (!date instanceof Date) return
38
44
  var dict = {
39
- 'yyyy': date.getFullYear(),
40
- 'M': date.getMonth() + 1,
41
- 'd': date.getDate(),
42
- 'H': date.getHours(),
43
- 'm': date.getMinutes(),
44
- 's': date.getSeconds(),
45
- 'MM': ('' + (date.getMonth() + 101)).substr(1),
46
- 'dd': ('' + (date.getDate() + 100)).substr(1),
47
- 'HH': ('' + (date.getHours() + 100)).substr(1),
48
- 'mm': ('' + (date.getMinutes() + 100)).substr(1),
49
- 'ss': ('' + (date.getSeconds() + 100)).substr(1)
45
+ yyyy: date.getFullYear(),
46
+ M: date.getMonth() + 1,
47
+ d: date.getDate(),
48
+ H: date.getHours(),
49
+ m: date.getMinutes(),
50
+ s: date.getSeconds(),
51
+ MM: ('' + (date.getMonth() + 101)).substr(1),
52
+ dd: ('' + (date.getDate() + 100)).substr(1),
53
+ HH: ('' + (date.getHours() + 100)).substr(1),
54
+ mm: ('' + (date.getMinutes() + 100)).substr(1),
55
+ ss: ('' + (date.getSeconds() + 100)).substr(1),
50
56
  }
51
57
  return format.replace(/(yyyy|MM?|dd?|HH?|ss?|mm?)/g, function () {
52
58
  return dict[arguments[0]]
@@ -58,10 +64,16 @@ String.prototype.replaceAll = function (oldStr, newStr) {
58
64
  // 遍历整个数组,移除匹配item的元素,使用强比较===,给第二个参数的话就从头开始找到第一个匹配item元素移除后返回;
59
65
  // 如有找到元素返回处理后的数组自身,如果没有找到过就返回undefined;
60
66
  Array.prototype.remove = function (item, all) {
61
- let result, isType = Object.prototype.toString, i, len, start, hasLast = arguments[2]
62
- start = 0, len = this.length
63
- for (i = start; i < len;) {
64
- var isPass = true, inx
67
+ let result,
68
+ isType = Object.prototype.toString,
69
+ i,
70
+ len,
71
+ start,
72
+ hasLast = arguments[2]
73
+ ;(start = 0), (len = this.length)
74
+ for (i = start; i < len; ) {
75
+ var isPass = true,
76
+ inx
65
77
  if (!hasLast) {
66
78
  inx = i
67
79
  } else {
@@ -102,4 +114,3 @@ Array.prototype.removeone = function (item) {
102
114
  }
103
115
  return -1
104
116
  }
105
-