ocpview-plus 0.0.1

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 (195) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +0 -0
  3. package/dist/efviewplus.min.esm.js +99954 -0
  4. package/dist/efviewplus.min.js +142 -0
  5. package/dist/locale/lang.js +1 -0
  6. package/dist/locale/zh-CN.js +1 -0
  7. package/dist/locale/zh-TW.js +1 -0
  8. package/dist/locale/zh-UG.js +1 -0
  9. package/dist/style.css +9 -0
  10. package/dist/styles/efviewplus.css +1 -0
  11. package/package.json +144 -0
  12. package/src/components/base/controlbase.vue +191 -0
  13. package/src/components/base/controlbox.vue +102 -0
  14. package/src/components/base/index.js +3 -0
  15. package/src/components/base/load.js +20 -0
  16. package/src/components/base/probase.js +220 -0
  17. package/src/components/base/size.js +78 -0
  18. package/src/components/billbox/billbox.vue +68 -0
  19. package/src/components/billbox/index.js +2 -0
  20. package/src/components/cascaderbox/cascaderbox.vue +184 -0
  21. package/src/components/cascaderbox/index.js +2 -0
  22. package/src/components/checkbox/checkbox.vue +76 -0
  23. package/src/components/checkbox/checkgroupbox.vue +104 -0
  24. package/src/components/checkbox/index.js +3 -0
  25. package/src/components/colorbox/colorbox.vue +44 -0
  26. package/src/components/colorbox/index.js +2 -0
  27. package/src/components/combobox/combobox.vue +220 -0
  28. package/src/components/combobox/index.js +2 -0
  29. package/src/components/conditionbox/conditionbase.vue +195 -0
  30. package/src/components/conditionbox/conditionbox.vue +63 -0
  31. package/src/components/conditionbox/conditionfilterbox.vue +477 -0
  32. package/src/components/conditionbox/conditionselectorbox.vue +237 -0
  33. package/src/components/conditionbox/index.js +5 -0
  34. package/src/components/conditionbox/queryconditionbox.vue +26 -0
  35. package/src/components/conditionbox/queryconditionboxbase.vue +124 -0
  36. package/src/components/conditionbox/searchconditionbox.vue +114 -0
  37. package/src/components/conditionbox/searchgrid.vue +391 -0
  38. package/src/components/datebox/datebox.vue +129 -0
  39. package/src/components/datebox/daterangebox.vue +155 -0
  40. package/src/components/datebox/index.js +3 -0
  41. package/src/components/form/baseform.vue +677 -0
  42. package/src/components/form/detailsbox.vue +487 -0
  43. package/src/components/form/formbox.vue +29 -0
  44. package/src/components/form/formcardbox.vue +268 -0
  45. package/src/components/form/formcardgroupbox.vue +252 -0
  46. package/src/components/form/formcompro.js +19 -0
  47. package/src/components/form/formdetail.vue +129 -0
  48. package/src/components/form/formdetailtwo.vue +302 -0
  49. package/src/components/form/index.js +8 -0
  50. package/src/components/form/toolanchor.js +46 -0
  51. package/src/components/form/workform.vue +168 -0
  52. package/src/components/grid/basegrid.vue +1061 -0
  53. package/src/components/grid/editgrid.vue +51 -0
  54. package/src/components/grid/editgridbase.vue +947 -0
  55. package/src/components/grid/editgridcard.vue +193 -0
  56. package/src/components/grid/expandrow.vue +137 -0
  57. package/src/components/grid/index.js +6 -0
  58. package/src/components/grid/viewgrid.vue +122 -0
  59. package/src/components/grid/viewgridbase.vue +1284 -0
  60. package/src/components/icon/common-icon.vue +53 -0
  61. package/src/components/icon/eicon.vue +29 -0
  62. package/src/components/icon/icons.vue +42 -0
  63. package/src/components/icon/index.js +2 -0
  64. package/src/components/label/index.js +3 -0
  65. package/src/components/label/showtext.vue +95 -0
  66. package/src/components/load/loadcartoon.vue +228 -0
  67. package/src/components/map/index.js +2 -0
  68. package/src/components/map/mapbox.vue +348 -0
  69. package/src/components/masterplate/appendix.vue +586 -0
  70. package/src/components/masterplate/approval.vue +803 -0
  71. package/src/components/masterplate/base.vue +985 -0
  72. package/src/components/masterplate/billasyncimport.vue +614 -0
  73. package/src/components/masterplate/billconditionbox.vue +224 -0
  74. package/src/components/masterplate/billconditionsbox.vue +427 -0
  75. package/src/components/masterplate/billdetailform.vue +990 -0
  76. package/src/components/masterplate/billimport.vue +263 -0
  77. package/src/components/masterplate/billquerygrid.vue +316 -0
  78. package/src/components/masterplate/billsinglegrid.vue +234 -0
  79. package/src/components/masterplate/birtreport.vue +185 -0
  80. package/src/components/masterplate/detailbtntoolbar.vue +311 -0
  81. package/src/components/masterplate/detailsbox.vue +386 -0
  82. package/src/components/masterplate/editgridcard.vue +222 -0
  83. package/src/components/masterplate/editgridcard2.vue +109 -0
  84. package/src/components/masterplate/formcard.vue +106 -0
  85. package/src/components/masterplate/formcardgroupbox.vue +168 -0
  86. package/src/components/masterplate/formdetailtwo.vue +356 -0
  87. package/src/components/masterplate/gridcolset.vue +227 -0
  88. package/src/components/masterplate/index.js +23 -0
  89. package/src/components/masterplate/layouttemplate.vue +33 -0
  90. package/src/components/masterplate/leftlistrightdetails.vue +474 -0
  91. package/src/components/masterplate/leftlistrightlist.vue +465 -0
  92. package/src/components/masterplate/lefttreerightdetails.vue +619 -0
  93. package/src/components/masterplate/levelreport.vue +510 -0
  94. package/src/components/masterplate/listbtntoolbar.vue +257 -0
  95. package/src/components/masterplate/listdetails.vue +769 -0
  96. package/src/components/masterplate/operlog.vue +272 -0
  97. package/src/components/masterplate/options.vue +110 -0
  98. package/src/components/masterplate/page.vue +102 -0
  99. package/src/components/masterplate/promptmessage.vue +74 -0
  100. package/src/components/masterplate/querybar.vue +490 -0
  101. package/src/components/masterplate/report.vue +357 -0
  102. package/src/components/masterplate/rowbtntoolbar.vue +126 -0
  103. package/src/components/masterplate/simpletree.vue +129 -0
  104. package/src/components/masterplate/simpleviewgrid.vue +144 -0
  105. package/src/components/mychart/bar/bar.vue +202 -0
  106. package/src/components/mychart/basechart.vue +190 -0
  107. package/src/components/mychart/complexmychart/barline.vue +154 -0
  108. package/src/components/mychart/gauge/gauge.vue +83 -0
  109. package/src/components/mychart/index.js +9 -0
  110. package/src/components/mychart/line/line.vue +202 -0
  111. package/src/components/mychart/liquidfill/liquidfill.vue +109 -0
  112. package/src/components/mychart/pie/pie.vue +96 -0
  113. package/src/components/mychart/radar/radar.vue +122 -0
  114. package/src/components/mychart/scatter/scatter.vue +76 -0
  115. package/src/components/numberbox/append.js +11 -0
  116. package/src/components/numberbox/index.js +3 -0
  117. package/src/components/numberbox/numberbox.vue +303 -0
  118. package/src/components/numberbox/numberrangebox.vue +423 -0
  119. package/src/components/picturebox/filebox.vue +365 -0
  120. package/src/components/picturebox/index.js +3 -0
  121. package/src/components/picturebox/picturebox.vue +541 -0
  122. package/src/components/picturebox/uploadbox.vue +164 -0
  123. package/src/components/poptagbox/index.js +2 -0
  124. package/src/components/poptagbox/poptagbox.vue +389 -0
  125. package/src/components/poptextbox/index.js +2 -0
  126. package/src/components/poptextbox/poptextbox.vue +601 -0
  127. package/src/components/radiobox/index.js +2 -0
  128. package/src/components/radiobox/radiogroupbox.vue +76 -0
  129. package/src/components/richtextbox/editor.vue +150 -0
  130. package/src/components/richtextbox/index.js +2 -0
  131. package/src/components/richtextbox/richtextbox.vue +448 -0
  132. package/src/components/textbox/index.js +2 -0
  133. package/src/components/textbox/textbox.vue +98 -0
  134. package/src/components/timebox/index.js +2 -0
  135. package/src/components/timebox/timebox.vue +76 -0
  136. package/src/components/toolbar/ebutton.vue +169 -0
  137. package/src/components/toolbar/index.js +3 -0
  138. package/src/components/toolbar/toolbar.vue +446 -0
  139. package/src/components/tree/basetree.vue +725 -0
  140. package/src/components/tree/index.js +3 -0
  141. package/src/components/tree/treedata.vue +51 -0
  142. package/src/components/tree/treedatabase.vue +189 -0
  143. package/src/components/upload/billimport.vue +233 -0
  144. package/src/components/upload/index.js +2 -0
  145. package/src/components/videobox/index.js +2 -0
  146. package/src/components/videobox/uploadbox.vue +148 -0
  147. package/src/components/videobox/videobox.vue +503 -0
  148. package/src/components/wrichtextbox/editor.vue +219 -0
  149. package/src/components/wrichtextbox/index.js +2 -0
  150. package/src/components/wrichtextbox/wrichtextbox.vue +63 -0
  151. package/src/index.js +215 -0
  152. package/src/locale/format.js +51 -0
  153. package/src/locale/index.js +63 -0
  154. package/src/locale/lang/zh-CN.js +123 -0
  155. package/src/locale/lang/zh-TW.js +114 -0
  156. package/src/locale/lang/zh-UG.js +115 -0
  157. package/src/locale/lang.js +15 -0
  158. package/src/method/case/case.js +1180 -0
  159. package/src/method/config/queryconfig.js +24 -0
  160. package/src/method/const/const.js +815 -0
  161. package/src/method/index.js +8 -0
  162. package/src/static/excel/exportexcel.js +627 -0
  163. package/src/static/iview/coustom.js +463 -0
  164. package/src/store/index.js +19 -0
  165. package/src/store/modules/app.js +53 -0
  166. package/src/styles/README.md +3 -0
  167. package/src/styles/common.less +75 -0
  168. package/src/styles/components/anchor.less +74 -0
  169. package/src/styles/components/approval.less +136 -0
  170. package/src/styles/components/button.less +208 -0
  171. package/src/styles/components/card.less +51 -0
  172. package/src/styles/components/content.less +38 -0
  173. package/src/styles/components/font.less +314 -0
  174. package/src/styles/components/form.less +72 -0
  175. package/src/styles/components/iconfont/fonts/iconfont.less +1376 -0
  176. package/src/styles/components/iconfont/fonts/iconfont.svg +699 -0
  177. package/src/styles/components/iconfont/fonts/iconfont.ttf +0 -0
  178. package/src/styles/components/iconfont/fonts/iconfont.woff +0 -0
  179. package/src/styles/components/iconfont/fonts/iconfont.woff2 +0 -0
  180. package/src/styles/components/index.less +16 -0
  181. package/src/styles/components/input.less +290 -0
  182. package/src/styles/components/modal.less +203 -0
  183. package/src/styles/components/page.less +340 -0
  184. package/src/styles/components/select.less +361 -0
  185. package/src/styles/components/steps.less +367 -0
  186. package/src/styles/components/table.less +544 -0
  187. package/src/styles/components/tabs.less +249 -0
  188. package/src/styles/components/upload.less +83 -0
  189. package/src/styles/custom.less +67 -0
  190. package/src/styles/index.less +6 -0
  191. package/src/styles/pack.less +6 -0
  192. package/src/utils/EfuMessenger.js +155 -0
  193. package/src/utils/assist.js +353 -0
  194. package/src/utils/index.js +1 -0
  195. package/src/utils/random_str.js +10 -0
@@ -0,0 +1,249 @@
1
+ @tabs-prefix-cls: ~"@{css-prefix}tabs";
2
+
3
+ .@{tabs-prefix-cls} {
4
+ box-sizing: border-box;
5
+ position: relative;
6
+ overflow: hidden;
7
+ color: @text-color;
8
+ .clearfix;
9
+
10
+ &-bar {
11
+ outline: none;
12
+ }
13
+
14
+ &-ink-bar {
15
+ height: 2px;
16
+ box-sizing: border-box;
17
+ background-color: @primary-color;
18
+ position: absolute;
19
+ left: 0;
20
+ bottom: 1px;
21
+ z-index: 1;
22
+ transition: transform .3s @ease-in-out;
23
+ transform-origin: 0 0;
24
+ }
25
+
26
+ &-bar {
27
+ border-bottom: 1px solid @border-color-base;
28
+ margin-bottom: @tab-bar-bottom;
29
+ }
30
+
31
+ &-nav-container {
32
+ margin-bottom: -1px;
33
+ line-height: @line-height-base;
34
+ font-size: @font-size-base;
35
+ box-sizing: border-box;
36
+ white-space: nowrap;
37
+ overflow: hidden;
38
+ position: relative;
39
+ .clearfix;
40
+ }
41
+
42
+ &-nav-container:focus {
43
+ outline: none;
44
+ .@{tabs-prefix-cls}-tab-focused {
45
+ border-color: @link-hover-color !important;
46
+ }
47
+ }
48
+
49
+ &-nav-container-scrolling {
50
+ padding-left: 32px;
51
+ padding-right: 32px;
52
+ }
53
+
54
+ &-nav-wrap {
55
+ overflow: hidden;
56
+ margin-bottom: -1px;
57
+ }
58
+
59
+ &-nav-scroll {
60
+ overflow: hidden;
61
+ white-space: nowrap;
62
+ }
63
+
64
+ &-nav-right{
65
+ float: right;
66
+ margin-left: 5px;
67
+ }
68
+
69
+ &-nav-prev, &-nav-next{
70
+ width: 32px;
71
+ text-align: center;
72
+ position: absolute;
73
+ line-height: 32px;
74
+ cursor: pointer;
75
+ i{
76
+ font-size: 16px;
77
+ }
78
+ }
79
+
80
+ &-nav-prev{
81
+ left: 0;
82
+ }
83
+
84
+ &-nav-next{
85
+ right: 0;
86
+ }
87
+
88
+ &-nav-scrollable{
89
+ padding: 0 32px;
90
+ }
91
+
92
+ &-nav-scroll-disabled{
93
+ display: none;
94
+ }
95
+
96
+ &-nav {
97
+ padding-left: 0;
98
+ margin: 0;
99
+ float: left;
100
+ list-style: none;
101
+ box-sizing: border-box;
102
+ position: relative;
103
+ transition: transform 0.5s @ease-in-out;
104
+
105
+ &:before,
106
+ &:after {
107
+ display: table;
108
+ content: " ";
109
+ }
110
+
111
+ &:after {
112
+ clear: both;
113
+ }
114
+
115
+ .@{tabs-prefix-cls}-tab-disabled {
116
+ pointer-events: none;
117
+ cursor: default;
118
+ color: #ccc;
119
+ }
120
+
121
+ .@{tabs-prefix-cls}-tab {
122
+ display: inline-block;
123
+ height: 100%;
124
+ padding: 8px 16px;
125
+ margin-right: 16px;
126
+ box-sizing: border-box;
127
+ cursor: pointer;
128
+ text-decoration: none;
129
+ position: relative;
130
+ transition: color .3s @ease-in-out;
131
+
132
+ &:hover {
133
+ color: @link-hover-color;
134
+ }
135
+
136
+ &:active {
137
+ color: @link-active-color;
138
+ }
139
+ .@{css-prefix-iconfont} {
140
+ width: 14px;
141
+ height: 14px;
142
+ margin-right: 8px;
143
+ }
144
+ }
145
+
146
+ .@{tabs-prefix-cls}-tab-active {
147
+ color: @primary-color;
148
+ }
149
+ }
150
+ &-mini &-nav-container {
151
+ font-size: @font-size-base;
152
+ }
153
+
154
+ &-mini &-tab {
155
+ margin-right: 0;
156
+ padding: 8px 16px;
157
+ font-size: @font-size-small;
158
+ }
159
+
160
+ & {
161
+ .@{tabs-prefix-cls}-content-animated {
162
+ display: flex;
163
+ flex-direction: row;
164
+ will-change: transform;
165
+ transition: transform .3s @ease-in-out;
166
+ }
167
+
168
+ .@{tabs-prefix-cls}-tabpane {
169
+ flex-shrink: 0;
170
+ width: 100%;
171
+ transition: opacity .3s;
172
+ opacity: 1;
173
+ outline: none;
174
+ }
175
+
176
+ .@{tabs-prefix-cls}-tabpane-inactive {
177
+ opacity: 0;
178
+ height: 0;
179
+ }
180
+ }
181
+
182
+ // card style
183
+ &&-card > &-bar &-nav-container {
184
+ height: 32px;
185
+ }
186
+ &&-card > &-bar &-ink-bar {
187
+ visibility: hidden;
188
+ }
189
+ &&-card > &-bar &-tab {
190
+ margin: 0;
191
+ margin-right: 4px;
192
+ height: 31px;
193
+ padding: 5px 16px 4px;
194
+ border: 1px solid @border-color-base;
195
+ border-bottom: 0;
196
+ border-radius: @btn-border-radius @btn-border-radius 0 0;
197
+ transition: all 0.3s @ease-in-out;
198
+ background: @table-thead-bg;
199
+ }
200
+ &&-card > &-bar &-tab-active {
201
+ height: 32px;
202
+ padding-bottom: 5px;
203
+ background: #fff;
204
+ transform: translateZ(0);
205
+ border-color: @border-color-base;
206
+ color: @primary-color;
207
+ }
208
+ &&-card > &-bar &-nav-wrap {
209
+ margin-bottom: 0;
210
+ }
211
+ &&-card > &-bar &-tab &-close {
212
+ width: 0;
213
+ height: 22px;
214
+ font-size: 22px;
215
+ margin-right: 0;
216
+ color: @legend-color;
217
+ text-align: right;
218
+ vertical-align: middle;
219
+ overflow: hidden;
220
+ position: relative;
221
+ top: -1px;
222
+ transform-origin: 100% 50%;
223
+ transition: all 0.3s @ease-in-out;
224
+ &:hover {
225
+ color: #444;
226
+ }
227
+ }
228
+
229
+ &&-card > &-bar &-tab-active &-close,
230
+ &&-card > &-bar &-tab:hover &-close {
231
+ width: 22px;
232
+ transform: translateZ(0);
233
+ margin-right: -6px;
234
+ }
235
+
236
+ &-context-menu{
237
+ position: absolute;
238
+ }
239
+ }
240
+
241
+ .@{tabs-prefix-cls}-no-animation{
242
+ > .@{tabs-prefix-cls}-content {
243
+ transform: none!important;
244
+
245
+ > .@{tabs-prefix-cls}-tabpane-inactive {
246
+ display: none;
247
+ }
248
+ }
249
+ }
@@ -0,0 +1,83 @@
1
+ @upload-prefix-cls: ~"@{css-prefix}upload";
2
+
3
+ .@{upload-prefix-cls} {
4
+ input[type="file"]{
5
+ display: none;
6
+ }
7
+
8
+ &-list{
9
+ margin-top: 8px;
10
+
11
+ &-file{
12
+ padding: 4px;
13
+ color: @text-color;
14
+ border-radius: @border-radius-small;
15
+ transition: background-color @transition-time @ease-in-out;
16
+ overflow: hidden;
17
+ position: relative;
18
+
19
+ & > span{
20
+ cursor: pointer;
21
+ transition: color @transition-time @ease-in-out;
22
+ i{
23
+ display: inline-block;
24
+ width: @font-size-small;
25
+ height: @font-size-small;
26
+ color: @text-color;
27
+ text-align: center;
28
+ }
29
+ }
30
+
31
+ &:hover{
32
+ background: @input-disabled-bg;
33
+ & > span{
34
+ color: @primary-color;
35
+ i{
36
+ color: @text-color;
37
+ }
38
+ }
39
+ .@{upload-prefix-cls}-list-remove{
40
+ opacity: 1;
41
+ }
42
+ }
43
+ }
44
+ &-remove{
45
+ opacity: 0;
46
+ font-size: 18px;
47
+ cursor: pointer;
48
+ float: right;
49
+ margin-right: 4px;
50
+ color: @legend-color;
51
+ transition: all @transition-time ease;
52
+ &:hover{
53
+ color: #444;
54
+ }
55
+ }
56
+ }
57
+
58
+ &-select {
59
+ display: inline-block;
60
+ }
61
+
62
+ &-drag{
63
+ background: @upload-drag-bg;
64
+ border: 1px dashed @border-color-base;
65
+ border-radius: @border-radius-small;
66
+ text-align: center;
67
+ cursor: pointer;
68
+ position: relative;
69
+ overflow: hidden;
70
+ transition: border-color @transition-time ease;
71
+
72
+ &:hover{
73
+ border: 1px dashed @primary-color;
74
+ }
75
+ }
76
+ &-dragOver{
77
+ border: 2px dashed @primary-color;
78
+ }
79
+ &-disabled {
80
+ .disabled();
81
+ }
82
+
83
+ }
@@ -0,0 +1,67 @@
1
+ // 自定义参数
2
+ // 自定义 table
3
+ @table-th-small-height: 32px;
4
+ @table-th-default-height: 40px;
5
+ @table-th-large-height: 48px;
6
+ @table-td-small-height: 40px;
7
+ @table-td-default-height: 48px;
8
+ @table-td-large-height: 60px;
9
+ @table-footer-small-height: 40px;
10
+ @table-footer-default-height: 48px;
11
+ @table-footer-large-height: 60px;
12
+ @table-cell-padding:18px;
13
+ @table-th-font-size:14px;
14
+ @table-td-font-size:14px;
15
+ @table-head-th-padding:5px 0px;
16
+
17
+ @table-th-default-height:40px;
18
+ @table-td-default-height:40px;
19
+ @table-footer-default-height: 40px;
20
+ @table-th-font-size:16px;
21
+ @table-td-font-size:14px;
22
+ @table-cell-padding:8px;
23
+ @form-item-margin-bottom:24px;
24
+
25
+ @page-font-hover-color:@primary-color;
26
+ @page-border-radius:@btn-border-radius;
27
+ @page-border-radius-small:@btn-border-radius-small;
28
+ @tab-bar-bottom:16px;
29
+ @table-border-width:1px;
30
+ @modal-body-padding:16px;
31
+ @modal-icon-size:31px;
32
+ @modal-icon-top:8px;
33
+ @modal-icon-right:8px;
34
+ @modal-header-border:1px;
35
+ @modal-header-color:#Fff;
36
+ @modal-header-padding:14px 16px;
37
+ @modal-top: 100px;
38
+ @combox-bg:#Fff;
39
+ @upload-drag-bg:#Fff;
40
+ @card-header-border:1px;
41
+ @card-header-padding:14px 16px;
42
+ @steps-background-color:#fff;
43
+ @page-background-color:#fff;
44
+ @page-item-font-weight:500;
45
+ @table-expended-cell-padding:20px 50px;
46
+
47
+ @title-font-color:#464c5b;
48
+ @title-font-weight:700;
49
+ @title-font-size-1:16px;
50
+ @title-font-size-2:14px;
51
+ @title-font-size-3:12px;
52
+ @table-border-width:0px;
53
+ @input-disabled-bg:#f8f8f9;
54
+ @table-td-hover-bg: #eaf4ff;
55
+ @table-td-highlight-bg: #e0eeff;
56
+ @form-item-margin-top:0px;
57
+ @body-background: #eee;
58
+ @input-disabled-font-color:#ccc;
59
+ @btn-icon-size:16px;
60
+ @efuture-checkbox-padding:6px;
61
+ @efuture-radiogroupbox-padding:6px;
62
+ @grid-head-required:@primary-color;
63
+ @boder-color:#DCDFE6;
64
+ @text-grey:#636569;
65
+ @asterisk-color:@primary-color;
66
+ @main-btn-disabled-color:#76b4f5;
67
+
@@ -0,0 +1,6 @@
1
+ //@import '../styles2/index.less';
2
+ //@import "../node_modules/view-ui-plus/src/styles/index.less"; //打包发布
3
+ @import 'view-ui-plus/src/styles/index.less'; //调试
4
+ @import './components/index.less';
5
+ @import './custom';
6
+ @import './common';
@@ -0,0 +1,6 @@
1
+ //@import '../styles2/index.less';
2
+ @import "../node_modules/view-ui-plus/src/styles/index.less"; //打包发布
3
+ //@import 'view-ui-plus/src/styles/index.less'; //调试
4
+ @import './components/index.less';
5
+ @import './custom';
6
+ @import './common';
@@ -0,0 +1,155 @@
1
+ const supportPostMessage = 'postMessage' in window
2
+
3
+ const serverMessageName = 'AMPframe'
4
+ const serverProjectName = 'AMP'
5
+
6
+ const clientMessageName = 'AMPclient'
7
+ const clientProjectName = 'AMP'
8
+ const clientTargetName = 'AMPframe'
9
+
10
+ class Target {
11
+ constructor(target, name, prefix) {
12
+ let errMsg = ''
13
+ if (arguments.length < 2) {
14
+ errMsg = 'target error - target and name are both required'
15
+ } else if (typeof target !== 'object') {
16
+ errMsg = 'target error - target itself must be window object'
17
+ } else if (typeof name !== 'string') {
18
+ errMsg = 'target error - target name must be string type'
19
+ }
20
+ if (errMsg) {
21
+ throw new Error(errMsg)
22
+ }
23
+ this.target = target
24
+ this.name = name
25
+ this.prefix = prefix
26
+ }
27
+ send(msg) {
28
+ if (supportPostMessage) {
29
+ this.target.postMessage(`${this.prefix}|${this.name}__Messenger__${msg}`, '*')
30
+ } else {
31
+ const targetFunc = window.navigator[this.prefix + this.name]
32
+ if (typeof targetFunc === 'function') {
33
+ targetFunc(this.prefix + msg, window)
34
+ } else {
35
+ throw new Error('target callback function is not defined')
36
+ }
37
+ }
38
+ }
39
+ }
40
+
41
+ class EfuMessenger {
42
+ constructor(messengerName, projectName) {
43
+ this.targets = {}
44
+ this.name = messengerName
45
+ this.listenFunc = []
46
+ this.prefix = projectName
47
+ this.initListen()
48
+ }
49
+ addTarget(target, name) {
50
+ const targetObj = new Target(target, name, this.prefix)
51
+ this.targets[name] = targetObj
52
+ }
53
+ listen(callback) {
54
+ let i = 0
55
+ const len = this.listenFunc.length
56
+ let cbIsExist = false
57
+ for (; i < len; i++) {
58
+ // 增加多组件对象定义重复声明判断
59
+ let o_fn_str = this.listenFunc[i].toString()
60
+ let n_fn_str = callback.toString()
61
+ if (o_fn_str === n_fn_str) {
62
+ this.listenFunc[i] = callback
63
+ cbIsExist = true
64
+ break
65
+ }
66
+ }
67
+ if (!cbIsExist) {
68
+ this.listenFunc.push(callback)
69
+ }
70
+ }
71
+ clear() {
72
+ this.listenFunc = []
73
+ }
74
+ send(msg) {
75
+ const { targets } = this
76
+ let target
77
+ for (target in targets) {
78
+ if (targets.hasOwnProperty(target)) {
79
+ targets[target].send(msg)
80
+ }
81
+ }
82
+ }
83
+ initListen() {
84
+ const self = this
85
+ const generalCallback = function (msg) {
86
+ if (typeof msg === 'object' && msg.data) {
87
+ msg = msg.data
88
+ }
89
+ if (typeof msg === 'string') {
90
+ const msgPairs = msg.split('__Messenger__')
91
+ var msg = msgPairs[1]
92
+ const pairs = msgPairs[0].split('|')
93
+ const prefix = pairs[0]
94
+ const name = pairs[1]
95
+ for (let i = 0; i < self.listenFunc.length; i++) {
96
+ if (prefix + name === self.prefix + self.name) {
97
+ self.listenFunc[i](msg)
98
+ }
99
+ }
100
+ }
101
+ }
102
+ if (supportPostMessage) {
103
+ if ('addEventListener' in document) {
104
+ window.addEventListener('message', generalCallback, false)
105
+ } else if ('attachEvent' in document) {
106
+ window.attachEvent('onmessage', generalCallback)
107
+ }
108
+ } else {
109
+ // 兼容IE 6/7
110
+ window.navigator[this.prefix + this.name] = generalCallback
111
+ }
112
+ }
113
+ }
114
+
115
+ class server {
116
+ constructor(messageName, projectName) {
117
+ this.messageName = messageName || serverMessageName
118
+ this.projectName = projectName || serverProjectName
119
+ return new EfuMessenger(this.messageName, this.projectName)
120
+ }
121
+ }
122
+
123
+ class client {
124
+ constructor(targetName, messageName, projectName) {
125
+ this.messengerOBJ = null
126
+ this.messageName = messageName || clientMessageName
127
+ this.targetName = targetName || clientTargetName
128
+ this.projectName = projectName || clientProjectName
129
+ this.init()
130
+ }
131
+ init() {
132
+ this.messengerOBJ = new EfuMessenger(this.messageName, this.projectName)
133
+ this.messengerOBJ.addTarget(window.parent, this.targetName)
134
+ }
135
+ openPortalTabPage(params) {
136
+ this.messengerOBJ.targets[this.targetName].send(
137
+ JSON.stringify({
138
+ name: this.messageName,
139
+ action: 'openPortalTabPage',
140
+ params: { ...params }
141
+ })
142
+ )
143
+ }
144
+ openPortalTabByModuleCode(params) {
145
+ this.messengerOBJ.targets[this.targetName].send(
146
+ JSON.stringify({
147
+ name: this.messageName,
148
+ action: 'openPortalTabByModuleCode',
149
+ params: { ...params }
150
+ })
151
+ )
152
+ }
153
+ }
154
+
155
+ export { EfuMessenger, server, client }