|  | @@ -85,6 +85,10 @@ $(document).ready(function() {
 | 
	
		
			
				|  |  |          node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  |      const ledgerTree = createNewPathTree('ledger', treeSetting);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    //初始化所有附件列表
 | 
	
		
			
				|  |  | +    getAllList();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      // 初始化 计量单元
 | 
	
		
			
				|  |  |      const pos = new PosData({
 | 
	
		
			
				|  |  |          id: 'id', ledgerId: 'lid',
 | 
	
	
		
			
				|  | @@ -1003,21 +1007,6 @@ $(document).ready(function() {
 | 
	
		
			
				|  |  |      sjsSettingObj.setFxTreeStyle(ledgerSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
 | 
	
		
			
				|  |  |      if (thousandth) sjsSettingObj.setTpThousandthFormat(ledgerSpreadSetting);
 | 
	
		
			
				|  |  |      ledgerTreeCol.initSpreadSetting(ledgerSpreadSetting);
 | 
	
		
			
				|  |  | -    // ledgerSpreadSetting.rowHeader = [
 | 
	
		
			
				|  |  | -    //     {
 | 
	
		
			
				|  |  | -    //         rowHeaderType: 'tag',
 | 
	
		
			
				|  |  | -    //         setting: {
 | 
	
		
			
				|  |  | -    //             getColor: function (index, data) {
 | 
	
		
			
				|  |  | -    //                 if (!data) return;
 | 
	
		
			
				|  |  | -    //                 if (index%10 === 0) return '#007bff';
 | 
	
		
			
				|  |  | -    //                 if (index%10 === 1) return '#28a745';
 | 
	
		
			
				|  |  | -    //                 if (index%10 === 2) return '#dc3545';
 | 
	
		
			
				|  |  | -    //                 if (index%10 === 3) return '#da9500';
 | 
	
		
			
				|  |  | -    //                 if (index%10 === 4) return '#17a2b8';
 | 
	
		
			
				|  |  | -    //             }
 | 
	
		
			
				|  |  | -    //         },
 | 
	
		
			
				|  |  | -    //     },
 | 
	
		
			
				|  |  | -    // ];
 | 
	
		
			
				|  |  |      ledgerSpreadSetting.headColWidth = [50];
 | 
	
		
			
				|  |  |      ledgerSpreadSetting.rowHeader = [
 | 
	
		
			
				|  |  |          {
 | 
	
	
		
			
				|  | @@ -1060,20 +1049,20 @@ $(document).ready(function() {
 | 
	
		
			
				|  |  |      SpreadJsObj.initSheet(ledgerSpread.getActiveSheet(), ledgerSpreadSetting);
 | 
	
		
			
				|  |  |      SpreadJsObj.selChangedRefreshBackColor(ledgerSpread.getActiveSheet());
 | 
	
		
			
				|  |  |      // 绑定事件
 | 
	
		
			
				|  |  | -    ledgerSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, treeOperationObj.selectionChanged);
 | 
	
		
			
				|  |  | +    ledgerSpread.bind(spreadNS.Events.SelectionChanged, treeOperationObj.selectionChanged);
 | 
	
		
			
				|  |  |      ledgerSpread.bind(spreadNS.Events.TopRowChanged, treeOperationObj.topRowChanged);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      if (!ledgerSpreadSetting.readOnly) {
 | 
	
		
			
				|  |  | -        ledgerSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, function (e, info) {
 | 
	
		
			
				|  |  | +        ledgerSpread.bind(spreadNS.Events.SelectionChanged, function (e, info) {
 | 
	
		
			
				|  |  |              treeOperationObj.refreshOperationValid(info.sheet, info.newSelections);
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | -        ledgerSpread.bind(GC.Spread.Sheets.Events.EditEnded, treeOperationObj.editEnded);
 | 
	
		
			
				|  |  | +        ledgerSpread.bind(spreadNS.Events.EditEnded, treeOperationObj.editEnded);
 | 
	
		
			
				|  |  |          SpreadJsObj.addDeleteBind(ledgerSpread, treeOperationObj.deletePress);
 | 
	
		
			
				|  |  | -        ledgerSpread.bind(GC.Spread.Sheets.Events.ClipboardChanging, function (e, info) {
 | 
	
		
			
				|  |  | +        ledgerSpread.bind(spreadNS.Events.ClipboardChanging, function (e, info) {
 | 
	
		
			
				|  |  |              const copyText = SpreadJsObj.getFilterCopyText(info.sheet);
 | 
	
		
			
				|  |  |              SpreadJsObj.Clipboard.setCopyData(copyText);
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | -        ledgerSpread.bind(GC.Spread.Sheets.Events.ClipboardPasting, treeOperationObj.clipboardPasting);
 | 
	
		
			
				|  |  | +        ledgerSpread.bind(spreadNS.Events.ClipboardPasting, treeOperationObj.clipboardPasting);
 | 
	
		
			
				|  |  |          ledgerSpread.bind(spreadNS.Events.EditStarting, treeOperationObj.editStarting);
 | 
	
		
			
				|  |  |          SpreadJsObj.addCutEvents(ledgerSpread, treeOperationObj.cut);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1527,6 +1516,15 @@ $(document).ready(function() {
 | 
	
		
			
				|  |  |          billsContextMenuOptions.items.sprBatch = '----';
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      if (!readOnly) {
 | 
	
		
			
				|  |  | +        const tenderSelect = TenderSelect({
 | 
	
		
			
				|  |  | +            type: 'ledger',
 | 
	
		
			
				|  |  | +            afterLoad: function (result) {
 | 
	
		
			
				|  |  | +                const ledgerSheet = ledgerSpread.getActiveSheet();
 | 
	
		
			
				|  |  | +                const refreshNode = ledgerTree.loadPostData(result);
 | 
	
		
			
				|  |  | +                treeOperationObj.refreshTree(ledgerSheet, refreshNode);
 | 
	
		
			
				|  |  | +                treeOperationObj.refreshOperationValid(ledgerSheet);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  |          billsContextMenuOptions.items.importExcel = {
 | 
	
		
			
				|  |  |              name: '导入分项清单Excel',
 | 
	
		
			
				|  |  |              icon: 'fa-file-excel-o',
 | 
	
	
		
			
				|  | @@ -1563,10 +1561,6 @@ $(document).ready(function() {
 | 
	
		
			
				|  |  |                      // }
 | 
	
		
			
				|  |  |                      //u_type: importExcel.uploadType.file,
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  | -                //$('#upload-ledger').modal('show');
 | 
	
		
			
				|  |  | -            },
 | 
	
		
			
				|  |  | -            visible: function (key, opt) {
 | 
	
		
			
				|  |  | -                return !readOnly;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  |          billsContextMenuOptions.items.importGclBills2Xmj = {
 | 
	
	
		
			
				|  | @@ -1605,9 +1599,19 @@ $(document).ready(function() {
 | 
	
		
			
				|  |  |                          }, null);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        billsContextMenuOptions.items.importGclBills2Xmj = {
 | 
	
		
			
				|  |  | +            name: '导入(其他标段)工程量清单至项目节',
 | 
	
		
			
				|  |  | +            icon: 'fa-file-excel-o',
 | 
	
		
			
				|  |  | +            disabled: function (key, opt) {
 | 
	
		
			
				|  |  | +                const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
 | 
	
		
			
				|  |  | +                return readOnly || !node
 | 
	
		
			
				|  |  | +                    || (node.children && node.children.length > 0)
 | 
	
		
			
				|  |  | +                    || (!_.isNil(node.b_code) && node.b_code !== '');
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  | -            visible: function (key, opt) {
 | 
	
		
			
				|  |  | -                return !readOnly;
 | 
	
		
			
				|  |  | +            callback: function (key, opt) {
 | 
	
		
			
				|  |  | +                tenderSelect.showSelect(SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet()));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          };
 | 
	
		
			
				|  |  |          billsContextMenuOptions.items.sprImport = '----';
 | 
	
	
		
			
				|  | @@ -1742,6 +1746,7 @@ $(document).ready(function() {
 | 
	
		
			
				|  |  |              if (node) {
 | 
	
		
			
				|  |  |                  const posData = pos.ledgerPos[itemsPre + node.id] || [];
 | 
	
		
			
				|  |  |                  SpreadJsObj.loadSheetData(posSpread.getActiveSheet(), 'data', posData);
 | 
	
		
			
				|  |  | +                getNodeList(node.id);
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  SpreadJsObj.loadSheetData(posSpread.getActiveSheet(), 'data', []);
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -2354,9 +2359,10 @@ $(document).ready(function() {
 | 
	
		
			
				|  |  |          if (!tab.hasClass('active')) {
 | 
	
		
			
				|  |  |              const close = $('.active', '#side-menu').length === 0;
 | 
	
		
			
				|  |  |              $('a', '#side-menu').removeClass('active');
 | 
	
		
			
				|  |  | +            $('.tab-content .tab-select-show').removeClass('active');
 | 
	
		
			
				|  |  |              tab.addClass('active');
 | 
	
		
			
				|  |  | -            $('.tab-content .tab-pane').removeClass('active');
 | 
	
		
			
				|  |  |              tabPanel.addClass('active');
 | 
	
		
			
				|  |  | +            // $('.tab-content .tab-pane').removeClass('active');
 | 
	
		
			
				|  |  |              showSideTools(tab.hasClass('active'));
 | 
	
		
			
				|  |  |              if (tab.attr('content') === '#std-xmj') {
 | 
	
		
			
				|  |  |                  if (!stdXmj) {
 | 
	
	
		
			
				|  | @@ -2429,6 +2435,9 @@ $(document).ready(function() {
 | 
	
		
			
				|  |  |                  errorList.spread.refresh();
 | 
	
		
			
				|  |  |              } else if (tab.attr('content') === '#check-list') {
 | 
	
		
			
				|  |  |                  checkList.spread.refresh();
 | 
	
		
			
				|  |  | +            } else if (tab.attr('content') === '#fujian') {
 | 
	
		
			
				|  |  | +              const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
 | 
	
		
			
				|  |  | +              getNodeList(node.id);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          } else { // 收起工具栏
 | 
	
		
			
				|  |  |              tab.removeClass('active');
 | 
	
	
		
			
				|  | @@ -3386,7 +3395,337 @@ $(document).ready(function() {
 | 
	
		
			
				|  |  |              checkList: checkList,
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // 切换附件里节点和所有附件
 | 
	
		
			
				|  |  | +    $('#fujian .nav-link').on('click', function () {
 | 
	
		
			
				|  |  | +      const tabPanel = $(this).attr('fujian-content');
 | 
	
		
			
				|  |  | +      if (tabPanel !== 'syfujian') {
 | 
	
		
			
				|  |  | +          $('#showPage').hide();
 | 
	
		
			
				|  |  | +          $('#bach-download').prop('type', 'curr');
 | 
	
		
			
				|  |  | +      } else {
 | 
	
		
			
				|  |  | +          $('#showPage').show();
 | 
	
		
			
				|  |  | +          $('#bach-download').prop('type', 'all')
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      $('#showAttachment').hide();
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +    // 上传附件
 | 
	
		
			
				|  |  | +    $('#upload-file-btn').click(function () {
 | 
	
		
			
				|  |  | +        // if (curAuditor && curAuditor.aid !== cur_uid) {
 | 
	
		
			
				|  |  | +        //     return toastr.error('当前操作没有权限!');
 | 
	
		
			
				|  |  | +        // }
 | 
	
		
			
				|  |  | +        const files = $('#upload-file')[0].files;
 | 
	
		
			
				|  |  | +        const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
 | 
	
		
			
				|  |  | +        console.log(node);
 | 
	
		
			
				|  |  | +        const formData = new FormData();
 | 
	
		
			
				|  |  | +        formData.append('lid', node.id);
 | 
	
		
			
				|  |  | +        for (const file of files) {
 | 
	
		
			
				|  |  | +            if (file === undefined) {
 | 
	
		
			
				|  |  | +                toastr.error('未选择上传文件!');
 | 
	
		
			
				|  |  | +                return false;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            const filesize = file.size;
 | 
	
		
			
				|  |  | +            if (filesize > 30 * 1024 * 1024) {
 | 
	
		
			
				|  |  | +                toastr.error('存在上传文件大小过大!');
 | 
	
		
			
				|  |  | +                return false;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            const fileext = '.' + file.name.toLowerCase().split('.').splice(-1)[0];
 | 
	
		
			
				|  |  | +            if (whiteList.indexOf(fileext) === -1) {
 | 
	
		
			
				|  |  | +                toastr.error('只能上传指定格式的附件!');
 | 
	
		
			
				|  |  | +                return false;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            formData.append('size', filesize);
 | 
	
		
			
				|  |  | +            formData.append('file[]', file);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        postDataWithFile('/tender/' + tender.id + '/ledger/upload/file', formData, function (data) {
 | 
	
		
			
				|  |  | +            $('#upload').modal('hide');
 | 
	
		
			
				|  |  | +            // 插入到attData中
 | 
	
		
			
				|  |  | +            attData = data.concat(attData);
 | 
	
		
			
				|  |  | +            // 重新生成List
 | 
	
		
			
				|  |  | +            getAllList();
 | 
	
		
			
				|  |  | +            getNodeList(node.id);
 | 
	
		
			
				|  |  | +        }, function () {
 | 
	
		
			
				|  |  | +            toastr.error('附件上传失败');
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        $('#upload-file').val('');
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +    // 获取附件信息
 | 
	
		
			
				|  |  | +    $('.list-table').on('click', '.att-file-name', function () {
 | 
	
		
			
				|  |  | +      const fid = $(this).attr('file-id');
 | 
	
		
			
				|  |  | +      if ($('#showAttachment').attr('file-id') === fid && !$('#showAttachment').is(":hidden")) {
 | 
	
		
			
				|  |  | +          return;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      const att = attData.find(function (item) {
 | 
	
		
			
				|  |  | +          return item.id === parseInt(fid);
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +      $('#edit-att').hide();
 | 
	
		
			
				|  |  | +      $('#show-att').show();
 | 
	
		
			
				|  |  | +      if (att !== undefined) {
 | 
	
		
			
				|  |  | +          // 进来先把编辑功能隐藏
 | 
	
		
			
				|  |  | +          $('#btn-att a').eq(3).hide()
 | 
	
		
			
				|  |  | +          $('#show-att tr').eq(0).children('td').text(att.filename + att.fileext);
 | 
	
		
			
				|  |  | +          const name = att.code !== null && att.code !== '' ? att.code : (att.b_code !== null ? att.b_code : '');
 | 
	
		
			
				|  |  | +          $('#show-att tr').eq(1).children('td').text($.trim(name + ' ' + att.lname));
 | 
	
		
			
				|  |  | +          // $('#show-att tr').eq(2).find('a').attr('href', '/tender/' + tender.id + '/measure/stage/' + stage.order + '/download/file/' + att.id);
 | 
	
		
			
				|  |  | +          // $('#show-att tr').eq(2).find('a').attr('href', att.filepath);
 | 
	
		
			
				|  |  | +          $('#show-att tr').eq(2).children('td').eq(0).text(att.username);
 | 
	
		
			
				|  |  | +          $('#show-att tr').eq(2).children('td').eq(1).text(att.in_time);
 | 
	
		
			
				|  |  | +          $('#show-att tr').eq(3).children('td').text(att.remark);
 | 
	
		
			
				|  |  | +          // 附件uid等于当前用户id, 附件上传本人
 | 
	
		
			
				|  |  | +          if (parseInt(cur_uid) === att.uid) {
 | 
	
		
			
				|  |  | +              $('#btn-att').show();
 | 
	
		
			
				|  |  | +              const showDel = tender.ledger_status === auditConst.status.checked ? Boolean(att.extra_upload) : true;
 | 
	
		
			
				|  |  | +              if (showDel) $('#btn-att a').eq(3).show();
 | 
	
		
			
				|  |  | +              // $('#btn-att a').eq(3).show();
 | 
	
		
			
				|  |  | +              $('#btn-att a').eq(2).hide();
 | 
	
		
			
				|  |  | +              $('#btn-att a').eq(4).hide();
 | 
	
		
			
				|  |  | +              $('#btn-att a').eq(5).hide();
 | 
	
		
			
				|  |  | +          } else {
 | 
	
		
			
				|  |  | +              $('#btn-att').hide();
 | 
	
		
			
				|  |  | +              $('#btn-att a').eq(3).hide();
 | 
	
		
			
				|  |  | +              $('#btn-att a').eq(2).hide();
 | 
	
		
			
				|  |  | +              $('#btn-att a').eq(4).hide();
 | 
	
		
			
				|  |  | +              $('#btn-att a').eq(5).hide();
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +          $('#showAttachment').attr('file-id', fid);
 | 
	
		
			
				|  |  | +          $('#showAttachment').show();
 | 
	
		
			
				|  |  | +      } else {
 | 
	
		
			
				|  |  | +          $('#showAttachment').hide();
 | 
	
		
			
				|  |  | +          $('#showAttachment').attr('file-id', '');
 | 
	
		
			
				|  |  | +          toastr.error('附件信息获取失败');
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +  });
 | 
	
		
			
				|  |  | +  // $('body').on('click', '.alllist-table a', handleFileList);
 | 
	
		
			
				|  |  | +  $('body').on('click', '#btn-att a', function () {
 | 
	
		
			
				|  |  | +      const content = $(this).attr('content');
 | 
	
		
			
				|  |  | +      const fid = $('#showAttachment').attr('file-id');
 | 
	
		
			
				|  |  | +      const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
 | 
	
		
			
				|  |  | +      if (content === 'edit') {
 | 
	
		
			
				|  |  | +          $('#btn-att a').eq(3).hide();
 | 
	
		
			
				|  |  | +          $('#btn-att a').eq(2).show();
 | 
	
		
			
				|  |  | +          $('#btn-att a').eq(4).show();
 | 
	
		
			
				|  |  | +          $('#btn-att a').eq(5).show();
 | 
	
		
			
				|  |  | +          $('#show-att').hide();
 | 
	
		
			
				|  |  | +          $('#edit-att').show();
 | 
	
		
			
				|  |  | +          const att = attData.find(function (item) {
 | 
	
		
			
				|  |  | +              return item.id === parseInt(fid);
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +          $('#edit-att .form-group').eq(0).find('input').val(att.filename);
 | 
	
		
			
				|  |  | +          $('#edit-att .form-group').eq(0).find('span').eq(1).text(att.fileext);
 | 
	
		
			
				|  |  | +          const name = att.code !== null && att.code !== '' ? att.code : (att.b_code !== null ? att.b_code : '');
 | 
	
		
			
				|  |  | +          $('#edit-att .form-group').eq(1).find('input').val($.trim(name + ' ' + att.lname));
 | 
	
		
			
				|  |  | +          $('#edit-att .form-group').eq(2).find('input').val(att.in_time);
 | 
	
		
			
				|  |  | +          $('#edit-att .form-group').eq(3).find('input').val(att.remark);
 | 
	
		
			
				|  |  | +      } else if (content === 'cancel') {
 | 
	
		
			
				|  |  | +          $('#show-att').show();
 | 
	
		
			
				|  |  | +          $('#edit-att').hide();
 | 
	
		
			
				|  |  | +          $('#btn-att a').eq(3).show();
 | 
	
		
			
				|  |  | +          $('#btn-att a').eq(2).hide();
 | 
	
		
			
				|  |  | +          $('#btn-att a').eq(4).hide();
 | 
	
		
			
				|  |  | +          $('#btn-att a').eq(5).hide();
 | 
	
		
			
				|  |  | +      } else if (content === 'save') {
 | 
	
		
			
				|  |  | +          const formData = new FormData();
 | 
	
		
			
				|  |  | +          formData.append('id', fid);
 | 
	
		
			
				|  |  | +          formData.append('filename', $('#edit-att .form-group').eq(0).find('input').val());
 | 
	
		
			
				|  |  | +          formData.append('fileext', $('#edit-att .form-group').eq(0).find('span').eq(1).text());
 | 
	
		
			
				|  |  | +          formData.append('remark', $('#edit-att .form-group').eq(3).find('input').val());
 | 
	
		
			
				|  |  | +          const file = $('#change-att-btn')[0];
 | 
	
		
			
				|  |  | +          if (file.files[0] !== undefined) {
 | 
	
		
			
				|  |  | +              const filesize = file.files[0].size;
 | 
	
		
			
				|  |  | +              formData.append('size', filesize);
 | 
	
		
			
				|  |  | +              formData.append('file', file.files[0]);
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +          postDataWithFile('/tender/' + tender.id + '/ledger/save/file', formData, function (data) {
 | 
	
		
			
				|  |  | +              // 替换到attData中
 | 
	
		
			
				|  |  | +              const att_index = attData.findIndex(function (item) {
 | 
	
		
			
				|  |  | +                  return item.id === parseInt(fid);
 | 
	
		
			
				|  |  | +              });
 | 
	
		
			
				|  |  | +              attData.splice(att_index, 1, data);
 | 
	
		
			
				|  |  | +              // 重新生成List
 | 
	
		
			
				|  |  | +              getAllList(parseInt($('#currentPage').text()));
 | 
	
		
			
				|  |  | +              getNodeList(node.id);
 | 
	
		
			
				|  |  | +              $('#show-att').show();
 | 
	
		
			
				|  |  | +              $('#edit-att').hide();
 | 
	
		
			
				|  |  | +              $('#show-att tr').eq(0).children('td').text(data.filename + data.fileext);
 | 
	
		
			
				|  |  | +              const name = data.code !== null && data.code !== '' ? data.code : (data.b_code !== null ? data.b_code : '');
 | 
	
		
			
				|  |  | +              $('#show-att tr').eq(1).children('td').text($.trim(name + ' ' + data.lname));
 | 
	
		
			
				|  |  | +              $('#show-att tr').eq(2).children('td').eq(0).text(data.username);
 | 
	
		
			
				|  |  | +              $('#show-att tr').eq(2).children('td').eq(1).text(data.in_time);
 | 
	
		
			
				|  |  | +              $('#show-att tr').eq(3).children('td').text(data.remark);
 | 
	
		
			
				|  |  | +              $('#btn-att a').eq(3).show();
 | 
	
		
			
				|  |  | +              $('#btn-att a').eq(2).hide();
 | 
	
		
			
				|  |  | +              $('#btn-att a').eq(4).hide();
 | 
	
		
			
				|  |  | +              $('#btn-att a').eq(5).hide();
 | 
	
		
			
				|  |  | +          }, function () {
 | 
	
		
			
				|  |  | +              toastr.error('附件上传失败');
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +          $('#change-att-btn').val('');
 | 
	
		
			
				|  |  | +      } else if (content === 'del') {
 | 
	
		
			
				|  |  | +          const data = {id: fid};
 | 
	
		
			
				|  |  | +          postData('/tender/' + tender.id + '/ledger/delete/file', data, function (result) {
 | 
	
		
			
				|  |  | +              // 删除到attData中
 | 
	
		
			
				|  |  | +              const att_index = attData.findIndex(function (item) {
 | 
	
		
			
				|  |  | +                  return item.id === parseInt(fid);
 | 
	
		
			
				|  |  | +              });
 | 
	
		
			
				|  |  | +              attData.splice(att_index, 1);
 | 
	
		
			
				|  |  | +              // 重新生成List
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +              if ($('#alllist-table tr').length === 1) {
 | 
	
		
			
				|  |  | +                  getAllList(parseInt($('#currentPage').text()) - 1);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +              } else {
 | 
	
		
			
				|  |  | +                  getAllList(parseInt($('#currentPage').text()));
 | 
	
		
			
				|  |  | +              }
 | 
	
		
			
				|  |  | +              getNodeList(node.id);
 | 
	
		
			
				|  |  | +              $('#showAttachment').hide();
 | 
	
		
			
				|  |  | +              $('#showAttachment').attr('file-id', '');
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +      } else if (content === 'view') {
 | 
	
		
			
				|  |  | +          const data = {id: fid};
 | 
	
		
			
				|  |  | +          postData('/tender/' + tender.id + '/ledger/check/file', data, function (result) {
 | 
	
		
			
				|  |  | +              const { filepath } = result
 | 
	
		
			
				|  |  | +              $('#load-file').attr('href', filepath);
 | 
	
		
			
				|  |  | +              $('#load-file')[0].click();
 | 
	
		
			
				|  |  | +          });
 | 
	
		
			
				|  |  | +      } else if (content === 'location') {
 | 
	
		
			
				|  |  | +          const att = attData.find(item => item.id === parseInt(fid));
 | 
	
		
			
				|  |  | +          if (Object.keys(att).length) {
 | 
	
		
			
				|  |  | +              SpreadJsObj.locateTreeNode(ledgerSpread.getActiveSheet(), att.ledger_id, true);
 | 
	
		
			
				|  |  | +              posOperationObj.loadCurPosData();
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +  });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // 替换附件
 | 
	
		
			
				|  |  | +  $('#change-att-btn').on('change', function () {
 | 
	
		
			
				|  |  | +      const file = $('#change-att-btn')[0].files[0];
 | 
	
		
			
				|  |  | +      const name = file.name;
 | 
	
		
			
				|  |  | +      const filename = name.substring(0, name.lastIndexOf("."));
 | 
	
		
			
				|  |  | +      const fileext = name.substr(name.indexOf("."));
 | 
	
		
			
				|  |  | +      const filesize = file.size;
 | 
	
		
			
				|  |  | +      if (filesize > 10 * 1024 * 1024) {
 | 
	
		
			
				|  |  | +          toastr.error('文件大小过大!');
 | 
	
		
			
				|  |  | +          $('#change-att-btn').val('');
 | 
	
		
			
				|  |  | +          return false;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      if (whiteList.indexOf(fileext) === -1) {
 | 
	
		
			
				|  |  | +          toastr.error('只能上传指定格式的附件!');
 | 
	
		
			
				|  |  | +          $('#change-att-btn').val('');
 | 
	
		
			
				|  |  | +          return false;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      $('#edit-att .form-group').eq(0).find('input').val(filename);
 | 
	
		
			
				|  |  | +      $('#edit-att .form-group').eq(0).find('span').eq(1).text(fileext);
 | 
	
		
			
				|  |  | +  });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // 切换页数
 | 
	
		
			
				|  |  | +  $('.page-select').on('click', function () {
 | 
	
		
			
				|  |  | +      const totalPageNum = parseInt($('#totalPage').text());
 | 
	
		
			
				|  |  | +      const lastPageNum = parseInt($('#currentPage').text());
 | 
	
		
			
				|  |  | +      const status = $(this).attr('content');
 | 
	
		
			
				|  |  | +      if (status === 'pre' && lastPageNum > 1) {
 | 
	
		
			
				|  |  | +          getAllList(lastPageNum-1);
 | 
	
		
			
				|  |  | +          $('#showAttachment').hide();
 | 
	
		
			
				|  |  | +          $('#syfujian .check-all-file').prop('checked', false)
 | 
	
		
			
				|  |  | +      } else if (status === 'next' && lastPageNum < totalPageNum) {
 | 
	
		
			
				|  |  | +          getAllList(lastPageNum+1);
 | 
	
		
			
				|  |  | +          $('#showAttachment').hide();
 | 
	
		
			
				|  |  | +          $('#syfujian .check-all-file').prop('checked', false)
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +  });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // 批量下载
 | 
	
		
			
				|  |  | +  $('#bach-download').click(function() {
 | 
	
		
			
				|  |  | +      const fileIds = [];
 | 
	
		
			
				|  |  | +      const type = $(this).prop('type');
 | 
	
		
			
				|  |  | +      let node = ''
 | 
	
		
			
				|  |  | +      if (type === 'curr') {
 | 
	
		
			
				|  |  | +          node = '#nodelist-table .check-file:checked'
 | 
	
		
			
				|  |  | +      } else {
 | 
	
		
			
				|  |  | +          node = '#alllist-table .check-file:checked'
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      $(node).each(function() {
 | 
	
		
			
				|  |  | +          const fileId = $(this).attr('file-id');
 | 
	
		
			
				|  |  | +          fileId && fileIds.push(fileId);
 | 
	
		
			
				|  |  | +      });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +      if (fileIds.length) {
 | 
	
		
			
				|  |  | +          const url = `/tender/${tender.id}/ledger/download/compresse-file?fileIds=${JSON.stringify(fileIds)}`;
 | 
	
		
			
				|  |  | +          $('#zipDown').attr('href', url);
 | 
	
		
			
				|  |  | +          $("#zipDown")[0].click();
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +  });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  // 监听附件check是否选中
 | 
	
		
			
				|  |  | +  $('.list-table').on('click', '.check-file', function() {
 | 
	
		
			
				|  |  | +      const checkedList = $(this).parents('.list-table').children().find('input:checked');
 | 
	
		
			
				|  |  | +      const childs = $(this).parents('.list-table').children().length;
 | 
	
		
			
				|  |  | +      const checkBox = $(this).parents('.list-table').parent().find('.check-all-file');
 | 
	
		
			
				|  |  | +      if (checkedList.length === childs) {
 | 
	
		
			
				|  |  | +          checkBox.prop("checked", true);
 | 
	
		
			
				|  |  | +      } else {
 | 
	
		
			
				|  |  | +          checkBox.prop("checked", false);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +  });
 | 
	
		
			
				|  |  | +  $('.check-all-file').click(function() {
 | 
	
		
			
				|  |  | +      const isCheck = $(this).is(':checked');
 | 
	
		
			
				|  |  | +      $(this).parents('table').find('.list-table').each(function() {
 | 
	
		
			
				|  |  | +          $(this).find('input:checkbox').prop("checked", isCheck);
 | 
	
		
			
				|  |  | +      })
 | 
	
		
			
				|  |  | +  });
 | 
	
		
			
				|  |  |  });
 | 
	
		
			
				|  |  | +// 生成当前节点列表
 | 
	
		
			
				|  |  | +function getNodeList(node) {
 | 
	
		
			
				|  |  | +  let html = '';
 | 
	
		
			
				|  |  | +  for(const att of attData) {
 | 
	
		
			
				|  |  | +      if (node === att.lid) {
 | 
	
		
			
				|  |  | +          // html += '<tr><td><a href="javascript:void(0)" file-id="'+ att.id +'">'+ att.filename + att.fileext +'</a></td><td>'+ att.username +'</td></tr>';
 | 
	
		
			
				|  |  | +          html += `<tr>
 | 
	
		
			
				|  |  | +          <td width="25"><input type="checkbox" class="check-file" file-id=${att.id}></td>
 | 
	
		
			
				|  |  | +          <td>
 | 
	
		
			
				|  |  | +          <div class="d-flex">
 | 
	
		
			
				|  |  | +              <a href="javascript:void(0)" class="pl-0 col-11 att-file-name" file-id=${att.id}>${att.filename}${att.fileext}</a>
 | 
	
		
			
				|  |  | +              <a href="/tender/${tender.id}/ledger/download/file/${att.id}" class="col-1 pl-0 att-file-btn"><i class="fa fa-download"></i></a>
 | 
	
		
			
				|  |  | +          </div>
 | 
	
		
			
				|  |  | +          </td><td>${att.username}</td></tr>`
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  $('#nodelist-table').html(html);
 | 
	
		
			
				|  |  | +  $('#nodelist-table').on('click', 'tr', function() {
 | 
	
		
			
				|  |  | +      $('#nodelist-table tr').removeClass('bg-light')
 | 
	
		
			
				|  |  | +      $(this).addClass('bg-light')
 | 
	
		
			
				|  |  | +  })
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +// 生成所有附件列表
 | 
	
		
			
				|  |  | +function getAllList(currPageNum = 1) {
 | 
	
		
			
				|  |  | +  // 每页最多几个附件
 | 
	
		
			
				|  |  | +  const pageCount = 15;
 | 
	
		
			
				|  |  | +  // 附件总数
 | 
	
		
			
				|  |  | +  const total = attData.length;
 | 
	
		
			
				|  |  | +  // 总页数
 | 
	
		
			
				|  |  | +  const pageNum = Math.ceil(total/pageCount);
 | 
	
		
			
				|  |  | +  $('#totalPage').text(pageNum);
 | 
	
		
			
				|  |  | +  $('#currentPage').text(total === 0 ? 0 : currPageNum);
 | 
	
		
			
				|  |  | +  // 当前页附件内容
 | 
	
		
			
				|  |  | +  const currPageAttData = attData.slice((currPageNum-1)*pageCount, currPageNum*pageCount);
 | 
	
		
			
				|  |  | +  let html = '';
 | 
	
		
			
				|  |  | +  for(const att of currPageAttData) {
 | 
	
		
			
				|  |  | +      html += `<tr>
 | 
	
		
			
				|  |  | +      <td width="25"><input type="checkbox" class="check-file" file-id=${att.id}></td>
 | 
	
		
			
				|  |  | +      <td>
 | 
	
		
			
				|  |  | +      <div class="d-flex">
 | 
	
		
			
				|  |  | +          <a href="javascript:void(0)" class="pl-0 col-11 att-file-name" file-id=${att.id}>${att.filename}${att.fileext}</a>
 | 
	
		
			
				|  |  | +          <a href="/tender/${tender.id}/ledger/download/file/${att.id}" class="col-1 pl-0 att-file-btn"><i class="fa fa-download"></i></a>
 | 
	
		
			
				|  |  | +      </div>
 | 
	
		
			
				|  |  | +      </td><td>${att.username}</td></tr>`
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  console.log(attData);
 | 
	
		
			
				|  |  | +  $('#alllist-table').html(html);
 | 
	
		
			
				|  |  | +  $('#alllist-table').on('click', 'tr', function() {
 | 
	
		
			
				|  |  | +      $('#alllist-table tr').removeClass('bg-light')
 | 
	
		
			
				|  |  | +      $(this).addClass('bg-light')
 | 
	
		
			
				|  |  | +  })
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // 检查上报情况
 | 
	
		
			
				|  |  |  function checkAuditorFrom () {
 |