cuiqian2004
2025-07-10 2db331628bbf94deee446d6e172e98f4db474a33
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
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
<template>
    <view class="view-data-new-dataobj">
        <uni-forms ref="baseForm" :modelValue="form" label-position="top" label-width="320">
            <view class="uni-group-item" v-for="(group,index) in showStyle" :key="group.attrgroup_name">
                <view class="uni-panel-title" @click="group.open = !group.open">
                    <text class="uni-title-icon" :style="{ backgroundColor: toHexColor(group.def?.bk_color) }"><text
                            class="uni-icon" :class="group.def?.img_font_style"></text></text>
                    <text class="uni-title-text">{{group.attrgroup_name}}</text>
                    <view class="uni-panel-icon-btn">
                        <uni-icons color="#000" type="down" size="18" />
                    </view>
                </view>
                <view v-if="group.open" class="uni-head-style" :class="hiddenAttrs.includes(attr.attr)? 'uni-hidden':''"
                    v-for="(attr,i) in group.attrs" :key="`attr-${index}-${i}`">
                    <uni-forms-item :label="attrLabel(attr)" :required="attrRequired(attr)" :error="errTip[attr.attr]">
                        <view class="input-wrapper">
                            <input v-if="attr.type == 'input'" v-model="form[attr.attr]" :ref="`ref${attr.attr}`"
                                :disabled="!attr.edit" @on-blur="onChange(attr)" />
                            <textarea v-if="attr.type == 'textarea'" v-model="form[attr.attr]" :ref="`ref${attr.attr}`"
                                :disabled="!attr.edit" @on-blur="onChange(attr)" />
                            <input v-else-if="attr.type == 'int'" v-model="form[attr.attr]" type="number"
                                :ref="`ref${attr.attr}`" :disabled="!attr.edit" @on-blur="onChange(attr)" />
                            <input v-else-if="attr.type == 'float'" v-model="form[attr.attr]" type="digit"
                                :ref="`ref${attr.attr}`" :disabled="!attr.edit" @on-blur="onChange(attr)" />
                            <switch v-else-if="attr.type == 'checkbox'" :checked="form[attr.attr]"
                                :ref="`ref${attr.attr}`" :disabled="!attr.edit" @change="form[attr.attr]=checked">
                            </switch>
                            <uni-data-select id="dv_select" v-if="attr.type == 'select'"
                                :class="attr.edit?'':'input-disabled'" v-model="form[attr.attr]"
                                :localdata="dictList[attr.attr]" @change="onChange(attr)" :disabled="!attr.edit"
                                clear></uni-data-select>
                            <picker v-else-if="attr.type == 'date'" mode="date" style="width: 100%"
                                :value="form[attr.attr]" :ref="`ref${attr.attr}`" :disabled="!attr.edit"
                                @change="form[attr.attr]=value" />
                            <picker v-else-if="attr.type == 'time'" mode="time" style="width: 100%"
                                :value="form[attr.attr]" :ref="`ref${attr.attr}`" :disabled="!attr.edit"
                                @change="form[attr.attr]=value" />
                            <text v-else-if="attr.type == 'ref-psn'">{{form[attr.attr]}}</text>
                        </view>
                    </uni-forms-item>
                </view>
            </view>
            <view class="uni-group-item" v-if="hasAttach">
                <view class="uni-panel-title" @click="clickShowAttach">
                    <text class="uni-title-icon" :style="{ backgroundColor: '#aaa' }"><text
                            class="uni-icon fs-attach"></text></text>
                    <text class="uni-title-text">附件</text>
                    <text class="uni-panel-icon-btn fs-floder" v-if="isCanSelFile" style="margin-left: 4px;"
                        @click.prevent.stop="clickSelFile"></text>
                    <text class="uni-panel-icon-btn fs-camera" v-if="isMobilePlatform" style="margin-left: 4px;"
                        @click.prevent.stop="clickCamera"></text>
                    <view class="uni-panel-icon-btn">
                        <uni-icons color="#000" type="down" size="18" />
                    </view>
                </view>
                <view v-if="showAttach" class="uni-panel-upfile">
                    <view class="uni-panel-upfile-item" v-for="(item,index) in attachList"
                        :style="{background:item.color}" :key="index" @longpress="longpressPic(item,index)"
                        @click="openAattachFile(item)">
                        <view v-if="!(item.isImg || item.isVideo)|| (( item.isImg) && !item.path)"
                            class="uni-panel-upfile-item-name">{{item.name}}</view>
                        <text v-if="!(item.isImg || item.isVideo)"
                            class="uni-panel-upfile-item-size">{{item.sizestr}}</text>
                        <image v-if=" (item.isImg && item.path)" class="uni-panel-upfile-img" :src="item.path"
                            mode="widthFix" />
                        <jvideo v-if="item.isVideo && item.path" :url="item.path" width="192rpx" height="192rpx"
                            :len="10"></jvideo>
                        <text v-if="item.errMsg" class="uni-panel-icon fs-wrong"
                            style="position: absolute; bottom:5rpx; right: 5rpx;  color: #fd3c46;"
                            @click="onErrInfo(item.errMsg)"></text>
                        <!-- #ifdef MP-WEIXIN -->
                        <circleProgressBar v-if="item.isUploading" style="position: absolute; top: 50rpx; left: 50rpx;"
                            :size="100" :border_width="16" border_back_color='#ccc' background='#ffffff80'
                            :pro="item.percent/100" />
                        <!-- #endif-->
                    </view>
 
                </view>
            </view>
        </uni-forms>
        <view class="uni-panel-bottom-button">
            <button class="uni-panel-button" @click="submitForm">提交</button>
        </view>
        <view class="uni-panel-safe-bottom" :style="{height:safeAreaBottom + 'px'}" />
        <uni-popup ref="popupFileSel" background-color="#fff">
            <view class="popup-content" style="padding: 2px 4px 12px;">
                <view class="popup-content_menu-item" style="border-bottom: 1px solid #eeeeee;"
                    @click="clickSelMessageFile">从会话中选择</view>
                <view class="popup-content_menu-item" style="border-bottom: 1px solid #eeeeee;"
                    @click="clickSelLocalFile">从本地文件选择</view>
                <view class="popup-content_menu-item" @click="closeFileSelPopup">取消</view>
            </view>
        </uni-popup>
    </view>
</template>
 
<script>
    import TaskInit from "@/common/extend.js"
    import {
        showModal,
        showToast,
        showLoading,
        hideLoading
    } from "@/common/Page.js"
    import dataObjItem from "@/components/dataobj-item.vue"
    // import {
    //     getDictValue,
    //     getClassAttr,
    //     getClsUIStyleInfo,
    //     getClassAttrAttach,
    //     getFileUrlS,
    //     downloadTaskFile,
    //     getDataAttrList,
    //     dataObjRunCustomEvent,
    //     getUploadType,
    //     getUploadUrlMinio,
    //     uploadTaskFileMinio,
    //     writeFileToMinioDB,
    //     uploadTaskFile,
    //     addClassAttr,
    //     updateClassAttr,
    //     invokeEvent
 
    // } from "@/common/api/app.js"
    import {
        loginWxQy
    
    } from "@/api/index.js"
    import jvideo from '@/components/j-video.vue'
    import circleProgressBar from '@/components/circle-progress-bar/circle-progress-bar.vue'
    export default {
        name: "pageDataNewDataObj",
        components: {
            jvideo,
            circleProgressBar,
        },
        data() {
            return {
                styleDef: {},
                showStyle: [],
                attrList: [],
                hiddenAttrs: [],
                attachList: [],
                delFileList: [],
                dictList: [],
                clsName: "",
                form: {},
                errTip: {},
                enviroment: {},
                hasAttach: false,
                isMobilePlatform: true,
                isCanSelFile: true,
                showAttach: true,
                globalAttr: "",
                extInfo: {},
                safeAreaBottom: getApp().globalData.safeAreaBottom,
            }
        },
        computed: {
            formAttrObj() {
                return this.form;
            },
            initialEvent() {
                let event = this.styleDef.Event?.find((e) => e.event_id == "initial");
                return {
                    id: event?.scrip_id,
                    name: event?.scrip_name,
                };
            },
        },
        methods: {
            setData: function(obj) {
                let that = this;
                let keys = [];
                let val, data;
 
                Object.keys(obj).forEach(function(key) {
                    keys = key.split(".");
                    val = obj[key];
                    data = that.$data;
                    keys.forEach(function(key2, index) {
                        if (index + 1 == keys.length) {
                            that.$set(data, key2, val);
                        } else {
                            if (!data[key2]) {
                                that.$set(data, key2, {});
                            }
                        }
                        data = data[key2];
                    });
                });
            },
            async loadData() {
                this.hasAttach = this.options.hasAttach
                this.extInfo = {
                    function: this.options.defCode,
                    cls_id: this.options.clsId,
                    obj_id: "",
                    panel: {},
                    button: this.options.button || "",
                    button_name: this.options.buttonName || "",
                    master: {
                        cls_id: this.options.clsId,
                        obj_id: ""
                    },
                    key: {
                        attr: "",
                        value: ""
                    }
                }
                await this.loadForm()
                await this.loadFormData()
                this.hideFormItems([])
                let attrs = [];
                this.showStyle.forEach((group) => {
                    group.attrs.forEach(async (attr) => {
                        attrs.push({
                            attr: attr.attr,
                            val: ""
                        })
                    })
                })
 
                dataObjRunCustomEvent(this.options.clsId, this.initialEvent.id, JSON.stringify(attrs), JSON.stringify(
                    this
                    .extInfo), "", this.globalAttr).then((res) => {
 
                    const resJson = JSON.parse(res)
                    let curIndex = (resJson.action || []).findIndex((item2, index, arr) => {
                        return item2.action_type == "set_dlg_attr";
                    })
                    if (curIndex >= 0) {
                        const value = resJson.action[curIndex].value;
                        (value || []).forEach((item) => {
                            this.form[item.attr] = item.value
                        })
 
                    }
                    console.log("dataObjRunCustomEvent", resJson, this.form)
                    // let curIndex = (resJson.action || []).findIndex((item2, index, arr) => {
                    //     return item2.action_type == "set_global_attr";
                    // })
                    // if (curIndex >= 0) {
                    //     this.globalAttr = resJson.action[curIndex].value
 
                    // }
                }).catch((err) => {
                    console.log("dataObjRunCustomEvent fail", err)
                })
            },
            async loadFormData() {
                try {
                    if (this.options.objId) {
                        const clsAttr = await getClassAttr(this.options.clsId, this.options.objId)
                        const objAttr = clsAttr.ObjAttr || []
                        const clsAttrAttach = await getClassAttrAttach(this.options.clsId, this.options.objId)
                        this.showStyle.forEach((group) => {
                            group.attrs.forEach((attr) => {
                                let info = objAttr.find((o) => o.Name == attr.attr);
                                if (info) {
                                    if (attr.type == "ref-psn")
                                        this.form[attr.attr] = {
                                            id: info.Value.split(";")[0],
                                            name: info.Value.split(";")[1],
                                            type: 0,
                                        };
                                    else this.form[attr.attr] = info.Value;
                                }
                            });
                        });
                        clsAttrAttach.forEach((ele, index) => {
                            let upfile = {
                                isUploading: false,
                                fileserver: ele.FileServer,
                                percent: 100,
                                fileId: ele.FileID,
                                fileMD5: ele.FileMD5 || "",
                                name: ele.FileName,
                                size: ele.FileSize,
                                path: ele.Url,
                                id:ele.ID,
                                color: TaskInit.fileUtils.getTypeBgColor(ele.FileName),
                                sizestr: TaskInit.fileUtils.getFileSizeStr(ele.FileSize)
                            };
                            if (TaskInit.fileUtils.isPictureType(ele.FileName)) //文档
                            {
                                upfile.isImg = true
                            }
                            if (TaskInit.fileUtils.isVideoType(ele.FileName)) //文档
                            {
                                
                                upfile.isVideo = true
                            }
                            
                            const attachs = this.attachList
                            attachs.push(upfile)
                            this.setData({
                                attachList: attachs,
                            })
                        })
                    }
                } catch (ex) {
                    let tip = typeof ex == "string" ? ex : ex.message;
                    console.log(`装载数据信息失败`, ex);
                    showModal(tip, "出错", false, false)
                }
            },
            async loadForm() {
                var _this = this;
 
                try {
                    this.form = {};
                    this.errTip = {};
                    const info = await getClsUIStyleInfo(_this.options.clsId, 2, _this.options.editName)
                    this.attrList = await getDataAttrList(_this.options.clsId)
                    const show_style = info.StyleDef.show_style || []
                    this.styleDef = info.StyleDef
                    //
 
                    // await getDictValue( "数据生命周期");
                    // console.log("getClsUIStyleInfo", info)
                    this.showStyle = show_style
                    await Promise.all(
                        show_style.map(async (group) => {
                            let group_def = this.attrList.find(
                                (a) => a.Name == group.attrgroup_name
                            );
                            group.def = {
                                bk_color: group_def.BkColor,
                                img_font_style: "fs-mobox_log",
                            };
 
                            await Promise.all(
                                group.attrs.map(async (attr) => {
                                    let attr_def = group_def.Attr.find(
                                        (a) => a.Name == attr.attr
                                    );
                                    // “小窗口”中“显示配置”指定的属性在当前数据类中已变更,无法得到相应的定义
                                    if (!attr_def) {
                                        const tip =
                                            `当前数据类“${this.clsName}(${this.clsId})”中找不到名为“${attr.name}(${attr.attr})”的属性`
                                        showModal(tip, "出错", false, false)
                                        return;
                                    }
                                    attr.def = attr_def;
                                    attr.type = this.getAttrType(attr.def);
 
                                    this.form[attr.attr] = this.defaultValue(attr.type);
                                    this.errTip[attr.attr] = "";
 
                                    if (attr.type == "select") {
                                        if (attr.def.DictName) {
                                            let res = await getDictValue(attr.def
                                                .DictName);
                                            let dictList = res || res;
 
                                            this.dictList[attr.attr] = dictList.map((dict) => {
                                                return {
                                                    text: dict.Value || dict.Name,
                                                    value: dict.Name
                                                }
                                            });
                                            let dictName = "";
                                            if (dictList?.length > 0) {
                                                let defaultValue = dictList.find(
                                                    (d) => d.IsDefault == 1
                                                )?.Name;
                                                if (defaultValue) dictName = defaultValue;
                                                else dictName = dictList[0].Name;
                                            }
                                            this.form[attr.attr] = dictName;
                                        } else {
                                            this.dictList[attr.attr] = [];
                                            this.form[attr.attr] = "";
                                        }
                                    }
                                })
                            );
                        })
                    );
 
                    console.log(`装载显示数据信息`, info, this.showStyle);
                } catch (ex) {
                    let tip = typeof ex == "string" ? ex : ex.message;
                    console.log(`装载显示数据信息失败`, ex);
                    showModal(tip, "出错", false, false)
                }
            },
            hideFormItems(attrs) {
                let attrList = [];
                this.showStyle.forEach((group) => attrList.push(...group.attrs));
                this.hiddenAttrs = [
                    ...attrList.filter((a) => (a.hidden === true || a.hidden === "True")).map((a) => a.attr),
                    ...attrs
                    .filter((attr) => attr.attr in this.form && (attr.show === false || attr.show === "False"))
                    .map((attr) => attr.attr),
                ];
                //console.log("hideFormItems", attrList, this.hiddenAttrs)
            },
            setFormAllValues(attrs) {
                this.$emit("on-set-all-value", attrs);
            },
            isValid() {
                let flag = true;
                this.showStyle.forEach((group) => {
                    group.attrs.forEach((attr) => {
                        let val = this.form[attr.attr];
                        if (attr.def.type == "日期") val = dayjs(val).format("YYYY-MM-DD");
                        if (attr.def.not_empty == 1 && isNullOrEmpty(val)) {
                            this.errTip[attr.attr] = `${attr.name}不能为空`;
                            flag = false;
                            if (this.$refs[`ref${attr.attr}`][0].focus)
                                this.$refs[`ref${attr.attr}`][0].focus();
                            else if (this.$refs[`ref${attr.attr}`][0].$el.focus)
                                this.$refs[`ref${attr.attr}`][0].$el.focus();
                        }
                    });
                });
                return flag;
            },
            getAttrType(def) {
                let type = def?.Type;
                let height = def?.Height;
                let ctrlType = "";
                this.showStyle?.forEach((group) => {
                    ctrlType = group.attrs?.find((a) => a.attr == def.Name)?.ctrl_type;
                });
 
                let guid = ["GUID"];
                let char = ["字符串", "可变长字符串", "char", "varchar"];
                let select = ["字典-字符串", "字典-整数", "dict-char", "dict-int"];
                let int = ["整数", "int"];
                let float = ["浮点数", "float"];
                let bool = ["布尔值", "bool"];
                let date = ["日期", "date"];
                let time = ["时间", "datetime"];
                let refPsn = ["引用人员", "user"];
 
                console.log("getAttrType", type, def)
                if (guid.includes(type) || char.includes(type))
                    return ctrlType == "dropdown" ?
                        "select" :
                        height == 2 ?
                        "textarea" :
                        height == 3 ?
                        "textarea" :
                        "input";
                else if (select.includes(type)) return "select";
                else if (int.includes(type)) return "int";
                else if (float.includes(type)) return "float";
                else if (bool.includes(type)) return "checkbox";
                else if (date.includes(type)) return "date";
                else if (time.includes(type)) return "time";
                else if (refPsn.includes(type)) return "ref-psn";
                else return "unknown";
            },
            defaultValue(type) {
                let value = undefined;
                switch (type) {
                    case "input":
                        value = "";
                        break;
                    case "select":
                        value = "";
                        break;
                    case "int":
                        value = "";
                        break;
                    case "float":
                        value = 0.0;
                        break;
                    case "checkbox":
                        value = false;
                        break;
                    case "date":
                        value = "";
                        break;
                    case "time":
                        value = "";
                        break;
                    case "ref-psn":
                        value = {};
                        break;
                }
                return value;
            },
            attrLabel(attr) {
                if (attr.notempty || attr.def?.not_empty == 1)
                    return `${attr.name}(必填)`;
                else return attr.name;
            },
            attrRequired(attr) {
                if (attr.notempty || attr.def?.not_empty == 1) return true;
                else return false;
            },
            toHexColor(num) {
                return `#${parseInt(num).toString(16)}`;
            },
            async onChange(attr) {
                if (!this.form[attr.attr]) return;
                let action = attr.action;
                if (!action) return;
                if (action[0] != "{" && action[action.length - 1] != "}")
                    action = `{${action}}`;
                let extInfo = {
                    ...this.enviroment,
                };
                try {
                    await dataObjRunCustomEvent(
                        this.options.clsId,
                        action,
                        JSON.stringify(this.formAttrObj),
                        JSON.stringify(extInfo),
                        "",
                        ""
                    )
                } catch (ex) {
                    console.log("执行脚本失败", ex)
                    showModal(ex, '错误', false)
                }
            },
            loadPlatform() {
                this.isCanSelFile = true
                this.isMobilePlatform = false
                const app = getApp()
                if (app.globalData.platform == "ios" || app.globalData.platform == "android") {
                    this.isMobilePlatform = true
                }
                // console.log("loadPlatform", app.globalData.osName)
                if (app.globalData.osName == "ios") {
                    this.isCanSelFile = false
                    //#ifdef MP-WEIXIN
                    if (uni.canIUse('chooseMessageFile')) {
                        this.isCanSelFile = true
                    }
                    //#endif
                }
            },
            clickShowAttach() {
                this.showAttach = !this.showAttach
            },
            clickSelFile() {
 
                let isCanMessageFile = false
                let isCanLocalFile = true
                const app = getApp()
    
                if (app.globalData.osName == "ios") {
                    isCanLocalFile = false
                }
                //#ifdef MP-WEIXIN
                if (app.globalData.qyWx.isWork) {
                    if (this.isMobilePlatform) {
                        if (uni.canIUse('chooseMessageFile')) {
                            isCanMessageFile = true
                        }
                    }
                } else {
                    if (uni.canIUse('chooseMessageFile')) {
                        isCanMessageFile = true
                    }
                }
                //#endif
                if (isCanLocalFile && isCanMessageFile) {
                    this.$refs.popupFileSel.open("bottom")
                } else {
                    if (isCanLocalFile) {
                        uni.navigateTo({
                            url: `/pages/common/fileselect?uploadType=${this.fileUploadType}`
                        })
                    } else if (isCanMessageFile) {
                        this.clickSelMessageFile()
                    }
                }
            },
            clickCamera() {
                console.log("clickCamera")
                var _this = this
                let sizeType = ['original', 'compressed']
                //#ifdef MP-DINGTALK
                sizeType = ['compressed']
                // #endif
 
                uni.chooseImage({
                    count: 10,
                    sizeType: sizeType, //original 原图,compressed 压缩图,默认二者都有
                    sourceType: ['album', 'camera'], //album 从相册选图,camera 使用相机,默认二者都有。
                    success: (res) => {
                        console.log("clickCamera res", res)
                        let tempFiles = []
                        if (res.files) {
                            for (let i = 0; i < res.files.length; i++) {
                                let tmpFile = {
                                    path: res.files[i].path,
                                    size: 0
                                }
                                tmpFile.name = tmpFile.path
                                if (res.files[i].fileType)
                                    tmpFile.name = tmpFile.path + "." + res.files[i].fileType
                                tempFiles.push(tmpFile)
                            }
                        } else if (res.tempFiles) {
                            for (let i = 0; i < res.tempFiles.length; i++) {
                                let tmpFile = {
                                    path: res.tempFiles[i].path,
                                    size: 0
                                }
                                tmpFile.name = tmpFile.path
                                tempFiles.push(tmpFile)
                            }
                        } else {
                            for (let i = 0; i < res.tempFilePaths.length; i++) {
                                tempFiles.push({
                                    path: res.tempFilePaths[i],
                                    name: res.tempFilePaths[i],
                                    size: 0
                                })
                            }
                        }
                        _this.uploadAttachs(tempFiles);
 
                    },
                    fail: (err) => {
                        console.log('chooseImage fail', err)
                        if (_this.isMobilePlatform && err.errMsg.indexOf('cancel') < 0) {
                            uni.getSetting({
                                success: (res) => {
                                    let authStatus = res.authSetting['scope.album'];
                                    if (!authStatus) {
                                        showModal("需要从您的相册获取图片,请在设置界面打开相关权限", "授权失败").then((
                                            res) => {
                                            if (res) {
                                                uni.openSetting()
                                            }
                                        })
                                    }
                                }
                            })
                        }
                    }
                })
            },
            clickSelMessageFile() {
                this.$refs.popupFileSel.close()
 
                var _this = this
                let app = getApp()
                let isCanMessageFile = false
                //#ifdef MP-WEIXIN
                if (app.globalData.qyWx.isWork) {
                    if (this.isMobilePlatform) {
                        if (uni.canIUse('chooseMessageFile')) {
                            isCanMessageFile = true
                        }
                    }
                } else {
                    if (uni.canIUse('chooseMessageFile')) {
                        isCanMessageFile = true
                    }
                }
                //#endif
                if (isCanMessageFile) {
                    console.log("clickSelMessageFile canIUse")
                    if (app.globalData.qyWx.isWork) {
                        console.log("clickSelMessageFile wx.qy.checkSession")
                        wx.qy.checkSession({
                            success: function() {
                                // console.log('clickSelMessageFile checkSession success!')
                                wx.qy.chooseMessageFile({
                                    count: 10,
                                    type: "file",
                                    success: (res) => {
                                        // console.log("clickSelMessageFile chooseMessageFile success",res)
                                        _this.uploadAttachs(res.tempFiles);
                                    },
                                    fail: (res) => {
                                        console.log("clickSelMessageFile chooseMessageFile fail",
                                            res)
                                    },
                                })
                            },
                            fail: function() {
                                console.log('clickSelMessageFile checkSession fail!')
                                // session_key 已经失效,需要重新执行登录流程
                                loginWxQy().then((res) => {
                                    wx.qy.chooseMessageFile({
                                        count: 10,
                                        type: "file",
                                        success: (res) => {
                                            console.log(
                                                "clickSelMessageFile chooseMessageFile success",
                                                res)
                                            _this.uploadAttachs(res.tempFiles);
                                        },
                                        fail: (res) => {
                                            console.log(
                                                "clickSelMessageFile chooseMessageFile fail",
                                                res)
                                        },
                                    })
                                }).catch((rej) => {
                                    console.log('clickSelMessageFile loginWxQy failed!', rej)
                                    showModal(rej, "提示", false)
                                })
                            }
                        })
                    } else {
                        uni.chooseMessageFile({
                            count: 10,
                            type: "all",
                            success: (res) => {
                                console.log("chooseMessageFile res", res)
                                _this.uploadAttachs(res.tempFiles);
                            }
                        })
                    }
                } else {
                    console.log("clickSelMessageFile no canIUse")
                    //showModal("不支持从聊天会话中选择文件","提示",false)
                    let sizeType = ['original', 'compressed']
                    //#ifdef MP-DINGTALK
                    sizeType = ['compressed']
                    // #endif
                    uni.chooseImage({
                        count: 10,
                        sizeType: sizeType, //original 原图,compressed 压缩图,默认二者都有
                        sourceType: ['album', 'camera'], //album 从相册选图,camera 使用相机,默认二者都有。
                        success: (res) => {
                            console.log("clickCamera res", res)
                            let tempFiles = []
                            if (res.files) {
                                for (let i = 0; i < res.files.length; i++) {
                                    let tmpFile = {
                                        path: res.files[i].path,
                                        size: 0
                                    }
                                    tmpFile.name = tmpFile.path.split('/').pop()
                                    if (res.files[i].fileType)
                                        tmpFile.name = tmpFile.path.split('/').pop() + "." + res.files[i]
                                        .fileType
                                    tempFiles.push(tmpFile)
                                }
                            } else if (res.tempFiles) {
                                for (let i = 0; i < res.tempFiles.length; i++) {
                                    let tmpFile = {
                                        path: res.tempFiles[i].path,
                                        size: 0
                                    }
                                    tmpFile.name = tmpFile.path.split('/').pop()
                                    tempFiles.push(tmpFile)
                                }
                            } else {
                                for (let i = 0; i < res.tempFilePaths.length; i++) {
                                    tempFiles.push({
                                        path: res.tempFilePaths[i],
                                        name: res.tempFilePaths[i].split('/').pop(),
                                        size: 0
                                    })
 
                                }
                            }
 
                            _this.uploadAttachs(tempFiles);
 
                        },
                        fail: (err) => {
                            console.log('chooseImage fail', err)
                            if (_this.isMobilePlatform && err.errMsg.indexOf('cancel') < 0) {
                                uni.getSetting({
                                    success: (res) => {
                                        let authStatus = res.authSetting['scope.album'];
                                        if (!authStatus) {
                                            showModal("需要从您的相册获取图片,请在设置界面打开相关权限", "授权失败").then((
                                                res) => {
                                                if (res) {
                                                    uni.openSetting()
                                                }
                                            })
                                        }
                                    }
                                })
                            }
                        }
                    })
                    return;
                }
 
            },
            clickSelLocalFile() {
                console.log("clickSelLocalFile")
                this.$refs.popupFileSel.close()
                uni.navigateTo({
                    url: `/pages/common/fileselect?uploadType=${this.fileUploadType}`
                })
            },
            uploadAttachs(files) {
                console.log("uploadAttachs", files)
                var _this = this
 
                let fileTemps = []
                var attachs = _this.attachList
                if (files.length <= 10) {
                    fileTemps = files
                } else {
                    for (let i = 0; i < 10; i++) {
                        fileTemps.push(files[i])
                    }
                }
                for (let i = 0; i < fileTemps.length; i++) {
                    let file = fileTemps[i];
                    file.isUploading = true
                    file.percent = 0
                    let aname = file.path
                    if (file.name)
                        aname = file.name
                    let aaa = aname.split('/');
                    if (aaa.length > 0) {
                        file.name = aaa[aaa.length - 1]
                    } else
                        file.name = aname
                    file.sizestr = TaskInit.fileUtils.getFileSizeStr(file.size)
                    file.color = TaskInit.fileUtils.getTypeBgColor(file.name)
                    file.isImg = false
                    file.isVideo = false
                    if (TaskInit.fileUtils.isPictureType(file.name)) //文档
                    {
                        file.isImg = true
                    } else if (TaskInit.fileUtils.isVideoType(file.name)) //文档
                    {
                        file.isVideo = true
                    }
                    attachs.push(file)
                }
                _this.setData({
                    attachList: attachs,
                })
                for (let i = 0; i < fileTemps.length; i++) {
                    let file = fileTemps[i];
                    if (_this.fileUploadType == 1) {
                        // #ifdef MP-WEIXIN
                        uni.getFileSystemManager().getFileInfo({
                            filePath: file.path,
                            digestAlgorithm: "md5",
                            success: (res) => {
                                console.log("uploadAttachs getFileInfo", res)
                                file.md5 = res.digest
                                _this.uploadAttachToMinio(file, file.isImg, file.isVideo)
                            },
                            fail: (res) => {
                                _this.setAttachFailed(file.path, res);
                            }
                        })
                        // #endif
                        // #ifndef MP-WEIXIN
                        uni.getFileInfo({
                            filePath: file.path,
                            digestAlgorithm: "md5",
                            success: (res) => {
                                file.md5 = res.digest
                                _this.uploadAttachToMinio(file, file.isImg, file.isVideo)
                            },
                            fail: (res) => {
                                _this.setAttachFailed(file.path, res);
                            }
                        })
                        // #endif
                    } else {
                        _this.uploadAttach(file, file.isImg, file.isVideo)
                    }
                }
 
            },
 
            closeFileSelPopup() {
                this.$refs.popupFileSel.close()
            },
            longpressPic(item, index) {
                var _this = this
                showModal("确定要删除附件吗?", "提醒").then((res) => {
                    if (res) {
                        let attachs = _this.attachList
                        if ( attachs[index].id)
                            this.delFileList.push(attachs[index].id)
                        attachs.splice(index, 1)
                        _this.setData({
                            attachList: attachs
                        })
                        
                    }
                })
            },
            onErrInfo(errMsg) {
                console.log("onErrInfo", errMsg)
                showToast(errMsg, 'none')
            },
            getBackUploadFile(data) {
                var _this = this
                let attachs = _this.attachList
                for (let i = 0; i < data.length; i++) {
                    let file = data[i];
                    let isImg = false
                    let isVideo = false
                    //console.log('getBackUploadFile', file)
                    if (TaskInit.fileUtils.isPictureType(file.CN_S_FILE_NAME)) //文档
                    {
                        isImg = true
                    }
                    if (TaskInit.fileUtils.isVideoType(file.CN_S_FILE_NAME)) //文档
                    {
                        isVideo = true
                    }
                    let color = TaskInit.fileUtils.getTypeBgColor(file.CN_S_FILE_NAME)
                    let upfile = {
                        isUploading: false,
                        fileserver: file.CN_N_FILE_SERVER,
                        percent: 100,
                        fileId: file.CN_G_FILE_ID,
                        name: file.CN_S_FILE_NAME,
                        size: file.CN_N_FILE_SIZE,
                        fileMD5: file.CN_S_FILE_MD5 || "",
                        isImg: isImg,
                        isVideo: isVideo,
                        color: color,
                        sizestr: TaskInit.fileUtils.getFileSizeStr(file.CN_N_FILE_SIZE)
                    };
                    attachs.push(upfile)
 
                }
                _this.setData({
                    attachList: attachs
                })
                // console.log('getBackUploadFile', _this.attachList)
                for (let i = 0; i < _this.attachList.length; i++) {
                    let file = _this.attachList[i];
                    if ((file.isImg || file.isVideo) && !file.path) {
                        getFileUrlS(file.fileId, file.fileserver, file.name).then((res) => {
                            console.log("getFileUrlS res:", res)
                            if (res.indexOf("file not exsits") < 0) {
                                const app = getApp()
                                if (res.indexOf("http://") < 0 && res.indexOf("https://") < 0)
                                    res = app.globalData.basehttpurl + res
                                file.path = res
                            }
                        }).catch((rej) => {
                            console.log("getFileUrlS fail:", rej)
                        })
                    }
                }
 
            },
            openAattachFile(item) {
                var _this = this
                if (!TaskInit.fileUtils.isCanPreviewType(item.name)) {
                    showToast("暂不支持此类型查看", "none")
                    return
                }
 
                if (TaskInit.fileUtils.isPictureType(item.name)) //文档
                {
                    if (item.path) {
                        let arrImg = _this.getImgsUrl();
                        uni.previewImage({
                            current: item.path,
                            urls: arrImg,
                        })
                        return
                    }
                    _this.dldAndPreviewImg(item)
                    return
                }
                if (item.path) {
                    if (TaskInit.fileUtils.isDocumentType(item.name)) //文档
                    {
                        let aaa = item.name.toLowerCase().split('.');
                        let ftype = aaa.length > 0 ? aaa[aaa.length - 1] : aaa[0];
                        uni.openDocument({
                            fileType: ftype,
                            filePath: item.path,
                            success: function(res) {
                                console.log('打开文档成功');
                            },
                            fail: function() {
                                showToast("暂不支持此类型‘"+ftype+"’查看" ,"none",5000)
                            }
                        })
                    }
                    return
                }
                if (TaskInit.fileUtils.isVideoType(item.name)) //文档
                {
                    getFileUrlS(item.fileId, item.fileserver, item.name).then((res) => {
                        console.log('getFileUrlS success:', res)
                        if (res.indexOf("file not exsits") < 0) {
                            const app = getApp()
                            if (res.indexOf("http://") < 0 && res.indexOf("https://") < 0)
                                res = app.globalData.basehttpurl + res
                            item.path = res
                            uni.navigateTo({
                                url: "/pages/common/videoPage?fileId=" + item.fileId + "&fileServer=" +
                                    item.fileserver + "&name=" + item.name + "&url=" + encodeURIComponent(
                                        item.path)
                            })
                        }
                    }).catch((rej) => {
                        console.log('getFileUrlS fail:', rej);
                        showModal(rej, '错误', false)
                    })
                    return
                }
                getFileUrlS(item.fileId, item.fileserver, item.name).then((res) => {
                    console.log('getFileUrlS success:', res)
                    if (res.indexOf("file not exsits") < 0) {
                        showLoading("正在下载,请稍后...")
                        const app = getApp()
                        if (res.indexOf("http://") < 0 && res.indexOf("https://") < 0)
                            res = app.globalData.basehttpurl + res
                        downloadTaskFile(item.name, res, function(docSuccess) {
 
                            hideLoading()
                            item.path = docSuccess.path
                            console.log('下载成功', docSuccess.path);
                            showLoading("下载成功,正在打开...")
                            let aaa = item.name.toLowerCase().split('.');
                            let ftype = aaa.length > 0 ? aaa[aaa.length - 1] : aaa[0];
                            uni.openDocument({
                                fileType: ftype,
                                filePath: docSuccess.path,
                                success: function(res) {
                                    hideLoading()
                                    console.log('打开文档成功');
                                },
                                fail: function() {
                                    hideLoading()
                                    showToast("暂不支持此类型‘"+ftype+"’查看" ,"none",5000)
                                }
                            })
                        }, function(docProgress, downloadTask) {
                            //下载进度
                        }, function(docFail) {
 
                            hideLoading()
                            showModal(docFail.errMsg, '错误', false)
                        })
                    } else {
                        showModal(res, '错误', false)
                    }
                }).catch((rej) => {
                    console.log('getFileUrlS fail:', rej);
                    showModal(rej, '错误', false)
                })
            },
 
            getImgsUrl() {
                let imgs = []
                this.attachList.forEach((item, index) => {
                    if (item.isImg && item.path) {
                        imgs.push(item.path)
                    }
                })
                return imgs
            },
            dldAndPreviewImg(item) {
                var _this = this
                getFileUrlS(item.fileId, item.fileserver, item.name).then((res) => {
                    console.log('getFileUrlS success:', res);
                    if (res.indexOf("file not exsits") < 0) {
                        const app = getApp()
                        if (res.indexOf("http://") < 0 && res.indexOf("https://") < 0)
                            res = app.globalData.basehttpurl + res
                        item.path = res
                        let arrImg = _this.getImgsUrl();
                        uni.previewImage({
                            current: item.path,
                            urls: arrImg,
                        })
                    } else {
                        showModal(res, '错误', false)
                    }
                }).catch((rej) => {
                    console.log('getFileUrlS fail:', rej);
                    showModal(rej, '错误', false)
                })
            },
 
            setAttachInfo(path, value) {
                var _this = this
                let attachs = [];
                attachs = _this.attachList;
                if (attachs.length == 0) {
                    return;
                }
                let curIndex = attachs.findIndex((item, index, arr) => {
                    return item.path == path;
                })
                if (curIndex == -1) {
                    return;
                }
                attachs[curIndex] = value;
                _this.setData({
                    attachList: attachs
                })
            },
            setAttachProgress(path, percent, uploadTask) {
                var _this = this
                if (percent < 1 || percent > 99) {
                    return;
                }
                let attachs = [];
                attachs = _this.attachList;
                if (attachs.length == 0) {
                    uploadTask.abort();
                    return;
                }
                let curIndex = attachs.findIndex((item, index, arr) => {
                    return item.path == path;
                })
                if (curIndex == -1) {
                    uploadTask.abort();
                    return;
                }
                let attachItem = attachs[curIndex]
                attachItem.percent = percent
                attachItem.isUploading = true
                attachs[curIndex] = attachItem;
                _this.setData({
                    attachList: attachs
                })
            },
            setAttachFailed(path, errMsg) {
                var _this = this
                let attachs = [];
                attachs = _this.attachList;
                if (attachs.length == 0) {
                    return;
                }
                let curIndex = attachs.findIndex((item, index, arr) => {
                    return item.path == path;
                })
                if (curIndex == -1) {
                    return;
                }
                let attachItem = attachs[curIndex]
                attachItem.isUploading = false
                attachItem.errMsg = errMsg
                attachs[curIndex] = attachItem;
                _this.setData({
                    attachList: attachs
                })
            },
            uploadAttachToMinio(file, isImg, isVideo) {
                var _this = this
                _this.setAttachFailed(file.path, "暂时不支持minio文件上传");
            },
            uploadAttach(file, isImg, isVideo) {
                var _this = this
                let color = TaskInit.fileUtils.getTypeBgColor(file.name)
                uploadTaskFile(file, function(docSuc) {
                        let upfile = {
                            isUploading: false,
                            fileserver: docSuc.FileServer,
                            percent: 100,
                            fileId: docSuc.ID,
                            fileMD5: docSuc.FileMD5 || "",
                            name: docSuc.Name,
                            size: docSuc.Size,
                            path: docSuc.path,
 
                            isImg: isImg,
                            isVideo: isVideo,
                            color: color,
                            sizestr: TaskInit.fileUtils.getFileSizeStr(docSuc.Size)
                        };
                        _this.setAttachInfo(upfile.path, upfile);
                        // console.log("uploadAttach uploadTaskFile res", upfile);
                    },
                    function(docProgress, uploadTask) {
                        console.log("uploadAttach uploadTaskFile Process", docProgress);
                        _this.setAttachProgress(docProgress.path, docProgress.progress, uploadTask);
                    },
                    function(docFail) {
                        console.log("uploadAttach uploadTaskFile fail", docFail);
                        _this.setAttachFailed(docFail.path, docFail.errMsg);
                    })
            },
            getPostDataObjAttr() {
                let obj_attr = {};
                let form = this.formAttrObj;
                this.showStyle.forEach((group) => {
                    group.attrs.forEach((attr) => {
                        if (attr.type == "ref-psn")
                            obj_attr[attr.attr] = `${(form[attr.attr].id || "").trim()};${(
                        form[attr.attr].name || ""
                      ).trim()}`;
                        else if (attr.type == "date")
                            obj_attr[attr.attr] = form[attr.attr] ?
                            dayjs(form[attr.attr]).format("YYYY-MM-DD") :
                            "";
                        else
                            obj_attr[attr.attr] =
                            form[attr.attr] && typeof form[attr.attr] == "string" ?
                            form[attr.attr].trim() :
                            form[attr.attr];
                    });
                });
                // 脚本返回的属性列表
                // Object.keys(this.otherAttrs).forEach((attr) => {
                //     if (!(attr in obj_attr)) obj_attr[attr] = this.otherAttrs[attr];
                // });
 
                // 新增模式中才需要使用默认值
                // if (!this.editMode) {
                //     // 属性定义中的默认值
                //     this.attrList.forEach((group) => {
                //         group.attr_list.forEach((attr) => {
                //             if (!(attr.name in obj_attr) && typeof attr.def_value !== undefined)
                //                 obj_attr[attr.name] = ['""', "''"].includes(attr.def_value) ?
                //                 "" :
                //                 attr.def_value;
                //         });
                //     });
                // }
                // // 数据指定为文件时,要附加文件信息
                // if (this.clsInfo.has_file == 1) {
                //     let {
                //         id,
                //         name,
                //         size,
                //         md5
                //     } = this.refFile.file;
                //     obj_attr["G_FILE_ID"] = id;
                //     obj_attr["S_FILE_NAME"] = name;
                //     obj_attr["S_FILE_SERVER"] = window.file_svr.files_flag;
                //     obj_attr["S_FILE_TYPE"] = name
                //         .slice(name.lastIndexOf("."))
                //         .toLowerCase();
                //     obj_attr["N_FILE_SIZE"] = size;
                //     obj_attr["S_FILE_MD5"] = md5;
                // }
 
                return obj_attr;
            },
 
            async submitForm() {
                console.log("submitForm")
                var _this = this
 
                try {
 
                    const attrs = _this.getPostDataObjAttr()
                    const req = Object.keys(attrs).map((a) => {
                        return {
                            name: a,
                            value: attrs[a] || ""
                        }
                    })
                    const upfile = []
                    if (this.options.objId) {
                        this.attachList.forEach((file) => {
                        
                            if (file.fileId && !file.id) {
        
                                const item = {
                                    FileID: file.fileId.includes("{") ? file.fileId : `{${file.fileId}}`,
                                    FileSize: file.size,
                                    FileName: file.name,
                                    FileMD5: file.fileMD5
                                }
                                upfile.push(item)
                            }
                        
                        })
                        const res = await updateClassAttr(this.options.clsId,this.options.objId ,req, upfile, this.delFileList)
                        
                    } else {
                        this.attachList.forEach((file) => {
                            if (file.fileId) {
                                const item = {
                                    FileID: file.fileId.includes("{") ? file.fileId : `{${file.fileId}}`,
                                    FileSize: file.size,
                                    FileName: file.name,
                                    FileMD5: file.fileMD5
                                }
                                upfile.push(item)
                            }
 
                        })
 
                        const res = await addClassAttr(this.options.clsId, req, upfile, this.extInfo)
                    }
 
                    uni.$emit('dataObjChange', this.options.appId)
                    uni.navigateBack();
 
                } catch (ex) {
                    let tip = typeof ex == "string" ? ex : ex.message;
                    console.log(`添加数据失败`, ex);
                    showModal(tip, "出错", false, false)
                }
            },
            showError(ex) {
                let tip = typeof ex == 'string' ? ex : typeof ex.err_msg == 'string' ? ex.err_msg : typeof ex.errMsg ==
                    'string' ? ex.errMsg : ""
                showModal(tip, "提示", false)
            },
 
        },
        onLoad(option) {
    
            this.options = option
            // #ifdef MP-DINGTALK
            
            my.setNavigationBar({
                backgroundColor: "#007AFF",
                frontColor: "#ffffff"
            })
            // #endif
            this.globalAttr = option.globalAttr || ""
            uni.setNavigationBarTitle({
                title: this.options.title || "新增"
            })
            this.loadPlatform()
            this.loadData()
            getUploadType().then((res) => {
                this.setData({
                    fileUploadType: res
                })
                console.log("getUploadType:", res)
            }).catch((rej) => {
                console.log("getUploadType fail:", rej)
            })
 
        },
    }
</script>
<style lang="scss">
    .view-data-new-dataobj {
        background-color: #e5eaee;
        width: 750rpx;
        height: 100vh;
        display: flex;
        flex-direction: column;
 
        .uni-forms {
            padding: 5px;
            overflow: auto;
            flex: 1;
        }
 
        .uni-collapse {
            background-color: #e5eaee;
 
            .uni-collapse-item {
                border-radius: 8px;
                background-color: #fff;
                margin: 5px;
                padding-bottom: 5px;
 
            }
 
        }
 
        .uni-group-item {
            border-radius: 8px;
            background-color: #fff;
            margin: 5px;
            padding-bottom: 5px;
 
        }
 
        .uni-select {
            border: 0;
        }
 
        .uni-panel-title {
            display: flex;
            width: calc(100% - 10rpx);
            flex-direction: row;
        }
 
        .uni-title-icon {
            background-color: #ffdd00;
            border-radius: 50%;
            width: 36px;
            height: 36px;
            margin: 5px;
            margin-right: 12px;
            display: inline-block;
            vertical-align: middle;
            text-align: center;
            line-height: 40px;
 
            .uni-icon {
                color: #fff;
                font-size: 20px
            }
 
        }
 
        .uni-title-text {
            flex: 1;
            font-weight: 600;
            line-height: 45px;
        }
 
        .uni-panel-icon-btn {
            font-size: 18px;
            padding: 8px;
            margin-top: 5px;
            // height: 36px;
            // width: 36px;
 
        }
 
        .uni-panel-text {
            flex: 1;
            color: #000000;
            font-weight: normal;
        }
 
        .uni-head-style {
            display: flex;
            flex-direction: column;
            width: calc(100% - 30rpx);
            padding: 15rpx;
        }
 
        .uni-head-style input {
            width: calc(100% - 20rpx);
            height: 52rpx;
            line-height: 34rpx;
            background: #FFF;
            border-radius: 0 !important;
            color: #2d8cf0;
            padding: 10rpx 10rpx 12rpx;
            font-size: 34rpx;
            font-family: inherit;
            box-shadow: none !important;
            transition-duration: 0.1s;
            margin-top: 4rpx;
        }
 
        .input-disabled {
            background-color: #f3f3f3 !important;
        }
 
        .uni-hidden {
            display: none;
        }
 
        .input-wrapper {
            border: 1px solid #d5d5d5;
            width: 100%;
            line-height: 22rpx;
        }
 
        .uni-panel-upfile {
            display: flex;
            flex-wrap: wrap;
            flex-direction: row !important;
 
            .uni-panel-upfile-item {
                display: flex;
                position: relative;
                margin: 2rpx;
                height: 200rpx;
                width: 30%;
                flex-direction: column;
                padding: 4px;
                justify-content: center;
                align-items: center;
            }
 
            .uni-panel-upfile-img {
                display: flex;
                height: 100%;
                width: 100%;
            }
 
            .uni-panel-video-playIcon {
                display: flex;
                flex: 1;
                width: 50%;
            }
 
            .uni-panel-upfile-item-name {
                display: flex;
                flex: 1;
                color: #fff;
                width: 100%;
                word-wrap: break-word;
                word-break: break-all;
                font-size: 14px;
                max-height: calc(200rpx - 20px);
                text-overflow: ellipsis;
                overflow: hidden;
                -webkit-line-clamp: 4; //表明是2行文本显示省略号,换成3则表明是3行文本显示省略号
                -webkit-box-orient: vertical;
            }
 
            .uni-panel-upfile-item-size {
                display: flex;
                height: 18px;
                color: #fff;
                font-size: 14px;
                text-align: left;
            }
 
            .uni-panel-icon {
                font-weight: normal;
                font-size: 16px;
                padding: 4px;
            }
 
 
 
        }
 
        .uni-panel-bottom-button {
            display: flex;
            justify-content: center;
            width: 100%;
            font-size: 17px !important;
            margin-top: 8px;
            margin-bottom: 8px;
            border-radius: 0px;
        }
 
        .uni-panel-button {
            flex: 1;
            border-radius: 12px;
            margin: 5px 12px 16px;
            background-color: #00aaff;
            color: #fff;
        }
 
        .popup-content {
            display: flex;
            justify-content: center;
            flex-direction: column;
            background-color: transparent;
        }
    .popup-content_menu-item {
            display: flex;
            background-color: transparent;
            justify-content: center;
            padding: 12px;
            font-size: 16px;
        }
 
 
 
    }
</style>