|
@@ -26,27 +26,40 @@ $(document).ready(function () {
|
|
|
formData.append('size', file.size)
|
|
|
})
|
|
|
postDataWithFile(window.location.pathname + '/upload', formData, function (result) {
|
|
|
+ const files = result.map(file => {
|
|
|
+ let showDel = false
|
|
|
+ // 只判断当前期,因为以往期都是只读的
|
|
|
+ if (file.mid === parseInt(mid) && file.tid === parseInt(tid) && file.user_id === parseInt(cur_uid)) {
|
|
|
+ if (!curAuditor) {
|
|
|
+ material.status === auditConst.status.uncheck && parseInt(cur_uid) === material.user_id && (showDel = true)
|
|
|
+ material.status === auditConst.status.checkNo && parseInt(cur_uid) === material.user_id && (showDel = true)
|
|
|
+ } else {
|
|
|
+ curAuditor.aid === parseInt(cur_uid) && (showDel = true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return showDel ? {...file, canDel: true} : file
|
|
|
+ })
|
|
|
$('#addfujian').modal('hide');
|
|
|
let html = '';
|
|
|
- result.forEach((fileInfo, idx) => {
|
|
|
+ files.forEach((fileInfo, idx) => {
|
|
|
html += `<tr>
|
|
|
<td>${idx + 1}</td>
|
|
|
- <td><a href="/${fileInfo.filepath}">${fileInfo.file_name}</a></td>
|
|
|
+ <td><a href="/${fileInfo.filepath}" target="_blank">${fileInfo.file_name}</a></td>
|
|
|
<td>${fileInfo.file_size}</td>
|
|
|
+ <td>第${fileInfo.s_order}期</td>
|
|
|
<td>${fileInfo.upload_time}</td>`
|
|
|
- if (user_id == fileInfo.user_id && checked) {
|
|
|
- html += `<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>`
|
|
|
- } else {
|
|
|
- html += `<td></td></tr>`
|
|
|
- }
|
|
|
+ if (fileInfo.canDel ) {
|
|
|
+ html += `<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>`
|
|
|
+ } else {
|
|
|
+ html += `<td></td></tr>`
|
|
|
+ }
|
|
|
})
|
|
|
$('#file-list').empty();
|
|
|
$('#file-list').append(html);
|
|
|
- console.log(result)
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -57,35 +70,35 @@ $(document).ready(function () {
|
|
|
isCheck = true
|
|
|
}
|
|
|
postData(window.location.pathname + '/find', {isCheck}, function(result) {
|
|
|
+ const files = result.map(file => {
|
|
|
+ let showDel = false
|
|
|
+ // 只判断当前期,因为以往期都是只读的
|
|
|
+ if (file.mid === parseInt(mid) && file.tid === parseInt(tid) && file.user_id === parseInt(cur_uid)) {
|
|
|
+ if (!curAuditor) {
|
|
|
+ material.status === auditConst.status.uncheck && parseInt(cur_uid) === material.user_id && (showDel = true)
|
|
|
+ material.status === auditConst.status.checkNo && parseInt(cur_uid) === material.user_id && (showDel = true)
|
|
|
+ } else {
|
|
|
+ curAuditor.aid === parseInt(cur_uid) && (showDel = true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return showDel ? {...file, canDel: true} : file
|
|
|
+ })
|
|
|
let html = '';
|
|
|
- result.forEach((fileInfo, idx) => {
|
|
|
+ files.forEach((fileInfo, idx) => {
|
|
|
html += `<tr>
|
|
|
<td>${idx + 1 }</td>
|
|
|
- <td><a href="/${fileInfo.filepath}">${fileInfo.file_name}</a></td>
|
|
|
+ <td><a href="/${fileInfo.filepath}" target="_blank">${fileInfo.file_name}</a></td>
|
|
|
<td>${fileInfo.file_size}</td>
|
|
|
+ <td>第${fileInfo.s_order}期</td>
|
|
|
<td>${fileInfo.upload_time}</td>`
|
|
|
- if (isCheck) {
|
|
|
- // 所有期
|
|
|
- if (fileInfo.pre_delete && user_id == fileInfo.user_id) {
|
|
|
- html += `<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>`
|
|
|
- } else {
|
|
|
- html += `<td></td></tr>`
|
|
|
- }
|
|
|
+ if (fileInfo.canDel ) {
|
|
|
+ html += `<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>`
|
|
|
} else {
|
|
|
- // 当前期
|
|
|
- if (user_id == fileInfo.user_id && checked) {
|
|
|
- html += `<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>`
|
|
|
- } else {
|
|
|
- html += `<td></td></tr>`
|
|
|
- }
|
|
|
+ html += `<td></td></tr>`
|
|
|
}
|
|
|
|
|
|
})
|
|
@@ -115,7 +128,7 @@ $(document).ready(function () {
|
|
|
* @param {Array} files 文件数组
|
|
|
*/
|
|
|
function validateFiles(files) {
|
|
|
- const reg = /(doc|docx|excel|pdf|xlsx|xls|txt|zip|jpg|jpeg|png|bmp|BMP|JPG|PNG|JPEG)$/;
|
|
|
+ const reg = /(doc|docx|excel|pdf|xlsx|xls|txt|zip|jpg|jpeg|png|bmp|BMP|JPG|PNG|JPEG|gif)$/;
|
|
|
return files.every(file => {
|
|
|
if (file.size > 1024 * 1024 * 10) {
|
|
|
toastr.error('文件大小限制为10MB');
|