xrk-components 0.1.0 → 0.3.2
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/.babelrc +2 -11
- package/lib/index.css +18560 -0
- package/lib/index.esm.js +2958 -0
- package/lib/index.umd.js +2997 -0
- package/package.json +47 -69
- package/rollup.config.js +59 -0
- package/tsconfig.json +24 -0
- package/typings/shims-vue.d.ts +6 -0
- package/.editorconfig +0 -9
- package/.eslintrc.js +0 -40
- package/.prettierrc.js +0 -16
- package/debug.log +0 -1
- package/dist/bundler.js +0 -7
- package/dist/bundler.js.map +0 -1
- package/index.html +0 -19
- package/src/App.vue +0 -134
- package/src/lib/index.js +0 -27
- package/src/main.js +0 -25
- package/src/packages/dialog/index.js +0 -32
- package/src/packages/dialog/src/main.vue +0 -197
- package/src/packages/slide-verify/index.js +0 -12
- package/src/packages/slide-verify/src/main.vue +0 -479
- package/src/packages/slide-verify/src/static/close.png +0 -0
- package/src/packages/slide-verify/src/static/placeholder.png +0 -0
- package/src/packages/slide-verify/src/static/range_btn.png +0 -0
- package/src/packages/slide-verify/src/static/refresh.png +0 -0
- package/src/packages/task-detail/index.js +0 -12
- package/src/packages/task-detail/src/components/formDetail.vue +0 -79
- package/src/packages/task-detail/src/components/mixin.js +0 -105
- package/src/packages/task-detail/src/components/styles/index.scss +0 -162
- package/src/packages/task-detail/src/components/surveyDetail.vue +0 -337
- package/src/packages/task-detail/src/config/fields.js +0 -655
- package/src/packages/task-detail/src/config/index.js +0 -34
- package/src/packages/task-detail/src/main.vue +0 -108
- package/src/packages/task-detail/src/static/fieldsMap.js +0 -274
- package/src/packages/task-detail/src/test/testData.js +0 -743
- package/src/packages/task-detail/src/tools/index.js +0 -290
- package/webpack.config.js +0 -93
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
* @Description:
|
|
3
|
-
* @LastEditors: xinzeedu@163.com
|
|
4
|
-
* @Date: 2021年2月20日12:03:16
|
|
5
|
-
-->
|
|
6
|
-
<template>
|
|
7
|
-
<div class="v-box" style="display: inline-block">
|
|
8
|
-
<slot></slot>
|
|
9
|
-
<transition name="fade">
|
|
10
|
-
<div class="v-box_box" v-show="visible" :style="boxStyle">
|
|
11
|
-
<!-- <div class="v-box_box">-->
|
|
12
|
-
<i class="v-box_close" @click="close"></i>
|
|
13
|
-
<p class="v-box_title">安全验证</p>
|
|
14
|
-
<p class="v-box_sub">拖动下方滑块完成拼图</p>
|
|
15
|
-
<div class="v-box_img" ref="imgWrap">
|
|
16
|
-
<img class="v-box_img_bg" ref="imgBg" :src="defaultImg" />
|
|
17
|
-
<img class="v-box_img_icon" ref="imgIcon" :src="defaultImg" />
|
|
18
|
-
</div>
|
|
19
|
-
<div class="v-box_range" ref="range">
|
|
20
|
-
<div class="v-box_range_track"></div>
|
|
21
|
-
<button class="v-box_range_btn" ref="rangeBtn"></button>
|
|
22
|
-
<div class="v-box_range_mask" ref="rangeMask"></div>
|
|
23
|
-
</div>
|
|
24
|
-
<div class="v-box_foot">
|
|
25
|
-
<div>
|
|
26
|
-
<span style="color: #ff0000" v-if="error">
|
|
27
|
-
{{ options.errorText }}
|
|
28
|
-
</span>
|
|
29
|
-
<span style="color: #00ff5d" v-if="success">
|
|
30
|
-
{{ options.successText }}
|
|
31
|
-
</span>
|
|
32
|
-
</div>
|
|
33
|
-
<img
|
|
34
|
-
@click="refresh"
|
|
35
|
-
class="v-box_foot_refresh"
|
|
36
|
-
src="./static/refresh.png"
|
|
37
|
-
alt=""
|
|
38
|
-
/>
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
</transition>
|
|
42
|
-
</div>
|
|
43
|
-
</template>
|
|
44
|
-
<script>
|
|
45
|
-
import defaultImg from './static/placeholder.png';
|
|
46
|
-
export default {
|
|
47
|
-
name: 'XrkSlideVerify',
|
|
48
|
-
props: {
|
|
49
|
-
options: {
|
|
50
|
-
type: [Object],
|
|
51
|
-
default: () => ({
|
|
52
|
-
remoteTimerInterval: 800,
|
|
53
|
-
errorText: '请控制拼图块对齐缺口',
|
|
54
|
-
successText: '验证成功',
|
|
55
|
-
remoteApi: {
|
|
56
|
-
// 获取图片,拼图Y轴
|
|
57
|
-
initImages: '',
|
|
58
|
-
// 验证接口
|
|
59
|
-
checkVerification: ''
|
|
60
|
-
},
|
|
61
|
-
errorAnimationDuration: 0
|
|
62
|
-
})
|
|
63
|
-
},
|
|
64
|
-
// position:{
|
|
65
|
-
// validator: function (value) {
|
|
66
|
-
// return !['top-right', 'top-left', 'bottom-right','bottom-left','auto'].indexOf(value)
|
|
67
|
-
// }
|
|
68
|
-
// }
|
|
69
|
-
boxStyle: {
|
|
70
|
-
type: [Object],
|
|
71
|
-
default: () => ({})
|
|
72
|
-
},
|
|
73
|
-
hasMask: {
|
|
74
|
-
type: [Boolean],
|
|
75
|
-
default: false
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
data() {
|
|
79
|
-
return {
|
|
80
|
-
visible: false,
|
|
81
|
-
error: false,
|
|
82
|
-
success: false,
|
|
83
|
-
startBtnX: 0,
|
|
84
|
-
requestLock: false,
|
|
85
|
-
remoteTimerId: '',
|
|
86
|
-
remoteTimerInterval: 600,
|
|
87
|
-
animationDuration: 300,
|
|
88
|
-
y: '',
|
|
89
|
-
x: '',
|
|
90
|
-
defaultImg: defaultImg
|
|
91
|
-
};
|
|
92
|
-
},
|
|
93
|
-
watch: {
|
|
94
|
-
visible: {
|
|
95
|
-
handler: function(v) {
|
|
96
|
-
if (v) {
|
|
97
|
-
this.initImg();
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
immediate: true
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
methods: {
|
|
104
|
-
refresh() {
|
|
105
|
-
this.error = false;
|
|
106
|
-
this.initImg();
|
|
107
|
-
},
|
|
108
|
-
// 手动关闭
|
|
109
|
-
close() {
|
|
110
|
-
this.$refs['imgBg'].src = defaultImg;
|
|
111
|
-
this.$refs['imgIcon'].src = defaultImg;
|
|
112
|
-
Object.assign(this.$data, this.$options.data());
|
|
113
|
-
this.$emit('close');
|
|
114
|
-
},
|
|
115
|
-
// 初始化图片
|
|
116
|
-
initImg() {
|
|
117
|
-
this.startBtnX = 0;
|
|
118
|
-
// let rangeBtn = this.$refs['rangeBtn'];
|
|
119
|
-
let imgBg = this.$refs['imgBg'];
|
|
120
|
-
let imgIcon = this.$refs['imgIcon'];
|
|
121
|
-
return new Promise((resolve, reject) => {
|
|
122
|
-
this.options['remoteApi']
|
|
123
|
-
.initImages()
|
|
124
|
-
.then(res => {
|
|
125
|
-
const {
|
|
126
|
-
data: {
|
|
127
|
-
data: {
|
|
128
|
-
shadeImage,
|
|
129
|
-
cutoutImage,
|
|
130
|
-
y,
|
|
131
|
-
cutoutImageWeight,
|
|
132
|
-
cutoutImageHeight,
|
|
133
|
-
shadeImageWeight,
|
|
134
|
-
shadeImageHeight
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
} = res;
|
|
138
|
-
let rangeBtn = this.$refs['rangeBtn'];
|
|
139
|
-
rangeBtn.style.left = '0px';
|
|
140
|
-
imgIcon.style.left = '0px';
|
|
141
|
-
|
|
142
|
-
imgIcon.style.width = cutoutImageWeight + 'px';
|
|
143
|
-
imgIcon.style.height = cutoutImageHeight + 'px';
|
|
144
|
-
|
|
145
|
-
imgBg.style.width = shadeImageWeight + 'px';
|
|
146
|
-
imgBg.style.height = shadeImageHeight + 'px';
|
|
147
|
-
|
|
148
|
-
imgBg.src = /data:image\/(jpg|png);base64,/.test(shadeImage)
|
|
149
|
-
? shadeImage
|
|
150
|
-
: 'data:image/jpg;base64,' + shadeImage;
|
|
151
|
-
|
|
152
|
-
imgIcon.src = /data:image\/(jpg|png);base64,/.test(cutoutImage)
|
|
153
|
-
? cutoutImage
|
|
154
|
-
: 'data:image/png;base64,' + cutoutImage;
|
|
155
|
-
|
|
156
|
-
imgIcon.style.top = y + 'px';
|
|
157
|
-
// FIXME
|
|
158
|
-
this.y = y;
|
|
159
|
-
resolve();
|
|
160
|
-
})
|
|
161
|
-
.catch(reject);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
mounted() {
|
|
166
|
-
let rangeBtn = this.$refs['rangeBtn'];
|
|
167
|
-
let rangeMask = this.$refs['rangeMask'];
|
|
168
|
-
let imgBg = this.$refs['imgBg'];
|
|
169
|
-
let imgIcon = this.$refs['imgIcon'];
|
|
170
|
-
|
|
171
|
-
// 移动滑块
|
|
172
|
-
let moveRangeBtn = e => {
|
|
173
|
-
e.preventDefault();
|
|
174
|
-
if (e.type === 'mousemove') {
|
|
175
|
-
rangeBtn.style.left = `${Math.max(0, e.offsetX - this.startBtnX)}px`;
|
|
176
|
-
imgIcon.style.left = `${Math.max(0, e.offsetX - this.startBtnX)}px`;
|
|
177
|
-
}
|
|
178
|
-
if (e.type === 'touchmove') {
|
|
179
|
-
rangeBtn.style.left = `${Math.max(
|
|
180
|
-
0,
|
|
181
|
-
e.touches[0].pageX - this.startBtnX
|
|
182
|
-
)}px`;
|
|
183
|
-
imgIcon.style.left = `${Math.max(
|
|
184
|
-
0,
|
|
185
|
-
e.touches[0].pageX - this.startBtnX
|
|
186
|
-
)}px`;
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
// 按下鼠标 监听 move 和 leave
|
|
191
|
-
rangeMask.addEventListener(
|
|
192
|
-
'mousedown',
|
|
193
|
-
e => {
|
|
194
|
-
if (e.offsetX > rangeBtn.offsetWidth || e.offsetX < 0) return;
|
|
195
|
-
|
|
196
|
-
// 点击区域 是按钮的位置
|
|
197
|
-
this.startBtnX = e.offsetX;
|
|
198
|
-
rangeMask.addEventListener('mousemove', moveRangeBtn);
|
|
199
|
-
// 抬起或者离开,监听一种即可
|
|
200
|
-
rangeMask.addEventListener('mouseup', remoteVerification);
|
|
201
|
-
rangeMask.addEventListener('mouseup', () =>
|
|
202
|
-
rangeMask.removeEventListener('mouseleave', remoteVerification)
|
|
203
|
-
);
|
|
204
|
-
rangeMask.addEventListener('mouseup', () =>
|
|
205
|
-
rangeMask.removeEventListener('mousemove', moveRangeBtn)
|
|
206
|
-
);
|
|
207
|
-
|
|
208
|
-
rangeMask.addEventListener('mouseleave', remoteVerification);
|
|
209
|
-
rangeMask.addEventListener('mouseleave', () =>
|
|
210
|
-
rangeMask.removeEventListener('mouseup', remoteVerification)
|
|
211
|
-
);
|
|
212
|
-
rangeMask.addEventListener('mouseleave', () =>
|
|
213
|
-
rangeMask.removeEventListener('mousemove', moveRangeBtn)
|
|
214
|
-
);
|
|
215
|
-
},
|
|
216
|
-
false
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
rangeMask.addEventListener(
|
|
220
|
-
'touchstart',
|
|
221
|
-
e => {
|
|
222
|
-
// if (e.touches[0].pageX > rangeBtn.offsetWidth || e.touches[0].pageX < 0)
|
|
223
|
-
// return;
|
|
224
|
-
e.preventDefault();
|
|
225
|
-
// 点击区域 是按钮的位置
|
|
226
|
-
this.startBtnX = e.touches[0].pageX;
|
|
227
|
-
rangeMask.addEventListener('touchmove', moveRangeBtn);
|
|
228
|
-
// 抬起或者离开,监听一种即可
|
|
229
|
-
rangeMask.addEventListener('touchend', remoteVerification);
|
|
230
|
-
},
|
|
231
|
-
false
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
// 服务器验证
|
|
235
|
-
const remoteVerification = e => {
|
|
236
|
-
let imgIcon = this.$refs['imgIcon'];
|
|
237
|
-
|
|
238
|
-
e.preventDefault();
|
|
239
|
-
if (this.requestLock) return;
|
|
240
|
-
this.requestLock = true;
|
|
241
|
-
|
|
242
|
-
let x;
|
|
243
|
-
|
|
244
|
-
if (~e.type.indexOf('touch')) {
|
|
245
|
-
x = imgIcon.style.left.replace('px', '');
|
|
246
|
-
} else {
|
|
247
|
-
x = e.offsetX - this.startBtnX;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
this.options['remoteApi']
|
|
251
|
-
.checkVerification({ x: Math.floor(+x), y: this.y })
|
|
252
|
-
.then(() => {
|
|
253
|
-
// const { status } = res;
|
|
254
|
-
this.remoteTimerId = setTimeout(() => {
|
|
255
|
-
this.requestLock = false;
|
|
256
|
-
clearTimeout(this.remoteTimerId);
|
|
257
|
-
}, this.remoteTimerInterval);
|
|
258
|
-
|
|
259
|
-
// 验证通过
|
|
260
|
-
// if (+status === 1) {
|
|
261
|
-
console.log('验证通过。。。');
|
|
262
|
-
this.error = false;
|
|
263
|
-
this.success = true;
|
|
264
|
-
this.animationTimer = setTimeout(() => {
|
|
265
|
-
this.success = false;
|
|
266
|
-
// 初始化样式
|
|
267
|
-
imgBg.src = defaultImg;
|
|
268
|
-
imgIcon.src = defaultImg;
|
|
269
|
-
imgIcon.style.top = '0px';
|
|
270
|
-
rangeBtn.style.left = '0px';
|
|
271
|
-
imgIcon.style.left = '0px';
|
|
272
|
-
|
|
273
|
-
this.error = false;
|
|
274
|
-
this.visible = false;
|
|
275
|
-
this.requestLock = false;
|
|
276
|
-
this.$emit('success');
|
|
277
|
-
}, 1000);
|
|
278
|
-
})
|
|
279
|
-
.catch(() => {
|
|
280
|
-
console.log('err');
|
|
281
|
-
console.log('验证失败。。。');
|
|
282
|
-
imgIcon.style.animation = `jitter ${this.animationDuration}ms`;
|
|
283
|
-
rangeBtn.style.animation = `jitter ${this.animationDuration}ms`;
|
|
284
|
-
|
|
285
|
-
this.error = true;
|
|
286
|
-
this.animationTimer = setTimeout(() => {
|
|
287
|
-
//初始化图片信息
|
|
288
|
-
this.initImg().then(() => {
|
|
289
|
-
clearTimeout(this.animationTimer);
|
|
290
|
-
imgIcon.style.animation = '';
|
|
291
|
-
rangeBtn.style.animation = '';
|
|
292
|
-
});
|
|
293
|
-
this.requestLock = false;
|
|
294
|
-
}, this.animationDuration);
|
|
295
|
-
});
|
|
296
|
-
};
|
|
297
|
-
},
|
|
298
|
-
destroyed() {
|
|
299
|
-
clearTimeout(this.remoteTimerId);
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
</script>
|
|
303
|
-
<style lang="scss">
|
|
304
|
-
.fade-enter-active,
|
|
305
|
-
.fade-leave-active {
|
|
306
|
-
transition: opacity 0.5s;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
|
|
310
|
-
opacity: 0;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
@keyframes jitter {
|
|
314
|
-
0% {
|
|
315
|
-
transform: translateX(0px);
|
|
316
|
-
}
|
|
317
|
-
25% {
|
|
318
|
-
transform: translateX(-5px);
|
|
319
|
-
}
|
|
320
|
-
50% {
|
|
321
|
-
transform: translateX(5px);
|
|
322
|
-
}
|
|
323
|
-
75% {
|
|
324
|
-
transform: translateX(-5px);
|
|
325
|
-
}
|
|
326
|
-
100% {
|
|
327
|
-
transform: translateX(0px);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
@media screen and (max-width: 500px) {
|
|
331
|
-
.v-box_box {
|
|
332
|
-
position: fixed;
|
|
333
|
-
top: 0;
|
|
334
|
-
right: 0;
|
|
335
|
-
bottom: 0;
|
|
336
|
-
left: 0;
|
|
337
|
-
margin: auto;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
@media screen and (min-width: 500px) {
|
|
342
|
-
.v-box_box {
|
|
343
|
-
position: absolute;
|
|
344
|
-
right: 0px;
|
|
345
|
-
bottom: 0;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
.v-box {
|
|
349
|
-
position: relative;
|
|
350
|
-
user-select: none;
|
|
351
|
-
|
|
352
|
-
&_box {
|
|
353
|
-
width: 310px;
|
|
354
|
-
height: 348px;
|
|
355
|
-
background-color: #ffffff;
|
|
356
|
-
border-radius: 8px;
|
|
357
|
-
z-index: 2;
|
|
358
|
-
box-shadow: 2px 4px 20px #2e2f2f;
|
|
359
|
-
padding: 16px 12px;
|
|
360
|
-
box-sizing: border-box;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
&_title {
|
|
364
|
-
font-size: 20px;
|
|
365
|
-
font-weight: normal;
|
|
366
|
-
font-stretch: normal;
|
|
367
|
-
line-height: 20px;
|
|
368
|
-
letter-spacing: 0;
|
|
369
|
-
color: #141413;
|
|
370
|
-
margin-top: 0;
|
|
371
|
-
margin-bottom: 16px;
|
|
372
|
-
text-align: center;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
&_sub {
|
|
376
|
-
font-size: 14px;
|
|
377
|
-
font-weight: normal;
|
|
378
|
-
font-stretch: normal;
|
|
379
|
-
line-height: 14px;
|
|
380
|
-
letter-spacing: 0;
|
|
381
|
-
color: #141413;
|
|
382
|
-
padding-bottom: 12px;
|
|
383
|
-
margin: 0 !important;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
&_close {
|
|
387
|
-
position: absolute;
|
|
388
|
-
right: 8px;
|
|
389
|
-
top: 8px;
|
|
390
|
-
width: 24px;
|
|
391
|
-
height: 24px;
|
|
392
|
-
border-radius: 14px;
|
|
393
|
-
background: url('./static/close.png');
|
|
394
|
-
cursor: pointer;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
&_img {
|
|
398
|
-
width: 280px;
|
|
399
|
-
height: 171px;
|
|
400
|
-
//background-color: #ffffff;
|
|
401
|
-
border-radius: 6px;
|
|
402
|
-
position: relative;
|
|
403
|
-
overflow: hidden;
|
|
404
|
-
|
|
405
|
-
&_bg {
|
|
406
|
-
width: 280px;
|
|
407
|
-
height: 171px;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
&_icon {
|
|
411
|
-
position: absolute;
|
|
412
|
-
top: 0;
|
|
413
|
-
left: 0;
|
|
414
|
-
width: 65px;
|
|
415
|
-
height: 65px;
|
|
416
|
-
//background-color: rgba(0, 0, 0, 0.2);
|
|
417
|
-
//box-shadow: inset 0px 0px 6px 0px #ffffff,
|
|
418
|
-
//0px 1px 4px 0px rgba(0, 0, 0, 0.56);
|
|
419
|
-
//border-radius: 2px;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
&_range {
|
|
424
|
-
margin-top: 20px;
|
|
425
|
-
height: 40px;
|
|
426
|
-
position: relative;
|
|
427
|
-
box-sizing: border-box;
|
|
428
|
-
display: flex;
|
|
429
|
-
align-items: center;
|
|
430
|
-
|
|
431
|
-
&_track {
|
|
432
|
-
width: 286px;
|
|
433
|
-
height: 12px;
|
|
434
|
-
background-color: #f0f0ef;
|
|
435
|
-
border-radius: 6px;
|
|
436
|
-
position: relative;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
&_btn {
|
|
440
|
-
width: 36px;
|
|
441
|
-
height: 28px;
|
|
442
|
-
//width: 54px;
|
|
443
|
-
//height: 42px;
|
|
444
|
-
box-shadow: 0 0 4px 0 #f7e00b;
|
|
445
|
-
border-radius: 14px;
|
|
446
|
-
border: none;
|
|
447
|
-
box-sizing: border-box;
|
|
448
|
-
outline: none;
|
|
449
|
-
position: absolute;
|
|
450
|
-
background: url('./static/range_btn.png');
|
|
451
|
-
background-size: 100% 100%;
|
|
452
|
-
left: 0;
|
|
453
|
-
//border: 1px solid #000;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
&_mask {
|
|
457
|
-
position: absolute;
|
|
458
|
-
top: -190px;
|
|
459
|
-
left: 0;
|
|
460
|
-
width: 100%;
|
|
461
|
-
height: 230px;
|
|
462
|
-
z-index: 9999;
|
|
463
|
-
cursor: pointer;
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
&_foot {
|
|
468
|
-
display: flex;
|
|
469
|
-
justify-content: space-between;
|
|
470
|
-
align-items: center;
|
|
471
|
-
|
|
472
|
-
&_refresh {
|
|
473
|
-
width: 28px;
|
|
474
|
-
height: 28px;
|
|
475
|
-
cursor: pointer;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
</style>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
* @Description:
|
|
3
|
-
* @Author: jml
|
|
4
|
-
* @Date: 2021-02-23 14:20:59
|
|
5
|
-
* @LastEditors: jml
|
|
6
|
-
* @LastEditTime: 2021-03-02 17:55:15
|
|
7
|
-
-->
|
|
8
|
-
<template>
|
|
9
|
-
<div class="detail">
|
|
10
|
-
<div
|
|
11
|
-
class="detail_item"
|
|
12
|
-
v-for="item in fieldsMap"
|
|
13
|
-
:key="String(item.prop)"
|
|
14
|
-
:style="item.style"
|
|
15
|
-
>
|
|
16
|
-
<span
|
|
17
|
-
class="detail_item_label"
|
|
18
|
-
:style="{ width: `${labelMaxWidth}px` }"
|
|
19
|
-
v-if="!hideLabel(item)"
|
|
20
|
-
>
|
|
21
|
-
{{ getLabel(item) }}:
|
|
22
|
-
</span>
|
|
23
|
-
<div class="detail_item_value">
|
|
24
|
-
<template v-if="isRenderField(item)" name="render渲染">
|
|
25
|
-
<CustomRender
|
|
26
|
-
:vnode="item.render(initData, item.prop)"
|
|
27
|
-
></CustomRender>
|
|
28
|
-
</template>
|
|
29
|
-
<template v-else-if="isTableField(item)" name="签到table渲染">
|
|
30
|
-
<ul
|
|
31
|
-
class="detail_item_value_table"
|
|
32
|
-
v-for="(items, indexs) in dealTableList(item.prop)"
|
|
33
|
-
:key="indexs"
|
|
34
|
-
>
|
|
35
|
-
<li class="first">
|
|
36
|
-
<div>昵称</div>
|
|
37
|
-
<div>签到时间</div>
|
|
38
|
-
</li>
|
|
39
|
-
<li v-for="(item, index) in items" :key="index">
|
|
40
|
-
<div class="nickName">
|
|
41
|
-
<span>{{ item.nickName }}</span>
|
|
42
|
-
</div>
|
|
43
|
-
<div>
|
|
44
|
-
<span>{{ dealTime(item.createDt) }}</span>
|
|
45
|
-
</div>
|
|
46
|
-
</li>
|
|
47
|
-
</ul>
|
|
48
|
-
</template>
|
|
49
|
-
<template v-else>
|
|
50
|
-
<template v-if="isStringProp(item.prop)">
|
|
51
|
-
<span>{{ initData[item.prop] }}</span>
|
|
52
|
-
</template>
|
|
53
|
-
<template v-if="isArraryProp(item.prop)">
|
|
54
|
-
<span>{{ getValue(item.prop) }}</span>
|
|
55
|
-
</template>
|
|
56
|
-
</template>
|
|
57
|
-
<template v-if="item.slot">
|
|
58
|
-
<CustomRender :vnode="item.slot(initData)"></CustomRender>
|
|
59
|
-
</template>
|
|
60
|
-
</div>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
</template>
|
|
64
|
-
<script>
|
|
65
|
-
import mixin from './mixin';
|
|
66
|
-
export default {
|
|
67
|
-
name: 'Detail',
|
|
68
|
-
mixins: [mixin],
|
|
69
|
-
data() {
|
|
70
|
-
return {};
|
|
71
|
-
},
|
|
72
|
-
computed: {},
|
|
73
|
-
methods: {}
|
|
74
|
-
};
|
|
75
|
-
</script>
|
|
76
|
-
|
|
77
|
-
<style lang="scss" scoped>
|
|
78
|
-
@import './styles/index.scss';
|
|
79
|
-
</style>
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Description:
|
|
3
|
-
* @Date: 2021-02-23 17:34:28
|
|
4
|
-
* @LastEditors: jml
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { check, date } from '../tools/index';
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
components: {
|
|
11
|
-
CustomRender: {
|
|
12
|
-
props: {
|
|
13
|
-
vnode: {
|
|
14
|
-
type: Object | String
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
render(h) {
|
|
18
|
-
if (check.isObject(this.vnode)) {
|
|
19
|
-
return this.vnode;
|
|
20
|
-
} else {
|
|
21
|
-
return h('span', this.vnode);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
props: {
|
|
27
|
-
config: {
|
|
28
|
-
type: Object,
|
|
29
|
-
default: () => ({})
|
|
30
|
-
},
|
|
31
|
-
initData: {
|
|
32
|
-
type: Object,
|
|
33
|
-
default: () => ({})
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
computed: {
|
|
37
|
-
labelMaxWidth() {
|
|
38
|
-
const { getLabel } = this;
|
|
39
|
-
return this.fieldsMap.reduce((pre, cur) => {
|
|
40
|
-
const _str = `${getLabel(cur)}`;
|
|
41
|
-
const allCount = _str.length;
|
|
42
|
-
const wordCount = _str.replace(/[^0-9a-zA-Z]+/g, '').length;
|
|
43
|
-
return Math.max(pre, wordCount * 10 + (allCount - wordCount) * 20);
|
|
44
|
-
}, 0);
|
|
45
|
-
},
|
|
46
|
-
fieldsMap() {
|
|
47
|
-
return this.config.fieldsArr.filter(item => {
|
|
48
|
-
const { isHideField, hide } = item;
|
|
49
|
-
if (check.isFunction(hide)) {
|
|
50
|
-
return !hide(this.initData);
|
|
51
|
-
}
|
|
52
|
-
return !isHideField;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
methods: {
|
|
57
|
-
isRenderField(field) {
|
|
58
|
-
return check.isFunction(field.render);
|
|
59
|
-
},
|
|
60
|
-
isTableField(field) {
|
|
61
|
-
return field.type === 'table';
|
|
62
|
-
},
|
|
63
|
-
isStringProp(prop) {
|
|
64
|
-
return check.isString(prop);
|
|
65
|
-
},
|
|
66
|
-
isArraryProp(prop) {
|
|
67
|
-
return Array.isArray(prop);
|
|
68
|
-
},
|
|
69
|
-
hideLabel(row) {
|
|
70
|
-
return row.hideLabel;
|
|
71
|
-
},
|
|
72
|
-
getLabel(row) {
|
|
73
|
-
const { label } = row;
|
|
74
|
-
if (check.isFunction(label)) {
|
|
75
|
-
return label(this.initData);
|
|
76
|
-
} else {
|
|
77
|
-
return label;
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
getValue(prop) {
|
|
81
|
-
const { initData } = this;
|
|
82
|
-
return initData[prop.find(item => initData[item])];
|
|
83
|
-
},
|
|
84
|
-
dealTableList(prop) {
|
|
85
|
-
const newArr = [];
|
|
86
|
-
const baseCount = 5;
|
|
87
|
-
(this.getValue(prop) || []).filter((item, index) => {
|
|
88
|
-
let count = index % baseCount;
|
|
89
|
-
let no = Math.floor(index / baseCount);
|
|
90
|
-
if (count === 0) {
|
|
91
|
-
newArr[no] = [];
|
|
92
|
-
}
|
|
93
|
-
newArr[no].push(item);
|
|
94
|
-
});
|
|
95
|
-
return newArr;
|
|
96
|
-
},
|
|
97
|
-
dealTime(value) {
|
|
98
|
-
return value ? date.dateFormat(value) : '-';
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
mounted() {
|
|
102
|
-
console.log('详情配置', this.config);
|
|
103
|
-
console.log('详情数据', this.initData);
|
|
104
|
-
}
|
|
105
|
-
};
|