|  | @@ -46,9 +46,9 @@ $(document).ready(function () {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      })
 | 
	
		
			
				|  |  |      // 选择/未选所有期列表
 | 
	
		
			
				|  |  | -    $('#file-checkbox').click(function() {
 | 
	
		
			
				|  |  | -        getAllList()
 | 
	
		
			
				|  |  | -    })
 | 
	
		
			
				|  |  | +    // $('#file-checkbox').click(function() {
 | 
	
		
			
				|  |  | +    //     getAllList()
 | 
	
		
			
				|  |  | +    // })
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // 删除附件
 | 
	
		
			
				|  |  |      $('body').on('click', '.delete-file', function () {
 | 
	
	
		
			
				|  | @@ -100,6 +100,20 @@ $(document).ready(function () {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              curPageNo !== $(this).text() && getAllList(parseInt($(this).text()))
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $('.dropdown-item').click(function() {
 | 
	
		
			
				|  |  | +        const type = $('#dropdownMenuButton').attr('btn-type')
 | 
	
		
			
				|  |  | +        if (type === 'curr') {
 | 
	
		
			
				|  |  | +            $(this).text('当前期')
 | 
	
		
			
				|  |  | +            $('#dropdownMenuButton').text('所有期')
 | 
	
		
			
				|  |  | +            $('#dropdownMenuButton').attr('btn-type', 'all')
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            $(this).text('所有期')
 | 
	
		
			
				|  |  | +            $('#dropdownMenuButton').text('当前期')
 | 
	
		
			
				|  |  | +            $('#dropdownMenuButton').attr('btn-type', 'curr')
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        getAllList()
 | 
	
		
			
				|  |  |      })
 | 
	
		
			
				|  |  |      // 生成所有附件列表
 | 
	
		
			
				|  |  |      function getAllList(currPageNum = 1) {
 | 
	
	
		
			
				|  | @@ -109,14 +123,14 @@ $(document).ready(function () {
 | 
	
		
			
				|  |  |          // 总页数
 | 
	
		
			
				|  |  |          const pageNum = Math.ceil(total/pageCount);
 | 
	
		
			
				|  |  |          // 当前页附件内容
 | 
	
		
			
				|  |  | -        const currPageAttData = fileData && $('#file-checkbox').is(':checked') ? fileData.slice((currPageNum-1)*pageCount, currPageNum*pageCount) : filterFileData.map((v, index) => {
 | 
	
		
			
				|  |  | +        const currPageAttData = fileData && $('#dropdownMenuButton').attr('type') === 'all' ? fileData.slice((currPageNum-1)*pageCount, currPageNum*pageCount) : filterFileData.map((v, index) => {
 | 
	
		
			
				|  |  |              return {...v, index }
 | 
	
		
			
				|  |  |          }).slice((currPageNum-1)*pageCount, currPageNum*pageCount);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          renderHtml(currPageAttData)
 | 
	
		
			
				|  |  |          // 渲染分页器
 | 
	
		
			
				|  |  |          renderPagination(currPageNum, pageNum)
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      function renderPagination(pageNo, pageSize) {
 | 
	
	
		
			
				|  | @@ -185,12 +199,14 @@ $(document).ready(function () {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          $('.page-next').before(html)
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      function renderHtml(list) {
 | 
	
		
			
				|  |  |          let html = '';
 | 
	
		
			
				|  |  | +        $('#check-all-file').prop("checked", false)
 | 
	
		
			
				|  |  |          list.forEach(fileInfo => {
 | 
	
		
			
				|  |  |              html += `<tr style="height: 31px;">
 | 
	
		
			
				|  |  | +            <td width="25"><input type="checkbox" class="check-file" file-id=${fileInfo.id}></td>
 | 
	
		
			
				|  |  |              <td>${fileInfo.index + 1}</td>
 | 
	
		
			
				|  |  |              <td><a href="/${fileInfo.filepath}" target="_blank">${fileInfo.file_name}</a></td>
 | 
	
		
			
				|  |  |              <td>${fileInfo.file_size}</td>
 | 
	
	
		
			
				|  | @@ -198,18 +214,50 @@ $(document).ready(function () {
 | 
	
		
			
				|  |  |              <td>${fileInfo.upload_time}</td>`
 | 
	
		
			
				|  |  |              if (fileInfo.canDel ) {
 | 
	
		
			
				|  |  |                  html += `<td>
 | 
	
		
			
				|  |  | -                <a class="btn btn-light btn-sm delete-file" data-attid="${fileInfo.id}" title="删除附件">
 | 
	
		
			
				|  |  | +                <a href="/${fileInfo.filepath}" class="btn btn-light btn-sm" title="下载"><span class="fa fa-download text-primary"></span></a>
 | 
	
		
			
				|  |  | +                <a href="javascript:void(0);" class="btn btn-light btn-sm delete-file" data-attid="${fileInfo.id}" title="删除附件">
 | 
	
		
			
				|  |  |                  <span class="fa fa-trash text-danger"></span>
 | 
	
		
			
				|  |  |                  </a>
 | 
	
		
			
				|  |  |                  </td></tr>`
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  | -                html += `<td></td></tr>`
 | 
	
		
			
				|  |  | +                html += `<td><a href="/${fileInfo.filepath}" class="btn btn-light btn-sm" title="下载"><span class="fa fa-download text-primary"></span></a></td></tr>`
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  |          $('#file-list').empty();
 | 
	
		
			
				|  |  |          $('#file-list').append(html);
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $('#file-list').on('click', '.check-file', function() {
 | 
	
		
			
				|  |  | +        const checkedList = $('#file-list').find('input:checked')
 | 
	
		
			
				|  |  | +        const childs = $('#file-list').children().length
 | 
	
		
			
				|  |  | +        const checkBox = $('#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')
 | 
	
		
			
				|  |  | +        $('#file-list').children().each(function() {
 | 
	
		
			
				|  |  | +            $(this).find('input:checkbox').prop("checked", isCheck)
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    $('#bach-download').click(function() {
 | 
	
		
			
				|  |  | +        const fileIds = []
 | 
	
		
			
				|  |  | +        $( '#file-list .check-file:checked').each(function() {
 | 
	
		
			
				|  |  | +            const fileId = $(this).attr('file-id')
 | 
	
		
			
				|  |  | +            fileId && fileIds.push(fileId)
 | 
	
		
			
				|  |  | +        })
 | 
	
		
			
				|  |  | +        console.log('fileIds', fileIds)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (fileIds.length) {
 | 
	
		
			
				|  |  | +            // postData( `/tender/${tid}/measure/material/${order}/file/download/compresse-file`, { fileIds })
 | 
	
		
			
				|  |  | +            $('#downloadZip').attr('href', `/tender/${tid}/measure/material/${order}/file/download/compresse-file?fileIds=${JSON.stringify(fileIds)}`);
 | 
	
		
			
				|  |  | +            $('#downloadZip')[0].click();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  |      function handleFileList(fileList) {
 | 
	
		
			
				|  |  |          fileData = fileList.map((file, index) => {
 | 
	
		
			
				|  |  |              let showDel = false
 | 
	
	
		
			
				|  | @@ -224,7 +272,7 @@ $(document).ready(function () {
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              return showDel ? {...file, canDel: true, index} : {...file, index}
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      function calcCount() {
 | 
	
		
			
				|  |  |          // 附件总数
 | 
	
	
		
			
				|  | @@ -233,7 +281,7 @@ $(document).ready(function () {
 | 
	
		
			
				|  |  |              total = fileData && fileData.filter(file => file.mid === parseInt(mid) && file.tid === parseInt(tid)).length
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return total
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | +    };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      $.subMenu({
 | 
	
		
			
				|  |  |          menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
 | 
	
	
		
			
				|  | @@ -273,4 +321,4 @@ function validateFiles(files) {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return true
 | 
	
		
			
				|  |  |      })
 | 
	
		
			
				|  |  | -}
 | 
	
		
			
				|  |  | +};
 |