yangys
2025-09-17 bbc859771de545dd34628064459c386b456ebd5d
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
<template>
  <basic-container>
    <div class="norightmenu" v-if="!isSearch">
      <avue-crud :addBtn="false" :option="option" :row-style="{height:'20px'}" :cell-style="{padding:'0px'}" :table-loading="loading" :data="treeData" ref="crud"
        v-model:search="search" v-model:page="mypage" @current-change="currentChange" @size-change="sizeChange"
        @refresh-change="refreshChange" @on-load="onLoad" @tree-load="treeLoad" @row-click="rowClick">
        <template #search>
          <el-row :gutter="24">
            <el-col :span="6" class="search-data-flex">
              <span class="search-data-title w68">程序状态:</span>
              <el-checkbox-group v-model="searchTreeData.programStatus" class="marginR12">
                <el-checkbox value="1" label="试切" />
                <el-checkbox value="2" label="固化" />
                <el-checkbox value="3" label="偏离" />
              </el-checkbox-group>
            </el-col>
            <el-col :span="4" class="search-data-flex">
              <span class="search-data-title">零组件号:</span>
              <el-select v-model="searchTreeData.drawingNo" clearable filterable remote reserve-keyword placeholder="输入至少3个字符过滤数据"
                :remote-method="remoteMethod" :loading="searchLoading">
                <el-option v-for="item in drawingNoList" :key="item.value" :label="item.label"
                  :value="item.value" /></el-select>
            </el-col>
            <el-col :span="6" class="search-data-flex">
              <span class="search-data-title">时间:</span>
              <el-date-picker v-model="searchTreeData.createTime" type="daterange" start-placeholder="开始时间"
                end-placeholder="结束时间" :size="size" format="YYYY-MM-DD" value-format="YYYY-MM-DD"
                @change="createTimeChange" /><!--:disabled-date="disabledDate" 不需要禁用日期-->
            </el-col>
            <el-col :span="6" class="search-data-flex">
              <el-button type="primary" @click="searchTree" :loading="treeSearchLoad"><el-icon class="el-icon--right"
                  style="margin-right: 6px;">
                  <Search />
                </el-icon>搜索</el-button>
              <el-button :icon="Delete" @click="setClearTree"><el-icon class="el-icon--right"
                  style="margin-right: 6px;">
                  <Delete />
                </el-icon>清空</el-button>
              <el-button type="danger" @click="refresh()">重置表格</el-button>
            </el-col>
          </el-row>
        </template>
       
        <template #name="{ row }">
          <span>{{ row.name }}</span>
          <el-tag v-if="row.nodeType == 60" size="mini" effect="plain">v{{ row.versionNumber }}</el-tag>
          <el-button icon="el-icon-download" @click="handleDownload(row)" class="treebtn" v-if="row.nodeType == 70" :size="size" text title="下载"></el-button>
          <el-button class="treebtn" :size="size" text v-if="permission.replace_button && row.nodeType == 60 && row.parentIds.indexOf('0,1,') > -1"
            icon="el-icon-switch" type="primary" @click="replacement(row)" placeholder="替换" title="替换"></el-button>
      <!---->
           <el-button icon="el-icon-unlock" class="treebtn" v-if="permission.lock_button && row.nodeType == 60 && row.parentIds.indexOf('0,2') > -1 && row.isLocked != 1"text type="primary" @click="showLockDlg(row)" placeholder="锁定" title="锁定"></el-button>
        
            <el-button icon="el-icon-lock" class="treebtn" :size="size" text
                v-if="permission.lock_button && row.nodeType == 60 && (row.parentIds.indexOf('0,2') > -1 || row.parentIds.indexOf('0,3') > -1)&& row.isLocked == 1"
              type="primary" @click="showUnLockDlg(row)" placeholder="解锁" title="解锁"></el-button>
           
        </template>
      </avue-crud>
    </div>
    <div class="norightmenu" v-else>
      <avue-crud :addBtn="false" :option="option" :row-style="{height:'20px'}" :cell-style="{padding:'0px'}" :table-loading="loading" :data="treeData" ref="crud"
        v-model:search="search" v-model:page="mypage" @current-change="currentChange" @size-change="sizeChange"
        @refresh-change="refreshChange" @on-load="onLoad" @tree-load="treeLoad" @row-click="rowClick">
        <template #search>
          <el-row :gutter="24">
            <el-col :span="6" class="search-data-flex">
              <span class="search-data-title w68">程序状态:</span>
              <el-checkbox-group v-model="searchTreeData.programStatus" class="marginR12">
                <el-checkbox value="1" label="试切" />
                <el-checkbox value="2" label="固化" />
                <el-checkbox value="3" label="偏离" />
              </el-checkbox-group>
            </el-col>
            <el-col :span="6" class="search-data-flex">
              <span class="search-data-title">零组件号:</span>
              <el-select v-model="searchTreeData.drawingNo" clearable filterable remote reserve-keyword placeholder="输入至少3个字符过滤数据"
                :remote-method="remoteMethod" :loading="searchLoading">
                <el-option v-for="item in drawingNoList" :key="item.value" :label="item.label"
                  :value="item.value" /></el-select>
            </el-col>
            <el-col :span="6" class="search-data-flex">
              <span class="search-data-title">时间:</span>
              <el-date-picker v-model="searchTreeData.createTime" type="daterange" start-placeholder="开始时间"
                end-placeholder="结束时间" :size="size" format="YYYY-MM-DD" value-format="YYYY-MM-DD"
                @change="createTimeChange" /><!--:disabled-date="disabledDate" 不需要禁用日期-->
            </el-col>
            <el-col :span="6" class="search-data-flex">
              <el-button type="primary" @click="searchTree" :loading="treeSearchLoad"><el-icon class="el-icon--right"
                  style="margin-right: 6px;">
                  <Search />
                </el-icon>搜索</el-button>
              <el-button :icon="Delete" @click="setClearTree"><el-icon class="el-icon--right"
                  style="margin-right: 6px;">
                  <Delete />
                </el-icon>清空</el-button>
                <el-button type="danger" @click="refresh()">重置表格</el-button>
            </el-col>
          </el-row>
        </template>
        <!-- <template #menu-left>
        <el-button :size="size" type="primary" @click="showAdd()">新增根节点</el-button>
      </template> -->
        <template #name="{ row }">
          <span>{{ row.name }}</span>
          <el-tag v-if="row.nodeType == 60" size="mini" effect="plain">v{{ row.versionNumber }}</el-tag>
          <el-button icon="el-icon-download" @click="handleDownload(row)" class="treebtn" v-if="row.nodeType == 70" :size="size" text title="下载"></el-button>
          <!-- 替换  v-if="permission.auto_dispatch"-->
          <el-button class="treebtn" :size="size" text v-if="permission.replace_button && row.nodeType == 60 && row.parentIds.indexOf('0,1,') > -1"
            icon="el-icon-switch" type="primary" @click="replacement(row)" placeholder="替换" title="替换"></el-button>
          <el-button class="treebtn" :size="size" text
            v-if="permission.lock_button && row.nodeType == 60 && row.parentIds.indexOf('0,2') > -1 && row.isLocked != 1"
            icon="el-icon-unlock" type="primary" @click="showLockDlg(row)" placeholder="锁定" title="锁定"></el-button>
          <el-button class="treebtn" :size="size" text
            v-if="permission.lock_button && row.nodeType == 60 && (row.parentIds.indexOf('0,2') > -1 || row.parentIds.indexOf('0,3') > -1)&& row.isLocked == 1"
            icon="el-icon-lock" type="primary" @click="showUnLockDlg(row)" placeholder="解锁" title="解锁"></el-button>
        </template>
      </avue-crud>
    </div>
 
    <!-- 锁定对话框 -->
    <el-dialog title="程序锁定" append-to-body v-model="lockBox">
      <avue-form :option="lockOption" v-model="lockForm" @submit="lockSubmit" @reset-change="lockCancel" />
    </el-dialog>
    <el-dialog title="程序解锁" append-to-body v-model="unlockBox">
      <avue-form :option="unlockOption" v-model="unlockForm" @submit="unlockSubmit" @reset-change="unlockCancel" />
    </el-dialog>
    <avue-tabs :option="tabsOption" @change="tabsHandleChange" style="margin-top: 30px;" v-if="isShowTabs"></avue-tabs>
    <avue-form v-if="tabsType == 'tab1'" :option="tabsFormOption" v-model="tabsForm"></avue-form>
    <!--<span v-else-if="tabsType == 'tab2'">版本信息</span>-->
    <template v-else-if="tabsType == 'tab3'">
      <div v-html="convertToHtml(fileContent)" class="convertToHtml"></div>
    </template>
    <template v-else-if="tabsType == 'tab4'">
      <!--
      <avue-crud :addBtn="false" :option="tabsFormOption4" :data="tabsForm4" ref="crud4"
        @selection-change="selectionChange">
        
        <template #menu-left>
          <el-button :size="size" type="primary" @click="comparison"
            :disabled="selectionList.length != 2">对比</el-button>
        </template>
    
      </avue-crud>
          -->
      <el-table :data="tabsForm4" border :row-style="{height:'20px'}" :cell-style="{padding:'0px'}" max-height="220" highlight-current-row>
           
            <el-table-column type="index" label="#" width="40" align="center" />
            <el-table-column prop="name" label="程序包名">
            </el-table-column>
            <el-table-column prop="versionNumber" label="程序版本">
            </el-table-column>
            <el-table-column prop="createTime" label="创建时间">
            </el-table-column>
            <el-table-column prop="createUserName" label="创建人">
            </el-table-column>
            <el-table-column fixed="right" label="操作" width="150" align="center">
                <template #default="scope">
                    <a style="color: blue;cursor: pointer;font-size: 12px;margin-right: 4px;" type="text" size="small"
                        @click.stop="showHisFileDlg(scope.$index, scope.row)">程序文件</a>
                    
                </template>
            </el-table-column>
        </el-table>
    </template>
 
  </basic-container>
  <!-- 文件对比 -->
  <el-drawer title="文件对比" append-to-body v-model="diffBox" size="100%" class="code-box">
    <div>
      <code-diff :old-string="this.content1" :new-string="this.content2" output-format="side-by-side" :hideStat="true"
        :filename="codeDiffFileName1" :newFilename="codeDiffFileName2" />
    </div>
  </el-drawer>
 
  <el-dialog title="查看历史文件" append-to-body v-model="hisFileViewModel">
      <el-table :data="hisFileTableData" ref="hisFilesTable" border @row-click="showHisContent" max-height="200" highlight-current-row>
        <el-table-column type="index" label="#" width="40" align="center"/>
        <el-table-column prop="name" label="文件名称"></el-table-column>
        <el-table-column prop="createTime" label="创建时间" width="180"></el-table-column>
        <el-table-column fixed="right" label="操作" width="80" align="center">
            <template #default="scope">
                <a style="color: blue;cursor: pointer;font-size: 12px;margin-right: 4px;" type="text" size="small"
                    @click.stop="handleDownload(scope.row)">下载</a>
            </template>
        </el-table-column>
      </el-table>
      <h4>程序内容</h4>
      <div v-html="hisFileContent" class="app-content"></div>
  </el-dialog>
 
  <!-- 替换 -->
  <el-drawer title="替换" append-to-body v-model="replaceModel" size="100%" class="code-box">
    <div class="approve-box">
      <div class="left">
        <ReplaceLeft ref="replaceLeft" v-if="replaceModel" :row="row" :replaceDataId="replaceDataId" :drawingNo="drawingNo" :processNo="processNo"
          :processEdition="processEdition" @selection-change="todoSelectionChange" />
      </div>
      <div class="right">
        <ReplaceRightTop :row="row" :name="name" />
        <avue-form ref="form" :option="optionApprove" v-model="formApprove" @submit="handleReplace" />
      </div>
    </div>
  </el-drawer>
 
</template>
 
<script>
 
import { Delete, Edit, Search, Share, Upload ,Lock,Unlock} from '@element-plus/icons-vue'
import debounce from 'lodash/debounce';
import NProgress from 'nprogress';
import { downloadXls } from '@/utils/util';
import { exportBlob } from '@/api/common';
import { ElMessage } from 'element-plus';
import ReplaceLeft from './components/ReplaceLeft.vue';
import ReplaceRightTop from './components/ReplaceRightTop.vue';
import qs from 'qs';
export default {
  components: {
    ReplaceLeft,
    ReplaceRightTop
  },
  data() {
    
    return {
      size:'large',//树里按钮的尺寸
      isSearch: null,
      treeSearchLoad: false,
      drawingNoList: [],
      searchLoading: false,
      searchTreeData: {
        programStatus: [],
        drawingNo: "",
        createTime: [],
        createTimeBegin: "",
        createTimeEnd: ""
      },
      drawingNo: '',
      processNo: '',
      processEdition: '',
      replaceDataId: "",
      formApprove: {
        title: '',
        comment: '',
        approve: '', // 默认同意
        assignee: ''
      },
      optionApprove: {
        labelWidth: 100,
        column: [
          {
            label: '流程标题',
            prop: 'title',
            rules: [{ required: true, message: '请输入流程标题', trigger: 'blur' }],
          },
          {
            label: '发送给',
            prop: 'assignee',
            type: 'select',
            dicUrl: `/api/blade-mdm/flow/flow-user-list?deptId=0`,
            dicFlag: true,
            props: {
              label: 'name',
              value: 'id',
            },
            filterable: true,
            span: 24,
            disabled: false,
            rules: [{ required: true, message: '请选择', trigger: 'change' }],
          },
          {
            label: '工序版次',
            prop: 'processEdition',
            type: 'input',
            span: 24,
            // disabled: true,
            display: false,// 隐藏显示
            // rules: [{ required: true, message: '请选择下一审批用户', trigger: 'blur' }],
          },
          {
            label: '备注',
            span: 24,
            prop: 'comment',
            type: 'textarea',
            // rules: [{ required: true, message: '请输入审批意见', trigger: 'blur' }],
            rules: [
              {
                validator: (rule, value, callback) => {
                  if (value === '' && this.formApprove.approve !== 'Y') {
                    callback(new Error('请输入备注'));
                  } else {
                    callback();
                  }
                },
                trigger: 'blur'
              }
            ]
          },
        ],
      },
      applist: [],
      row: {},
      replaceModel: false,
      diffBox: false,
      content1: "",
      content2: "",
      codeDiffFileName1: "",
      codeDiffFileName2: "",
      selectionList: [],
      targetRow: {},
      file: null,
      fileContent: "",
      isShowTabs: true,
      nodeTypeList: [],
      
      tabsType: "tab1",
      tabsOption: {},
      tabsOption1: {
        column: [{
          icon: 'el-icon-info',
          label: '节点信息',
          prop: 'tab1',
        }
      ]
      },
      tabsOption2: {
        column: [{
          icon: 'el-icon-info',
          label: '节点信息',
          prop: 'tab1',
        },
        {
          icon: 'el-icon-warning',
          label: '文件内容',
          prop: 'tab3'
        }
        ]
      },
      tabsOptionPackage: {
        column: [{
          icon: 'el-icon-info',
          label: '节点信息',
          prop: 'tab1',
        },
        {
          icon: 'el-icon-warning',
          label: '历史记录',
          prop: 'tab4'
        }]
      },
      hisFileViewModel: false,//历史文件列表对话框
      hisFileTableData:[], //历史文件列表数据
      hisFileContent:'',//历史文件内容
 
      tabsFormOption: {
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: '节点类型',
            prop: 'nodeTypeName',
            disabled: true,
            placeholder: " "
          },
          {
            label: '创建人',
            prop: 'createUserName',
            disabled: true,
            placeholder: " "
          },
          {
            label: '节点名称',
            prop: 'name',
            disabled: true,
            placeholder: " "
          },
          {
            label: '创建时间',
            prop: 'createTime',
            disabled: true,
            placeholder: " "
          },
          {
            label: '修改时间',
            prop: 'updateTime',
            disabled: true,
            placeholder: " "
          }
        ]
      },
      tabsForm: {},
      
      selectedColumn: {},
      modalForm: {},
      
      lockOption: {
        submitText: "锁定",
        emptyText: "取消",
        menuPosition: "right",
        column: [
          {
            label: '程序包名',
            prop: 'name',
            disabled:true,
            labelWidth: "120",
          },
          
          {
            label: '锁定原因',
            prop: 'remark',
            type: "textarea",
            labelWidth: "120",
            span: 24,
            rules: [{ required: true, message: '必填', trigger: 'blur' }],
          }
        ]
      },
      lockForm: {},
      lockBox: false,
 
      unlockOption: {
        submitText: "启动解锁流程",
        emptyText: "取消",
        menuPosition: "right",
        column: [
          {
            label: '程序包名',
            prop: 'name',
            disabled:true,
            labelWidth: "120",
          },
          {
            label: '锁定原因',
            prop: 'remark',
            type: "textarea",
            placeholder:'<内容为空>',
            disabled:true,
            labelWidth: "120",
            span: 24,
          },
          {
            label: '解锁原因',
            prop: 'unlockReason',
            type: "textarea",
            labelWidth: "120",
            span: 24,
          }
        ]
      },
      unlockForm: {},
      unlockBox: false,
 
      id: "",
      parentId: 1,
      loading: true,
      mypage: {
        size: 10,
        current: 1,
        total: 0,
      },
      /*
      tabsFormOption4: {
        rowKey: "id",
        selection: true,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        searchBtn: false,
        emptyBtn: false,
        menu: false,
        column: [
          { label: '版本号', prop: 'versionNumber' },
          { label: '创建时间', prop: 'createTime' },
          { label: '创建人', prop: 'createUserName' },
        ]
      },*/
      tabsForm4: {},
      defaultExpandedKeys: [],
      option: {
        highlightCurrentRow: true,
        treeProps: {
          children: "children",
          hasChildren: 'hasChildren',
          value: 'id',
          label: 'name'
        },
        defaultExpandedKeys: [],
        defaultExpandAll: false,
        lazy: true,
        rowKey: 'id',
        addBtn: false,
        editBtn: false,
        delBtn: false,
        fit: true,
        menu: false,
        searchBtn: false,
        emptyBtn: false,
        refreshBtn: false,
        columnBtn: false,
        searchShowBtn: false,
        refreshBtn: false,
        copyBtn: false,
        gridBtn: false,
        column: [
          {
            label: '目录',
            prop: 'name',
            width: '420'
          },
          /*{
            label: '程序版本',
            prop: 'versionNumber',
            formatter: (val, value, label) => {
              if (val.nodeType == '60') {
                if (value == -1) {
                  return '';
                } else {
                  return value;
                }
              } else {
                return '';
              }
            }
          },*/
          {
            label: '类型',
            prop: 'nodeTypeName'
          },
          {
            label: '锁定状态',
            prop: 'isLocked',
            formatter: (val, value, label) => {
              if (val.nodeType == '60') {
                if (value == 1) {
                  return '已锁定';
                } else {
                  return '未锁定';
                }
              }
            }
 
          },
          {
            label: '流程状态',
            prop: 'flowStatus',
            formatter: (val, value, label) => {
              if (val.nodeType != '60') {
                //非程序节点
                return '';
              } else {
                if (value == 0 || value == -1) {
                  return '未启动';
                } else if (value == 1) {
                  return '审批中';
                } else if (value == 2) {
                  return '已通过';
                } else {
                  return '';
                }
              }
            },
          },
          {
            label: '创建人',
            prop: 'createUserName',
            width: '180'
          },
          {
            label: '创建时间',
            prop: 'createTime',
            width: '180'
          }
        ],
      },
      treeData: [],
    };
  },
  computed: {
    ...mapGetters(['userInfo', 'permission']),
    
  },
  watch: {
 
  },
  methods: {
    disabledDate(time) {
      //不需要禁用日期
      // 获取当前日期
      const today = new Date();
      today.setHours(0, 0, 0, 0); // 设置为当天开始时间
 
      // 获取三个月前的日期
      const threeMonthsAgo = new Date();
      threeMonthsAgo.setMonth(threeMonthsAgo.getMonth() - 3);
      threeMonthsAgo.setHours(0, 0, 0, 0);
 
      // 禁用今天之后的日期 即可
      return time.getTime() > today.getTime() || time.getTime() < threeMonthsAgo.getTime();//
    },
    createTimeChange(value) {
      this.searchTreeData.createTimeBegin = value[0];
      this.searchTreeData.createTimeEnd = value[1];
    },
    remoteMethod(query) {
      if (query && query.length>2) {
        this.searchLoading = true;
        this.getRemote(query);
      } else {
        this.drawingNoList = [];
      }
    },
    getRemote: debounce(function(query){
            //防抖,这里设置600毫秒请求一次后台
            this.getList(query)
    },600),
    async getList(query){
      this.searchLoading = false;
      axios({
          url: '/blade-mdm/program/node/drawing-no-pick',
          method: 'get',
          params: { drawingNo: query }
        }).then(resp => {
          this.searchLoading = false;
          var drawingNoList = [];
          resp.data.data.forEach(item => {
            drawingNoList.push({ label: item, value: item })
          })
          this.drawingNoList = drawingNoList;
        });
    },
    refresh(){
      //表格重置
      this.treeData=[];
      //this.$refs.curd.refreshTable();
      let curS = this.isSearch;
      this.isSearch = null;
      this.onLoad();
      this.isSearch = !curS
      
    },
    handleDownload(row){
      NProgress.start();
      exportBlob(
          `/blade-mdm/program/node/download-by-nodeid?nodeId=${row.id}`
      ).then(res => {
          if (res.status !== 200) {
              return this.$message.error(res.msg);
          }
          downloadXls(res.data, `${row.name}`);
          NProgress.done();
      });
    },
    showLockDlg(row){
      //this.lockForm = row;
      this.lockForm.id = row.id;
      this.lockForm.name = row.name
      this.lockForm.parentId = row.parentId;
      this.lockForm.remark = '';
      this.lockBox = true;
    },
    lockCancel() {
      this.lockBox = false;
      this.lockForm = {};
    },
    showUnLockDlg(row){
      this.unlockForm.id = row.id;
      this.unlockForm.name = row.name
      this.unlockForm.remark = row.remark;
      this.unlockForm.unlockReason='';
      this.unlockForm.parentId = row.parentId;
      this.unlockBox = true;
    },
    lockSubmit(row,done) {  
      //锁定提交
      this.$confirm('是否锁定', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        axios.post('/blade-mdm/program/node/lock',qs.stringify(this.lockForm)).then(res=>{
          if (res.data.code == 200) {
            this.$message({ type: 'success', message: '操作成功!' });
            this.addLocalTreeNode(this.lockForm.parentId);
            this.lockBox = false;
          } else {
            this.$message({ type: 'error', message: res.data.msg });
          }
          this.lockBox = false;
        }).catch(error => {
          this.$message({ type: 'error', message: res.data.msg });
        });
        done();
      }).catch(action => {
        console.log('cancel')
      });
    },
    unlockSubmit(row,done) {
      //启动解锁流程
      this.$confirm(`确认解锁`, {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        axios({
          url: '/blade-mdm/flow/lock/start-unlock',
          method: 'post',
          params: {nodeId: row.id,unlockReason:row.unlockReason }
        }).then(res => {
          if (res.data.code == 200) {
            this.$message({ type: 'success', message: '解锁流程已启动!' });
            //this.addLocalTreeNode(row.parentId);
            this.unlockBox = false;
          } else {
            this.$message({ type: 'error', message: res.data.msg });
          }
        });
        done();
      }).catch(action => {
        console.log('cancel')
      });
    },
    unlockCancel() {
      this.unlockBox = false;
    },
    replacement(row) {  //替换
      this.id = row.id;
      this.formApprove = {
        comment: '',
        approve: 'Y', // 默认同
      }
      //准备程序替换流程 
      axios({
        url: '/blade-mdm/flow/replace/pre',
        method: 'post',
        params: { nodeId: row.id }
      }).then(resp => {
        this.row = row;
 
        this.drawingNo = resp.data.data.drawingNo;
        this.replaceDataId = resp.data.data.processInstanceId;
        //console.log('replaceDataId',this.replaceDataId)
        this.processNo = resp.data.data.processNo;
        this.processEdition = resp.data.data.processEdition;
       
        this.formApprove.title = resp.data.data.name + "替换";
 
        this.getHandler(); //获取处理人
        this.$nextTick(() => {
          //等待dom更新再显示界面
          this.replaceModel = true;
        })
        
      });
    },
    getHandler() {  //获取处理人
      axios({
        url: '/blade-mdm/flow/replace/default-assignees',
        method: 'get',
        params: { drawingNo: this.drawingNo }
      }).then(
        resp => {
          if (resp.data.code == 200) {
            this.formApprove.assignee = resp.data.data.checkerId;
          } else {
            this.$message.success(resp.msg);
          }
        });
    },
    handleReplace(form, done) {
      //发起程序替换流程
      var obj = {
        title: this.formApprove.title,
        nodeId: this.id,
        tempInstanceId: this.replaceDataId,
        comment: this.formApprove.comment,
        assignee: this.formApprove.assignee
      }
      axios({
        url: '/blade-mdm/flow/replace/start',
        method: 'post',
        data: obj
      }).then(resp => {
        this.$message({
          type: 'success',
          message: '操作成功!',
        });
        done();
        this.replaceModel = false;
      }).catch(error => {
        done();
      });
      
    },
 
    showHisFileDlg(index,row){
      this.hisFileViewModel = true;
 
      //查询文件列表
      axios({
        url: '/blade-mdm/program/nodehis/files-by-parent-id',
        method: 'get',
        params: {id: row.id}
      }).then(
      res => {
        
        if(res.data.code === 200) {
          this.hisFileTableData = res.data.data
        } else {
          this.$message.error('程序内容加载失败');
        }
      });
    },
    showHisContent(row, column, event) {
     
      axios({
        url: '/blade-mdm/program/nodehis/content-by-nodeid',
        method: 'get',
        params: {nodeId: row.id}
      }).then(
      res => {
        console.log(res)
        if(res.data.code === 200) {
            this.hisFileContent = res.data.data;
        } else {
            this.hisFileContent = '程序内容加载失败'
        }
      });
    },
    todoSelectionChange(applist) {
      this.applist = applist;
    },
    convertToHtml(text) {
      return text.replace(/\n/g, '<br>');
    },
    // 递归查找目标行(name="机床1")
    findTargetRow(data, targetName) {
      for (const item of data) {
        if (item.name === targetName) {
          return item; // 找到目标行
        }
        if (item.children && item.children.length > 0) {
          const found = this.findTargetRow(item.children, targetName);
          if (found) return found; // 在子节点中找到
        }
      }
      return null; // 未找到
    },
    highlightTargetRow() {  // 高亮目标行
      const targetName = this.searchTreeData.drawingNo;
      this.targetRow = this.findTargetRow(this.treeData, targetName);
      if (this.targetRow && this.$refs.crud) {
        this.$refs.crud.setCurrentRow(this.targetRow); // 高亮目标行
      }
    },
    removeHasChildren(treeData) {  //查询时候使用,删掉hasChildren 
      return treeData.map(node => {
        if (node.children && node.children.length > 0) {
          this.defaultExpandedKeys.push(node.id);
          node.children = this.removeHasChildren(node.children);
        }
        if (node.children.length > 0) {
          const { hasChildren, ...rest } = node;
          return Object.assign(rest, {});
        } else {
          return node;
        }
        // 删除当前节点的 hasChildren 属性
      });
    },
    searchTree() {
      if (this.searchTreeData.programStatus.length == 0 || !this.searchTreeData.drawingNo){
        this.$message.warning('请输入程序状态和零组件号进行搜索');
        return;
      }
      
      this.treeSearchLoad = true;
      this.isSearch = !this.isSearch
      this.searchTreeData.status = this.searchTreeData.programStatus.join();
      this.treeData = []
      this.defaultExpandedKeys = []
      axios({
        url: '/blade-mdm/program/node/search-list2',
        method: 'get',
        params: this.searchTreeData
      }).then(res => {
        
        if (res.data.data.length == 0) {
          this.treeData = [];
          this.treeSearchLoad = false;
          return
        };
        // this.option.defaultExpandAll = true;
        let treeData = this.removeHasChildren(res.data.data);
        this.option = Object.assign({},this.option,{defaultExpandedKeys: this.defaultExpandedKeys,lazy: true,defaultExpandAll: true});
        setTimeout(() => {
          this.treeSearchLoad = false;
          this.treeData = treeData;
          this.$nextTick(() => {
            this.highlightTargetRow();  // 设置当前行高亮
            this.tabsForm = this.targetRow;  //tabs节点信息
            if (this.tabsForm == null) return;
            this.nodeTypeList.forEach(item => {
              if (item.dictKey == this.tabsForm.nodeType) {
                this.tabsForm.nodeTypeName = item.dictValue;
              }
            })
          })
          if (this.treeData.length == 0) {
            return;
          }
        }, 100);
 
      });
 
    },
    setClearTree() {
      this.option.defaultExpandAll = false;
      this.searchTreeData = {
        programStatus: [],
        status: '',
        drawingNo: "",
        createTime: [],
        createTimeBegin: "",
        createTimeEnd: ""
      };
      this.treeData = [];
      this.$nextTick(() => {
        this.onLoad();
      })
    },
    
    downsend(row) {  //下发
      this.loading = true;
      axios({
        url: '/blade-mdm/program/ncfile/send-to-machine-by-nodeid',
        method: 'post',
        params: { nodeId: row.id },
      }).then(
        res => {
          this.loading = false;
          this.$message.success('操作成功');
        }
      );
    },
    upgrade(row) {  //升版
      this.upgradeModalForm = { ...row };
      this.upgradeModal = true;
    },
    delFile(item) {
      this.loading = true;
      var obj = { id: item.id }
      axios({
        url: '/blade-mdm/program/ncfile/remove',
        method: 'post',
        params: obj,
      }).then(
        resp => {
          this.loading = false;
          this.getFile(this.id);
        }
      );
    },
    
    rowClick(row) {
      this.tabsForm = row;
      this.id = row.id;
      this.isShowTabs = false;
      this.nodeTypeList.forEach(item => {
        if (item.dictKey == row.nodeType) {
          this.tabsForm.nodeTypeName = item.dictValue;
        }
      })
      if (this.tabsForm.nodeType == 60) {
        //包名节点
        this.tabsOption = this.tabsOptionPackage;
        //获取历史记录
        this.getHistory(row.id);
      } else if (this.tabsForm.nodeType == 70){
        //文件节点
        this.tabsOption = this.tabsOption2;
        //获取文件内容
        this.getFile(row.id);
        
        //清空对比记录
        this.content1 = "";
        this.content2 = "";
      }else{
        this.tabsOption = this.tabsOption1;
      }
      this.$nextTick(() => {
        this.tabsType = 'tab1';
        this.isShowTabs = true;
      })
    },
    tabsHandleChange(tabs) {
      this.tabsType = tabs.prop;
    },
    
    getFile(id) { //查看文件内容
      this.loading = true;
      axios({
        url: '/blade-mdm/program/nodehis/content-by-nodeid',
        method: 'get',
        params: { nodeId: id },
      }).then(
        res => {
          this.loading = false;
          this.fileContent = res.data.data;
        }
      );
    },
    getHistory(id) {  //查看历史记录
      this.loading = true;
      axios({
        url: '/blade-mdm/program/nodehis/history-by-nodeid',
        method: 'get',
        params: { id },
      }).then(
        res => {
          this.loading = false;
          this.tabsForm4 = res.data.data;
        }
      );
    },
    comparison() { //对比
      this.loading = true;
      axios({
        url: '/blade-mdm/program/node/compare-content',
        method: 'get',
        params: { id1: this.selectionList[0].id, id2: this.selectionList[1].id },
      }).then(
        res => {
          this.loading = false;
          this.content1 = res.data.data.content1;
          this.content2 = res.data.data.content2;
          this.codeDiffFileName1 = this.selectionList[0].versionNumber;
          this.codeDiffFileName2 = this.selectionList[1].versionNumber;
          this.diffBox = true;
        }
      );
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    
    addLocalTreeNode(parentId) {
      if (this.modalTitle == "新增根节点") {
        this.onLoad();
        return;
      }
      this.loading = true;
      var obj = { parentId: parentId }
      axios({
        url: '/blade-mdm/program/node/lazy-list',
        method: 'get',
        params: obj,
      }).then(
        res => {
          var children = res.data.data || [];
          if (parentId == 0) {
            this.treeData = [...children];
          } else {
           
            this.$refs.crud.$refs.table.store.states.lazyTreeNodeMap.value[parentId] = [...children];
          }
          this.loading = false;
        }
      );
    },
    treeLoad(tree, treeNode, resolve) {
      this.loading = true;
      var obj = { parentId: tree.id }
      
      axios({
        url: '/blade-mdm/program/node/lazy-list',
        method: 'get',
        params: obj,
      }).then(
        res => {
          this.loading = false;
          resolve(res.data.data);
        }
      );
    },
    currentChange(current) {
      this.mypage.current = current;
    },
    sizeChange(size) {
      this.mypage.size = size;
    },
    refreshChange() {
 
    },
    onLoad() {  //查询treeTable
      if(this.isSearch !== null){
        return
      }
      this.loading = true;
      var obj = { parentId: "" }
      
      axios({
        url: '/blade-mdm/program/node/lazy-list',
        method: 'get',
        params: obj,
      }).then(
        res => {
          this.loading = false;
          this.treeData = res.data.data;
          if (this.treeData.length == 0) {
            return;
          }
          this.tabsForm = res.data.data[0];  //节点信息
          this.nodeTypeList.forEach(item => {
            if (item.dictKey == this.treeData[0].nodeType) {
              this.tabsForm.nodeTypeName = item.dictValue;
            }
          })
        }
      );
    },
    
    subtractMonths(date, months) {
      const newDate = new Date(date);
      const currentMonth = newDate.getMonth();
      newDate.setMonth(currentMonth - months);
      return newDate;
    },
    getBeginDate() {
      var beginDate = this.subtractMonths(new Date(), 3);
      return `${beginDate.getFullYear()}-${(beginDate.getMonth() + 1).toString().padStart(2, '0')}-${beginDate.getDate().toString().padStart(2, '0')}`;
    },
    getToday() {
      let today = new Date();
      return `${today.getFullYear()}-${(today.getMonth() + 1).toString().padStart(2, '0')}-${today.getDate().toString().padStart(2, '0')}`;
 
    },
  },
  mounted() {
    let b = this.getBeginDate()
    //this.defaultTimeRange = [b,this.getToday()];
    let defTimeRange = [b, this.getToday()];
    this.searchTreeData.createTime = defTimeRange
    this.createTimeChange(defTimeRange)
 
    this.tabsOption = this.tabsOption1;
    //获取nodetype
    axios({ url: '/blade-system/dict-biz/dictionary?code=nc_node_type', method: 'get' }).then(res => {
      this.nodeTypeList = res.data.data;
    }
    );
  }
};
</script>
 
<style lang="scss">
.treebtn {
   font-size:16px;
}
.norightmenu .avue-crud .avue-crud__header {
  display: none !important;
}
 
.delFile {
  color: red;
  margin-left: 12px;
  cursor: pointer;
}
 
.fileListStyle {
  margin-left: 10px;
  margin-top: 12px;
}
 
.highlight-row {
  background-color: #f0f7ff !important;
  /* 浅蓝色背景 */
  font-weight: bold;
  /* 加粗文字 */
}
 
/* 如果需要悬停效果 */
.highlight-row:hover {
  background-color: #e6f0ff !important;
}
 
.approve-box {
  display: flex;
 
  &>div {
    border: 1px solid #ccc;
  }
 
  .left {
    width: 400px;
  }
 
  .right {
    flex: 1;
  }
}
 
.convertToHtml {
  background-color: #fffee1;
  padding: 6px 12px;
}
</style>
<style>
.highlight-row {
  background-color: #f0f7ff;
  font-weight: bold;
}
 
.code-box .el-drawer__header {
  margin-bottom: 0;
}
 
.search-data-title {
  font-size: 14px;
  margin-right: 8px;
  display: inline-block;
  width: 95px;
}
 
.search-data-flex {
  display: flex !important;
  align-items: center;
}
 
.w68 {
  width: 68px;
}
 
.marginR12 label {
  margin-right: 12px;
}
</style>