2023西安数博会CIM演示-【前端】-Web
AdaKing88
2023-08-21 bc03b832caa49bbcd2674fe4cae3701b5059bf95
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
<template>
  <div>
    <el-collapse v-model="activeName" accordion>
      <el-collapse-item title="量算工具" name="1">
        <div style="width: 100%; text-align: center">
          <el-row>
            <div class="opt_button" @click="measure(1)">
              <div><i class="el-icon-film"></i></div>
              <span>距离量算</span>
            </div>
            <div class="opt_button" @click="measure(2)">
              <div><i class="el-icon-film"></i></div>
              <span>面积量算</span>
            </div>
          </el-row>
          <el-row>
            <div class="opt_button" @click="measure(3)">
              <div><i class="el-icon-film"></i></div>
              <span>高度量算</span>
            </div>
            <div class="opt_button" @click="measure(4)">
              <div><i class="el-icon-film"></i></div>
              <span>测表面积</span>
            </div>
          </el-row>
          <el-row>
            <div class="opt_button" @click="measure(5)">
              <div><i class="el-icon-film"></i></div>
              <span>表面距离</span>
            </div>
            <div class="opt_button" @click="measure(6)">
              <div><i class="el-icon-film"></i></div>
              <span>清除</span>
            </div>
          </el-row>
        </div>
      </el-collapse-item>
      <el-collapse-item title="地上地下" name="3">
        <el-form style="padding: 10px">
          <el-form-item label="地表透明">
            <el-switch v-model="dxmsParams.turnon" active-color="#13ce66" inactive-color="#a9a9a9"
                       @change="turnonChange">
            </el-switch>
          </el-form-item>
          <el-form-item label="透明度:">
            <el-slider style="width: 50%; margin-left: 80px" size="mini" v-model="dxmsParams.terropacity"
                       @change="terropacityChange" :disabled="dxmsParams.sliderDisabled"></el-slider>
          </el-form-item>
        </el-form>
      </el-collapse-item>
      <el-collapse-item title="地面开挖" name="4">
        <el-form :inline="true" style="font-color: 0; text-align: center" label-position="right">
          <el-form-item label="挖开深度(m):" class="input-item">
            <el-input size="small" placeholder="请输入内容" v-model="dmkwParams.dmkwdeep" clearable>
            </el-input>
          </el-form-item>
        </el-form>
        <div class="buttongroups">
          <el-button size="small" @click="startKW">绘制开挖范围</el-button>
          <el-button size="small" @click="clearKW">清除</el-button>
        </div>
 
      </el-collapse-item>
      <el-collapse-item title="地面压平" name="5">
        <el-form :inline="true" style="font-color: 0; text-align: center" label-position="right">
          <el-form-item label="压平高度(m):" class="input-item">
            <el-input size="small" placeholder="请输入内容" v-model="dmypParams.dmypdeep" clearable>
            </el-input>
          </el-form-item>
        </el-form>
        <div class="buttongroups">
          <el-button size="small" @click="startDMYP">绘制压平范围</el-button>
          <el-button size="small" @click="clearYP">清除</el-button>
        </div>
      </el-collapse-item>
      <el-collapse-item title="模型压平" name="6">
        <el-form :inline="true" style="font-color: 0; text-align: center" label-position="right">
          <el-form-item label="压平高度(m):" class="input-item">
            <el-input size="small" placeholder="请输入内容" v-model="mxypParams.mxypdeep" clearable>
            </el-input>
          </el-form-item>
        </el-form>
        <div class="buttongroups">
          <el-button size="small" @click="startMXYP">绘制压平范围</el-button>
          <el-button size="small" @click="clearMXYP">清除</el-button>
        </div>
      </el-collapse-item>
      <!-- <el-collapse-item title="分层分户" name="7">
        <div></div>
      </el-collapse-item> -->
      <el-collapse-item title="地形分析" name="8">
        <el-switch active-text="开始分析" inactive-text="关闭分析" v-model="value" active-color="#13ce66"
                   inactive-color="#a9a9a9"
                   @change="dxfx">
        </el-switch>
      </el-collapse-item>
      <el-collapse-item title="材质工具" name="9" class="collapse-item" style="position: relative">
        <div class="modelTool">
          <div style="position: absolute;right: 30px;top: 4px;z-index: 996;color:#fff">
            <el-switch v-model="showMaterialCaseList" active-color="#3384C6" inactive-color="#BEC2C6" active-text="材质模式"
                       inactive-text="普通模式" @change="startMaterialModel">
            </el-switch>
          </div>
          <material-tool-box ref="materialtoolboxRef"></material-tool-box>
        </div>
      </el-collapse-item>
      <el-collapse-item title="分层工具" name="10" style="margin-bottom: 80px">
        <div v-if="louceng.length==0" style="color: darkgray;text-align: center">
          请在目录中选择Bim模型并双击飞到模型
        </div>
        <div v-for="(item, index) in louceng" :key="index">
          <div class="floor_button">
            <span style="text-align: center; display: inline-block" @click="openStructure(item)">{{
                item.name
              }}</span>
          </div>
        </div>
      </el-collapse-item>
    </el-collapse>
    <div class="funcBox layui-form" v-show="false">
      <div class="layui-form-item">
        <label class="layui-form-label">地表渲染</label>
        <div class="layui-input-block">
          <input type="radio" name="sex" value="无" title="无" checked/>
          <input type="radio" name="sex" value="坡度" title="坡度"/>
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">等高线</label>
        <div class="layui-input-block">
          <input type="checkbox" lay-skin="switch" lay-filter="open" lay-text="开|关"/>
          <div id="lineColor"></div>
        </div>
      </div>
      <div class="layui-form-item lineValue">
        <label class="layui-form-label">间距</label>
        <div class="layui-input-block">
          <div id="spacing" class="slider"></div>
        </div>
      </div>
      <div class="layui-form-item lineValue">
        <label class="layui-form-label">线宽</label>
        <div class="layui-input-block">
          <div id="width" class="slider"></div>
        </div>
      </div>
    </div>
    <div></div>
 
 
    <div class="drag_black scrollbar" v-draw v-if="isInstallationOn" style="background-color: #272727B2">
      <div class="pop-header">
        <i class="el-icon-menu"></i>属性
        <div style="float: right; cursor: pointer" @click="closePopouDlg">
          <i class="el-icon-close"></i>
        </div>
      </div>
      <div class="scrollbar" style="overflow-y: auto;width:100%;">
        <div style="margin: 20px">
          <el-row>
            <el-col :span="12">
              当前构件:
              <el-select @change="modelListChange" size="small" placeholder="请选择" style="width: 200px;margin: 10px;"
                         v-model="nowModel.id" class="selectStyle">
                <el-option v-for="item in componentIdList" :key="item" :label="item" :value="item">
                </el-option>
              </el-select>
            </el-col>
            <el-col :span="12" style="line-height: 50px;text-align: right">
              <el-button size="small" class="bimBtn" @click="editAttributes()">编辑</el-button>
              <el-button size="small" class="bimBtn" @click="saveAttributes()">保存</el-button>
              <el-button size="small" class="bimBtn" @click="openAddAttributes()">批量增加属性</el-button>
              <!-- <el-button size="small" class="bimBtn" @click="openEncode()">批量编码</el-button> -->
            </el-col>
          </el-row>
          <el-form ref="attributeForm" :model="attributeForm" label-width="120px" style="margin:20px;">
            <el-row>
              <el-form-item v-for="(val, key, i) in attributeForm" :key="i" :label="key">
                <el-input v-model="attributeForm[key]" :disabled="editAttribute" class="inputStyle"
                          style="width: 610px">
                </el-input>
              </el-form-item>
            </el-row>
          </el-form>
        </div>
      </div>
    </div>
 
    <div class="drag_black1 scrollbar" v-draw v-if="addAttributesD">
      <div class="pop-header">
        <i class="el-icon-menu"></i>新增属性
        <div style="float: right; cursor: pointer" @click="OffAddAttributes()">
          <i class="el-icon-close"></i>
        </div>
      </div>
      <div class="scrollbar" style="overflow-y: auto;width:100%;">
        <div v-for="(item, i) in inputList" :key="i">
          <el-form ref="AddAttributeForm" :rules="rules" :model="item" label-width="80px"
                   style="margin:30px 20px 20px 20px;">
            <el-row>
              <el-col :span="12">
                <el-form-item label="属性名称" prop="name">
                  <el-input v-model="inputList[i].name" class="inputStyle"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="属性值">
                  <el-input v-model="inputList[i].value" class="inputStyle"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="属性类型">
                  <!--<el-input v-model="inputList[i].type" class="inputStyle"></el-input>-->
                  <el-select placeholder="请选择" style="width: 240px;" v-model="inputList[i].type" class="selectStyle">
                    <el-option label="string" value="string"></el-option>
                    <el-option label="int" value="int"></el-option>
                    <el-option label="double" value="double"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="属性长度">
                  <!--                  <el-input v-model="inputList[i].length" class="inputStyle"></el-input>-->
                  <el-input-number v-model="inputList[i].length" :min="1" :max="1000"></el-input-number>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>
 
 
        <div style="margin: 20px;text-align: center">
          <el-button size="small" class="bimBtn" @click="addInput()">新增</el-button>
          <el-button size="small" class="bimBtn" @click="addAttributes()">保存</el-button>
          <el-button size="small" class="bimBtn" @click="OffAddAttributes()">取消</el-button>
        </div>
      </div>
    </div>
    <div class="drag_black1 scrollbar" v-draw v-if="encode">
      <div class="pop-header">
        <i class="el-icon-menu"></i>自定义批量编码
        <div style="float: right; cursor: pointer" @click="closeEncode">
          <i class="el-icon-close"></i>
        </div>
      </div>
      <div class="scrollbar" style="overflow-y: auto;width:100%;">
        <el-form ref="CustomCoding" :rules="rules" :model="encodeList" label-width="100px" style="margin-top: 20px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="属性名称" prop="name">
                <el-input v-model="encodeList.name" class="inputStyle"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="编码前缀">
                <el-input v-model="encodeList.prefix" class="inputStyle"></el-input>
              </el-form-item>
            </el-col>
 
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="编码连接符">
                <el-input v-model="encodeList.connector" class="inputStyle"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="编码位数">
                <!--                <el-input :placeholder="'至少不小于'+componentIdList.length.toString().length+'位!'"-->
                <!--                          v-model="encodeList.number" class="inputStyle"></el-input>-->
                <el-input-number v-model="encodeList.number" :min="componentIdList.length.toString().length" :max="100">
                </el-input-number>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div style="margin: 20px;text-align: center;box-sizing: border-box">
          <el-button size="small" class="bimBtn" @click="saveEncode()">保存</el-button>
          <el-button size="small" class="bimBtn" @click="closeEncode()">取消</el-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import axios from "axios";
import * as SmartEarth from "../../../../public/CimSDK/index.js"
import MaterialToolBox from './MaterialToolBox.vue';
// CIMSDK中layui 注册
// import layui from "../../../../public/CimSDK/Workers/layui/layui.js"
 
let Cesium = SmartEarth.Cesium;
let measureData = [];
let colorAll = {
  point: Cesium.Color.fromCssColorString("#ff0000"),
  polyline: Cesium.Color.fromCssColorString("#ffff0050"),
  polygon: Cesium.Color.fromCssColorString("#ffff0050"),
};
let test = null;
let testmodel = [
  {
    id: 0,
    modulename: "bim",
    urls: "http://103.85.165.99:9001/gisserver/c3dserver/js_a67_mx/tileset.json",
  },
];
let dxkw = null
let terrainFlatten = null
let currentModel = null
export default {
  components: {
    MaterialToolBox
  },
  data() {
    this.dxms = {
      UndergroundMode: null
    };
    //地面开挖
    this.dmkw = {
      Excavation: null
    };
    this.dmyp = {
      TerrainFlattening: null, positions: [],
    };
    this.mxyp = {
      ModelFlattening: null,
    };
    return {
      radiusSize: 0.4,
      bimFCFH: false,
      louceng: [],
      //地下模式
      dxmsParams: {
        turnon: false,
        terropacity: 100,
        sliderDisabled: true,
      },
      //地面开挖
      dmkwParams: {
        dmkwdeep: 0
      },
      dmypParams: {
        dmypdeep: 0
      }, mxypParams: {
        mxypdeep: 0
      },
      value: false,
      showElevation: false,
      activeName: "1",
      cutdistance: 0,
      radiovalue: 6,
      isInstallationOn: false,
      // modelList:[],//多选构件列表
      nowModel: {},
      attributeForm: {},
      attributeFormOld: {},
      editAttribute: true,
      selectPosition: null,
      bimModelID: null,
      setCompoent: null,//设置框选显示状态
      componentIdList: [],//构件id列表
      clickComponentId: [],
      saveGuid: null,
      addAttributesD: false,
      // addAttributeForm: null,
      inputList: [{
        name: '',
        type: '',
        value: '',
        length: ''
      }],
      encode: false,
      encodeList: {
        prefix: '',
        connector: '',
        number: '',
        name: ''
      },
      rules: {
        name: [
          {required: true, message: '请输入属性名称', trigger: 'blur'},
        ],
      },
      serviceName: null,
      flattenPolygon: null,
      // currentModel: null,
      componentId: null,
      showMaterialCaseList: false,
    };
  },
  methods: {
    async getModelPosition(modelId) {
      let res = await axios.get(BIM_SERVER_GET + "getPosition?modelId=" + modelId);
      return res.data;
    },
    async getModelByFloorstorey(modelid, storey) {
      let res = await axios.get(BIM_SERVER_GET + "getComponentIds?modelId=" + modelid + "&storey=" + storey);
      return res.data
    },
    async _aloop(x, y, z, bim, icTran, _Cesium, modelId) {
      let that = this;
      bim.SetComponentTransform(_Cesium.Matrix4.toArray(_Cesium.Matrix4.fromTranslation(new _Cesium.Cartesian3(x, y, z))),
          new Int32Array(icTran),
          false
      );
      let res = await this.getModelPosition(modelId);
      if (res.code !== 200) {
        return
      }
      let lng = Number(res.data.x), lat = Number(res.data.y), height = Number(res.data.height);
      var position = Cesium.Cartesian3.fromDegrees(lng || 118.70647245037493, lat || 31.973898289550043, height || 0);
      let modelTransform = Cesium.Matrix4.toArray(Cesium.Transforms.eastNorthUpToFixedFrame(position));
      if (res.data.roll) {
        let rz = Cesium.Math.toRadians(res.data.roll);
        var rotationZ = Cesium.Matrix4.fromRotationTranslation(Cesium.Matrix3.fromRotationZ(rz));
        Cesium.Matrix4.multiply(modelTransform, rotationZ, modelTransform);
      }
      let currentModel = this.$store.state.bimModelListAll[modelId]
      let boxMin = currentModel.boxMin;
      let boxMax = currentModel.boxMax;
      boxMin = Cesium.Cartesian3.fromArray(boxMin, 0);
      boxMax = Cesium.Cartesian3.fromArray(boxMax, 0);
      boxMin = Cesium.Matrix4.multiplyByPoint(modelTransform, boxMin, {})
      boxMax = Cesium.Matrix4.multiplyByPoint(modelTransform, boxMax, {})
      let boundingSphere = Cesium.BoundingSphere.fromPoints([boxMin, boxMax], new Cesium.BoundingSphere())
      let offset = 0
      if (y > -22) {
        this.isMoveing = true
        let moveTimer = setInterval(() => {
          if (offset >= (boundingSphere.radius) * this.radiusSize) {
            clearInterval(moveTimer)
            this.isMoveing = false
          }
          offset += 10;
          bim.SetComponentTransform(_Cesium.Matrix4.toArray(_Cesium.Matrix4.fromTranslation(new _Cesium.Cartesian3(x, y - offset, z))),
              new Int32Array(icTran),
              false
          );
        }, 30);
      }
    },
    async openStructure(index) {
      let item = this.$store.state.currentSelectNode;
      if (item) {
        this.bimFCFH = !this.bimFCFH;
        let modelId = this.getModelIdByUniqueId();
        //展开分层分户
        let that = this;
        let bim = window.BIM;
        if (bim) {
          // window.canGL = level === 9;
          let icTran = [];
          let res = await this.getModelByFloorstorey(modelId, index.name);
          for (let i = 0; i < res.data.length; i++) {
            icTran.push(modelId, res.data[i].id);
          }
          if (!index.isOpen) {
            this._aloop(0, 0, 0, bim, icTran, Cesium, modelId);
            index.isOpen = true;
          } else {
            bim.SetComponentTransform(Cesium.Matrix4.toArray(Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(0, 0, 0))),
                new Int32Array(icTran),
                false
            );
            index.isOpen = false;
          }
        }
      }
    },
    startMaterialModel(val) {
      if (window.handler) {
        console.log(val)
        this.showMaterialCaseList = false;
        this.$message.error("请先结束批注!");
        return;
      }
      this.$nextTick(() => {
        this.$refs.materialtoolboxRef.startMaterialModel(val)
      })
    },
    measure(tag) {
      let colorAll = {};
      switch (tag) {
        case 1:
          let m1 = window.sgworld.Command.execute(0, 10, colorAll, () => {
          });
          measureData.push(m1);
          break;
        case 2:
          sgworld.analysis.getPlaneArea()
          break;
        case 3:
          let m3 = sgworld.Command.execute(0, 5, colorAll, () => {
          });
          measureData.push(m3);
          break;
        case 4:
          sgworld.analysis.getSurfaceArea3d()
          break;
        case 5:
          let m5 = sgworld.Command.execute(0, 2, colorAll, () => {
          });
          measureData.push(m5);
          break;
        case 6:
          // 清除
          measureData.forEach((item) => {
            item.deleteObject();
          });
          sgworld.analysis.deleteObject();
          measureData = [];
          break;
      }
    },
    turnonChange(val) {
      if (val === true) {
        this.dxmsParams.terropacity = 50;
        this.dxmsParams.sliderDisabled = false;
      } else {
        this.dxmsParams.terropacity = 100;
        this.dxmsParams.sliderDisabled = true;
      }
      this.dxms.UndergroundMode = sgworld.Analysis.UndergroundMode(
          val,
          this.dxmsParams.terropacity / 100
      );
    },
    terropacityChange(val) {
      this.dxms.UndergroundMode &&
      (this.dxms.UndergroundMode.alpha = val / 100);
    },
    // 模型切割
    clippingModel() {
      var model = this.$store.state.modelData;
      if (model) {
        model && model.clippingModel();
      } else {
        this.$message.error("请选择模型");
      }
    },
    // 全球地形分析
    dxfx(val) {
      console.log(val)
      if (val) {
        this.showElevation = true;
        //跳转视角
        sgworld.camera.flyTo(107.5, 32.5, 5000, 0, -20, 0.0, 5);
        // sgworld.Navigate.jumpTo({
        //   //跳转视角
        //   destination: {
        //     x: 311837.3471863137,
        //     y: 5628280.936629815,
        //     z: 2992581.921482893,
        //   },
        //   orientation: {
        //     heading: 2.5028896264234364,
        //     pitch: -0.2201285642360813,
        //     roll: 0.0,
        //   },
        // });
        //添加cts地形
        if (test == null) {
          test = sgworld.factory.createTerrainLayer({
            sourceType: "ctb",
            url: 'http://103.85.165.99:9001/gisserver/ctsserver/srtm_cts'
          });
        }
      } else {
        this.showElevation = false;
        test.removeFromMap();
        test = null;
      }
      let elevationTool = new SmartEarth.ElevationTool(window.sgworld);
      layui.use(["form", "slider", "colorpicker"], function () {
        var slider = layui.slider;
        var form = layui.form;
        var colorpicker = layui.colorpicker;
        form.on("radio", function (data) {
          if (data.value === "无") {
            elevationTool.type = "none";
            $(".renderValue").hide();
          } else {
            elevationTool.type = "slope";
            $(".renderValue").show();
          }
          elevationTool.render();
        });
        // 等高线开关
        form.on("switch(open)", function (data) {
          // 是否显示等高线
          elevationTool.tf = this.checked;
          elevationTool.render();
          if (this.checked) {
            $(".lineValue").show();
          } else {
            $(".lineValue").hide();
          }
        });
 
        //间距
        slider.render({
          elem: "#spacing",
          max: 500,
          min: 20,
          value: elevationTool.spacing,
          change: function (value) {
            elevationTool.setSpacing(value);
          },
        });
        //线宽
        slider.render({
          elem: "#width",
          max: 10,
          min: 1,
          value: elevationTool.width,
          change: function (value) {
            elevationTool.setWidth(value);
          },
        });
        //等高线颜色
        colorpicker.render({
          elem: "#lineColor", //绑定元素
          color: elevationTool.contourColor,
          done: function (color) {
            elevationTool.setContourColor(color);
          },
        });
      });
 
    },
 
    startKW() {
      // this.clearKW()
      // if (!this.isLoadTerrain()) {
      //   this.$message.error("请先加载地形");
      //   return;
      // }
      let deepVal = parseFloat(this.dmkwParams.dmkwdeep);
      if (isNaN(deepVal)) {
        this.$message.error("请输入数字");
      } else {
        dxkw = sgworld.analysis.createTerrainExcavation({
          height: deepVal,
          callback: function (a) {
          },
        })
      }
    },
    isLoadTerrain() {
      for (let i of sgworld.userScene.rootNode.childNodes) {
        if (i.name === "terrainProviders") {
          if (i.childNodes.length !== 0) {
            return true;
          } else {
            return false;
          }
        }
      }
    },
    startDMYP() {
      // if (!this.isLoadTerrain()) {
      //   this.$message.error("请先加载地形");
      //   return;
      // }
      let that = this;
      let deepVal = parseFloat(this.dmypParams.dmypdeep);
      if (isNaN(deepVal)) {
        this.$message.error("请输入数字");
      } else {
        terrainFlatten = new SmartEarth.Cesium.TerrainFlatten(
            sgworld.coreMap.scene
        )
        let draw = sgworld.shapeTool.createDrawShapeTool((e) => {
          let polygonI = []
          for (let i of e.result) {
            let ellipsoid = sgworld.coreMap.scene.globe.ellipsoid
            let cartographic = ellipsoid.cartesianToCartographic(i)
            let lon = SmartEarth.Cesium.Math.toDegrees(cartographic.longitude) // 经度
            let lat = SmartEarth.Cesium.Math.toDegrees(cartographic.latitude) // 纬度
            let height = SmartEarth.Cesium.Math.toDegrees(cartographic.height) // 纬度
            polygonI.push(lon, lat, deepVal)
          }
          terrainFlatten.addPolygon(polygonI) //添加压平面
          terrainFlatten.update() //更新地形
          draw.removeFromMap()
        })
      }
    },
    clearYP() {
      // if (this.dmyp.TerrainFlattening) {
      //   earthCtrl.TerrainFlattening.remove();
      //   this.dmyp.TerrainFlattening = undefined;
      // }
      if (terrainFlatten) {
        terrainFlatten.clearPolygon()
      }
    },
    clearKW() {
      // if (this.dmyp.TerrainFlattening) {
      //   earthCtrl.TerrainFlattening.remove();
      //   this.dmyp.TerrainFlattening = undefined;
      // }
      if (Object.keys(dxkw).length > 0) {
        dxkw.removeFromMap()
        dxkw = {}
      }
    },
    createTerrainModifier(name, positions, deep) {
      let viewer = sgworld._Viewer;
      let findDirectParent = function (e) {
        try {
          var t = [];
          if (e.width == Math.PI)
            return null;
          for (var i = 0; i < viewer.scene.globe._surface._tilesToRender.length; i++) {
            var o = viewer.scene.globe._surface._tilesToRender[i], r = o._rectangle;
            Cesium.Rectangle.intersection(r, e) && t.push(o)
          }
          return t;
        } catch (e) {
 
        }
        return null;
      }
      if (positions && positions.length > 0) {
        var ellipsoid = viewer.scene.globe.ellipsoid;
        for (let i = 0; i < positions.length; ++i) {
          const position = positions[i];
 
          let h = viewer.scene.globe.getHeight(
              Cesium.Cartographic.fromCartesian(position));
 
          console.log(h)
        }
 
        // let _heightArray = new Array(positions.length);
        // _heightArray.fill(deep);
 
        // let _id = Cesium.createGuid();
        // let _now = Date.now();
        // let _rectangle = Cesium.Rectangle.fromCartesianArray(positions);
 
        // let _parent = findDirectParent(_rectangle);
 
        // viewer.terrainProvider && void 0 === viewer.terrainProvider._modifyTerrainObjects && (viewer.terrainProvider._modifyTerrainObjects = []);
 
        // let a = { id: _id, name: name, show: true, rectangle: _rectangle, vertices: positions, heights: _heightArray, timeStamp: _now };
        // a.remove = function () {
        //   if (viewer.terrainProvider && viewer.terrainProvider._modifyTerrainObjects)
        //     for (var i = viewer.terrainProvider._modifyTerrainObjects.length - 1; 0 <= i; i--)
        //       viewer.terrainProvider._modifyTerrainObjects[i].id == n && viewer.terrainProvider._modifyTerrainObjects.splice(i, 1);
        //   if (_parent)
        //     try {
        //       for (let j = 0; j < _parent.length; j++)
        //         try {
        //           _parent[j]._parent.freeResources()
        //         } catch (e) { }
 
        //     } catch (e) { }
        // }
 
        // if (viewer.terrainProvider._modifyTerrainObjects.push(a), _parent)
        //   try {
        //     for (let l = 0; l < _parent.length; l++)
        //       try {
        //         _parent[l]._parent.freeResources()
        //       } catch (e) { }
        //   } catch (e) { }
        // return a;
      }
 
    },
    startMXYP() {
      this.clearMXYP()
 
      let item = this.$store.state.currentSelectNode;
      if (!item) {
        this.$message.warning("先选中需要压平的模型!")
        return;
      }
 
      let model = sgworld.userScene.getChildById(item.id)
      if (!model) {
        this.$message.warning("请重新选择模型!")
        return;
      }
      currentModel = model
      let deepVal = parseFloat(this.mxypParams.mxypdeep);
      if (isNaN(deepVal)) {
        this.$message.error('请输入数字');
      } else {
        sgworld.drawObj = sgworld.Creator.createSimpleGraphic(
            'polygon',
            {
              clampToGround: true,
            },
            entity => {
              let positions = window.positions = entity.polygon.hierarchy.getValue().positions;
              sgworld.Creator.SimpleGraphic.remove(entity.id);
              let coord = []
              positions.forEach(position => {
                let cartographic = Cesium.Cartographic.fromCartesian(position)
                coord.push(Cesium.Math.toDegrees(cartographic.longitude), Cesium.Math.toDegrees(cartographic.latitude))
              });
              this.flattenPolygon = window.Cesium.PolygonGeometry.fromPositions({
                positions: window.Cesium.Cartesian3.fromDegreesArray(coord),
                height: deepVal,
              });
              if (model._primitive && model._primitive.hasOwnProperty('addFlattenPolygon')) {
                model._primitive.addFlattenPolygon(this.flattenPolygon);
                model._primitive._needUpdateFlatten = true;
              }
              // that.mxyp.ModelFlattening = sgworld.Creator.createModelModifier("模型压平", positions, deepVal, {});
            }
        );
      }
 
    },
    clearMXYP() {
      if (currentModel) {
        if (currentModel._primitive && currentModel._primitive.hasOwnProperty('removeFlattenPolygon') && this.flattenPolygon) {
          currentModel._primitive.removeFlattenPolygon(this.flattenPolygon);
          this.flattenPolygon = null
          currentModel = null
        }
      }
    },
    clearPQ() {
      this.changeDirection("");
    },
    clearTS() {
      this.tsfx.lineOfSight.forEach((line) => {
        line && line.deleteObject();
      });
      this.tsfx.lineOfSight = [];
    },
    clearPQDM() {
      let id = sgworld.ProjectTree.findItem("测量结果");
      if (id) {
        sgworld.ProjectTree.deleteItem(id);
      }
      this.$emit("pmfxshow", {ison: false, data: {}});
    },
    addInput() {
      this.inputList.push({
        name: '',
        type: '',
        value: '',
        length: ''
      })
    },
    OffAddAttributes() {
      this.addAttributesD = false
      this.inputList = [{
        name: '',
        type: '',
        value: '',
        length: ''
      }]
    },
    bimSelect() {
      var _that = this
      this.bimSelectEnd()
      if (this.componentIdList.length > 0) {
        this.isInstallationOn = true
      } else {
        this.$message.error("请先选择构件!")
      }
 
    },
    clickAddCompoent() {
      let _that = this;
      window.ClickHandler = new Cesium.ScreenSpaceEventHandler(sgworld._Viewer.canvas);
      // window.bimClickHandler = new Geoworld.ScreenSpaceEventHandler(earthCtrl.coreMap.canvas);
      window.ClickHandler.setInputAction(function onLeftClick(movement) {
        // 拾取:模型id,实例id,构件id
        window.BIM.PickId(movement.position.x, movement.position.y).then(idArr => {
          let modelId = idArr[0];
          _that.bimModelID = idArr[0];
          let instancesId = idArr[1]
          let componentId = idArr[2]
          _that.clickComponentId.push(modelId, instancesId)
          _that.componentIdList.push(componentId)
          console.log("模型id", modelId, "实例id", instancesId, "构件id", componentId)
          window.BIM.SetInstancesStatus(2, new Int32Array([modelId, instancesId]))
        })
      }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
    },
    bimSelectShow() {
      var _that = this
      _that.$store.commit("START_LOADING");
      if (window.BIM) {
        window.BIM.FrameSelection(_that.selectPosition.sx, _that.selectPosition.sy, _that.selectPosition.ex, _that.selectPosition.ey).then(result => {
          //返回的内容是数组[modelId, componentId, instancesId,...]
          _that.bimModelID = result[0]
          var setCompoent = []
          var compoentList = []
          for (let i = 0; i < result.length; i += 3) {
            setCompoent.push(result[i], result[i + 2])
            compoentList.push(result[i + 1])
          }
          _that.setCompoent = setCompoent
          _that.componentIdList = [...new Set(compoentList)]
          window.BIM.SetInstancesStatus(2, new Int32Array(setCompoent));
          _that.$store.commit("CLOSE_LOADING");
        })
      }
    },
    bimSelectOff() {
      let setCompoent = []
      let _that = this
      if (_that.setCompoent) {
        for (let i = 0; i < _that.setCompoent.length; i += 2) {
          setCompoent.push(_that.setCompoent[i], _that.setCompoent[i + 1])
        }
        window.BIM.SetInstancesStatus(1, new Int32Array(setCompoent));
        _that.setCompoent = null
      }
      // for(let i = 0;i< _that.clickComponentId.length;i++){
      //   window.BIM.SetInstancesStatus(new Int32Array(_that.clickComponentId[i]));
      // }
      console.log('点击列表', _that.clickComponentId)
      if (_that.clickComponentId.length > 0) {
        window.BIM.SetInstancesStatus(1, new Int32Array(_that.clickComponentId));
        _that.clickComponentId = []
      }
 
    },
    bimSelectEnd() {
      // var handler = new Cesium.ScreenSpaceEventHandler(sgworld._Viewer.canvas);
      // handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_DOWN);
      // handler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_UP);
      // handler.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE);
      // sgworld._Viewer.scene.screenSpaceCameraController.zoomEventTypes=[Cesium.CameraEventType.RIGHT_DRAG, Cesium.CameraEventType.WHEEL,Cesium.CameraEventType.PINCH]
      if (window.SelectHandler) {
        window.SelectHandler.destroy()
        window.SelectHandler = undefined
      }
      if (window.ClickHandler) {
        window.ClickHandler.destroy()
        window.ClickHandler = undefined
      }
    },
    bimSelectBegin() {
      let item = this.$store.state.currentSelectNode;
      if (!item) return this.$message.error("请先选择需模型!")
      this.serviceName = item.num
      this.clickAddCompoent()
      var _that = this
      _that.setCompoent = null
      let viewer = sgworld._Viewer;
      //cesium默认右键为放大缩小,此处给zoomEventTypes设置新值
      viewer.scene.screenSpaceCameraController.zoomEventTypes = [Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK]
      //earthsdk默认右键为改变视角,此处禁止。
      viewer.scene.screenSpaceCameraController.lookEventTypes = {
        eventType: Cesium.CameraEventType.LEFT_DRAG,
        modifier: Cesium.KeyboardEventModifier.SHIFT,
      }
      //右键按下标识
      var flag = false
      //起点终点x,y
      var startX = null;
      var startY = null;
      var endX = null;
      var endY = null;
      //创建框选元素
      var selDiv = document.createElement("div")
      window.SelectHandler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
      //右键按下事件,设置起点,div设置样式和位置,添加到页面
      window.SelectHandler.setInputAction(function (event) {
        flag = true
        _that.bimSelectOff()
        startX = event.position.x
        startY = event.position.y
 
        selDiv.style.cssText = "position:absolute;width:0px;height:0px;font-size:0px;margin:0px;padding:0px;border:1px dashed #0099FF;background-color:#C3D5ED;z-index:1000;filter:alpha(opacity:30);opacity:0.3;";
        selDiv.id = "selectDiv";
        selDiv.style.left = startX + "px";
        selDiv.style.top = startY + "px";
        document.getElementById('sdkContainer').appendChild(selDiv);
      }, Cesium.ScreenSpaceEventType.RIGHT_DOWN);
 
      //鼠标抬起事件,获取div坐上和右下的x,y 转为经纬度坐标
      window.SelectHandler.setInputAction(function (event) {
        flag = false
        var l = parseInt(selDiv.style.left);
        var t = parseInt(selDiv.style.top);
        var w = parseInt(selDiv.style.width);
        var h = parseInt(selDiv.style.height);
        // var earthPosition = viewer.camera.pickEllipsoid({x:l,y:t}, viewer.scene.globe.ellipsoid);
        // var cartographic = Cesium.Cartographic.fromCartesian(earthPosition, viewer.scene.globe.ellipsoid, new Cesium.Cartographic());
        // console.log("左上坐标为:"+[Cesium.Math.toDegrees(cartographic.longitude),Cesium.Math.toDegrees(cartographic.latitude)])
        // earthPosition = viewer.camera.pickEllipsoid({x:l+w,y:t+h}, viewer.scene.globe.ellipsoid);
        // cartographic = Cesium.Cartographic.fromCartesian(earthPosition, viewer.scene.globe.ellipsoid, new Cesium.Cartographic());
        // console.log("右下坐标为:"+[Cesium.Math.toDegrees(cartographic.longitude),Cesium.Math.toDegrees(cartographic.latitude)])
        _that.bimSelectShow()
        //根据业务确定是否删除框选div
        document.getElementById("selectDiv").parentNode.removeChild(document.getElementById("selectDiv"))
      }, Cesium.ScreenSpaceEventType.RIGHT_UP);
 
      //鼠标移动事件,处理位置css
      window.SelectHandler.setInputAction(function (event) {
        if (flag) {
          endX = event.endPosition.x
          endY = event.endPosition.y
 
          selDiv.style.left = Math.min(endX, startX) + "px";
          selDiv.style.top = Math.min(endY, startY) + "px";
          selDiv.style.width = Math.abs(endX - startX) + "px";
          selDiv.style.height = Math.abs(endY - startY) + "px";
          _that.selectPosition = {
            sx: startX,
            sy: startY,
            ex: endX,
            ey: endY
          }
 
        }
 
      }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
    },
    clearBimSelect() {
      this.bimSelectEnd()
      this.bimSelectOff()
      this.isInstallationOn = false
      this.componentIdList = []
    },
    modelListChange(val) {
      this.componentId = val
      let deleteAttributes = ['GlobalId', 'guid', 'function', 'pid', 'fileName', 'Guid']
      let serviceName = this.serviceName
      var _that = this
      //切换显示属性
      let modelId = _that.bimModelID;
      let sqldb = window.BIM.GetModelSqlDb(modelId);
      console.log("aaa")
      let ifcurl = BIM_SERVER_GET + "getProperty?modelId=" + modelId + "&id=" + val;
      axios.get(ifcurl).then((res) => {
        console.log(res)
        if (res.status == 200) {
          let attr = res.data.data.attributes
          console.log(attr)
          // _that.attributeForm = attr
          deleteAttributes.map(e => {
            delete attr[e]
          })
          console.log(attr)
          let attrs = {}
          Object.keys(attr).map(key => {
            if (typeof (attr[key]) === 'object') {
              attrs = {...attr[key]}
              attrs = JSON.parse(JSON.stringify(attrs))
              // attrName = key
              attr = {...attr, ...attrs}
              delete attr[key]
            }
          })
          _that.attributeForm = attr
          _that.attributeFormOld = JSON.parse(JSON.stringify(attr))
        }
      })
      return
      sqldb.then(modelDb => {
        modelDb.each(`select component.*,modelChild.md5 from component left join modelChild on component.modelChildId = modelChild.id where component.id = ?`, [val], (component) => {
          let guid = component.md5 + '_' + component.ifcId
          // let ifcurl =
          //     BIM_PROPERTY_URL +
          //     serviceName + "/query?keyValues=(gmlid:$eq:" +
          //     guid +
          //     ")&type=installation";
          let ifcurl =
              BIM_LIST_URL + "api/v1/" + serviceName + "/bim/" + guid;
          axios.get(ifcurl).then(res => {
            if (res.data.code !== 200) return _that.$message.error(res.data.msg)
            // _that.attributeForm = res.data[0].attributes
            _that.saveGuid = res.data.data.attributes.GlobalId
            let attr = res.data.data.attributes
            deleteAttributes.map(e => {
              delete attr[e]
            })
            let attrs = {}
            // let attrName = null
            Object.keys(attr).map(key => {
              if (typeof (attr[key]) === 'object') {
                attrs = {...attr[key]}
                attrs = JSON.parse(JSON.stringify(attrs))
                // attrName = key
                attr = {...attr, ...attrs}
                delete attr[key]
              }
            })
 
            _that.attributeForm = attr
          })
        })
      })
    },
    editAttributes() {
      this.editAttribute = false
    },
    //存储属性
    saveAttributes() {
      this.editAttribute = true
      //获取所有属性键值
      var keys = Object.keys(this.attributeFormOld);
      let url = BIM_SERVER_GET + "updateProperty?modelId=" + this.bimModelID;
      keys.forEach((item) => {
        //判断新旧属性是否做出更改
        if (this.attributeFormOld[item] != this.attributeForm[item]) {
          axios.post(url,
              [{
                "id": this.componentId,
                "attributes": [{
                  "name": item,
                  "value": this.attributeForm[item]
                }]
              }
              ]
          ).then(res => {
            if (res.data.code === 200) {
              this.attributeFormOld.item = this.attributeForm.item
              this.$message({
                message: "编辑成功!",
                type: "success",
              });
            } else {
              this.$message.error(res.data.msg)
            }
          })
        }
      })
    },
    //打开添加属性对话框
    openAddAttributes() {
      this.OffAddAttributes()
      this.addAttributesD = true
    },
    // 批量添加构建属性
    addAttributes() {
      this.$refs.AddAttributeForm[0].validate(e => {
        if (!e) return this.$message.error('请输入属性名称!')
        let url = BIM_SERVER_GET + "addProperty?modelId=" + this.bimModelID;
        //post  data构件属性编辑
        let attributes = []
        this.inputList.forEach((item) => {
          attributes.push({
            "name": item.name,
            "value": item.value,
            "type": item.type,
            "length": item.length
          })
        })
        //批量增加构件属性
        axios.post(url, [{"id": this.componentId, "attributes": attributes}]
        ).then(res => {
          if (res.data.code === 200) {
            console.log(attributes)
            attributes.forEach((item => {
              console.log(item)
              this.attributeForm[item.name] = item.value
              this.attributeFormOld = JSON.parse(JSON.stringify(this.attributeForm))
              console.log(this.attributeForm)
            }))
            this.$message({
              message: "编辑成功!",
              type: "success",
            });
            this.OffAddAttributes()
          } else this.$message.error(res.data.msg)
        })
      })
    },
    closePopouDlg() {
      this.isInstallationOn = false
      this.clearBimSelect()
      this.componentIdList = []
    },
    openEncode() {
      this.encode = true
    },
    closeEncode() {
      this.encode = false
      this.encodeList = {
        prefix: '',
        connector: '',
        number: '',
        name: ''
      }
    },
    formatZero(num, len) {
      if (String(num).length > len) {
        return num;
      }
      return (Array(len).join('0') + num).slice(-len)
    },
    saveEncode() {
      var _that = this
      this.$refs.CustomCoding.validate(e => {
        if (!e) return
        let serviceName = _that.serviceName
        let url = BIM_LIST_URL + "api/v1/" + serviceName + "/bim";
        let ifcid1000 = []
        let num = 0
        for (let i = 0; i < _that.componentIdList.length; i += 1000) {
          ifcid1000.push(_that.componentIdList.slice(i, i + 1000))
        }
        for (let i = 0; i < ifcid1000.length; i++) {
          let modelId = _that.bimModelID;
          let sqldb = window.BIM.GetModelSqlDb(modelId);
          let ids = ifcid1000[i].toString()
          sqldb.then(modelDb => {
            let values = []
            modelDb.each(`select component.*,modelChild.md5 from component left join modelChild on component.modelChildId = modelChild.id where component.id in (${ids})`, [], (component) => {
              let guid = component.md5 + '_' + component.ifcId
              num = num + 1
              var zeroNum = _that.formatZero(num, Number(_that.encodeList.number))
              var code = _that.encodeList.prefix + _that.encodeList.connector + zeroNum
              values.push({
                guid: guid,
                attributes: [{
                  name: _that.encodeList.name,
                  value: code,
                  type: 'string',
                  length: 10000
                }]
              })
            })
            axios.post(url, values).then(res => {
              if (res.data.code === 200) {
                // this.$message({
                //   message: "编辑成功!",
                //   type: "success",
                // });
              } else {
                this.$message.error(res.data.msg)
              }
            })
          })
        }
      })
 
    },
    getModelIdByUniqueId() {
      let item = this.$store.state.currentSelectNode;
      for (let model in this.$store.state.bimModelListAll) {
        if (this.$store.state.bimModelListAll[model].uniqueId == item.uniqueId) {
          return model
        }
      }
    }
  },
  created() {
    const _this = this;
    layui.use(["layer"], function () {
      _this.layer = layui.layer;
    });
    this.$bus.$on("BimChange", obj => {
      let item = this.$store.state.currentSelectNode;
      _this.louceng = [];
      if (item.sourceType == "bim") {
        for (let model in this.$store.state.bimModelListAll) {
          if (this.$store.state.bimModelListAll[model].uniqueId == item.uniqueId) {
            let url = BIM_SERVER_GET + "getStorey?modelId=" + parseInt(model);
            axios.get(url).then((floor) => {
              console.log(floor)
              _this.louceng = floor.data.data.map((d) => {
                return d.storey
              }).filter((value, index, self) => {
                return self.indexOf(value) === index
              })
              _this.louceng.sort()
              _this.louceng = _this.louceng.map(item => {
                return {name: item, isOpen: false}
              })
            })
          }
        }
      }
    })
  },
 
};
</script>
<style lang="less" scoped>
.modelTool {
  /deep/ .el-switch__label {
    color: #bbb !important;
  }
 
  /deep/ .el-switch__label.is-active {
    color: #409EFF !important;
  }
}
 
.drag_black {
  width: 800px;
  height: 520px;
  background: rgba(39, 39, 39, 0.38);
  position: absolute;
  top: 80px;
  left: 500px;
  border: #00000090 2px solid;
  overflow-y: auto;
}
 
.drag_black1 {
  width: 800px;
  min-height: 240px;
  background: rgba(39, 39, 39, 0.90);
  position: absolute;
  top: 80px;
  left: 500px;
  border: #00000090 2px solid;
  overflow-y: auto;
 
  .pop-header {
    font-weight: 600;
    font-size: 16px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: rgb(232, 232, 232);
  }
}
 
.opt_button {
  display: inline-block;
  height: 50px;
  width: 60px;
  margin: 10px;
  border-radius: 5px;
  color: white;
  border: 1px solid rgb(212, 212, 212);
  padding: 5px;
  cursor: pointer;
}
 
.opt_button_disabled {
  display: inline-block;
  height: 50px;
  width: 60px;
  margin: 10px;
  border-radius: 5px;
  color: rgb(143, 143, 143);
  border: 1px solid rgb(212, 212, 212);
  padding: 5px;
  background: rgb(196, 196, 196);
}
 
.opt_button:hover {
  border: 1px solid rgb(224, 224, 255);
  box-shadow: 2px 2px 3px rgb(207, 207, 207);
}
 
.funcBox {
  position: absolute;
  top: 100px;
  padding: 10px;
  width: 300px;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 4px;
  left: 80px;
  color: #fff;
}
 
 
.item {
  display: inline-block;
}
 
 
#spacing,
#width {
  padding-top: 16px;
  margin-right: 20px;
}
 
.lineValue {
  display: none;
}
 
#lineColor {
  height: 25px;
  margin-left: 20px;
}
 
.layui-form-label {
  width: 60px;
}
 
.layui-input-block {
  margin-left: 90px;
}
 
.box-card {
  color: white;
  border: 0 !important;
  overflow: auto;
  border-radius: 0 !important;
  background: rgba(30, 44, 69, 0.5);
 
  /deep/ .el-card__header {
    background: rgba(0, 166, 226, 0.6) !important;
    // box-shadow: 0px 0px 4px 0px rgba(14, 22, 32, 0.2);
    // border-radius: 6px 6px 0px 0px;
    height: 30px;
    font-size: 16px;
    font-weight: 400;
    border-bottom: 0;
    padding: 5px;
  }
 
 
  .rzxfBtn {
    background: rgba(61, 190, 253, 0.1) !important;
    border: 1px solid #00A6E2 !important;
    color: white
  }
 
  .rzxfBtn:hover {
    background: #3DBEFD !important;
    color: white
  }
}
 
.input-item {
  margin: 0px;
  color: white;
 
  /deep/ .el-input__inner {
    -webkit-appearance: none;
    background-color: #1b1b1b;
    background-image: none;
    border-radius: 0px;
    border: 0;
    box-sizing: border-box;
    color: #ffffff;
    display: inline-block;
    font-size: inherit;
    height: 30px;
    line-height: 30px;
    outline: 0;
    padding: 0 15px;
    transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
    width: 100%;
  }
 
  /deep/ .el-form-item__label {
    color: #ffffff;
  }
 
  /deep/ .el-range-input {
    color: #ffffff;
    background: transparent;
  }
}
 
.buttongroups {
  margin: 8px auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
 
  /deep/ .el-button {
    width: 140px;
    background: transparent;
    border: none;
    color: #ffffff;
    border-radius: 0px;
 
    width: 199px;
    height: 26px;
    background: url("../../../assets/img/small_btn_back.png") no-repeat;
    background-size: 100% 100%;
 
    font-size: 11px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #E0E5FA;
    text-shadow: 0px 1px 4px rgba(5, 28, 55, 0.42);
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    margin: 0px;
  }
}
 
.bimBtn {
  width: auto !important;
 
  &:hover {
    background: rgba(24, 164, 240, 0.8);
    color: #fff;
    border: 1px solid #7596fa;
  }
}
 
.inputStyle {
  width: 80%;
 
  /deep/ .el-input__inner {
    color: #fff;
    background-color: transparent !important;
  }
}
 
.selectStyle {
  /deep/ .el-input__inner {
    color: #fff;
    background-color: transparent !important;
  }
}
 
.floor_button {
  height: 24px;
  text-align: center;
  color: aliceblue;
  background-color: #666;
  padding-top: 10px;
  vertical-align: middle;
  margin: 1px;
}
 
.floor_button:hover {
  cursor: pointer;
  opacity: 0.8;
}
</style>