|
@@ -25,6 +25,8 @@ $(function () {
|
|
|
autoFlashHeight();
|
|
|
auditRptPrintHelper.showPage();
|
|
|
iniPage();
|
|
|
+ //初始化所有附件列表
|
|
|
+ getAllList();
|
|
|
|
|
|
$('#rpt-form input').on('change', function () {
|
|
|
const newVal = $(this).val();
|
|
@@ -72,16 +74,21 @@ $(function () {
|
|
|
$('#sign_path').prop('checked', rptAudit.signature_msg.sign_path !== null);
|
|
|
$('#company_stamp').prop('checked', rptAudit.signature_msg.company_stamp !== null);
|
|
|
$('#stamp_path').prop('checked', rptAudit.signature_msg.stamp_path !== null);
|
|
|
- $('#signature_date').val(rptAudit.signature_msg.date ? rptAudit.signature_msg.date : '');
|
|
|
+ $('#signature_date').val(rptAudit.signature_msg.date ? rptAudit.signature_msg.date : new Date());
|
|
|
signatureDate = !signatureDate ? $('#signature_date').datepicker().data('datepicker') : signatureDate;
|
|
|
if (signatureDate && rptAudit.signature_msg.date) {
|
|
|
signatureDate.selectDate(new Date(rptAudit.signature_msg.date));
|
|
|
} else if (signatureDate) {
|
|
|
- signatureDate.clear();
|
|
|
+ signatureDate.selectDate(new Date());
|
|
|
+ // signatureDate.clear();
|
|
|
}
|
|
|
$('#signature_content').val(rptAudit.signature_msg.content ? rptAudit.signature_msg.content : '');
|
|
|
});
|
|
|
|
|
|
+ $('#sp-done').on('show.bs.modal', function () {
|
|
|
+ $('#sp-done').find('textarea').val(rptAudit.signature_msg.content ? rptAudit.signature_msg.content : '同意');
|
|
|
+ });
|
|
|
+
|
|
|
$('#commit_sign').click(function () {
|
|
|
rptAudit.signature_msg.sign_path = $('#sign_path').is(':checked') ? $('#sign_path').val() : null;
|
|
|
rptAudit.signature_msg.company_stamp = $('#company_stamp').is(':checked') ? $('#company_stamp').val() : null;
|
|
@@ -132,4 +139,188 @@ $(function () {
|
|
|
clearTimeout(timer);
|
|
|
}, 500);
|
|
|
}
|
|
|
+
|
|
|
+ //tab change
|
|
|
+ $('a[data-toggle="tab"]').on('shown.bs.tab', function () {
|
|
|
+ const tab = $(this).data('tab');
|
|
|
+ if (tab === 'fujian') {
|
|
|
+ $('#fujian_btn').show();
|
|
|
+ } else {
|
|
|
+ $('#fujian_btn').hide();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 切换页数
|
|
|
+ $('.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);
|
|
|
+ $('#annex .check-all-file').prop('checked', false)
|
|
|
+ } else if (status === 'next' && lastPageNum < totalPageNum) {
|
|
|
+ getAllList(lastPageNum+1);
|
|
|
+ $('#annex .check-all-file').prop('checked', false)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 上传附件
|
|
|
+ $('#upload-file-btn').click(function () {
|
|
|
+ const files = $('#upload-file')[0].files;
|
|
|
+ const formData = new FormData();
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ if (uidList.indexOf(accountId) === -1) {
|
|
|
+ return toastr.error('暂无权限上传!');
|
|
|
+ }
|
|
|
+ postDataWithFile(window.location.pathname + '/file/upload', formData, function (data) {
|
|
|
+ attData = data.concat(attData);
|
|
|
+ // 重新生成List
|
|
|
+ getAllList();
|
|
|
+ $('#addfujian').modal('hide');
|
|
|
+ }, function () {
|
|
|
+ });
|
|
|
+ $('#upload-file').val('');
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ // 删除附件
|
|
|
+ $('body').on('click', '.delete-file', function () {
|
|
|
+ let attid = $(this).data('attid');
|
|
|
+ let self = $(this);
|
|
|
+ const data = {id: attid};
|
|
|
+ postData(window.location.pathname + '/file/delete', data, function (result) {
|
|
|
+ // 删除到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()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#attList').on('click', '.file-atn', function() {
|
|
|
+ const id = $(this).attr('f-id');
|
|
|
+ postData(`/payment/${tenderId}/detail/${detailId}/file/${id}/download`, {}, (data) => {
|
|
|
+ const { filepath } = data;
|
|
|
+ $('#file-upload').attr('href', filepath);
|
|
|
+ $('#file-upload')[0].click();
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#attList').on('click', '.check-file', function() {
|
|
|
+ const checkedList = $('#attList').find('input:checked');
|
|
|
+ const childs = $('#attList').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');
|
|
|
+ $('#attList').children().each(function() {
|
|
|
+ $(this).find('input:checkbox').prop("checked", isCheck);
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#bach-download').click(function() {
|
|
|
+ const fileIds = [];
|
|
|
+ $( '#attList .check-file:checked').each(function() {
|
|
|
+ const fileId = $(this).attr('file-id');
|
|
|
+ fileId && fileIds.push(fileId);
|
|
|
+ });
|
|
|
+
|
|
|
+ if (fileIds.length) {
|
|
|
+ if (fileIds.length > 20) {
|
|
|
+ return toastr.warning(`最大允许20个文件(当前${fileIds.length}个)`);
|
|
|
+ }
|
|
|
+ toastr.success('正在进行压缩文件...', '', { timeOut: 0, extendedTimeOut: 0});
|
|
|
+ $(this).attr('disabled', "true");
|
|
|
+ const btn = $(this);
|
|
|
+
|
|
|
+ const fileArr = [];
|
|
|
+ for (const id of fileIds) {
|
|
|
+ const fileInfo = _.find(currPageFileData, { id: parseInt(id) });
|
|
|
+ fileArr.push({
|
|
|
+ url: fileInfo.orginpath, //文件的oss存储路径 (必填)
|
|
|
+ name: fileInfo.filename, // 文件名 (可选, 不需要填扩展名)
|
|
|
+ foldPath: '' // (可选, 文件在压缩包中的存储路径)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ const packageName = `${trName}-${detailName}-附件.zip`;
|
|
|
+ try {
|
|
|
+ zipOss.downloadFromAliOss(fileArr, packageName, btn);
|
|
|
+ } catch (e) {
|
|
|
+ btn.removeAttr('disabled');
|
|
|
+ toastr.clear();
|
|
|
+ toastr.error('批量下载失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
+
|
|
|
+// 生成附件列表
|
|
|
+function getAllList(currPageNum = 1) {
|
|
|
+ // 每页最多几个附件
|
|
|
+ const pageCount = 20;
|
|
|
+ // 附件总数
|
|
|
+ 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);
|
|
|
+ currPageFileData = currPageAttData;
|
|
|
+ let html = '';
|
|
|
+ // '/tender/' + tender.id + '/measure/stage/' + stage.order + '/download/file/' + att.id
|
|
|
+ for(const [index,att] of currPageAttData.entries()) {
|
|
|
+ html += `<tr>
|
|
|
+ <td width="25"><input type="checkbox" class="check-file" file-id=${att.id}></td>
|
|
|
+ <td>${((currPageNum-1)*pageCount)+index+1}</td>
|
|
|
+ <td><a href="${att.filepath}" target="_blank" class="pl-0 col-11 att-file-name" file-id=${att.id}>${att.filename}${att.fileext}</a></td>
|
|
|
+ <td>${moment(att.upload_time).format("YYYY-MM-DD HH:mm:ss")}<br>${bytesToSize(att.filesize)}</td>
|
|
|
+ <td>
|
|
|
+ <a href="/payment/${tenderId}/detail/${detailId}/file/${att.id}/download" class="mr-2" title="下载"><span class="fa fa-download text-primary"></span></a>`
|
|
|
+ html += (att.uid === accountId && (detailStatus === auditConst.status.checked ? 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];
|
|
|
+}
|