|
@@ -86,6 +86,36 @@ function needCheckDetail() {
|
|
|
$('#check_point').show();
|
|
|
}
|
|
|
|
|
|
+// 生成所有附件列表
|
|
|
+function getAllList(currPageNum = 1) {
|
|
|
+ // 每页最多几个附件
|
|
|
+ const pageCount = 11;
|
|
|
+ // 附件总数
|
|
|
+ const total = attData.length;
|
|
|
+ // 总页数
|
|
|
+ const pageNum = Math.ceil(total/pageCount);
|
|
|
+ $('#totalPage').text(pageNum);
|
|
|
+ $('#currentPage').text(currPageNum);
|
|
|
+ // 当前页附件内容
|
|
|
+ const currPageAttData = attData.slice((currPageNum-1)*pageCount, currPageNum*pageCount);
|
|
|
+ let html = '';
|
|
|
+ for(const att of currPageAttData) {
|
|
|
+ html += '<tr><td><a href="javascript:void(0)" file-id="'+ att.id +'">'+ att.filename + att.fileext +'</a></td><td>'+ att.username +'</td></tr>';
|
|
|
+ }
|
|
|
+ $('#alllist-table').html(html);
|
|
|
+}
|
|
|
+// 生成当前节点列表
|
|
|
+function getNodeList(node) {
|
|
|
+ let html = '';
|
|
|
+ for(const att of attData) {
|
|
|
+ if (parseInt(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>';
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('#nodelist-table').html(html);
|
|
|
+}
|
|
|
+
|
|
|
$(document).ready(() => {
|
|
|
// 界面布局
|
|
|
autoFlashHeight();
|
|
@@ -413,6 +443,9 @@ $(document).ready(() => {
|
|
|
// 绘制界面
|
|
|
SpreadJsObj.loadSheetData(slSpread.getActiveSheet(), 'tree', stageTree);
|
|
|
|
|
|
+ //初始化所有附件列表
|
|
|
+ getAllList();
|
|
|
+
|
|
|
// 初始化 部位明细 Spread
|
|
|
const spSpread = SpreadJsObj.createNewSpread($('#stage-pos')[0]);
|
|
|
const spCol = _.find(posSpreadSetting.cols, {field: 'qc_qty'});
|
|
@@ -599,6 +632,7 @@ $(document).ready(() => {
|
|
|
} else {
|
|
|
SpreadJsObj.loadSheetData(spSpread.getActiveSheet(), 'data', []);
|
|
|
}
|
|
|
+ getNodeList(node.id);
|
|
|
},
|
|
|
editEnded: function (e, info) {
|
|
|
if (info.sheet.zh_setting) {
|
|
@@ -972,7 +1006,7 @@ $(document).ready(() => {
|
|
|
}
|
|
|
});
|
|
|
// 展开收起附件
|
|
|
- $('a', '.side-menu').bind('click', function () {
|
|
|
+ $('a', '.right-nav').bind('click', function () {
|
|
|
//const main = $('#main-view'), tool = $('#tools-view');
|
|
|
const tab = $(this), tabPanel = $(tab.attr('content'));
|
|
|
const showTools = function (show) {
|
|
@@ -1000,7 +1034,7 @@ $(document).ready(() => {
|
|
|
};
|
|
|
if (!tab.hasClass('active')) {
|
|
|
$('a', '.side-menu').removeClass('active');
|
|
|
- $('.tab-content .tab-pane').removeClass('active');
|
|
|
+ $('.tab-content .tab-select-show').removeClass('active');
|
|
|
tab.addClass('active');
|
|
|
tabPanel.addClass('active');
|
|
|
showTools(tab.hasClass('active'));
|
|
@@ -1008,6 +1042,10 @@ $(document).ready(() => {
|
|
|
searchLedger = new SearchLedger($('#search'), slSpread);
|
|
|
searchLedger.spread.refresh();
|
|
|
}
|
|
|
+ if (tab.attr('content') === '#fujian') {
|
|
|
+ const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
|
|
|
+ getNodeList(node.id);
|
|
|
+ }
|
|
|
} else {
|
|
|
tab.removeClass('active');
|
|
|
tabPanel.removeClass('active');
|
|
@@ -1016,4 +1054,210 @@ $(document).ready(() => {
|
|
|
slSpread.refresh();
|
|
|
spSpread.refresh();
|
|
|
});
|
|
|
-});
|
|
|
+
|
|
|
+ // 切换附件里节点和所有附件
|
|
|
+ $('#fujian .nav-link').on('click', function () {
|
|
|
+ const tabPanel = $(this).attr('fujian-content');
|
|
|
+ if (tabPanel !== 'syfujian') {
|
|
|
+ $('#showPage').hide();
|
|
|
+ } else {
|
|
|
+ $('#showPage').show();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 上传附件
|
|
|
+ $('#upload-file-btn').click(function () {
|
|
|
+ const file = $('#upload-file')[0];
|
|
|
+ if (file.files[0] === undefined) {
|
|
|
+ toast('未选择上传文件!', 'error');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const filesize = file.files[0].size;
|
|
|
+ if (filesize > 10 * 1024 * 1024) {
|
|
|
+ toast('文件大小过大!', 'error');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const fileext = '.' + file.files[0].name.toLowerCase().split('.').splice(-1)[0];
|
|
|
+ if (whiteList.indexOf(fileext) === -1) {
|
|
|
+ toast('只能上传指定格式的附件!', 'error');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append('lid', node.id);
|
|
|
+ formData.append('size', filesize);
|
|
|
+ formData.append('file', file.files[0]);
|
|
|
+ postDataWithFile('/tender/' + tender.id + '/measure/stage/' + tender.ledger_times + '/upload/file', formData, function (data) {
|
|
|
+ $('#upload').modal('hide');
|
|
|
+ // 插入到attData中
|
|
|
+ console.log(data);
|
|
|
+ attData.unshift(data);
|
|
|
+ // 重新生成LIst
|
|
|
+ getAllList();
|
|
|
+ getNodeList(node.id);
|
|
|
+ }, function () {
|
|
|
+ toast('附件上传失败', 'error');
|
|
|
+ });
|
|
|
+ $('#upload-file').val('');
|
|
|
+ });
|
|
|
+
|
|
|
+ // 获取附件信息
|
|
|
+ $('body').on('click', '.list-table a', 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);
|
|
|
+ });
|
|
|
+ console.log(att);
|
|
|
+ $('#edit-att').hide();
|
|
|
+ $('#show-att').show();
|
|
|
+ if (att !== undefined) {
|
|
|
+ $('#show-att tr').eq(0).children('td').text(att.filename + att.fileext);
|
|
|
+ const name = att.code !== null && att.code !== '' ? att.code : att.b_code;
|
|
|
+ $('#show-att tr').eq(1).children('td').text(name + ' ' + att.lname);
|
|
|
+ $('#show-att tr').eq(2).find('a').attr('href', '/tender/' + tender.id + '/measure/stage/' + tender.ledger_times + '/download/file/' + att.id);
|
|
|
+ $('#show-att tr').eq(3).children('td').eq(0).text(att.username);
|
|
|
+ $('#show-att tr').eq(3).children('td').eq(1).text(att.in_time);
|
|
|
+ $('#show-att tr').eq(4).children('td').text(att.remark);
|
|
|
+ console.log(userID);
|
|
|
+ console.log(att.uid);
|
|
|
+ if (parseInt(userID) === att.uid) {
|
|
|
+ $('#btn-att').show();
|
|
|
+ $('#btn-att a').eq(1).show();
|
|
|
+ $('#btn-att a').eq(0).hide();
|
|
|
+ $('#btn-att a').eq(2).hide();
|
|
|
+ $('#btn-att a').eq(3).hide();
|
|
|
+ } else {
|
|
|
+ $('#btn-att').hide();
|
|
|
+ $('#btn-att a').eq(1).hide();
|
|
|
+ $('#btn-att a').eq(0).hide();
|
|
|
+ $('#btn-att a').eq(2).hide();
|
|
|
+ $('#btn-att a').eq(3).hide();
|
|
|
+ }
|
|
|
+ $('#showAttachment').attr('file-id', fid);
|
|
|
+ $('#showAttachment').show();
|
|
|
+ } else {
|
|
|
+ $('#showAttachment').hide();
|
|
|
+ $('#showAttachment').attr('file-id', '');
|
|
|
+ toast('附件信息获取失败', 'error');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $('body').on('click', '#btn-att a', function () {
|
|
|
+ const content = $(this).attr('content');
|
|
|
+ const fid = $('#showAttachment').attr('file-id');
|
|
|
+ const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
|
|
|
+ if (content === 'edit') {
|
|
|
+ $('#btn-att a').eq(1).hide();
|
|
|
+ $('#btn-att a').eq(0).show();
|
|
|
+ $('#btn-att a').eq(2).show();
|
|
|
+ $('#btn-att a').eq(3).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;
|
|
|
+ $('#edit-att .form-group').eq(1).find('input').val(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(1).show();
|
|
|
+ $('#btn-att a').eq(0).hide();
|
|
|
+ $('#btn-att a').eq(2).hide();
|
|
|
+ $('#btn-att a').eq(3).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 + '/measure/stage/' + tender.ledger_times + '/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;
|
|
|
+ $('#show-att tr').eq(1).children('td').text(name + ' ' + data.lname);
|
|
|
+ $('#show-att tr').eq(2).find('a').attr('href', '/tender/' + tender.id + '/measure/stage/' + tender.ledger_times + '/download/file/' + data.id);
|
|
|
+ $('#show-att tr').eq(3).children('td').eq(0).text(data.username);
|
|
|
+ $('#show-att tr').eq(3).children('td').eq(1).text(data.in_time);
|
|
|
+ $('#show-att tr').eq(4).children('td').text(data.remark);
|
|
|
+ $('#btn-att a').eq(1).show();
|
|
|
+ $('#btn-att a').eq(0).hide();
|
|
|
+ $('#btn-att a').eq(2).hide();
|
|
|
+ $('#btn-att a').eq(3).hide();
|
|
|
+ }, function () {
|
|
|
+ toast('附件上传失败', 'error');
|
|
|
+ });
|
|
|
+ $('#change-att-btn').val('');
|
|
|
+ } else if (content === 'del') {
|
|
|
+ const data = {id: fid};
|
|
|
+ postData('/tender/' + tender.id + '/measure/stage/' + tender.ledger_times + '/delete/file', data, function (result) {
|
|
|
+ // 删除到attData中
|
|
|
+ const att_index = attData.findIndex(function (item) {
|
|
|
+ return item.id === parseInt(fid);
|
|
|
+ });
|
|
|
+ attData.splice(att_index, 1);
|
|
|
+ // 重新生成List
|
|
|
+ getAllList();
|
|
|
+ getNodeList(node.id);
|
|
|
+ $('#showAttachment').hide();
|
|
|
+ $('#showAttachment').attr('file-id', '');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 替换附件
|
|
|
+ $('#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) {
|
|
|
+ toast('文件大小过大!', 'error');
|
|
|
+ $('#change-att-btn').val('');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (whiteList.indexOf(fileext) === -1) {
|
|
|
+ toast('只能上传指定格式的附件!', '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 = $('#totalPage').text();
|
|
|
+ const lastPageNum = $('#currentPage').text();
|
|
|
+ const status = $(this).attr('content');
|
|
|
+ console.log(totalPageNum,lastPageNum,status);
|
|
|
+ if (status === 'pre' && lastPageNum > 1) {
|
|
|
+ getAllList(parseInt(lastPageNum)-1);
|
|
|
+ } else if (status === 'next' && lastPageNum < totalPageNum) {
|
|
|
+ getAllList(parseInt(lastPageNum)+1);
|
|
|
+ }
|
|
|
+ })
|
|
|
+});
|