浏览代码

Merge branch 'master' of http://192.168.1.41:3000/maixinrong/Calculation

TonyKang 4 年之前
父节点
当前提交
03add0d8a6

+ 6 - 6
app/base/base_bills_service.js

@@ -595,9 +595,9 @@ class BaseBillsSerivce extends TreeService {
                             in_time: new Date(),
                             porder: pos.porder,
                             position: pos.position,
-                            sgfh_expr: pos.sgfh_expr,
-                            sjcl_expr: pos.sjcl_expr,
-                            qtcl_expr: pos.qtcl_expr,
+                            sgfh_expr: pos.sgfh_expr ? pos.sgfh_expr : '',
+                            sjcl_expr: pos.sjcl_expr ? pos.sjcl_expr : '',
+                            qtcl_expr: pos.qtcl_expr ? pos.qtcl_expr : '',
                             add_stage: 0,
                             add_times: 0,
                         };
@@ -606,9 +606,9 @@ class BaseBillsSerivce extends TreeService {
                         this._calcExpr(newPos, 'qtcl_qty', pos.qtcl_expr, pos.qtcl_qty, precision);
                         newPos.quantity = this.ctx.helper.add(newPos.sgfh_qty,
                             this.ctx.helper.add(newPos.sjcl_qty, newPos.qtcl_qty));
-                        newBills.sgfh_qty = this.ctx.helper.add(newBills.sgfh_qty, pos.sgfh_qty);
-                        newBills.sjcl_qty = this.ctx.helper.add(newBills.sjcl_qty, pos.sjcl_qty);
-                        newBills.qtcl_qty = this.ctx.helper.add(newBills.qtcl_qty, pos.qtcl_qty);
+                        newBills.sgfh_qty = this.ctx.helper.add(newBills.sgfh_qty, newPos.sgfh_qty);
+                        newBills.sjcl_qty = this.ctx.helper.add(newBills.sjcl_qty, newPos.sjcl_qty);
+                        newBills.qtcl_qty = this.ctx.helper.add(newBills.qtcl_qty, newPos.qtcl_qty);
                         if (defaultData) this.ctx.helper._.assignIn(newPos, defaultData);
                         pastePosData.push(newPos);
                     }

+ 2 - 2
app/controller/change_controller.js

@@ -37,7 +37,7 @@ module.exports = app => {
             const tenderId = ctx.params.id;
             ctx.session.sessionUser.tenderId = tenderId;
             const tender = await this.service.tender.getDataById(tenderId);
-            const tenderList = await this.service.tender.getList();
+            // const tenderList = await this.service.tender.getList();
 
             const page = ctx.page;
             const changes = await ctx.service.change.getListByStatus(tender.id, status);
@@ -122,7 +122,7 @@ module.exports = app => {
                 uid: ctx.session.sessionUser.accountId,
                 moment,
                 tender,
-                tenderList,
+                // tenderList,
                 pageInfo,
                 changes,
                 filter,

+ 8 - 4
app/controller/material_controller.js

@@ -624,19 +624,23 @@ module.exports = app => {
                     autoFields: true,
                 });
                 const files = [];
+                const create_time = Date.parse(new Date()) / 1000;
                 let idx = 0;
-                while ((stream = await parts()) != null) {
+                while ((stream = await parts()) !== undefined) {
                     if (!stream.filename) {
                         // 如果没有传入直接返回
                         return;
                     }
-                    const create_time = Date.parse(new Date()) / 1000;
                     const fileInfo = path.parse(stream.filename);
                     // const filepath = path.join('public/upload', this.ctx.tender.id.toString(), 'tc', 'fujian_' + create_time + fileInfo.ext);
-                    const filepath = `public/upload/${this.ctx.tender.id.toString()}/tc/fujian_${create_time + idx + fileInfo.ext}`;
+                    const filepath = `public/upload/${this.ctx.tender.id.toString()}/tc/fujian_${create_time + idx.toString() + fileInfo.ext}`;
                     await ctx.helper.saveStreamFile(stream, path.join(this.app.baseDir, 'app', filepath));
+
+                    if (stream) {
+                        await sendToWormhole(stream);
+                    }
                     files.push({ filepath, name: stream.filename });
-                    idx++;
+                    ++idx;
                 }
                 const upload_time = this.ctx.helper.dateTran(new Date());
                 const payload = files.map(file => {

+ 2 - 2
app/controller/setting_controller.js

@@ -393,7 +393,7 @@ module.exports = app => {
                 }
 
                 const categoryData = await ctx.service.category.getAllCategory(projectId);
-                const tenderData = await ctx.service.tender.getList();
+                const tenderData = await ctx.service.tender.getList('', null, 1);
                 const renderData = {
                     projectData,
                     categoryType: settingConst.cType,
@@ -480,7 +480,7 @@ module.exports = app => {
                 await ctx.service.categoryValue.setCategoryValue(data.id, data.updateValue);
 
                 responseData.data.category = await ctx.service.category.getCategory(data.id);
-                responseData.data.tenders = await ctx.service.tender.getList();
+                responseData.data.tenders = await ctx.service.tender.getList('', null, 1);
 
                 ctx.body = responseData;
             } catch (err) {

+ 0 - 6
app/public/css/main.css

@@ -945,12 +945,6 @@ legend {
 .custom-control-label::after{
   top:.1rem;
 }
-.dropdown-menu .custom-control-label::before{
-  top:.5rem;
-}
-.dropdown-menu .custom-control-label::after{
-  top:.5rem;
-}
 .form-control-sm{
   height:calc(1.4125rem + 2px);
 }

+ 13 - 13
app/public/js/change_set.js

@@ -75,12 +75,12 @@ $(document).ready(() => {
             gcl_index = gclhtml !== '' ? ++gcl_index : gcl_index;
             const lid = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? gcl.leafXmjs[0].gcl_id : gcl.id;
             listHtml += '<tr data-lid="' + lid + '"'+ gclhtml +' data-index="' + list_index + '" data-bwmx="">' +
-                '<td>' + list_index + '</td>' +
+                '<td class="text-center">' + list_index + '</td>' +
                 '<td>' + gcl.code + '</td>' +
-                '<td>' + gcl.name + '</td>' +
-                '<td>' + unit + '</td>' +
-                '<td>' + roundnum(unit_price, unitPriceUnit) + '</td>' +
-                '<td>' + quantity + '</td>' +
+                '<td class="text-left">' + gcl.name + '</td>' +
+                '<td class="text-center">' + unit + '</td>' +
+                '<td class="text-right">' + roundnum(unit_price, unitPriceUnit) + '</td>' +
+                '<td class="text-right">' + quantity + '</td>' +
                 '</tr>';
             list_index++;
         }
@@ -357,13 +357,13 @@ $(document).ready(() => {
                 const bwmx = leaf.bwmx !== undefined ? leaf.bwmx : '';
                 const isChecked = data_bwmx.indexOf(leaf.code + '_' + (bwmx !== '' ? bwmx : leaf.jldy ? leaf.jldy : '') + ';' + quantity) !== -1 && isCheck ? 'checked' : '';
                 codeHtml += '<tr quantity="' + quantity + '"><td>' + leaf.code + '</td>' +
-                    '<td>' + (leaf.jldy ? leaf.jldy: '') + '</td>' +
-                    '<td>' + bwmx + '</td>' +
-                    '<td>' + (leaf.dwgc ? leaf.dwgc : '') + '</td>' +
-                    '<td>' + (leaf.fbgc ? leaf.fbgc : '') + '</td>' +
-                    '<td>' + (leaf.fxgc ? leaf.fxgc : '') + '</td>' +
-                    '<td>' + roundnum(quantity, findDecimal(gcl.unit)) + '</td>' +
-                    '<td><input type="checkbox"' + isChecked +
+                '<td>' + bwmx + '</td>' +
+                '<td>' + (leaf.dwgc ? leaf.dwgc : '') + '</td>' +
+                '<td>' + (leaf.fbgc ? leaf.fbgc : '') + '</td>' +
+                '<td>' + (leaf.fxgc ? leaf.fxgc : '') + '</td>' +
+                '<td>' + (leaf.jldy ? leaf.jldy: '') + '</td>' +
+                    '<td class="text-right">' + roundnum(quantity, findDecimal(gcl.unit)) + '</td>' +
+                    '<td class="text-center"><input type="checkbox"' + isChecked +
                     '></td></tr>';
             }
         } else if (!isDeal && isCheck) {
@@ -770,7 +770,7 @@ function makeCodeTable(search = '') {
         if (length === 8) {
             const code = $('#code-list tr').eq(i).children('td').eq(0).text();
             const name = $('#code-list tr').eq(i).children('td').eq(1).text();
-            const jldy = $('#code-list tr').eq(i).children('td').eq(2).text();
+            const jldy = $('#code-list tr').eq(i).children('td').eq(5).text();
             console.log(code, name, jldy, search, code.indexOf(search) !== -1 || name.indexOf(search) !== -1 || jldy.indexOf(search) !== -1);
             const isShow = code.indexOf(search) !== -1 || name.indexOf(search) !== -1 || jldy.indexOf(search) !== -1;
             $('#code-list tr').eq(i).css('display', (isShow ? 'table-row' : 'none'));

+ 8 - 4
app/public/js/gcl_gather.js

@@ -162,9 +162,13 @@ const gclGatherModel = (function () {
      * @param xmj - 计量单元(最底层项目节)
      * @returns {string}
      */
-    function getDwgc(xmj) {
-        const node = getNodeByLevel(xmj, 2);
-        return node ? node.name : '';
+    function getDwgc(peg, xmj) {
+        if (peg) {
+            return peg.name;
+        } else {
+            const node = getNodeByLevel(xmj, 2);
+            return node ? node.name : '';
+        }
     }
 
     /**
@@ -233,7 +237,7 @@ const gclGatherModel = (function () {
             jldy: leafXmj.name,
             fbgc: getFbgc(peg, leafXmj),
             fxgc: getFxgc(peg, leafXmj),
-            dwgc: getDwgc(leafXmj),
+            dwgc: getDwgc(peg, leafXmj),
             drawing_code: leafXmj.drawing_code,
         };
         leafXmjs.push(cacheLX);

+ 3 - 5
app/public/js/ledger.js

@@ -1193,15 +1193,13 @@ $(document).ready(function() {
                 posterity.unshift(node);
                 copyBlockList.push(sheet.zh_tree.getDefaultData(posterity));
             }
-            const tenderId = _.toInteger(getTenderId());
             for (const cbl of copyBlockList) {
-                for (b of cbl) {
+                for (const b of cbl) {
                     const posRange = pos.getLedgerPos(b.id);
                     if (posRange && posRange.length > 0) b.pos = posRange;
                 }
             }
-            setLocalCache(copyBlockTag, JSON.stringify({tid: tenderId, block: copyBlockList}));
-            //treeOperationObj.block = copyBlockList;
+            setLocalCache(copyBlockTag, JSON.stringify({block: copyBlockList}));
         },
         visible: function (key, opt) {
             const sheet = ledgerSpread.getActiveSheet();
@@ -1225,7 +1223,7 @@ $(document).ready(function() {
             disabled: function (key, opt) {
                 //const block = treeOperationObj.block || [];
                 const copyInfo = JSON.parse(getLocalCache(copyBlockTag));
-                return !(copyInfo && copyInfo.tid && copyInfo.tid > 0 && copyInfo.block && copyInfo.block.length > 0);
+                return !(copyInfo && copyInfo.block && copyInfo.block.length > 0);
             },
             callback: function (key, opt) {
                 //const block = treeOperationObj.block || [];

+ 1 - 0
app/public/js/ledger_bwtz.js

@@ -31,6 +31,7 @@ $(document).ready(() => {
             } else {
                 SpreadJsObj.initSheet(unitSheet, unitSpreadSetting);
             }
+            SpreadJsObj.resetTopAndSelect(unitSheet);
         }
     };
     xmjSpread.bind(spreadNS.Events.SelectionChanged, function (e, info) {

+ 7 - 3
app/public/js/ledger_gather.js

@@ -66,9 +66,8 @@ $(document).ready(() => {
             return data
                 ? $('#compare-tag')[0].checked && data.compare_differ
                     ? '#f8d7da'
-                    : (data.differ ? '#FFE699' : defaultColor)
-                : defaultColor;
-            //return data && data.differ ? '#FFE699' : defaultColor;
+                    : (data.differ ? '#FFE699' : '#ffffff')
+                : '#ffffff';
         }
     };
     if (thousandth) sjsSettingObj.setTpThousandthFormat(gclSpreadSetting);
@@ -185,6 +184,11 @@ $(document).ready(() => {
     }, null, true);
 
     $('#compare-tag').click(() => {
+        // const rows = [];
+        // for (let i = 0; i< gclSheet.getRowCount(); ++i) {
+        //     rows.push(i);
+        // }
+        // SpreadJsObj.reloadRowsBackColor(gclSheet, rows);
         SpreadJsObj.reLoadSheetData(gclSheet);
     });
     // 展开收起附件

+ 124 - 28
app/public/js/material_file.js

@@ -6,7 +6,10 @@
  * @date 2020/06/30
  * @version
  */
+
 $(document).ready(function () {
+    // 每页最多几个附件
+    const pageCount = 15;
     // 全局fileData初始化
     let fileData = fileList || []
     handleFileList(fileData)
@@ -34,7 +37,8 @@ $(document).ready(function () {
                     if (!$('#file-list tr').length) {
                         getAllList();
                     } else {
-                        getAllList(parseInt($('#currentPage').text()));
+                        const curPageNo = $('#file-pagination > li[class="page-item active"] > a').text() || 1
+                        getAllList(parseInt(curPageNo));
                     }
                 });
             }
@@ -52,10 +56,12 @@ $(document).ready(function () {
         postData('/tender/measure/material/file/delete', data, function () {
             const idx = fileData.findIndex(file => file.id === parseInt(attid))
             idx !== -1 && fileData.splice(idx, 1)
+            const curPageNo = parseInt($('#file-pagination > li[class="page-item active"] > a').text()) || 1
             if ($('#file-list tr').length === 1) {
-                getAllList(parseInt($('#currentPage').text()) - 1);
+                getAllList(curPageNo - 1);
             } else {
-                getAllList(parseInt($('#currentPage').text()));
+
+                getAllList(curPageNo);
             }
             // self.parents('tr').remove();
             // // 重新排序
@@ -67,43 +73,124 @@ $(document).ready(function () {
         });
     });
     // 切换页数
-    $('.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);
-        } else if (status === 'next' && lastPageNum < totalPageNum) {
-            getAllList(lastPageNum+1);
+    $('#file-pagination').on('click', '.page-item a', function () {
+        // 找到当前的pageNo
+        const curPageNo = $('#file-pagination > li[class="page-item active"] > a').text() || 1
+        const btnType = $(this).attr('aria-label')
+        const total = calcCount();
+        // btnType存在,说明点击的是前一个/后一个
+        // btnType不存在,点击的是页数
+        if (btnType) {
+            if (btnType === 'Previous') {
+                // 只有大于1时才处理
+                if (parseInt(curPageNo) !== 1) {
+                    getAllList(curPageNo - 1)
+                }
+            } else if(btnType === 'Next') {
+                if (parseInt(curPageNo) !== Math.ceil(total/pageCount)) {
+                    getAllList(parseInt(curPageNo) + 1)
+                }
+            } else if(btnType === 'Start') {
+                getAllList(1)
+            } else {
+                getAllList(Math.ceil(total/pageCount))
+            }
+        } else {
+
+            curPageNo !== $(this).text() && getAllList(parseInt($(this).text()))
         }
-    });
+    })
     // 生成所有附件列表
     function getAllList(currPageNum = 1) {
-        // 每页最多几个附件
-        const pageCount = 15;
-        // 附件总数
-        let total = fileData && fileData.length;
-        // 未选中checkbox,需要过滤出来当前期的数据
+         // 未选中checkbox,需要过滤出来当前期的数据
         const filterFileData = fileData && fileData.filter(file => file.mid === parseInt(mid) && file.tid === parseInt(tid))
-        if(!$('#file-checkbox').is(':checked')) {
-            total = filterFileData.length
-        }
+        const total = calcCount(filterFileData);
         // 总页数
         const pageNum = Math.ceil(total/pageCount);
-        $('#totalPage').text(pageNum);
-        // total为0,当前还没上传过附件
-        $('#currentPage').text(total ? currPageNum : 0);
         // 当前页附件内容
-        const currPageAttData = fileData && $('#file-checkbox').is(':checked') ? fileData.slice((currPageNum-1)*pageCount, currPageNum*pageCount) : filterFileData.slice((currPageNum-1)*pageCount, currPageNum*pageCount);
+        const currPageAttData = fileData && $('#file-checkbox').is(':checked') ? 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) {
+        $('#file-pagination').empty()
+        if (pageSize < 2) return
+        const btnHtml = `
+        <li class="page-item page-begin">
+            <a class="page-link" href="#" aria-label="Start">
+                <span aria-hidden="true">&laquo;</span>
+            </a>
+        </li>
+        <li class="page-item page-back">
+            <a class="page-link" href="#" aria-label="Previous">
+                <span aria-hidden="true">&lsaquo;</span>
+            </a>
+        </li>
+        <li class="page-item page-next">
+            <a class="page-link" href="#" aria-label="Next">
+                <span aria-hidden="true">&rsaquo;</span>
+            </a>
+        </li>
+        <li class="page-item page-end">
+            <a class="page-link" href="#" aria-label="End">
+                <span aria-hidden="true">&raquo;</span>
+            </a>
+        </li>`
+        $('#file-pagination').append(btnHtml)
+        let html = ''
+        // 考虑极端情况
+        if (pageNo - 2 <= 0 || pageNo + 2 >= pageSize)  {
+            if (pageNo < 3) {
+                const max = pageSize > 5 ? 5 : pageSize
+                for (let i = 0; i < max; i++) {
+                    html += pageNo === i + 1 ?
+                        `<li class="page-item active"><a class="page-link" href="#">${i+1}</a></li>` :
+                        `<li class="page-item"><a class="page-link" href="#">${i+1}</a></li>`
+                }
+            } else {
+                for (let i = (pageSize-4 > 0 ? pageSize-4 : 1 ); i <= pageSize; i++) {
+                    html += pageNo === i ?
+                        `<li class="page-item active"><a class="page-link" href="#">${i}</a></li>` :
+                        `<li class="page-item"><a class="page-link" href="#">${i}</a></li>`
+                }
+            }
+
+        } else {
+            for (let i = 0; i < pageSize; i++) {
+                if (i + 1 === pageNo) {
+                    // 当前
+                    html+=`<li class="page-item active"><a class="page-link" href="#">${i + 1}</a></li>`
+                } else if(i + 2 === pageNo && i + 2 <= pageSize) {
+                    // 后一页
+                    html+=`<li class="page-item"><a class="page-link" href="#">${i + 1}</a></li>`
+                } else if (i + 3 === pageNo && i + 3 <= pageSize) {
+                    // 后两页
+                    html+=`<li class="page-item"><a class="page-link" href="#">${i + 1}</a></li>`
+                } else if(i === pageNo) {
+                    // 前一页
+                    html+=`<li class="page-item"><a class="page-link" href="#">${i + 1}</a></li>`
+                } else if (i -1  === pageNo && i -1 >= 0) {
+                    // 前两页
+                    html+=`<li class="page-item"><a class="page-link" href="#">${i + 1}</a></li>`
+                }
+            }
+
+        }
+
+        $('.page-next').before(html)
+    }
+
     function renderHtml(list) {
         let html = '';
-        list.forEach((fileInfo, idx) => {
+        list.forEach(fileInfo => {
             html += `<tr style="height: 31px;">
-            <td>${idx + 1}</td>
+            <td>${fileInfo.index + 1}</td>
             <td><a href="/${fileInfo.filepath}" target="_blank">${fileInfo.file_name}</a></td>
             <td>${fileInfo.file_size}</td>
             <td>第${fileInfo.s_order}期</td>
@@ -123,7 +210,7 @@ $(document).ready(function () {
     }
 
     function handleFileList(fileList) {
-        fileData = fileList.map(file => {
+        fileData = fileList.map((file, index) => {
             let showDel = false
             // 只判断当前期,因为以往期都是只读的
             if (file.mid === parseInt(mid) && file.tid === parseInt(tid) && file.user_id === parseInt(cur_uid)) {
@@ -134,9 +221,18 @@ $(document).ready(function () {
                     curAuditor.aid === parseInt(cur_uid) && (showDel = true)
                 }
             }
-            return showDel ? {...file, canDel: true} : file
+            return showDel ? {...file, canDel: true, index} : {...file, index}
         })
     }
+
+    function calcCount() {
+        // 附件总数
+        let total = fileData && fileData.length;
+        if(!$('#file-checkbox').is(':checked')) {
+            total = fileData && fileData.filter(file => file.mid === parseInt(mid) && file.tid === parseInt(tid)).length
+        }
+        return total
+    }
 });
 
 /**

+ 6 - 5
app/public/js/revise.js

@@ -1031,12 +1031,13 @@ $(document).ready(() => {
                 posterity.unshift(node);
                 copyBlockList.push(sheet.zh_tree.getDefaultData(posterity));
             }
-            const tenderId = _.toInteger(getTenderId());
             for (const cbl of copyBlockList) {
-                const posRange = pos.getLedgerPos(cbl.id);
-                if (posRange && posRange.length > 0) cbl.pos = posRange;
+                for (const b of cbl) {
+                    const posRange = pos.getLedgerPos(b.id);
+                    if (posRange && posRange.length > 0) b.pos = posRange;
+                }
             }
-            setLocalCache(copyBlockTag, JSON.stringify({tid: tenderId, block: copyBlockList}));
+            setLocalCache(copyBlockTag, JSON.stringify({ block: copyBlockList }));
         },
         visible: function (key, opt) {
             const sheet = billsSheet;
@@ -1060,7 +1061,7 @@ $(document).ready(() => {
             disabled: function (key, opt) {
                 //const block = treeOperationObj.block || [];
                 const copyInfo = JSON.parse(getLocalCache(copyBlockTag));
-                return !(copyInfo && copyInfo.tid && copyInfo.tid > 0 && copyInfo.block && copyInfo.block.length > 0);
+                return !(copyInfo && copyInfo.block && copyInfo.block.length > 0);
             },
             callback: function (key, opt) {
                 //const block = treeOperationObj.block || [];

+ 1 - 1
app/public/js/se_other.js

@@ -96,7 +96,7 @@ $(document).ready(() => {
 
     const otherSpread = SpreadJsObj.createNewSpread($('#other-spread')[0]);
     const otherSheet = otherSpread.getActiveSheet();
-    if (thousandth) sjsSettingObj.setTpThousandthFormat(spreadSetting);
+    if (thousandth) sjsSettingObj.setTpThousandthFormat(otherSpreadSetting);
     SpreadJsObj.initSheet(otherSheet, otherSpreadSetting);
 
     $.subMenu({

+ 4 - 4
app/public/js/stage.js

@@ -109,7 +109,7 @@ function getAllList(currPageNum = 1) {
     // 总页数
     const pageNum = Math.ceil(total/pageCount);
     $('#totalPage').text(pageNum);
-    $('#currentPage').text(currPageNum);
+    $('#currentPage').text(total === 0 ? 0 : currPageNum);
     // 当前页附件内容
     const currPageAttData = attData.slice((currPageNum-1)*pageCount, currPageNum*pageCount);
     let html = '';
@@ -1129,9 +1129,9 @@ $(document).ready(() => {
                 SpreadJsObj.loadSheetData(spSpread.getActiveSheet(), 'data', posData);
                 getNodeList(node.id);
                 // 如果是附件是当前节点,隐藏
-                if ($('#dqjiedian').hasClass('active')) {
-                    $('#showAttachment').hide();
-                }
+                // if ($('#dqjiedian').hasClass('active')) {
+                //     $('#showAttachment').hide();
+                // }
             } else {
                 SpreadJsObj.loadSheetData(spSpread.getActiveSheet(), 'data', []);
             }

+ 3 - 3
app/service/category.js

@@ -89,7 +89,7 @@ module.exports = app => {
         async deleteCategory(pid, cid) {
             const category = await this.getDataById(cid);
             if (category.pid !== pid) {
-                throw '提交数据错误'
+                throw '提交数据错误';
             }
             this.transaction = await this.db.beginTransaction();
             try {
@@ -98,7 +98,7 @@ module.exports = app => {
                     await this._upLevelCategory(pid, category.level);
                 }
                 // 删除标段分类数据
-                const tenders = await this.ctx.service.tender.getList();
+                const tenders = await this.ctx.service.tender.getList('', null, 1);
                 for (const t of tenders) {
                     if (t.category && t.category.length > 0) {
                         this._.remove(t.category, function (c) {
@@ -171,4 +171,4 @@ module.exports = app => {
     }
 
     return Category;
-};
+};

+ 2 - 2
app/service/category_value.js

@@ -65,7 +65,7 @@ module.exports = app => {
         }
 
         async setCategoryValue(cid, value) {
-            const tenders = await this.ctx.service.tender.getList();
+            const tenders = await this.ctx.service.tender.getList('', null, 1);
 
             this.transaction = await this.db.beginTransaction();
             try {
@@ -107,4 +107,4 @@ module.exports = app => {
     }
 
     return CategoryValue;
-};
+};

+ 3 - 4
app/service/material.js

@@ -9,7 +9,6 @@
  */
 
 const auditConst = require('../const/audit').material;
-
 module.exports = app => {
     class Material extends app.BaseService {
         /**
@@ -174,6 +173,9 @@ module.exports = app => {
         async deleteMaterial(id) {
             const transaction = await this.db.beginTransaction();
             try {
+                // 删除文件
+                const attList = await this.ctx.service.materialFile.getAllMaterialFiles(this.ctx.tender.id, id);
+                await this.ctx.helper.delFiles(attList);
                 await transaction.delete(this.ctx.service.materialAudit.tableName, { mid: id });
                 await transaction.delete(this.ctx.service.materialBills.tableName, { mid: id });
                 await transaction.delete(this.ctx.service.materialList.tableName, { mid: id });
@@ -192,9 +194,6 @@ module.exports = app => {
                 }
                 await transaction.delete(this.tableName, { id });
                 await transaction.commit();
-                // 删除期第一个参数不用传,第二个为期数
-                const attList = await this.ctx.service.materialFile.getAllMaterialFiles('', id);
-                await this.ctx.helper.delFiles(attList);
                 return true;
             } catch (err) {
                 await transaction.rollback();

+ 3 - 4
app/service/material_audit.js

@@ -195,7 +195,9 @@ module.exports = app => {
                 await transaction.update(this.ctx.service.material.tableName, {
                     id: materialId, status: auditConst.status.checking,
                 });
-
+                // 添加记录至推送表
+                await transaction.insert('zh_notice', { type: 'material', uid: audit.aid, status: auditConst.status.checking, is_read: 0, content: '待审核' });
+                console.log('1111');
                 // 本期一些必要数据(如应耗数量和上期调差金额)插入到material_bills_history表里
                 const materialBillsData = await this.ctx.service.materialBills.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
                 if (materialBillsData.length === 0) {
@@ -410,7 +412,6 @@ module.exports = app => {
             const time = new Date();
             // 整理当前流程审核人状态更新
             const audit = await this.getDataByCondition({ mid: materialId, times, status: auditConst.status.checking });
-            console.log('audit', audit);
             if (!audit || audit.order <= 1) {
                 throw '审核数据错误';
             }
@@ -459,8 +460,6 @@ module.exports = app => {
             if (checkData.checkType !== auditConst.status.checked && checkData.checkType !== auditConst.status.checkNo && checkData.checkType !== auditConst.status.checkNoPre) {
                 throw '提交数据错误';
             }
-            console.log('checkData:', checkData);
-            console.log('times', times);
             switch (checkData.checkType) {
                 case auditConst.status.checked:
                     await this._checked(materialId, checkData, times);

+ 6 - 4
app/service/tender.js

@@ -75,9 +75,12 @@ module.exports = app => {
         /**
          * 获取你所参与的标段的列表
          *
+         * @param {String} listStatus - 取列表状态,如果是管理页要传
+         * @param {String} permission - 根据权限取值
+         * @param {Number} getAll - 是否取所有标段
          * @return {Array} - 返回标段数据
          */
-        async getList(listStatus = '', permission = null) {
+        async getList(listStatus = '', permission = null, getAll = 0) {
             // 获取当前项目信息
             const session = this.ctx.session;
             let sql = '';
@@ -91,7 +94,7 @@ module.exports = app => {
                     '  ON t.`user_id` = pa.`id` ' +
                     '  WHERE t.`project_id` = ? AND t.`user_id` = ? ORDER BY CONVERT(t.`name` USING GBK) ASC';
                 sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, session.sessionProject.id, session.sessionUser.accountId];
-            } else if (permission !== null && permission.tender !== undefined && permission.tender.indexOf('2') !== -1) {
+            } else if (getAll === 1 || (permission !== null && permission.tender !== undefined && permission.tender.indexOf('2') !== -1)) {
                 // 具有查看所有标段权限的用户查阅标段
                 sql = 'SELECT t.`id`, t.`project_id`, t.`name`, t.`status`, t.`category`, t.`ledger_times`, t.`ledger_status`, t.`measure_type`, t.`user_id`, t.`create_time`, t.`total_price`, t.`deal_tp`,' +
                     '    pa.`name` As `user_name`, pa.`role` As `user_role`, pa.`company` As `user_company` ' +
@@ -293,8 +296,6 @@ module.exports = app => {
                 await transaction.delete(this.ctx.service.materialBillsHistory.tableName, { tid: id });
                 await transaction.delete(this.ctx.service.materialList.tableName, { tid: id });
                 await transaction.delete(this.ctx.service.materialListNotjoin.tableName, { tid: id });
-                await transaction.delete(this.ctx.service.materialFile.tableName, { tid: id });
-
                 await transaction.delete(this.ctx.service.signatureUsed.tableName, { tender_id: id });
                 await transaction.delete(this.ctx.service.signatureRole.tableName, { tender_id: id });
                 // 先删除附件文件
@@ -303,6 +304,7 @@ module.exports = app => {
                 attList.concat(newAttList);
                 await this.ctx.helper.delFiles(attList);
                 await transaction.delete(this.ctx.service.changeAtt.tableName, { tid: id });
+                await transaction.delete(this.ctx.service.materialFile.tableName, { tid: id });
                 await transaction.commit();
                 return true;
             } catch (err) {

+ 19 - 6
app/view/change/info_modal.ejs

@@ -115,7 +115,7 @@
                         </div>
                         <div style="overflow-y:auto" class="sjs-biangeng-height">
                             <table class="table table-striped table-bordered table-hover table-sm fixed_headers">
-                                <thead><tr><th width="40">序号</th><th>清单编号</th><th>名称</th><th width="50">单位</th><th width="100">单价</th><th width="100">数量</th></tr></thead>
+                                <thead><tr class="text-center"><th width="40">序号</th><th>清单编号</th><th>名称</th><th width="50">单位</th><th width="100">单价</th><th width="100">数量</th></tr></thead>
                                 <tbody id="table-list-select">
                                 </tbody>
                             </table>
@@ -129,7 +129,7 @@
                         <div style="overflow-y:auto" class="sjs-biangeng-height">
                             <table class="table table-striped table-bordered table-hover table-sm fixed_headers2">
                                 <thead>
-                                <tr><th width="100">项目节编号</th><th>名称</th><th>计量单元</th><th>单位工程</th><th>分部工程</th><th>分项工程</th><th width="70">数量</th><th width="40">选择</th></tr>
+                                <tr class="text-center"><th width="100">项目节编号</th><th>细目</th><th>单位工程</th><th>分部工程</th><th>分项工程</th><th>计量单元</th><th width="70">数量</th><th width="40">选择</th></tr>
                                 </thead>
                                 <tbody id="code-list" data-index="">
                                 </tbody>
@@ -731,13 +731,26 @@
 
 <script>
     $('.modal').on('shown.bs.modal', function () {
-        const height = $(this)[0].scrollHeight
-        const scrollBox = $(this).find('div[class="col-8 modal-height-500"]')
+        const height = $(this)[0].scrollHeight;
+        const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');
+        const bdiv = (scrollBox.offset() && scrollBox.offset().top) || 0;
         // 450是modal没有滚动条时的最大高度,超过则出现滚动条,需要自动下拉到底部
-        if (scrollBox.length && scrollBox[0].scrollHeight > 450) {
-            scrollBox.scrollTop(height);
+        // if (scrollBox.length && scrollBox[0].scrollHeight > 450) {
+        //     scrollBox.scrollTop(height);
+        // }
+        scrollBox.scrollTop(0);
+        const hdiv = divSearch($(this).find('textarea')) ? $(this).find('textarea') : null;
+        const hdheight = hdiv ? hdiv.parents('.list-group-item').offset().top : null;
+        if (hdiv && scrollBox.length &&  scrollBox[0].scrollHeight > 450 && hdheight - bdiv > 450) {
+            scrollBox.scrollTop(hdheight - bdiv);
         }
     });
+    function divSearch(div) {
+        if (div.length > 0) {
+            return true;
+        }
+        return false;
+    }
     $('#led-warning').click(function () {
         $('#warning-ledger').modal('hide');
     });

+ 18 - 4
app/view/material/audit_modal.ejs

@@ -868,11 +868,25 @@
 
 <script>
     $('.modal').on('shown.bs.modal', function () {
-        const height = $(this)[0].scrollHeight
-        const scrollBox = $(this).find('div[class="col-8 modal-height-500"]')
+        const height = $(this)[0].scrollHeight;
+        const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');
+        const bdiv = (scrollBox.offset() && scrollBox.offset().top) || 0;
+
         // 450是modal没有滚动条时的最大高度,超过则出现滚动条,需要自动下拉到底部
-        if (scrollBox.length && scrollBox[0].scrollHeight > 450) {
-            scrollBox.scrollTop(height);
+        // if (scrollBox.length && scrollBox[0].scrollHeight > 450) {
+        //     scrollBox.scrollTop(height);
+        // }
+        scrollBox.scrollTop(0);
+        const hdiv = divSearch($(this).find('textarea')) ? $(this).find('textarea') : null;
+        const hdheight = hdiv ? hdiv.parents('.list-group-item').offset().top : null;
+        if (hdiv && scrollBox.length &&  scrollBox[0].scrollHeight > 450 && hdheight - bdiv > 450) {
+            scrollBox.scrollTop(hdheight - bdiv);
         }
     });
+    function divSearch(div) {
+        if (div.length > 0) {
+            return true;
+        }
+        return false;
+    }
 </script>

+ 24 - 4
app/view/material/file.ejs

@@ -7,10 +7,7 @@
           <span class="d-flex align-items-center" style="margin-left: 5px;">
             <input type="checkbox" id="file-checkbox">
             <span class="text-primary" style="margin-left: 5px;">所有期</span>
-            <div style="margin-left: 20px;">
-              <!--所有附件 翻页-->
-              <span id="showPage"><a href="javascript:void(0);" class="page-select" content="pre"><i class="fa fa-chevron-left"></i></a> <span id="currentPage">1</span>/<span id="totalPage">10</span> <a href="javascript:void(0);" class="page-select" content="next"><i class="fa fa-chevron-right"></i></a></span>
-            </div>
+
           </span>
         </div>
     </div>
@@ -63,6 +60,29 @@
             <% }) %> -->
           </tbody>
         </table>
+        <div class="d-flex justify-content-center">
+          <!--所有附件 翻页-->
+<!--
+          <span id="showPage"><a href="javascript:void(0);" class="page-select" content="pre"><i class="fa fa-chevron-left"></i></a> <span id="currentPage">1</span>/<span id="totalPage">10</span> <a href="javascript:void(0);" class="page-select" content="next"><i class="fa fa-chevron-right"></i></a></span> -->
+          <nav aria-label="Page navigation example">
+            <ul id="file-pagination" class="pagination">
+              <li class="page-item page-back">
+                <a class="page-link" href="#" aria-label="Previous">
+                  <span aria-hidden="true">&laquo;</span>
+                </a>
+              </li>
+              <!-- <li class="page-item active"><a class="page-link" href="#">1</a></li>
+              <li class="page-item"><a class="page-link" href="#">2</a></li>
+              <li class="page-item"><a class="page-link" href="#">3</a></li> -->
+              <li class="page-item page-next">
+                <a class="page-link" href="#" aria-label="Next">
+                  <span aria-hidden="true">&raquo;</span>
+                </a>
+              </li>
+            </ul>
+          </nav>
+        </div>
+
       </div>
     </div>
   </div>

+ 21 - 4
app/view/stage/audit_modal.ejs

@@ -1593,12 +1593,29 @@
         // $('#hide-all').hide();
         // return false;
     });
+
+    // 定位到审批框高度
     $('.modal').on('shown.bs.modal', function () {
-        const height = $(this)[0].scrollHeight
-        const scrollBox = $(this).find('div[class="col-8 modal-height-500"]')
+        const height = $(this)[0].scrollHeight;
+        const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');
+        const bdiv = (scrollBox.offset() && scrollBox.offset().top) || 0;
+
         // 450是modal没有滚动条时的最大高度,超过则出现滚动条,需要自动下拉到底部
-        if (scrollBox.length && scrollBox[0].scrollHeight > 450) {
-            scrollBox.scrollTop(height);
+        // if (scrollBox.length && scrollBox[0].scrollHeight > 450) {
+        //     scrollBox.scrollTop(height);
+        // }
+        scrollBox.scrollTop(0);
+        const hdiv = divSearch($(this).find('textarea')) ? $(this).find('textarea') : null;
+        const hdheight = hdiv ? hdiv.parents('.list-group-item').offset().top : null;
+        if (hdiv && scrollBox.length &&  scrollBox[0].scrollHeight > 450 && hdheight - bdiv > 450) {
+            scrollBox.scrollTop(hdheight - bdiv);
         }
     });
+
+    function divSearch(div) {
+        if (div.length > 0) {
+            return true;
+        }
+        return false;
+    }
 </script>

+ 1 - 1
app/view/stage/gather_modal.ejs

@@ -4,7 +4,7 @@
     <div class="modal-dialog modal-xl" role="document">
         <div class="modal-content">
             <div class="modal-header">
-                <h5 class="modal-title">列显示</h5>
+                <h5 class="modal-title">章节合计</h5>
             </div>
             <div class="modal-body">
                 <table class="table table-bordered table-sm">

+ 3 - 0
config/web.js

@@ -439,6 +439,7 @@ const JsFiles = {
                 mergeFiles: [
                     '/public/js/sub_menu.js',
                     '/public/js/spreadjs_rela/spreadjs_zh.js',
+                    '/public/js/shares/sjs_setting.js',
                     '/public/js/zh_calc.js',
                     '/public/js/se_jgcl.js',
                 ],
@@ -457,6 +458,7 @@ const JsFiles = {
                 mergeFiles: [
                     '/public/js/sub_menu.js',
                     '/public/js/spreadjs_rela/spreadjs_zh.js',
+                    '/public/js/shares/sjs_setting.js',
                     '/public/js/zh_calc.js',
                     '/public/js/se_bonus.js',
                 ],
@@ -476,6 +478,7 @@ const JsFiles = {
                     '/public/js/sub_menu.js',
                     '/public/js/div_resizer.js',
                     '/public/js/spreadjs_rela/spreadjs_zh.js',
+                    '/public/js/shares/sjs_setting.js',
                     '/public/js/zh_calc.js',
                     '/public/js/path_tree.js',
                     '/public/js/se_other.js',

+ 12 - 3
sql/update.sql

@@ -100,9 +100,18 @@ ALTER TABLE `zh_project_account` ADD `wx_type` TEXT NULL DEFAULT NULL COMMENT '
 ALTER TABLE `zh_rpt_custom_define`
 ADD COLUMN `stage_select`  text CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '用户定制信息 - 多期汇总表' AFTER `gather_select`;
 
-ALTER TABLE `calculation`.`zh_material_file`
-ADD COLUMN `s_order` VARCHAR(255) NOT NULL  COMMENT '期数order' AFTER `file_name`;
-
 -- ----------------------------
 -- 以上于2020-7-23 15:00 因测试需求更新至uat,尚未更新prod,如需增加sql,请一定在其后添加
 -- ----------------------------
+CREATE TABLE `zh_material_file` (
+  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
+  `tid` int(11) NOT NULL COMMENT '标段id',
+  `user_id` int(11) NOT NULL COMMENT '用户id',
+  `mid` int(11) NOT NULL COMMENT '期id',
+  `upload_time` varchar(45) COLLATE utf8_unicode_ci NOT NULL COMMENT '上传时间',
+  `filepath` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件存储路径',
+  `file_size` varchar(45) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件大小',
+  `file_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '文件名',
+  `s_order` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT '期数order',
+  PRIMARY KEY (`id`)
+)COMMENT = '调差附件表';