king
2023-11-05 e01d39d4a2c3137fdce5f18f9589a34df13b7963
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Col, Tooltip, notification, Typography, message } from 'antd'
import moment from 'moment'
 
import Api from '@/api'
import asyncComponent from '@/utils/asyncComponent'
import { getMark } from '@/utils/utils.js'
import MkIcon from '@/components/mk-icon'
import Encrypts from '@/components/encrypts'
import './index.scss'
 
moment.suppressDeprecationWarnings = true
const { Paragraph } = Typography
const NormalButton = asyncComponent(() => import('@/tabviews/zshare/actionList/normalbutton'))
const ExcelInButton = asyncComponent(() => import('@/tabviews/zshare/actionList/excelInbutton'))
const ExcelOutButton = asyncComponent(() => import('@/tabviews/zshare/actionList/exceloutbutton'))
const PopupButton = asyncComponent(() => import('@/tabviews/zshare/actionList/popupbutton'))
const TabButton = asyncComponent(() => import('@/tabviews/zshare/actionList/tabbutton'))
const NewPageButton = asyncComponent(() => import('@/tabviews/zshare/actionList/newpagebutton'))
const ChangeUserButton = asyncComponent(() => import('@/tabviews/zshare/actionList/changeuserbutton'))
const PrintButton = asyncComponent(() => import('@/tabviews/zshare/actionList/printbutton'))
const FuncMegvii = asyncComponent(() => import('@/tabviews/zshare/actionList/funcMegvii'))
const FuncZip = asyncComponent(() => import('@/tabviews/zshare/actionList/funczip'))
const EditLine = asyncComponent(() => import('@/tabviews/zshare/actionList/editLine'))
const BarCode = asyncComponent(() => import('@/components/barcode'))
const QrCode = asyncComponent(() => import('@/components/qrcode'))
const MkProgress = asyncComponent(() => import('@/components/mkProgress'))
const Video = asyncComponent(() => import('@/components/video'))
const MkPicture = asyncComponent(() => import('@/components/mkPicture'))
const PicRadio = {
  '4:3': '75%', '3:2': '66.67%', '16:9': '56.25%', '2:1': '50%', '3:1': '33.33%', '4:1': '25%',
  '5:1': '20%', '6:1': '16.67%', '7:1': '14.29%', '8:1': '12.5%', '9:1': '11.11%',
  '10:1': '10%', '3:4': '133.33%', '2:3': '150%', '9:16': '177.78%'
}
 
class TextCell extends Component {
  componentDidMount() {
    if (this.node && this.node.scrollHeight > this.node.offsetHeight) {
      this.node.style.display = 'block'
    }
  }
 
  componentDidUpdate() {
    if (this.node) {
      if (this.node.scrollHeight > this.node.offsetHeight) {
        this.node.style.display = 'block'
      } else {
        this.node.style.display = 'flex'
      }
    }
  }
 
  render() {
    const { card, className, value } = this.props
 
    let lineStyle = {height: card.innerHeight}
    lineStyle.display = 'flex'
    lineStyle.alignItems = card.alignItems
    lineStyle.justifyContent = card.style.textAlign || 'left'
  
    return (
      <div ref={ref => this.node = ref} className={className} style={lineStyle}>{value}</div>
    )
  }
}
 
class CardCellComponent extends Component {
  static propTpyes = {
    cards: PropTypes.object,         // 菜单配置信息
    cardCell: PropTypes.object,
    data: PropTypes.object,
    syncData: PropTypes.array,
    elements: PropTypes.array,       // 元素集
  }
 
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props.data), fromJS(nextProps.data)) || (nextProps.syncData ? !is(fromJS(this.props.syncData), fromJS(nextProps.syncData)) : false)
  }
 
  /**
   * @description 组件销毁,清除state更新,清除快捷键设置
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
  }
 
  openNewView = (e, card) => {
    const { cardCell, data, cards } = this.props
 
    if (data.$disabled) return
 
    if (card.anchors && card.anchors.length > 0) {
      let id = card.anchors[card.anchors.length - 1]
      let node = document.getElementById('anchor' + id)
      node && node.scrollIntoView({behavior: 'smooth', block: 'center', inline: 'nearest'})
    }
 
    if (!card.link || (card.linkType === 'qywx' || card.linkType === 'linkmenu')) return
    e.stopPropagation()
    
    let url = ''
 
    if (card.link === 'static') {
      url = card.linkurl
    } else {
      url = data[card.linkurl]
    }
 
    if (!url) {
      notification.warning({
        top: 92,
        message: '链接地址不存在!',
        duration: 5
      })
      return
    }
 
    if (card.linkType === 'tel') {
      window.open('tel:' + url)
      return
    } else if (card.linkType === 'email') {
      let _url = 'mailto:' + url
      let fullName = sessionStorage.getItem('Full_Name') || ''
      if (fullName) {
        _url = _url + `?subject=来自${fullName}的邮件`
      }
      window.open(_url)
      return
    } else if (card.linkType === 'other' && /^@menuid@/ig.test(url)) {
      return
    }
 
    // positecgroup
    if (/^sso$/ig.test(url)) {
      if (!data.LinkUrl1) {
        notification.warning({
          top: 92,
          message: '链接地址不存在!',
          duration: 5
        })
        return
      }
 
      let _url = data.LinkUrl1
      if (/index\.html/ig.test(_url)) {
        _url = _url.replace(/index\.html.*/ig, '')
      } else if (!/\/$/ig.test(_url)) {
        _url = _url + '/'
      }
 
      let key = (() => {
        let uuid = []
        let timestamp = new Date().getTime()
        let _options = '0123456789abcdefghigklmnopqrstuv'
        for (let i = 0; i < 19; i++) {
          uuid.push(_options.substr(Math.floor(Math.random() * 0x20), 1))
        }
        uuid = timestamp + uuid.join('')
        return uuid
      })()
 
      let _param = {
        func: 'webapi_scan_binding_key',
        binding_type: 'mk',
        scan_type: 'toggle',
        scan_appkey: data.scan_appkey || '',
        id: key
      }
  
      Api.getSystemConfig(_param).then(res => {
        if (!res.status) {
          notification.warning({
            top: 92,
            message: res.message,
            duration: 5
          })
        } else if (res.thd_party_appid && res.thd_party_member_id && res.thd_party_openid) {
          let href = _url + 'admin/index.html#/ssologin/' + window.btoa(window.encodeURIComponent(JSON.stringify({
            appid: res.thd_party_appid,
            memberId: res.thd_party_member_id,
            openid: res.thd_party_openid,
            key: key
          })))
  
          window.open(href)
        } else {
          notification.warning({
            top: 92,
            message: '信息缺失,请联系管理员!',
            duration: 5
          })
        }
      })
      return
    }
 
    let Id = ''
 
    if (cards.subtype === 'propcard' && cardCell) {
      Id = cardCell.setting.primaryId || ''
    } else {
      Id = data[cards.setting.primaryKey] || ''
    }
    
    if (card.joint === 'true') {
      let con = '?'
 
      if (/\?/ig.test(url)) {
        con = '&'
      }
 
      url = url + `${con}id=${Id}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}`
    }
 
    window.open(url)
  }
 
  getColor = (marks) => {
    const { data } = this.props
    let color = ''
 
    marks.some(mark => {
      let originVal = data[mark.field[0]] + ''
      let contrastVal = ''
      let result = false
 
      if (mark.field[1] === 'static') {
        contrastVal = mark.contrastValue + ''
      } else {
        contrastVal = data[mark.field[2]] + ''
      }
 
      if (mark.match === '=') {
        result = originVal === contrastVal
      } else if (mark.match === '!=') {
        result = originVal !== contrastVal
      } else if (mark.match === 'like') {
        result = originVal.indexOf(contrastVal) > -1
      } else if (mark.match === '>') {
        result = parseFloat(originVal) > parseFloat(contrastVal)
      } else if (mark.match === '<') {
        result = parseFloat(originVal) < parseFloat(contrastVal)
      }
 
      if (result) {
        color = mark.color
      }
      return result
    })
 
    return color
  }
 
  getContent = () => {
    const { data, cards, elements } = this.props
 
    let contents = []
 
    elements.forEach(card => {
      let _style_ = null
 
      if (card.style && card.style.clear === 'left') {
        _style_ = {clear: 'left'}
      } else if (card.style && card.style.clear === 'right') {
        _style_ = {float: 'right'}
      }
 
      if (card.eleType === 'sequence') {
        let _style = {}
        let className = ''
        if (card.marks) {
          _style.width = card.innerHeight
          _style.height = card.innerHeight
          _style.lineHeight = card.innerHeight + 'px'
  
          let mark = getMark(card.marks, data, _style)
 
          className = mark.signType
        }
        contents.push(
          <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
            <div style={card.style}>
              <div className={'ant-mk-text line1' + className} style={{height: card.innerHeight || 'auto'}}><span className="sequence-wrap" style={_style}>{data.$Index || ''}</span></div>
            </div>
          </div>
        )
      } else if (card.eleType === 'text') {
        let val = ''
        let _style = {...card.style}
  
        if (card.datatype === 'static') {
          val = card.value || ''
          if (/@username@|@fullName@|@mk_city@|@appname@|@bid@/ig.test(val)) {
            let userName = sessionStorage.getItem('User_Name') || ''
            let fullName = sessionStorage.getItem('Full_Name') || ''
            let city = sessionStorage.getItem('city') || ''
            let appname = sessionStorage.getItem('appname') || ''
            let bid = data.$$BID || ''
            val = val.replace(/@username@/ig, userName).replace(/@fullName@/ig, fullName).replace(/@mk_city@/ig, city).replace(/@appname@/ig, appname).replace(/@bid@/ig, bid)
          } else if (/@month@/ig.test(val)) {
            val = val.replace(/@month@/ig, new Date().toLocaleString('en-US', { month: 'long' }))
          } else if (/@week@/ig.test(val)) {
            val = val.replace(/@week@/ig, (() => {
              let day = new Date().getDay()
              let weeks = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
              return weeks[day]
            })())
          } else if (/@day@/ig.test(val)) {
            val = val.replace(/@day@/ig, (() => {
              let day = new Date().getDate()
              return day < 10 ? '0' + day : day
            })())
          }
        } else if (data.hasOwnProperty(card.field)) {
          val = data[card.field]
        }
  
        if (!val && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
        if (val !== '' && card.format) {
          let _val = null
  
          if (card.format === 'calendar1') {
            _val = moment(val).calendar(null, {
              sameDay: '[今天] ahh:mm',
              nextDay: '[明天] ahh:mm',
              nextWeek: 'MM月DD日 ahh:mm',
              lastDay: '[昨天] ahh:mm',
              lastWeek: 'dddd ahh:mm',
              sameElse: 'MM月DD日 ahh:mm'
            })
          } else if (card.format === 'calendar2') {
            let time = new Date(val).getTime()
            if (!isNaN(time)) {
              time = parseInt(time / 60000)                                     // 时间值
              let now = parseInt(new Date().getTime() / 60000)                  // 当前时间值
              let start = new Date(new Date().toDateString()).getTime() / 60000 // 今天零点时间值
              let split = now - time
  
              if (split < 0) { // 时间值在当前时间之后
                _val = moment(val).format('MM月DD日 HH:mm')
              } else if (split < 3) {
                _val = '刚刚'
              } else if (split < 5) {
                _val = '3分钟前'
              } else if (split < 10) {
                _val = '5分钟前'
              } else if (split < 20) {
                _val = '10分钟前'
              } else if (split < 30) {
                _val = '20分钟前'
              } else if (split < 60) {
                _val = '30分钟前'
              } else if (split < 420 || time > start) { // 7小时内或时间值在今天零点后
                _val = parseInt(split / 60) + '小时前'
              } else {                                  // 时间值在今天零点之前
                let _day = parseInt((start - time) / (24 * 60)) + 1
                if (_day === 1) {
                  _val = '昨天'
                } else if (_day <= 30) {
                  _val = _day + '天前'
                } else {
                  _val = moment(val).format('MM月DD日 HH:mm')
                }
              }
            }
          } else {
            _val = moment(val).format(card.format)
          }
          
          // if (card.format === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(val)) {
          //   val = `${val.substr(0, 4)}-${val.substr(5, 2)}-${val.substr(8, 2)}`
          // }
          if (_val && _val !== 'Invalid date') {
            val = _val
          }
        }
  
        if (val !== '') {
          let orival = val
          if (card.format === 'encryption') {
            val = <Encrypts value={val} />
          }
          if (card.fixStyle === 'alone') {
            let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
            val = <><span style={_s}>{card.prefix || ''}</span>{val}<span style={_s}>{card.postfix || ''}</span></>
          } else {
            val = <span>{card.prefix || ''}{val}{card.postfix || ''}</span>
          }
 
          if (card.copyable === 'true') {
            if (card.link || (card.anchors && card.anchors.length > 0)) {
              let url = orival
 
              if (card.link === 'static') {
                url = card.linkurl
              } else if (card.link === 'dynamic') {
                url = data[card.linkurl]
              }
 
              val = <span>{val}<Paragraph style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()} copyable={{ text: url }}></Paragraph></span>
            } else {
              val = <Paragraph copyable={{ text: orival }}>{val}</Paragraph>
            }
          }
        } else if (card.fixStyle === 'alone') {
          let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
          val = <span style={_s}>{card.prefix || ''}{card.postfix || ''}</span>
        }
  
        let className = ''
        if (card.marks) {
          let mark = getMark(card.marks, data, _style)
  
          if (mark.icon) {
            if (mark.position === 'front') {
              val = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {val}</span>
            } else {
              val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
            }
          } else if (mark.space) {
            val = <><span style={{float: 'left'}} dangerouslySetInnerHTML={{__html: mark.space}}></span>{val}</>
          } else if (mark.point) {
            if (mark.position === 'front') {
              val = <>{mark.point}{val}</>
            } else {
              val = <>{val}{mark.point}</>
            }
          }
          className = mark.signType
        }
  
        if (card.link || (card.anchors && card.anchors.length > 0)) {
          _style.cursor = 'pointer'
        }
    
        if (card.bgImage && data[card.bgImage]) {
          _style.backgroundImage = `url('${data[card.bgImage]}')`
        }
  
        contents.push(
          <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
            <div style={_style} onClick={(e) => {this.openNewView(e, card)}}>
              {card.alignItems ? <TextCell card={card} className={'ant-mk-text line' + (card.height || '') + className} value={val}/> : 
              <div className={'ant-mk-text line' + (card.height || '') + className} style={{height: card.innerHeight}}>{val}</div>}
            </div>
          </div>
        )
      } else if (card.eleType === 'number') {
        let val = ''
        let _style = {...card.style}
  
        if (card.datatype === 'static') {
          val = card.value
        } else if (data.hasOwnProperty(card.field)) {
          val = data[card.field]
        }
  
        if (!val && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
        if (!isNaN(val) && val !== '') {
          val = +val
          if (card.round) {
            val = Math.round(val * card.round) / card.round
          }
          if (card.format === 'percent') {
            val = val * 100
          } else if (card.format === 'abs') {
            val = Math.abs(val)
          }
  
          if (card.round) {
            val = val.toFixed(card.decimal)
          } else {
            val = '' + val
          }
 
          if (card.format === 'percent' && (!card.postfix || card.postfix.indexOf('%') === -1)) {
            val = val + '%'
          } else if (card.format === 'thdSeparator') {
            val = val.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
          }
        }
  
        if (val !== '') {
          if (card.fixStyle === 'alone') {
            let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
            val = <><span style={_s}>{card.prefix || ''}</span>{val}<span style={_s}>{card.postfix || ''}</span></>
          } else {
            val = `${card.prefix || ''}${val}${card.postfix || ''}`
          }
        } else if (card.fixStyle === 'alone') {
          let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
          val = <span style={_s}>{card.prefix || ''}{card.postfix || ''}</span>
        }
        
        let className = ''
        if (card.marks) {
          let mark = getMark(card.marks, data, _style)
  
          if (mark.icon) {
            if (mark.position === 'front') {
              val = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {val}</span>
            } else {
              val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
            }
          } else if (mark.space) {
            val = <><span style={{float: 'left'}} dangerouslySetInnerHTML={{__html: mark.space}}></span>{val}</>
          } else if (mark.point) {
            if (mark.position === 'front') {
              val = <>{mark.point}{val}</>
            } else {
              val = <>{val}{mark.point}</>
            }
          }
          className = mark.signType
        }
 
        contents.push(
          <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
            <div style={_style}>
              {card.alignItems ? <TextCell card={card} className={'ant-mk-text line' + (card.height || '') + className} value={val}/> : 
              <div className={'ant-mk-text line' + (card.height || '') + className} style={{height: card.innerHeight}}>{val}</div>}
            </div>
          </div>
        )
      } else if (card.eleType === 'icon') {
        let val = ''
        let icon = ''
 
        if (card.datatype === 'dynamic') {
          icon = data[card.field] || ''
        } else if (card.tipType === 'text') {
          icon = card.value
        } else {
          icon = card.icon
        }
 
        if (!icon && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
        if (data.hasOwnProperty(card.tooltip)) {
          val = data[card.tooltip]
        } else {
          val = card.tooltip
        }
 
        if (/\\n|\n/.test(val)) {
          val = val.replace(/(\\n|\n)$/, '')
        
          if (val) {
            val = val.split(/\\n|\n/)
        
            val = <div>{val.map((cell, i) => <div style={{marginBottom: 2}} key={i}>{cell}</div>)}</div>
          }
        }
 
        if (card.tipType === 'text') {
          contents.push(
            <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
              <div style={card.style}>
                {val ? <Tooltip title={val}>
                  <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight}}>{icon}</div>
                </Tooltip> : <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight}}>{icon}</div>}
              </div>
            </div>
          )
        } else {
          contents.push(
            <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
              <div style={card.style}>
                {val ? <Tooltip title={val}>
                  <MkIcon className="ant-mk-icon" style={{height: card.innerHeight}} type={icon}/>
                </Tooltip> : <MkIcon className="ant-mk-icon" style={{height: card.innerHeight}} type={icon}/>}
              </div>
            </div>
          )
        }
      } else if (card.eleType === 'slider') {
        let val = 0
        let color = card.color
  
        if (card.datatype === 'static') {
          val = card.value
        } else if (data.hasOwnProperty(card.field)) {
          val = parseFloat(data[card.field])
          if (isNaN(val)) {
            val = 0
          }
        }
  
        val = val / card.maxValue * 100
        val = parseInt(val * 100) / 100
  
        if (card.marks) {
          let _color = this.getColor(card.marks)
          color = _color ? _color : color
        }
  
        contents.push(
          <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
            <div style={card.style}>
              <MkProgress value={val} config={card} color={color}/>
            </div>
          </div>
        )
      } else if (card.eleType === 'picture') {
        let _imagestyle = {}
        let _style = {margin: '0 auto', ...card.style}
        let url = ''
        if (card.maxWidth) {
          _style.maxWidth = card.maxWidth
          if (_style.marginLeft === '0px') {
            delete _style.marginLeft
          }
          if (_style.marginRight === '0px') {
            delete _style.marginRight
          }
        }
  
        if (card.datatype === 'static') {
          url = card.url || ''
          if (url === '@icon@') {
            url = sessionStorage.getItem('avatar') || ''
          }
        } else {
          url = data[card.field] || ''
        }
  
        if (url === '' && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
        if (PicRadio[card.lenWidRadio]) {
          _imagestyle.paddingTop = PicRadio[card.lenWidRadio]
        } else {
          _imagestyle.paddingTop = '100%'
        }
 
        _imagestyle.borderRadius = _style.borderRadius || 0
        _imagestyle.backgroundSize = _style.backgroundSize || 'cover'
        _imagestyle.backgroundPosition = _style.backgroundPosition || 'center'
        _imagestyle.backgroundRepeat = _style.backgroundRepeat || 'no-repeat'
  
        if (card.link) {
          _style.cursor = 'pointer'
        }
  
        let scale = url && card.scale === 'true'
        let urls = url ? url.split(',').filter(Boolean) : ['']
 
        urls.forEach((u, i) => {
          contents.push(<div className={'ant-col ant-col-' + card.width} key={card.uuid + i} style={_style_} span={card.width}>
            <div style={_style} onClick={(e) => {this.openNewView(e, card)}}>
              <MkPicture style={_imagestyle} scale={scale} url={u} urls={urls}/>
            </div>
          </div>)
        })
      } else if (card.eleType === 'splitline') {
        let _borderWidth = card.borderWidth === undefined ? 1 : card.borderWidth
        _style_ = _style_ || {}
        _style_.minHeight = _borderWidth
        contents.push(
          <div className={'ant-col ant-col-' + card.width} key={card.uuid} span={card.width} style={_style_}>
            <div style={card.style}>
              <div className="ant-mk-splitline" style={{borderColor: card.color, borderWidth: _borderWidth}}></div>
            </div>
          </div>
        )
      } else if (card.eleType === 'barcode') {
        let val = ''
  
        if (card.datatype === 'static') {
          val = card.value
        } else if (data.hasOwnProperty(card.field)) {
          val = data[card.field] || ''
        }
  
        if (!val && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
        contents.push(
          <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
            <div style={card.style}>
              <div style={{height: card.innerHeight || 25}}>
                {val ? <BarCode card={card} value={val}/> : null}
              </div>
            </div>
          </div>
        )
      } else if (card.eleType === 'video') {
        let url = ''
  
        if (card.datatype === 'static') {
          url = card.url
        } else {
          url = data[card.field] || ''
        }
  
        if (!url && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
        let poster = ''
  
        if (card.posterType === 'dynamic') {
          poster = data[card.posterField] || ''
        } else {
          poster = card.posterUrl || ''
        }
 
        let urls = url.split(',').filter(Boolean)
  
        urls.forEach((u, i) => {
          contents.push(
            <div className={'ant-col ant-col-' + card.width} key={card.uuid + i} style={_style_} span={card.width}>
              <div className="video-wrap" style={card.style}>
                <Video card={card} poster={poster} value={u}/>
              </div>
            </div>
          )
        })
      } else if (card.eleType === 'qrcode') {
        let val = ''
  
        if (card.datatype === 'static') {
          val = card.value
        } else if (data.hasOwnProperty(card.field)) {
          val = data[card.field] || ''
        }
  
        if (!val && card.noValue === 'hide') { // 空值隐藏
          return null
        }
  
        contents.push(
          <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
            <div style={card.style}>
              <div style={{minHeight: card.qrWidth || 50}}>
                {val ? <QrCode card={card} value={val}/> : null}
              </div>
            </div>
          </div>
        )
      } else if (card.eleType === 'currentDate') {
        let val = moment().format(card.dateFormat || 'YYYY-MM-DD')
        
        if (card.fixStyle === 'alone') {
          let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
          val = <><span style={_s}>{card.prefix || ''}</span>{val}<span style={_s}>{card.postfix || ''}</span></>
        } else {
          val = `${card.prefix || ''}${val}${card.postfix || ''}`
        }
  
        contents.push(
          <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
            <div style={card.style}>
              <div className="ant-mk-text line1" style={{height: card.innerHeight || 'auto'}}>{val}</div>
            </div>
          </div>
        )
      } else if (card.eleType === 'formula') {
        let val = 0
        let _style = {...card.style}
        
        if (card.eval === 'func') {
          let _data = []
          if (card.$sync) {
            _data = this.props.syncData
          } else if (data && !data.$$empty) {
            _data = [data]
          }
 
          try {
            // eslint-disable-next-line
            let func = new Function('data', card.formula)
            val = func(_data)
          } catch (e) {
            console.warn(e)
            val = ''
          }
        } else if (card.$sync) {
          if (card.eval === 'false') {
            val = ''
          }
          this.props.syncData.forEach(item => {
            let _val = card.formula
            Object.keys(item).forEach(key => {
              let reg = new RegExp('@' + key + '@', 'ig')
              _val = _val.replace(reg, item[key])
            })
            if (card.eval !== 'false') {
              try {
                // eslint-disable-next-line
                _val = eval(_val)
              } catch (e) {
                console.info(_val)
                console.warn(e)
                _val = 0
              }
            }
  
            // if (!val) return
  
            val += _val
          })
        } else if (data && data.$$empty && /@.*@/.test(card.formula)) {
          val = ''
        } else if (data) {
          let _val = card.formula
          Object.keys(data).forEach(key => {
            let reg = new RegExp('@' + key + '@', 'ig')
            _val = _val.replace(reg, data[key])
          })
 
          if (card.eval !== 'false') {
            try {
              // eslint-disable-next-line
              _val = eval(_val)
            } catch (e) {
              console.info(_val)
              console.warn(e)
              _val = ''
            }
          }
  
          val = _val === undefined ? '' : _val
        }
 
        if (!val && card.noValue === 'hide') { // 空值隐藏
          return null
        } else if (card.eval === 'func') {
          contents.push(
            <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
              <div style={_style}>
                <div className={'ant-mk-text line' + (card.height || '')} style={{height: card.innerHeight}} dangerouslySetInnerHTML={{__html: val}}></div>
              </div>
            </div>
          )
          return
        }
 
        if (card.round && typeof(val) === 'number') {
          val = Math.round(val * card.round) / card.round
          val = val.toFixed(card.decimal)
        }
  
        if (val !== '') {
          if (val && typeof(val) === 'string') {
            val = val.replace(/\n/ig, '<br/>')
            if (!/<(span|div|p|a|img)\s/g.test(val)) {
              val = val.replace(/\s/ig, '&nbsp;')
            }
 
            val = <span dangerouslySetInnerHTML={{__html: val}}></span>
          }
  
          if (card.fixStyle === 'alone') {
            let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
            val = <><span style={_s}>{card.prefix || ''}</span>{val}<span style={_s}>{card.postfix || ''}</span></>
          } else {
            val = <>{card.prefix || ''}{val}{card.postfix || ''}</>
          }
        } else if (card.fixStyle === 'alone') {
          let _s = {fontSize: card.fixSize, color: card.fixColor, marginLeft: card.fixLeft, marginRight: card.fixRight}
          val = <span style={_s}>{card.prefix || ''}{card.postfix || ''}</span>
        }
 
        let className = ''
        if (card.marks) {
          let mark = getMark(card.marks, data, _style)
  
          if (mark.icon) {
            if (mark.position === 'front') {
              val = <span><MkIcon style={mark.innerStyle} type={mark.icon} /> {val}</span>
            } else {
              val = <span>{val} <MkIcon style={mark.innerStyle} type={mark.icon} /></span>
            }
          } else if (mark.space) {
            val = <><span style={{float: 'left'}} dangerouslySetInnerHTML={{__html: mark.space}}></span>{val}</>
          } else if (mark.point) {
            if (mark.position === 'front') {
              val = <>{mark.point}{val}</>
            } else {
              val = <>{val}{mark.point}</>
            }
          }
          className = mark.signType
        }
 
        contents.push(
          <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
            <div style={_style}>
              {card.alignItems ? <TextCell card={card} className={'ant-mk-text line' + (card.height || '') + className} value={val}/> : 
              <div className={'ant-mk-text line' + (card.height || '') + className} style={{height: card.innerHeight}}>{val}</div>}
            </div>
          </div>
        )
      } else if (card.eleType === 'color') {
        let color = ''
  
        if (card.datatype === 'static') {
          color = card.value
        } else {
          color = data[card.field] || ''
        }
  
        if (!color && card.noValue === 'hide') { // 空值隐藏
          return null
        }
 
        let _bgstyle = {backgroundColor: color}
  
        if (PicRadio[card.lenWidRadio]) {
          _bgstyle.paddingTop = PicRadio[card.lenWidRadio]
        } else {
          _bgstyle.paddingTop = '100%'
        }
 
        if (card.copyable === 'true') {
          _bgstyle.cursor = 'pointer'
        }
 
        contents.push(
          <div className={'ant-col ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
            <div className="ant-mk-color" style={card.style}>
              <div style={_bgstyle} onClick={(e) => {
                if (card.copyable === 'true') {
                  e.stopPropagation()
 
                  let oInput = document.createElement('input')
                  oInput.value = color
                  document.body.appendChild(oInput)
                  oInput.select()
                  document.execCommand('Copy')
                  document.body.removeChild(oInput)
 
                  message.success('复制成功。')
                }
              }}></div>
            </div>
          </div>
        )
      } else if (card.eleType === 'button') {
        let _disabled = data.$disabled
        let _data = [data]
  
        if (data.$$type === 'extendCard') {
          _data = data.$$selectedData || []
          if (card.Ot === 'notRequired' && _data.length === 0) {
            _data = [data]
          }
        } else if (card.$sync) {
          _data = this.props.syncData || []
        } else if (data.$$empty) {
          _data = []
        }
 
        _style_ = _style_ || {}
        if (card.wrapStyle) {
          _style_ = {..._style_, ...card.wrapStyle}
        }
  
        if (['exec', 'prompt', 'pop', 'form'].includes(card.OpenType)) {
          contents.push(
            <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
              <NormalButton
                btn={card}
                BID={data.$$BID}
                BData={data.$$BData || ''}
                disabled={_disabled}
                setting={cards.setting}
                columns={cards.columns}
                selectedData={_data}
              />
            </div>
          )
        } else if (card.OpenType === 'excelIn') {
          contents.push(
            <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
              <ExcelInButton
                btn={card}
                BID={data.$$BID}
                BData={data.$$BData || ''}
                disabled={_disabled}
                setting={cards.setting}
                selectedData={_data}
              />
            </div>
          )
        } else if (card.OpenType === 'excelOut') {
          contents.push(
            <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
              <ExcelOutButton
                btn={card}
                BID={data.$$BID}
                BData={data.$$BData || ''}
                disabled={_disabled}
                setting={cards.setting}
                selectedData={_data}
              />
            </div>
          )
        } else if (card.OpenType === 'popview') {
          contents.push(
            <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
              <PopupButton
                btn={card}
                BID={data.$$BID}
                BData={data.$$BData || ''}
                disabled={_disabled}
                setting={cards.setting}
                selectedData={_data}
              />
            </div>
          )
        } else if (card.OpenType === 'tab') {
          contents.push(
            <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
              <TabButton
                btn={card}
                BID={data.$$BID}
                BData={data.$$BData || ''}
                disabled={_disabled}
                selectedData={_data}
              />
            </div>
          )
        } else if (card.OpenType === 'innerpage') {
          contents.push(
            <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
              <NewPageButton
                btn={card}
                BID={data.$$BID}
                BData={data.$$BData || ''}
                disabled={_disabled}
                selectedData={_data}
              />
            </div>
          )
        } else if (card.OpenType === 'funcbutton') {
          if (card.funcType === 'changeuser' || card.funcType === 'closetab') {
            contents.push(
              <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
                <ChangeUserButton
                  btn={card}
                  BID={data.$$BID}
                  BData={data.$$BData || ''}
                  disabled={_disabled}
                  setting={cards.setting}
                  selectedData={_data}
                />
              </div>
            )
          } else if (card.funcType === 'print') {
            contents.push(
              <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
                <PrintButton
                  btn={card}
                  BID={data.$$BID}
                  BData={data.$$BData || ''}
                  disabled={_disabled}
                  setting={cards.setting}
                  columns={cards.columns}
                  selectedData={_data}
                />
              </div>
            )
          } else if (card.funcType === 'megvii') {
            contents.push(
              <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
                <FuncMegvii
                  btn={card}
                  BID={data.$$BID}
                  disabled={_disabled}
                  setting={cards.setting}
                  selectedData={_data}
                />
              </div>
            )
          } else if (card.funcType === 'filezip') {
            contents.push(
              <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
                <FuncZip
                  btn={card}
                  BID={data.$$BID}
                  disabled={_disabled}
                  setting={cards.setting}
                  selectedData={_data}
                />
              </div>
            )
          } else if (card.funcType === 'addline' || card.funcType === 'delline') {
            contents.push(
              <div className={'ant-col mk-cell-btn ant-col-' + card.width} key={card.uuid} style={_style_} span={card.width}>
                <EditLine
                  btn={card}
                  disabled={_disabled}
                  selectedData={_data}
                />
              </div>
            )
          }
        }
      }
    })
 
    return contents
  }
 
  render() {
    const { cardCell } = this.props
    
    return (
      <div className={'card-cell-list ' + (cardCell && cardCell.setting && cardCell.setting.layout === 'flex' ? 'mk-flex' : '')}>
        {this.getContent()}
        <Col style={{display: 'none'}} span={24}></Col>
      </div>
    )
  }
}
 
export default CardCellComponent