safecheck-client 3.0.34-39 → 3.0.34-42

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.
@@ -0,0 +1,421 @@
1
+ <template>
2
+ <div v-el:group class="btn-group" v-bind:class="{open: show, dropup: direction === 'up'}" :style="{width:width, fontSize: fontSize}">
3
+ <button v-el:btn type="button" class="btn btn-default dropdown-toggle select-style" :style="{minWidth: '100%', fontSize: fontSize}"
4
+ :id="'vc-select-button-'+attach"
5
+ @click="toggleDropdown"
6
+ @blur="show = (search ? show : false)"
7
+ v-bind="{disabled: disabled}"
8
+ >
9
+ <span class="btn-placeholder" v-show="showPlaceholder">{{placeholder}}</span>
10
+ <span class="btn-content" :style="{textOverflow:'ellipsis',overflow: 'hidden'}">{{ selectedItems }}</span>
11
+ <span class="caret"></span>
12
+ </button>
13
+ <ul class="dropdown-menu" v-bind:class="{'menu-align-right': align=== 'right'}" :style="{overflow:'scroll',maxHeight: maxHeight + 'px',width: menuWidth,minWidth:minWidth,left:left+'px', fontSize: fontSize }" v-el:dropdown>
14
+ <template v-if="options.length">
15
+ <li v-if="search" class="bs-searchbox" style="white-space: nowrap">
16
+ <input type="text" placeholder="Search"
17
+ style="width: 80%;display: inline"
18
+ v-model="searchText"
19
+ class="form-control" autocomplete="off"
20
+ @keyup.enter="putOptions(searchText)">
21
+
22
+ <span style="width: 20%;display: inline"
23
+ v-if="search&&multiple&&show&&!isSelectAll"
24
+ @mousedown.prevent="selectAll(options)">全选</span>
25
+ <span style="width: 20%;display: inline"
26
+ v-if="search&&multiple&&show&&isSelectAll"
27
+ @mousedown.prevent="selectAll(options)">取消</span>
28
+ </li>
29
+ <li v-for="option in options | findBy searchText " style="position:relative">
30
+ <a @mousedown.prevent="select(option.value,null)" style="cursor:pointer" :id="'vc-select-a-'+attach+'-'+$index">
31
+ {{ option.label }}
32
+ <span class="glyphicon glyphicon-ok check-mark" v-show="isSelected(option.value)"></span>
33
+ </a>
34
+ </li>
35
+ </template>
36
+ <slot v-else></slot>
37
+ <div class="notify" v-show="showNotify" transition="fadein">Limit reached ({{limit}} items max).
38
+ </div>
39
+ </ul>
40
+ </div>
41
+ </template>
42
+
43
+ <script>
44
+ import EventListener from '../utils/EventListener'
45
+ import coerceBoolean from '../utils/coerceBoolean.js'
46
+
47
+ export default {
48
+ props: {
49
+ options: {
50
+ type: Array,
51
+ default() { return [] },
52
+ },
53
+ value: {
54
+ twoWay: true
55
+ },
56
+ placeholder: {
57
+ type: String,
58
+ default: '请选择'
59
+ },
60
+ multiple: {
61
+ type: Boolean,
62
+ coerce: coerceBoolean,
63
+ default: false
64
+ },
65
+ search: { // Allow searching (only works when options are provided)
66
+ type: Boolean,
67
+ coerce: coerceBoolean,
68
+ default: true
69
+ },
70
+ limit: {
71
+ type: Number,
72
+ default: 1024
73
+ },
74
+ closeOnSelect: { // only works when multiple==false
75
+ type: Boolean,
76
+ coerce: coerceBoolean,
77
+ default: false
78
+ },
79
+ disabled: {
80
+ type: Boolean,
81
+ coerce: coerceBoolean,
82
+ default: false
83
+ },
84
+ attach: {
85
+ type: String,
86
+ default: 'vuestrap'
87
+ },
88
+ enterPush: {
89
+ type: Boolean,
90
+ dafault: false
91
+ },
92
+ maxHeight: {
93
+ type: [Number,String],
94
+ default: 300
95
+ },
96
+ minWidth:{
97
+ type:[Number,String],
98
+ default:'100%'
99
+ },
100
+ valueSingle: {
101
+ type: Boolean,
102
+ default: false
103
+ },
104
+ //全选标志位
105
+ isSelectAll: {
106
+ type: Boolean,
107
+ default: false
108
+ },
109
+ filerKey: {
110
+ default: 'id'
111
+ },
112
+ direction: { // 展开方向,默认为向下,可以向上up
113
+ type: String,
114
+ default: 'down'
115
+ },
116
+ align: {
117
+ type: String,
118
+ default: 'left' // 内内容框对齐方式,默认是左对齐,也可以right,右对齐
119
+ },
120
+ width:{
121
+ type:String,
122
+ default:'60%'
123
+ },
124
+ timeout: {
125
+ type: Number,
126
+ default: 300
127
+ },
128
+ fontSize: {
129
+ type: String,
130
+ default: '16px'
131
+ },
132
+ menuMode: {
133
+ type: String
134
+ }
135
+ },
136
+ ready() {
137
+ if(this.search&&this.multiple){
138
+ this.minWidth='190px'
139
+ }
140
+ // 如果this.value不存在或正length不等于0
141
+ if ((this.value === false? false :!this.value) || this.value.length === 0) {
142
+ if (this.valueSingle) {
143
+ this.value = ''
144
+ } else {
145
+ this.value = []
146
+ }
147
+ }else {
148
+ // 如果this.value不是数组
149
+ if (this.value.constructor !== Array) {
150
+ if (!this.valueSingle) {
151
+ this.value = [this.value]
152
+ }
153
+ } else {
154
+ // this.value不是数组并且不是多选
155
+ if (!this.multiple && this.value.length > 1) {
156
+ this.value = this.value.slice(0, 1)
157
+ } else if (this.multiple && this.value.length > this.limit) {
158
+ this.value = this.value.slice(0, this.limit)
159
+ }
160
+ }
161
+ }
162
+ let el = this.$els.dropdown
163
+ let elbtn = this.$els.btn
164
+ this._closeEvent = EventListener.listen(window, 'mouseup', (e)=> {
165
+ if (!el.contains(e.target) && this.show && !elbtn.contains(e.target)) {
166
+ this.show = false
167
+ }
168
+ })
169
+ },
170
+ data() {
171
+ return {
172
+ left:'0',
173
+
174
+ searchText: null,
175
+ show: false,
176
+ showNotify: false,
177
+ paramsData: [],
178
+ // isShowModify: false
179
+ timer: null,
180
+ menuwidth: 'auto'
181
+ }
182
+ },
183
+ computed: {
184
+ // 返回显示的选择内容
185
+ selectedItems() {
186
+ // 值为空,返回空串
187
+ if (this.value === false? false: !this.value) {
188
+ return ''
189
+ }
190
+ // 把单选变成数组
191
+ let value
192
+ if (this.valueSingle) {
193
+ value = [this.value]
194
+ } else {
195
+ value = this.value
196
+ }
197
+
198
+ // 根据value值,找到label
199
+ let foundItems = []
200
+ if (value === false?true:value && value.length) {
201
+ for (var item of value) {
202
+ // 如果没有可选项,直接value内容
203
+ if (this.options.length === 0)
204
+ {
205
+ foundItems = value;
206
+ }
207
+ // 有可选项
208
+ else
209
+ {
210
+ // 如果是对象,显示对象给定的列
211
+ if (typeof item === "object") {
212
+ for(let o of this.options) {
213
+ // 选中对象鱼可选项value值相同,取选项的label
214
+ if((o.value === false?true:o.value)&& o.value[this.filerKey] === item[this.filerKey]) {
215
+ foundItems.push(o.label)
216
+ break
217
+ }
218
+ }
219
+ } else {
220
+ // 否则,显示值本身
221
+ let option
222
+ this.options.some(o => {
223
+ if(o.value === item) {
224
+ option = o
225
+ return true
226
+ }
227
+ })
228
+ option && foundItems.push(option.label)
229
+ }
230
+ }
231
+ }
232
+ if (foundItems.length === 0 || foundItems[0].constructor === Object) {
233
+ return ''
234
+ }
235
+ //选中的
236
+ let str= foundItems.join(', ')
237
+ // if(str.length > 4)
238
+ // return str.substring(0,4)+'...'
239
+ // else
240
+ return str
241
+ }
242
+ },
243
+ showPlaceholder() {
244
+ if (this.value ===false? true :this.value) {
245
+ return this.value.length === 0 || this.selectedItems === ''
246
+ }
247
+ return true
248
+ }
249
+ },
250
+ watch: {
251
+ menuMode: {
252
+ immediate: true,
253
+ handler() {
254
+ if (this.menuMode == 'align-button'){
255
+ this.menuWidth = '100%'
256
+ }
257
+ }
258
+ },
259
+ value(val) {
260
+ this.$emit('change', val)
261
+ this.$emit('selected', this.selected)
262
+ if (val && val.length > this.limit) {
263
+ this.showNotify = true
264
+ this.value.pop()
265
+ setTimeout(() => this.showNotify = false, 1000)
266
+ }
267
+ },
268
+ show(){
269
+ this.judgBoundary();
270
+ },
271
+ searchText() {
272
+ // 防抖
273
+ if (this.timer) {
274
+ clearTimeout(this.timer)
275
+ }
276
+ this.timer = setTimeout(() => {
277
+ this.$emit('select-search', this.searchText)
278
+ }, this.timeout)
279
+ }
280
+ },
281
+ methods: {
282
+ //全选
283
+ selectAll(v) {
284
+ this.isSelectAll=!this.isSelectAll
285
+ if(this.searchText === null){
286
+ v.forEach((item) => {
287
+ this.select(item.value, this.isSelectAll)
288
+ })
289
+ }else {
290
+ let result= v.filter((item) => {
291
+ return item.label.includes(this.searchText)
292
+ }).forEach((item) => {
293
+ this.select(item.value, this.isSelectAll)
294
+ })
295
+ }
296
+ },
297
+ select (v, flag) {
298
+ if (flag == true) {
299
+ if (this.multiple) {
300
+ this.value.$remove(v)
301
+ this.value.push(v)
302
+ } else if (this.closeOnSelect) {
303
+ this.toggleDropdown()
304
+ }
305
+ } else if (flag == false) {
306
+ if (this.multiple) {
307
+ this.value.$remove(v)
308
+ } else if (this.closeOnSelect) {
309
+ this.toggleDropdown()
310
+ }
311
+ } else if (flag == null) {
312
+ if (this.valueSingle || !this.value || this.value.indexOf(v) === -1) {
313
+ if (this.multiple) {
314
+ this.value.push(v)
315
+ } else {
316
+ if (this.value == v) {
317
+ this.value = undefined
318
+ } else if (this.valueSingle) {
319
+ this.value = v
320
+ } else {
321
+ this.value = [v]
322
+ }
323
+ }
324
+ } else {
325
+ if (this.multiple || this.value) {
326
+ this.value.$remove(v)
327
+ }
328
+ }
329
+ if (this.closeOnSelect) {
330
+ this.toggleDropdown()
331
+ }
332
+ }
333
+ this.judgBoundary()
334
+ this.$emit('select-changed', v)
335
+ },
336
+
337
+ isSelected(v) {
338
+ if (this.value === false? false: !this.value) {
339
+ return false
340
+ }
341
+ if (this.value.constructor !== Array) {
342
+ return this.value == v
343
+ } else {
344
+ return this.value.indexOf(v) !== -1
345
+ }
346
+
347
+ },
348
+ toggleDropdown() {
349
+ this.width = this.$els.group.clientWidth * this.width +'px'
350
+ this.show = !this.show
351
+ },
352
+ putOptions (val) {
353
+ if (this.enterPush) {
354
+ let sign = false
355
+ this.options.forEach((item) => {
356
+ if (val === item.label) {
357
+ sign = true
358
+ }
359
+ })
360
+ }
361
+ this.judgBoundary();
362
+ },
363
+ judgBoundary(){
364
+ //判断是否超出边界,超出移动
365
+ if(this.menuMode != 'align-button' && document.documentElement.offsetWidth< this.$els.dropdown.getBoundingClientRect().right){
366
+ this.left = document.documentElement.offsetWidth - this.$els.dropdown.getBoundingClientRect().right - 25
367
+ }
368
+ }
369
+ },
370
+ beforeDestroy() {
371
+ if (this._closeEvent) this._closeEvent.remove()
372
+ }
373
+ }
374
+ </script>
375
+
376
+ <style scoped>
377
+ .bs-searchbox {
378
+ padding: 4px 8px;
379
+ }
380
+ .menu-align-right {
381
+ left: unset;
382
+ right: 0;
383
+ }
384
+ .btn-group .dropdown-menu .notify {
385
+ position: absolute;
386
+ bottom: 5px;
387
+ width: 96%;
388
+ margin: 0 2%;
389
+ min-height: 26px;
390
+ padding: 3px 5px;
391
+ background: #f5f5f5;
392
+ /*border: 1px solid #e3e3e3;*/
393
+ box-shadow: inset 0 1px 1px rgba(0,0,0,.05);
394
+ pointer-events: none;
395
+ opacity: .9;
396
+ overflow: hidden;
397
+ text-overflow: ellipsis;
398
+ }
399
+ .select-style {
400
+ border: 0px;
401
+ /*border-bottom: 2px solid #C9CCCF;*/
402
+ border: 1px solid #93B2D3;
403
+ border-radius: 0px;
404
+ color: #555;
405
+ overflow:hidden;text-overflow:ellipsis;
406
+ }
407
+ /* 为新产品增加修改菜单选项 */
408
+ .vselect-self-style {
409
+ text-align: center;
410
+ border: 2px dashed #ccc;
411
+ margin: 5px 10px;
412
+ border-radius: 5px;
413
+ }
414
+ /* 当内容超过最大时,显示省略,长度不能超过最大值 */
415
+ .btn-group > button {
416
+ max-width: 100%;
417
+ }
418
+ .btn-group > button .btn-content {
419
+ max-width: 100%;
420
+ }
421
+ </style>
@@ -1,20 +1,21 @@
1
- // 分公司特殊组件页面注册
2
- import Vue from "vue";
3
-
4
- // 手机特殊目录注册到该文件中
5
- let specialComp = {
6
- 'safecheck-order-v': (resolve) => { require(['./android/SafecheckOrderV'], resolve) },
7
- 'paper-feedback' : (resolve) => { require(['./android/PaperFeedback'], resolve) },
8
- 'safecheck-userinfo' : (resolve) => { require(['./android/SafecheckUserInfo'], resolve) },
9
- 'safecheck-devices' : (resolve) => { require(['./android/SafecheckDevices'], resolve) },
10
- 'switch-valve' : (resolve) => { require(['./android/SwitchValve'], resolve) },
11
- 'current-create' : (resolve) => { require(['./android/CurrentCreate'], resolve) },
12
- 'add-plan-item' : (resolve) => { require(['./android/AddPlanItem'], resolve) },
13
- 'PhoneUpUserinfo' : (resolve) => { require(['./android/PhoneUpUserinfo'], resolve) },
14
- 'PhoneUpDetail': (resolve) => { require(['./android/PhoneUpDetail'], resolve) },
15
- 'phone-record-info' : (resolve) => { require(['./android/PhoneRecordInfo'], resolve) },
16
- 'android-defect-deal' : (resolve) => { require(['./android/AndroidDefectDeal'], resolve) }
17
- }
18
-
19
- exports.specialComp = specialComp
20
-
1
+ // 分公司特殊组件页面注册
2
+ import Vue from "vue";
3
+
4
+ // 手机特殊目录注册到该文件中
5
+ let specialComp = {
6
+ 'safecheck-order-v': (resolve) => { require(['./android/SafecheckOrderV'], resolve) },
7
+ 'v-select': (resolve) => { require(['./android/Select'], resolve) },
8
+ 'paper-feedback' : (resolve) => { require(['./android/PaperFeedback'], resolve) },
9
+ 'safecheck-userinfo' : (resolve) => { require(['./android/SafecheckUserInfo'], resolve) },
10
+ 'safecheck-devices' : (resolve) => { require(['./android/SafecheckDevices'], resolve) },
11
+ 'switch-valve' : (resolve) => { require(['./android/SwitchValve'], resolve) },
12
+ 'current-create' : (resolve) => { require(['./android/CurrentCreate'], resolve) },
13
+ 'add-plan-item' : (resolve) => { require(['./android/AddPlanItem'], resolve) },
14
+ 'PhoneUpUserinfo' : (resolve) => { require(['./android/PhoneUpUserinfo'], resolve) },
15
+ 'PhoneUpDetail': (resolve) => { require(['./android/PhoneUpDetail'], resolve) },
16
+ 'phone-record-info' : (resolve) => { require(['./android/PhoneRecordInfo'], resolve) },
17
+ 'android-defect-deal' : (resolve) => { require(['./android/AndroidDefectDeal'], resolve) }
18
+ }
19
+
20
+ exports.specialComp = specialComp
21
+
@@ -0,0 +1,29 @@
1
+ const EventListener = {
2
+ /**
3
+ * Listen to DOM events during the bubble phase.
4
+ *
5
+ * @param {DOMEventTarget} target DOM element to register listener on.
6
+ * @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
7
+ * @param {function} callback Callback function.
8
+ * @return {object} Object with a `remove` method.
9
+ */
10
+ listen(target, eventType, callback) {
11
+ if (target.addEventListener) {
12
+ target.addEventListener(eventType, callback, false)
13
+ return {
14
+ remove() {
15
+ target.removeEventListener(eventType, callback, false)
16
+ }
17
+ }
18
+ } else if (target.attachEvent) {
19
+ target.attachEvent('on' + eventType, callback)
20
+ return {
21
+ remove() {
22
+ target.detachEvent('on' + eventType, callback)
23
+ }
24
+ }
25
+ }
26
+ }
27
+ }
28
+
29
+ export default EventListener
@@ -0,0 +1,7 @@
1
+ // Attempt to convert a string value to a Boolean. Otherwise, return the value
2
+ // without modification so Vue can throw a warning.
3
+ export default (val) => (typeof val !== "string" ? val :
4
+ val === "true" ? true :
5
+ val === "false" ? false :
6
+ val === "null" ? false :
7
+ val === "undefined" ? false : val)