| 
					
				 | 
			
			
				@@ -15,6 +15,8 @@ const is_numeric = (value) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //初始化所有附件列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    getAllList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     const cca = getLocalCache('change-checkbox-account-' + accountId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if (cca !== null && cca !== undefined) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $('#customCheck1').prop('checked', cca !== 'false'); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -80,28 +82,31 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             formData.append('file[]', file); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (auditList.findIndex(item => item.uid === parseInt(accountId)) === -1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return toastr.error('暂无权限上传!') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return toastr.error('暂无权限上传!'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         postDataWithFile(window.location.pathname + '/file/upload', formData, function (data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            attData = data.concat(attData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 重新生成List 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            getAllList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             $('#addfujian').modal('hide'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            let html = ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            let index = $('#attList tr').length + 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            for (const fileInfo of data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                html += '<tr> ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    `<td width="20"><input type="checkbox" class="check-file" file-id=${fileInfo.id}></td>` + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    '<td>' + index + '</td> ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    `<td><a href="javascript: void(0);" class="file-atn" f-id="${fileInfo.id}">${fileInfo.filename}${fileInfo.fileext}</a></td>`+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    '<td>' + fileInfo.in_time + '<br>' + fileInfo.filesize + '</td> ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    `<td><a href="/change/download/file/${fileInfo.id}" class="mr-2" title="下载"><span class="fa fa-download text-primary"></span></a>`+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    ( auditStatus === 4 ? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        fileInfo.extra_upload ? `<a class="mr-2 delete-file" data-attid="${fileInfo.id}"  title="删除附件"><span class="fa fa-trash text-danger"></span></a>` : '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        : ` <a href="javascript:void(0);" class="mr-2 delete-file" data-attid="${fileInfo.id}"  title="删除附件"><span class="fa fa-trash text-danger"></span></a>`)+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    `</td>`+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    // '<td> <a class="btn btn-light btn-sm delete-file" data-attid="' + fileInfo.id + '"  title="删除附件"><span class="fa fa-trash text-danger"></span></a> </td> ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    '</tr>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ++index; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $('#attList').append(html); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // let html = ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // let index = $('#attList tr').length + 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // for (const fileInfo of data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     html += '<tr> ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         `<td width="20"><input type="checkbox" class="check-file" file-id=${fileInfo.id}></td>` + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         '<td>' + index + '</td> ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         `<td><a href="javascript: void(0);" class="file-atn" f-id="${fileInfo.id}">${fileInfo.filename}${fileInfo.fileext}</a></td>`+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         '<td>' + fileInfo.in_time + '<br>' + fileInfo.filesize + '</td> ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         `<td><a href="/change/download/file/${fileInfo.id}" class="mr-2" title="下载"><span class="fa fa-download text-primary"></span></a>`+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         ( auditStatus === 4 ? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //             fileInfo.extra_upload ? `<a class="mr-2 delete-file" data-attid="${fileInfo.id}"  title="删除附件"><span class="fa fa-trash text-danger"></span></a>` : '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //             : ` <a href="javascript:void(0);" class="mr-2 delete-file" data-attid="${fileInfo.id}"  title="删除附件"><span class="fa fa-trash text-danger"></span></a>`)+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         `</td>`+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         // '<td> <a class="btn btn-light btn-sm delete-file" data-attid="' + fileInfo.id + '"  title="删除附件"><span class="fa fa-trash text-danger"></span></a> </td> ' + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //         '</tr>'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     ++index; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // $('#attList').append(html); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }, function () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $('#upload-file').val(''); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -114,13 +119,26 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         let self = $(this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         const data = {id: attid}; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         postData(window.location.pathname + '/file/delete', data, function (result) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            self.parents('tr').remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 重新排序 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            let newsort = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $('#attList tr').each(function(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                $(this).children('td').eq(1).text(newsort); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                newsort++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // self.parents('tr').remove(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // // 重新排序 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // let newsort = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // $('#attList tr').each(function(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     $(this).children('td').eq(1).text(newsort); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //     newsort++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 删除到attData中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const att_index = attData.findIndex(function (item) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return item.id === parseInt(attid); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            attData.splice(att_index, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 重新生成List 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if ($('#attList tr').length === 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                getAllList(parseInt($('#currentPage').text()) - 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                getAllList(parseInt($('#currentPage').text())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // /change/download/file/ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -182,6 +200,22 @@ $(document).ready(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             changeSpread.refresh(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 切换页数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $('.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) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function findDecimal(unit) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     let value = precision.other.value; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -194,4 +228,46 @@ function findDecimal(unit) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 生成附件列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+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 = ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // '/tender/' + tender.id + '/measure/stage/' + stage.order + '/download/file/' + att.id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for(const [index,att] of currPageAttData.entries()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.log(att.uid, accountId, auditStatus, Boolean(att.extra_upload)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        html += `<tr> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <td width="25"><input type="checkbox" class="check-file" file-id=${att.id}></td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <td>${index+1}</td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <td><a href="javascript:void(0)" class="pl-0 col-11 att-file-name" file-id=${att.id}>${att.filename}${att.fileext}</a></td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <td>${moment(att.in_time * 1000).format('YYYY-MM-DD')}<br>${bytesToSize(att.filesize)}</td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        <td> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            <a href="/change/download/file/${att.id}" class="mr-2" title="下载"><span class="fa fa-download text-primary"></span></a>` 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        html += (att.uid === accountId && (auditStatus === 4 ? Boolean(att.extra_upload) : true)) ? 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            `<a href="javascript:void(0)" class="mr-2 delete-file" data-attid="${att.id}" title="删除附件"><span class="fa fa-trash text-danger"></span></a>` : ''; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        html += `</td>`; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $('#attList').html(html); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    $('#attList').on('click', 'tr', function() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $('#attList tr').removeClass('bg-light'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $(this).addClass('bg-light'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function bytesToSize(bytes) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (parseInt(bytes) === 0) return '0 B'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const k = 1024; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const i = Math.floor(Math.log(bytes) / Math.log(k)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // return (bytes / Math.pow(k, i)) + ' ' + sizes[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |