lyh
14 小时以前 b6247699693bdc200539f20851b3d2105fe8b674
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
<template>
  <div >
    <el-row @contextmenu.prevent.native="">
    <el-table
      id="ncDocTable"
      :data="ncTableData"
      class="show_table"
      highlight-current-row
      @row-contextmenu="ncRightClick"
      @row-click="handleCurrentChange"
      border
      :height="tableHeight"
      size='mini'
      >
      <el-table-column
        type="index"
        label="序号"
        align="center"
        >
      </el-table-column>
      <el-table-column
        prop="docName"
        label="文件名称"
        sortable
        align="center"
        class-name="left"
      >
      </el-table-column>
      <el-table-column
        prop="docAlias"
        label="代码版本"
        sortable
         class-name="left"
      >
      </el-table-column>
      <el-table-column
        prop="pullStatus"
        label="出库状态"
        sortable
        align="center"
      >
      <template slot-scope="scope">
          {{pullStatusMap[scope.row.pullStatus]}}
      </template>
      </el-table-column>
      <el-table-column
        prop="docStatus"
        label="状  态"
        align="center"
        sortable
      >
      <template slot-scope="scope">
          {{productStatusMap[scope.row.docStatus]}}
      </template>
      </el-table-column>
      <el-table-column
        prop="publishVersion"
        label="系统指定版本"
        sortable
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="上传时间"
        sortable
        align="center"
      >
      </el-table-column>
    </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        :current-page="pageData.page"
        :page-sizes="pageData.pageSizeArr"
        :page-size="pageData.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pageData.total">
      </el-pagination>
      <div class="ncRightMenu">
        <NContextMenu
          @showDocEditDialog="showDocEditDialog"
          @showAssignDeviceDialog="showAssignDeviceDialog"
          @docDelete="docDelete"
          @docDownload="docDownload"
          @showBatchDeleteDialog="showBatchDeleteDialog"
          @docPublish="docPublish"
          @docRepublish="docRepublish"
          @docPull="docPull"
          @docCancelPull="docCancelPull"
          @docPush="docPush"
          @docPigeonhole="docPigeonhole"
          @showUploadDialog="showUploadDialog"
          ref="NContextMenu"
        />
      </div>
    </el-row>
    <!--文档入库窗口-->
    <el-dialog :visible.sync="ncDocPushVisible" :close-on-click-modal="false" title="文件上传" :before-close="closeDialog" width="480px">
      <el-upload
        class="upload-demo"
        ref="upload"
        action="string"
        show-file-list
        :before-remove="beforeRemove"
        :on-exceed="handleExceed"
        :http-request="handleRequest"
        :limit="1"
        :file-list="ncDocList"
        :auto-upload="false">
        <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
        <el-button style="margin-left: 10px;" size="small" type="success" @click="submitNCUpload">上传到服务器</el-button>
      </el-upload>
    </el-dialog>
    <!--指派到设备-->
    <el-dialog :visible.sync="assignVisible" :close-on-click-modal="false" title="文档指派" @close="closeAssignDialog"  width="75%" top="60px">
      <template>
        <div style="display: flex;justify-content: space-between">
          <el-tabs style="width: 72%">
            <el-tab-pane label="文档列表">
              <div style="display: flex;">
                <el-form :model="ncParams" :inline="true" class="demo-form-inline">
                  <el-form-item label="文件名称">
                    <el-input type="text" v-model="ncParams.docName" show-word-limit placeholder="请输入文件名称" clearable></el-input>
                  </el-form-item>
                  <el-form-item label="上传时间">
                    <el-date-picker v-model="ncParams.startTime" placeholder="请选择开始时间" value-format="yyyy-MM-dd HH:mm:ss" type="datetime">
                    </el-date-picker>
                    <el-date-picker v-model="ncParams.endTime" placeholder="请选择结束时间" value-format="yyyy-MM-dd HH:mm:ss" type="datetime">
                    </el-date-picker>
                  </el-form-item>
                  <el-form-item>
                    <el-button type="primary" @click="queryNCDocList" size="small" icon="el-icon-search">查询</el-button>
                  </el-form-item>
                </el-form>
              </div>
              <el-table
                class="show_table"
                ref="multipleTable"
                :data="tableData"
                tooltip-effect="dark"
                height="550"
                style="width: 100%"
                @selection-change="ncFileSelectionChange">
                <el-table-column
                  type="selection"
                  width="55">
                </el-table-column>
                <el-table-column
                  type="index"
                  label="序号"
                  align="center"
                >
                </el-table-column>
                <el-table-column
                  prop="docName"
                  label="文件名称"
                  sortable
                  align="center"
                  class-name="left"
                >
                </el-table-column>
                <el-table-column
                  prop="docCode"
                  label="设备编号"
                  sortable
                  class-name="left"
                >
                </el-table-column>
                <el-table-column
                  prop="pullStatus"
                  label="出库状态"
                  sortable
                  align="center"
                >
                  <template slot-scope="scope">
                    {{pullStatusMap[scope.row.pullStatus]}}
                  </template>
                </el-table-column>
                <el-table-column
                  prop="docStatus"
                  label="状  态"
                  align="center"
                  sortable
                >
                  <template slot-scope="scope">
                    {{productStatusMap[scope.row.docStatus]}}
                  </template>
                </el-table-column>
                <el-table-column
                  prop="createTime"
                  label="上传时间"
                  sortable
                  align="center"
                >
                </el-table-column>
              </el-table>
            </el-tab-pane>
          </el-tabs>
 
          <div style="width: 25%">
            <el-tabs  v-model="activeName">
              <el-tab-pane label="设备列表" name="first">
                <div class="treeType">
                  <div style="display: flex;">
                    <el-input
                      placeholder="输入关键字进行过滤"
                      v-model="filterDeviceCode">
                    </el-input>
                    <el-button style="margin-left: 10px" type="primary" @click="expand">展开/折叠</el-button>
                  </div>
 
                  <el-tree
                    class="filter-tree"
                    :data="deviceTreeData"
                    ref="deviceTreeData"
                    show-checkbox
                    node-key="id"
                    :default-expand-all="isExpand"
                    :filter-node-method="filterDevice"
                  />
                </div>
 
                <el-form class="demo-form-inline" :model="assignForm" ref="assignForm" :rules="rules">
                  <el-form-item label="指派原因:" prop="applyReason">
                    <el-input type="textarea" v-model.trim="assignForm.applyReason" :rows=rows resize="none"></el-input>
                  </el-form-item>
                </el-form>
              </el-tab-pane>
            </el-tabs>
 
          </div>
        </div>
 
        <div slot="footer" class="dialog-footer">
          <el-button @click.native="assignCommit" :loading="buttonLoading" type="primary" class="btn-custom">
            <span>保 存</span>
          </el-button>
          <el-button @click="closeAssignDialog"  class="btn-custom">
            <span>取 消</span>
          </el-button>
        </div>
      </template>
    </el-dialog>
    <!--批量删除文档-->
    <el-dialog :visible.sync="docBatchDeleteVisible" :close-on-click-modal="false" title="批量删除" @close="closeDocDeleteDialog" width="1000px">
      <el-form :model="delParams" :inline="true" class="demo-form-inline">
        <el-form-item label="文件名称">
          <el-input type="text" v-model="delParams.docName" show-word-limit placeholder="请输入文件名称" clearable></el-input>
        </el-form-item>
        <el-form-item label="上传时间">
          <el-date-picker v-model="delParams.startTime" placeholder="请选择开始时间" value-format="yyyy-MM-dd HH:mm:ss" type="datetime">
          </el-date-picker>
          <el-date-picker v-model="delParams.endTime" placeholder="请选择结束时间" value-format="yyyy-MM-dd HH:mm:ss" type="datetime">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="LogSearch" size="small" icon="el-icon-search">查询</el-button>
        </el-form-item>
      </el-form>
      <template>
        <el-table
          :data="delDocList"
          class="show_table"
          ref="table"
          highlight-current-row
          border
          height="410"
          size='mini'
          @selection-change="docSelectionChange"
        >
          <el-table-column
            type="selection"
            width="55">
          </el-table-column>
          <el-table-column
            type="index"
            label="序号"
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="docName"
            label="文件名称"
            sortable
            align="center"
            class-name="left"
          >
          </el-table-column>
          <el-table-column
            prop="docCode"
            label="设备编号"
            sortable
            class-name="left"
          >
          </el-table-column>
          <el-table-column
            prop="pullStatus"
            label="出库状态"
            sortable
            align="center"
          >
            <template slot-scope="scope">
              {{pullStatusMap[scope.row.pullStatus]}}
            </template>
          </el-table-column>
          <el-table-column
            prop="docStatus"
            label="状  态"
            align="center"
            sortable
          >
            <template slot-scope="scope">
              {{productStatusMap[scope.row.docStatus]}}
            </template>
          </el-table-column>
          <el-table-column
            prop="publishVersion"
            label="系统指定版本"
            sortable
            align="center"
          >
          </el-table-column>
          <el-table-column
            prop="createTime"
            label="上传时间"
            sortable
            align="center"
          >
          </el-table-column>
        </el-table>
        <el-pagination
          @size-change="handleDelSizeChange"
          @current-change="handlerDelPageChange"
          :current-page="pageDelData.page"
          :page-sizes="pageDelData.pageSizeArr"
          :page-size="pageDelData.size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pageDelData.total">
        </el-pagination>
        <div slot="footer" class="dialog-footer">
          <el-button @click.native="docBatchDelete" :loading="buttonLoading" type="primary" class="btn-custom">
            <span>删 除</span>
          </el-button>
          <el-button @click="closeDocDeleteDialog"  class="btn-custom">
            <span>取 消</span>
          </el-button>
        </div>
      </template>
    </el-dialog>
 
  </div>
 
</template>
 
<script>
  import NContextMenu from '@/module/productManager/components/ncDocContexttMenu.vue'
  import Bus from './bus.js'
  import * as productApi from '../api/product'
   import * as SystemApi from "../../../base/api/system";
    export default {
      name: "nc_file_table_info",
      props:['nodeList'],
      components:{
        NContextMenu,
        Bus
      },
      computed:{
       pullStatusMap() {
        let localeMap = JSON.parse(localStorage.getItem('pullStatusMap'));
        if(!localeMap) {
          return {};
        }else {
          return localeMap;
        }
      },
      productStatusMap() {
        let localeMap = JSON.parse(localStorage.getItem('productStatusMap'));
        if(!localeMap) {
          return {};
        }else {
          return localeMap;
        }
      },
    },
      data() {
        return {
          isExpand:false,
          rows:3,
          tableHeight:220,
          buttonLoading:false,
          ncDocPushVisible:false,
          assignVisible:false,
          assignBatchVisible:false,
          docBatchDeleteVisible:false,
          ncDocList:[],
          ncTableData: [],
          delDocList:[],
          tableData:[],
          deviceTreeData:[],
          activeName:'first',
          assignForm:{
            applyReason: '',
          },
          rules:{
            applyReason: [
              { required: false, message: '请输入指派原因', trigger: 'blur' }
            ],
          },
          pageData : {
            page:1,
            size : 10,
            total:0,
            pageSizeArr:[10, 20, 40]
          },
          pageDelData : {
            page:1,
            size : 10,
            total:0,
            pageSizeArr:[10, 20, 40]
          },
          ncParams: {
            attributionType :'',//绑定类型
            attributionId :'', //绑定类型对应的id
            docClassCode:'NC', //文档类型为其他文档
            docName:'', //文件名称
          },
          delParams:{
            attributionType :'',//绑定类型
            attributionId :'', //绑定类型对应的id
            docClassCode:'NC', //文档类型为其他文档
            docName:'', //文件名称
            startTime:"",
            endTime:""
          },
          deleteParam:{
            id:''
          },
          contextQueryParams:{
            flag:2, //查询按钮的范围 1 菜单 2 对象
            param:'document', //查询参数,按类型而不同 1 菜单路径 2 对象权限码
            objectId:null, //flag 为2时需要传递该参数 该参数与param对应数据id
            relativeObjectId:null, //param 为process,document,file 时需要传该参数 该参数为关联树节点的id
            relativeParam:null, //param 为process,document,file 时需要传该参数 该参数为关联树节点的对象权限码
          },
          nodeData: {
            index: 6,
            list: []
          },
          rightClickRow:null,
          docUploadParams:{
            attributionId:'',
            attributionType:5,
            docClassCode:'NC',
          },
          defaultAssignParams:{},
          assignFileRequest:{
            applyReason: "",
            deviceList: [],
            docId: [],
            fileId: "",
            processId: ""
          },
          docName:'',
          productmap:{},
          pullmap:{},
          multipleSelection: [],
          docSelectionAll:[],
          docSelection:[],
          idKey:'docId', // 标识列表数据中每一行的唯一键的名称
          filterDeviceCode:''//过滤设备的查询关键字
        }
      },
      methods: {
        expand(){
          console.log(this.isExpand);
          this.isExpand = !this.isExpand;
          const nodes = this.$refs.deviceTreeData.store._getAllNodes();
          for(let i in nodes){
            nodes[i].expanded = this.isExpand
          }
          },
        dateFormat(row, column, cellValue, index){
          const daterc = row[column.property]
          if(daterc!=null){
            const dateMat= new Date(daterc);
            const year = dateMat.getFullYear();
            const month = dateMat.getMonth() + 1;
            const day = dateMat.getDate();
            const hh = dateMat.getHours();
            const mm = dateMat.getMinutes();
            const ss = dateMat.getSeconds();
            const timeFormat= year + "-" + month + "-" + day;
            return timeFormat;
            }
        },
        filterDevice(value, data) {
          if (!value) return true;
          return data.label.indexOf(value) !== -1;
        },
        docSelectionChange(val) {
          this.docSelection = val;
        },
        showDocEditDialog(){
          this.$emit('showDocEditDialog', this.rightClickRow);
        },
        LogSearch() {
            this.LogQuery();
        },
        LogQuery() {
          this.listLoading = true;
          this.delParams=this.ncParams;
          this.delParams.startTime=this.startTime;
          this.delParams.endTime=this.endTime;
          if ((this.delParams.docName!= null && this.delParams.docName !== '')||
            (this.delParams.startTime != null && this.delParams.startTime !== '')||
            (this.delParams.endTime!= null && this.delParams.endTime !== '')){
            //重置分页参数
            this.pageDelData.page = 1;
            this.pageDelData.size = 10;
          }
          productApi.query_doc_list(this.pageDelData.page,this.pageDelData.size,this.delParams).then((res)=>{
            if (res.success) {
              this.pageDelData.total = res.page.total;
              this.delDocList = res.page.records;
            }
          });
        },
        showUploadDialog(){
          let paramList = this.nodeList.list;
          this.docUploadParams.attributionId = JSON.parse(JSON.stringify(paramList)).processId;
          this.$emit('showUploadDialog',this.docUploadParams)
        },
        showAssignDeviceDialog(){
          this.assignFileRequest = JSON.parse(JSON.stringify(this.defaultAssignParams));
          this.queryNCDocList();//查询文档列表,重置指派的设备选项
          this.queryDeviceList();//查询设备列表,重置指派的设备选项
          this.assignVisible = true;//打开指派设备弹窗
          this.assignFileRequest.processId= this.rightClickRow.attributionId;
        },
        showBatchDeleteDialog(){
          this.docBatchDeleteVisible = true;//打开批量删除文档弹窗
          this.delParams=this.ncParams;
          this.delParams.startTime=this.startTime;
          this.delParams.endTime=this.endTime;
          productApi.query_doc_list(this.pageDelData.page,this.pageDelData.size,this.delParams).then((res)=>{
            if (res.success) {
              this.pageDelData.total = res.page.total;
              this.delDocList = res.page.records;
            }
          });
        },
        queryDeviceList(){
          let nodeType ,paramId;
          if (this.nodeList.list.partsId != null) {
            nodeType = 3;
            paramId  = this.nodeList.list.partsId;
          }else if (this.nodeList.list.componentId != null) {
            nodeType = 2;
            paramId  = this.nodeList.list.componentId;
          }
          productApi.getDeviceTree(nodeType ,paramId).then((res) =>{
            if (res.success) {
              this.deviceTreeData = res.list;
            }
          })
        },
        queryNCDoc(){
          if (this.nodeList.list != null && this.nodeList.list != '') {
            let paramList = this.nodeList.list;
            this.ncParams.attributionType = this.nodeList.index;
            if (this.nodeList.index == 1) {
              //this.ncParams.attributionId = JSON.parse(JSON.stringify(paramList)).productId;
            }else if (this.nodeList.index == 2) {
              //this.ncParams.attributionId = JSON.parse(JSON.stringify(paramList)).componentId;
            }else if (this.nodeList.index == 3) {
              //this.ncParams.attributionId = JSON.parse(JSON.stringify(paramList)).partsId;
            }else if (this.nodeList.index == 4) {
              //this.ncParams.attributionId = JSON.parse(JSON.stringify(paramList)).productId;
            }else if (this.nodeList.index == 5) {
              this.ncParams.attributionId = JSON.parse(JSON.stringify(paramList)).processId;
            }
            this.ncParams.docName = '';
            productApi.query_doc_list(this.pageData.page,this.pageData.size,this.ncParams).then((res)=>{
              if (res.success) {
                this.pageData.total = res.page.total;
                this.ncTableData = res.page.records;
                setTimeout(()=>{
                  this.setSelectRow();
                }, 50)
              }
            })
          }
        },
        // 得到选中的所有数据
        getAllSelectionData () {
          // 再执行一次记忆勾选数据匹配,目的是为了在当前页操作勾选后直接获取选中数据
          this.changePageCoreRecordData();
        },
        queryNCDocList(){
          if (this.nodeList.list != null && this.nodeList.list != '') {
            let paramList = this.nodeList.list;
            this.ncParams.attributionType = this.nodeList.index;
            this.ncParams.attributionId = JSON.parse(JSON.stringify(paramList)).processId;
            productApi.query_process_doc(this.ncParams).then((res)=>{
              if (res.success) {
                this.tableData = res.list;
              }
            })
          }
        },
        handleSizeChange(val) {
          // 改变每页显示条数的时候调用一次
          this.changePageCoreRecordData();
          this.pageData.size = val;
          this.queryNCDoc();
        },
        handlePageChange(val){
          // 改变页的时候调用一次
          this.changePageCoreRecordData();
          this.pageData.page = val;
          this.queryNCDoc();
        },
        handleDelSizeChange(val) {
          // 改变每页显示条数的时候调用一次
          this.changePageCoreRecordData();
          this.pageDelData.size = val;
          this.queryDocDel();
        },
        handlerDelPageChange(val) {
          // 改变页的时候调用一次
          this.changePageCoreRecordData();
          this.pageDelData.page = val;
          this.queryDocDel();
        },
        queryDocDel(){
          if (this.nodeList.list != null && this.nodeList.list != '') {
            let paramList = this.nodeList.list;
            this.ncParams.attributionType = this.nodeList.index;
            if (this.nodeList.index == 1) {
              //this.ncParams.attributionId = JSON.parse(JSON.stringify(paramList)).productId;
            }else if (this.nodeList.index == 2) {
              //this.ncParams.attributionId = JSON.parse(JSON.stringify(paramList)).componentId;
            }else if (this.nodeList.index == 3) {
              //this.ncParams.attributionId = JSON.parse(JSON.stringify(paramList)).partsId;
            }else if (this.nodeList.index == 4) {
              //this.ncParams.attributionId = JSON.parse(JSON.stringify(paramList)).productId;
            }else if (this.nodeList.index == 5) {
              this.delParams.attributionId = JSON.parse(JSON.stringify(paramList)).processId;
            }
            productApi.query_doc_list(this.pageDelData.page,this.pageDelData.size,this.delParams).then((res)=>{
              if (res.success) {
                this.pageDelData.total = res.page.total;
                this.delDocList = res.page.records;
                setTimeout(()=>{
                  this.setSelectRow();
                }, 50)
              }
            })
          }
        },
        handleCurrentChange(val) {
          this.nodeData.list = val;
          this.$emit('indexChange', this.nodeData); // 调用父组件传递过来的方法,同时把数据传递出去
        },
        // 设置选中的方法
        setSelectRow() {
          if (!this.docSelectionAll || this.docSelectionAll.length <= 0) {
            return;
          }
          // 标识当前行的唯一键的名称
          let idKey = this.idKey;
          let selectAllIds = [];
          let that = this;
          this.docSelectionAll.forEach(row=>{
            selectAllIds.push(row[idKey]);
          });
          this.$refs.table.clearSelection();
          for(var i = 0; i < this.ncTableData.length; i++) {
            if (selectAllIds.indexOf(this.ncTableData[i][idKey]) >= 0) {
              // 设置选中,记住table组件需要使用ref="table"
              this.$refs.table.toggleRowSelection(this.ncTableData[i], true);
            }
          }
        } ,
        // 记忆选择核心方法
        changePageCoreRecordData () {
          // 标识当前行的唯一键的名称
          let idKey = this.idKey;
          let that = this;
          // 如果总记忆中还没有选择的数据,那么就直接取当前页选中的数据,不需要后面一系列计算
          if (this.docSelectionAll.length <= 0) {
            this.docSelectionAll = this.docSelection;
            return;
          }
          // 总选择里面的key集合
          let selectAllIds = [];
          this.docSelectionAll.forEach(row=>{
            selectAllIds.push(row[idKey]);
          })
          let selectIds = []
          // 获取当前页选中的id
          this.docSelection.forEach(row=>{
            selectIds.push(row[idKey]);
            // 如果总选择里面不包含当前页选中的数据,那么就加入到总选择集合里
            if (selectAllIds.indexOf(row[idKey]) < 0) {
              that.docSelectionAll.push(row);
            }
          })
          let noSelectIds = [];
          // 得到当前页没有选中的id
          this.ncTableData.forEach(row=>{
            if (selectIds.indexOf(row[idKey]) < 0) {
              noSelectIds.push(row[idKey]);
            }
          })
          noSelectIds.forEach(id=>{
            if (selectAllIds.indexOf(id) >= 0) {
              for(let i = 0; i< that.docSelectionAll.length; i ++) {
                if (that.docSelectionAll[i][idKey] == id) {
                  // 如果总选择中有未被选中的,那么就删除这条
                  that.docSelectionAll.splice(i, 1);
                  break;
                }
              }
            }
          })
        },
        ncRightClick(row, column, event) { // 鼠标右击触发事件
          if (this.nodeList.index == 5) {
            if (event != undefined) {
              this.rightClickRow = row;
              this.docName = row.docName;
              if (this.nodeList.partsId == null) {
                this.contextQueryParams.relativeParam ='component';
                this.contextQueryParams.relativeObjectId = this.nodeList.list.componentId;
              }else {
                this.contextQueryParams.relativeParam ='parts';
                this.contextQueryParams.relativeObjectId = this.nodeList.list.partsId;
              }
              this.contextQueryParams.objectId = row.processId;
              this.$refs.NContextMenu.ncDocRightClick(row, column, event, this.contextQueryParams);
            }
          }
        },
        ncFileSelectionChange(val){
          this.multipleSelection=val;
        },
        docDelete(){
          this.$confirm('删除后不可取消,确认删除吗?', '提示', {}).then(() => {
            this.deleteParam.id = this.rightClickRow.docId;
            productApi.doc_delete(this.deleteParam).then((res) => {
              if (res.success) {
                let totalPage = Math.ceil((this.pageData.total-1)/this.pageData.size);
                totalPage = (totalPage < 1 ? 1 : totalPage);
                this.pageData.page = this.pageData.page > totalPage ? totalPage : this.pageData.page;
                this.queryNCDoc();
                Bus.$emit('setIndex',this.nodeList); // 调用组件传递过来的方法,同时把数据传递出去
                this.$message({
                  message: res.message,
                  type: 'success'
                });
              } else if (res.message) {
                this.$message({
                  message: res.message,
                  type: 'error'
                });
              }
            });
          });
        },
        /*NC文档,其他文档 下载*/
        docDownload(){
          productApi.doc_download(this.rightClickRow.docId).then((res) =>{
            if(res.success){
            }else{
              this.$message({
                message: res.message,
                type: 'error'
              });
            }
          }).catch((err)=>{ //上传失败 调用onError方法 //处理自己的逻辑
            this.$message({
              message: '下载失败',
              type: 'error'
            });
          });
        },
        //批量删除
        docBatchDelete(){
          // 得到选中的所有数据
          this.getAllSelectionData();
          this.$confirm('删除后不可取消,确认删除吗?', '提示', {}).then(() => {
            let docList = this.docSelectionAll;
            let _this = this;
            docList.forEach((v, k) => {
              (function (value) {
                setTimeout(()=> {
                  let mgs = value.docName;
                  _this.deleteParam.id = value.docId;
                  productApi.doc_delete(_this.deleteParam).then((res) => {
                    if(res.success){
                      _this.buttonLoading = false;
                      _this.$notify({
                        title: '成功',
                        message:'删除 '+ mgs + res.message,
                        type: 'success'
                      });
                      let totalPage = Math.ceil(( _this.pageDelData.total-1)/ _this.pageDelData.size);
                      totalPage = (totalPage < 1 ? 1 : totalPage);
                      _this.pageDelData.page =  _this.pageDelData.page > totalPage ? totalPage :  _this.pageDelData.page;
                      _this.docSelectionAll=[];
                      _this.queryDocDel();
                    }else{
                      _this.buttonLoading = false;
                      _this.$notify({
                        title: '警告',
                        message:'删除 '+ mgs + res.message,
                        type: 'warning',
                        duration: 0
                      });
                    }
                  });
                },(k+1)*200)
              })(docList[k]);
            });
 
          });
        },
        /*NC文档,其他文档 发布*/
        docPublish(){
          this.$confirm('确认发布吗?', '提示', {}).then(() => {
            productApi.doc_publish(this.rightClickRow.docId).then((res) =>{
              if(res.success){
                Bus.$emit('queryFileList');
                this.queryNCDoc();
                this.$message({
                  message: res.message,
                  type: 'success'
                });
              }else if(res.message){
                this.$message({
                  message: res.message,
                  type: 'error'
                });
              }
            })
          });
        },
        /*NC文档,其他文档 重发布*/
        docRepublish(){
          this.$confirm('确认重发布吗?', '提示', {}).then(() => {
            productApi.doc_republish(this.rightClickRow.docId).then((res) =>{
              if(res.success){
                Bus.$emit('queryFileList');
                this.$message({
                  message: res.message,
                  type: 'success'
                });
                this.queryNCDoc();
              }else if(res.message){
                this.$message({
                  message: res.message,
                  type: 'error'
                });
              }
            })
          });
        },
        /*NC文档,其他文档 出库*/
        docPull(){
          this.$confirm('确认出库吗?', '提示', {}).then(() => {
            productApi.doc_pull(this.rightClickRow.docId).then((res) =>{
              if(res.success){
                this.$message({
                  message: res.message,
                  type: 'success'
                });
              }else {
                this.$message({
                  message: res.message,
                  type: 'error'
                });
              }
            });
            this.queryNCDoc();
          });
        },
        /*NC文档,其他文档 取消出库*/
        docCancelPull(){
          this.$confirm('确认取消出库吗?', '提示', {}).then(() => {
            productApi.doc_cancel_pull(this.rightClickRow.docId).then((res) =>{
              if(res.success){
                this.$message({
                  message: res.message,
                  type: 'success'
                });
                this.queryNCDoc();
              }else {
                this.$message({
                  message: res.message,
                  type: 'error'
                });
              }
            })
          })
        },
        /*NC文档,其他文档 入库*/
        docPush(){
          this.ncDocList = [];
          this.ncDocPushVisible = true;
        },
        /*NC文档,其他文档 归档*/
        docPigeonhole(){
          this.$confirm('归档后不可取消,确认归档吗?', '提示', {}).then(() => {
            productApi.doc_pigeonhole(this.rightClickRow.docId).then((res) =>{
              if(res.success){
                this.$message({
                  message: res.message,
                  type: 'success'
                });
                this.queryNCDoc();
              }else {
                this.$message({
                  message: res.message,
                  type: 'error'
                });
              }
            })
          })
        },
        //上传
        handleExceed(files, fileList) {
          this.$message.warning(`当前限制选择 1 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
        },
        beforeRemove(file, fileList) {
          return this.$confirm(`确定移除 ${ file.name }?`);
        },
        submitNCUpload(){
          this.$confirm('确认提交吗?', '提示', {}).then(() => {
            this.$refs.upload.submit();
          })
        },
        handleRequest(uploader){
          let formData = new FormData();
          formData.append("file", uploader.file);
          productApi.doc_push(this.rightClickRow.docId,formData,uploader).then((res)=>{
            if (res.success) {
              //上传成功 调用onSuccess方法,否则没有完成图标 //处理自己的逻辑
              uploader.onSuccess();
              Bus.$emit('queryFileList')
            }else {
              this.$message({
                message: res.message,
                type: 'error'
              });
            }
          }).catch((err)=>{ //上传失败 调用onError方法 //处理自己的逻辑
            //uploader.onError();
          })
        },
        closeDialog(){
          this.ncDocPushVisible = false;
          this.queryNCDoc();
        },
        closeAssignDialog(){
          this.assignVisible = false;
          this.assignBatchVisible = false;
          this.assignForm.applyReason = '';
          Bus.$emit('queryActivitList')
        },
        closeDocDeleteDialog(){
          this.docBatchDeleteVisible = false;
          this.docSelection = [];
          this.docSelectionAll =[];
          this.pageData = {
            page:1,
            size : 10,
            total:0,
            pageSizeArr:[10, 20, 40]
          };
          this.pageDelData={
            page:1,
            size : 10,
            total:0,
            pageSizeArr:[10, 20, 40]
          };
          this.queryNCDoc();
        },
        //指派到设备
        assignCommit(){
          this.$refs.assignForm.validate((valid) =>{
            if (valid) {
              this.$confirm('确认提交吗?', '提示', {}).then(() => {
                let resMessage = [];
                let devices = this.$refs['deviceTreeData'].getCheckedNodes(true);
                let docList = this.multipleSelection;
                let assignFileArr = [];
                devices.forEach((d, i) => {
                  docList.forEach((doc, k) => {
                    assignFileArr.push({
                      applyReason: this.assignForm.applyReason,
                      deviceId: d['id'],
                      docId: doc['docId'],
                      fileId: doc['publishFileId'],
                      processId: this.assignFileRequest.processId});
                    resMessage.push(doc.docName + '==>'+ d.label+ ' ')
                  });
                });
                let _this = this;
                assignFileArr.forEach((v, k) => {
                  (function (value) {
                    setTimeout(()=> {
                      let mgs = resMessage[k];
                      productApi.file_apply(value).then((res) => {
                        if(res.success){
                          _this.buttonLoading = false;
                          _this.$notify({
                            title: '成功',
                            message:mgs + res.message,
                            type: 'success'
                          });
                        }else{
                          _this.buttonLoading = false;
                          _this.$notify({
                            title: '警告',
                            message:mgs + res.message,
                            type: 'warning',
                            duration: 0
                          });
                        }
                      });
                    },(k+1)*500)
                  })(assignFileArr[k]);
                })
              });
            }
          })
        }
      },
      //初始化  模板渲染前调用
      created(){
        this.defaultAssignParams = JSON.parse(JSON.stringify(this.assignFileRequest));
        Bus.$off('queryNCDoc');
        Bus.$on("queryNCDoc",()=>{
          this.queryNCDoc()
        });
 
      },
      mounted(){
        let h = document.getElementById('filesTab').offsetHeight;
        if (h > 0) {
          this.$nextTick(function () {
            this.tableHeight = h - 95;
          })
        }
      },
      //监听
      watch:{
        nodeList:{
          deep: true,  // 深度监听
          handler(newValue, oldValue) {
            this.pageData = {
              page:1,
              size : 10,
              total:0,
              pageSizeArr:[10, 20, 40]
            };
            this.queryNCDoc();
          }
        },
        filterDeviceCode(val) {
          this.$refs.deviceTreeData.filter(val);
        }
      },
    }
</script>
 
<style scoped lang="scss">
  .menu_item {
    line-height: 20px;
    text-align: left;
    margin-top: 10px;
  }
  #ncDocTable{
    border: 1px solid #EBEEF5;
  }
  .menu {
    height: 100px;
    width: 80px;
    position: absolute;
    /* border-radius: 10px;*/
    border: 1px solid #999999;
    background-color: #f4f4f4;
  }
 
  li:hover {
    background-color: #1790ff;
    color: white;
  }
  li{
    list-style-type:none;
    font-size:15px
  }
  .contextmenu {
    margin: 0;
    background: #fff;
    z-index: 99999;
    position: absolute;
    list-style-type: none;
    padding: 5px 0;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 400;
    color: #333;
    box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.3);
    li {
      margin: 0;
      padding: 7px 16px;
      cursor: pointer;
    }
  }
  .ncRightMenu{
    position: absolute;
    top: 0;
    height: 100%;
  }
  .tabDiv{
    display: inline-block;
    vertical-align: top;
    width: 49%;
  }
  .treeType{
    overflow: hidden;
    .el-tree{
      margin: 20px 0 10px;
      height: 400px;
      overflow: auto;
    }
  }
</style>