MaiXinRong hace 8 meses
padre
commit
8d6642c350

+ 8 - 1
app/controller/sub_proj_controller.js

@@ -352,7 +352,14 @@ module.exports = app => {
         }
 
         async pushUpdate(ctx) {
-
+            try {
+                const data = JSON.parse(ctx.request.body.data);
+                const result = await ctx.service.subProjPush.updateDatas(data);
+                ctx.body = { err: 0, msg: '', data: result };
+            } catch (error) {
+                ctx.helper.log(error);
+                ctx.body = this.ajaxErrorBody(error, '提交数据失败,请重试');
+            }
         }
 
         /**

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

@@ -492,7 +492,7 @@ $(document).ready(() => {
                     }
                 }
             },
-        })
+        });
     }
 
     $('#exportExcel').click(function () {

+ 2 - 2
app/public/js/shares/select_rela_tender.js

@@ -8,7 +8,7 @@ class srObject {
         const srSpreadSetting = {
             cols: [
                 {title: '选择', field: 'selected', hAlign: 1, width: 40, formatter: '@', cellType: 'checkbox'},
-                {title: '名称', field: 'name', hAlign: 0, width: 180, formatter: '@', cellType: 'tree'},
+                {title: '名称', field: 'name', hAlign: 0, width: 400, formatter: '@', cellType: 'tree', wordWrap: true},
                 {title: '期数', field: 'lastStageOrder', hAlign: 1, width: 60, formatter: '@'},
                 {title: '审批状态', field: 'lastStageStatus', hAlign: 1, width: 60, formatter: '@'},
             ],
@@ -28,7 +28,7 @@ class srObject {
 
         const srResultSpreadSetting = {
             cols: [
-                {title: '名称', field: 'name', hAlign: 0, width: 180, formatter: '@', },
+                {title: '名称', field: 'name', hAlign: 0, width: 400, formatter: '@', wordWrap: true },
             ],
             emptyRows: 0,
             headRows: 1,

+ 23 - 3
app/public/js/shares/tools_att.js

@@ -54,12 +54,15 @@
 
         let allAtts = [], nodeIndexes = {};
 
+        const getNodeHint = function(node) {
+            return setting.getCurHint ? setting.getCurHint(node) : `${node.code || node.b_code || ''}/${node.name || ''}`;
+        };
         const getAttHtml = function(att, tipNode = false) {
             const html = [];
             html.push('<tr>');
             html.push(`<td width="25"><input type="checkbox" class="check-file" file-id=${att.id}></td>`);
             let nodeInfo = '';
-            if (tipNode && att.node) nodeInfo = `${att.node.code || att.node.b_code || ''}/${att.node.name || ''}`;
+            if (tipNode && att.node) nodeInfo = getNodeHint(att.node);
             const tipHtml = nodeInfo ? `${nodeInfo}\n${att[fileInfo.create_time]}` : att[fileInfo.create_time];
             const tipType = 'title='; //'data-toggle="tooltip" data-html="true" data-placement="left" data-original-title=';
             html.push(`<td><div class="d-flex"><a href="javascript:void(0)" ${tipType}"${tipHtml}" class="pl-0 col-11" file-id=${att.id}>${att.filename}${att.fileext}</a></div></td>`);
@@ -106,7 +109,7 @@
         const getCurAttHtml = function (node) {
             curNode = node;
             if (curNode) {
-                $('#att-cur-hint').text(`${curNode.code || curNode.b_code || ''}/${curNode.name || ''}`);
+                $('#att-cur-hint').text(getNodeHint(curNode));
             } else {
                 $('#att-cur-hint').text('');
             }
@@ -287,7 +290,24 @@
             }
             getAllAttHtml();
         };
+        const deleteFileByNodeId = function(nodeIds) {
+            for (const id of nodeIds) {
+                const nodeIndex = nodeIndexes[id];
+                if (!nodeIndex || nodeIndex.length === 0) continue;
+                for (const att of nodeIndex) {
+                    const att_index = findFileIndex(allAtts, att.id);
+                    allAtts.splice(att_index, 1);
+                }
+                delete nodeIndexes[id];
+            }
+            if (allAtts.length === 1) {
+                getAllAttHtml();
+            } else {
+                refreshAllAttHtml();
+            }
+            refreshCurAttHtml();
+        };
 
-        return { loadDatas, getCurAttHtml }
+        return { loadDatas, getCurAttHtml, deleteFileByNodeId }
     };
 })(jQuery);

+ 2 - 0
app/public/js/sp_progress.js

@@ -307,12 +307,14 @@ $(document).ready(() => {
             if (type === 'delete') {
                 deleteAfterHint(function () {
                     postData('progress/update', updateData, function (result) {
+                        progressFile.deleteFileByNodeId(result.delete.map(x => { return x.id; }));
                         const refreshData = tree.loadPostData(result);
                         self.refreshTree(refreshData);
                         if (sel) {
                             sheet.setSelection(sel.row, sel.col, 1, sel.colCount);
                         }
                         self.refreshOperationValid();
+                        self.loadRelaData();
                     });
                 });
             } else {

+ 482 - 0
app/public/js/sp_push.js

@@ -1,3 +1,485 @@
+const showSideTools = function (show) {
+    const left = $('#left-view'), right = $('#right-view'), parent = left.parent();
+    if (show) {
+        right.show();
+        autoFlashHeight();
+        /**
+         * right.show()后, parent被撑开成2倍left.height, 导致parent.width减少了10px
+         * 第一次left.width调整后,parent的缩回left.height, 此时parent.width又增加了10px
+         * 故需要通过最终的parent.width再计算一次left.width
+         *
+         * Q: 为什么不通过先计算left.width的宽度,以避免计算两次left.width?
+         * A: 右侧工具栏不一定显示,当右侧工具栏显示过一次后,就必须使用parent和right来计算left.width
+         *
+         */
+            //left.css('width', parent.width() - right.outerWidth());
+            //left.css('width', parent.width() - right.outerWidth());
+        const percent = 100 - right.outerWidth() /parent.width() * 100;
+        left.css('width', percent + '%');
+    } else {
+        left.width(parent.width());
+        right.hide();
+    }
+};
+
 $(document).ready(() => {
     autoFlashHeight();
+    let datepicker;
+
+    class PushObj {
+        constructor() {
+            this.spread = SpreadJsObj.createNewSpread($('#push-spread')[0]);
+            this.sheet = this.spread.getActiveSheet();
+            this.data = [];
+            this.spreadSetting = {
+                cols: [
+                    { title: '序号', colSpan: '1', rowSpan: '1', field: 'push_order', hAlign: 1, width: 80, readOnly: true },
+                    {
+                        title: '日期', colSpan: '1', rowSpan: '1', field: 'push_date', hAlign: 2, width: 100, formatter: '@',
+                        formatter: 'yyyy-MM-dd', cellType: 'activeImageBtn', normalImg: '#ellipsis-icon', indent: 5
+                    },
+                    {title: '记录内容', colSpan: '1', rowSpan: '1', field: 'push_content', hAlign: 0, width: 450, formatter: '@', wordWrap: true},
+                    {title: '备注', colSpan: '1', rowSpan: '2', field: 'memo', hAlign: 0, width: 200, formatter: '@', cellType: 'ellipsisAutoTip'},
+                ],
+                emptyRows: 3,
+                headRows: 1,
+                headRowHeight: [32],
+                defaultRowHeight: 21,
+                headerFont: '12px 微软雅黑',
+                font: '12px 微软雅黑',
+                localCache: {
+                    key: 'sub-proj-push',
+                    colWidth: true,
+                },
+                forceLoadEmpty: true,
+                imageClick: function (data, hitinfo) {
+                    const setting = hitinfo.sheet.zh_setting;
+                    if (!setting) return;
+                    const col = setting.cols[hitinfo.col];
+                    if (!col || col.field.indexOf('_date') < 0) return;
+
+                    const pos = SpreadJsObj.getObjPos(hitinfo.sheet.getParent().qo);
+                    if (!datepicker) {
+                        datepicker = $('.datepicker-here').datepicker({
+                            language: 'zh',
+                            dateFormat: 'yyyy-MM-dd',
+                            autoClose: true,
+                            onSelect: function (formattedDate, date, inst) {
+                                if (!inst.visible) return;
+                                const sels = hitinfo.sheet.getSelections();
+                                if (!sels || !sels[0]) return;
+                                const node = SpreadJsObj.getSelectObject(hitinfo.sheet);
+                                const relaCol = hitinfo.sheet.zh_setting.cols[sels[0].col];
+
+                                const updateData = {};
+                                if (node) {
+                                    updateData.update = { id: node.id };
+                                    updateData.update[relaCol.field] = formattedDate;
+                                } else {
+                                    updateData.add = { push_order: hitinfo.sheet.zh_data.length + 1 };
+                                    updateData.add[relaCol.field] = formattedDate;
+                                }
+
+                                postData('push/update', updateData, function (result) {
+                                    pushObj.refreshData(result);
+                                    SpreadJsObj.reLoadSheetData(pushObj.sheet);
+                                }, function () {
+                                    SpreadJsObj.reLoadRowData(hitinfo.sheet, sels[0].row, 1);
+                                });
+                            }
+                        }).data('datepicker');
+                    }
+                    const value = hitinfo.sheet.getValue(hitinfo.row, hitinfo.col);
+                    if (value) {
+                        datepicker.selectDate(value);
+                    } else {
+                        datepicker.clear();
+                    }
+                    datepicker.show();
+                    $('#datepickers-container').css('top', hitinfo.cellRect.y + pos.y).css('left', hitinfo.cellRect.x + pos.x);
+                }
+            };
+            this.ckSpread = window.location.pathname + '-pushSelect';
+
+            this.initSpread();
+            this.initOtherEvent();
+        }
+        initSpread() {
+            SpreadJsObj.initSheet(this.sheet, this.spreadSetting);
+            this.spread.bind(spreadNS.Events.SelectionChanged, this.selectionChanged);
+            this.spread.bind(spreadNS.Events.topRowChanged, this.topRowChanged);
+            this.spread.bind(spreadNS.Events.ClipboardChanging, function (e, info) {
+                const copyText = SpreadJsObj.getFilterCopyText(info.sheet);
+                SpreadJsObj.Clipboard.setCopyData(copyText);
+            });
+            this.spread.bind(spreadNS.Events.EditEnded, this.editEnded);
+            this.spread.bind(spreadNS.Events.ClipboardPasting, this.clipboardPasting);
+            SpreadJsObj.addDeleteBind(this.spread, this.deletePress);
+        }
+        initOtherEvent() {
+            const self = this;
+            // 增删上下移升降级
+            $('a[name="base-opr"]').click(function () {
+                self.baseOpr(this.getAttribute('type'));
+            });
+            $.contextMenu({
+                selector: '#push-spread',
+                build: function ($trigger, e) {
+                    const target = SpreadJsObj.safeRightClickSelection($trigger, e, self.spread);
+                    return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
+                },
+                items: {
+                    add: {
+                        name: '插入',
+                        icon: 'fa-plus',
+                        callback: function (key, opt) {
+                            pushObj.insert();
+                        },
+                    },
+                    del: {
+                        name: '删除',
+                        icon: 'fa-remove',
+                        callback: function (key, opt) {
+                            pushObj.delete();
+                        },
+                        disabled: function (key, opt) {
+                            const node = SpreadJsObj.getSelectObject(pushObj.sheet);
+                            return !node;
+                        },
+                    },
+                    sprDel: '------------',
+                    upMove: {
+                        name: '上移',
+                        icon: 'fa-arrow-up',
+                        callback: function (key, opt) {
+                            pushObj.upMove();
+                        },
+                        disabled: function (key, opt) {
+                            const sels = pushObj.sheet.getSelections();
+                            if (!sels || !sels[0] || sels[0].row === 0) return true;
+                        },
+                    },
+                    downMove: {
+                        name: '下移',
+                        icon: 'fa-arrow-down',
+                        callback: function (key, opt) {
+                            pushObj.downMove();
+                        },
+                        disabled: function (key, opt) {
+                            const sels = pushObj.sheet.getSelections();
+                            if (!sels || !sels[0] || sels[0].row >= pushObj.data.length - 1) return true;
+                        },
+                    }
+                },
+            })
+        }
+        loadRelaData() {
+            SpreadJsObj.saveTopAndSelect(this.sheet, this.ckSpread);
+            pushFile.getCurAttHtml(SpreadJsObj.getSelectObject(this.sheet));
+        }
+        refreshData(data) {
+            if (data.add) {
+                for (const a of data.add) {
+                    this.data.push(a);
+                }
+            }
+            if (data.update) {
+                for (const u of data.update) {
+                    const d = this.data.find(function (x) {
+                        return u.id === x.id;
+                    });
+                    if (d) {
+                        _.assign(d, u);
+                    } else {
+                        this.data.push(d);
+                    }
+                }
+            }
+            if (data.del) {
+                _.remove(this.data, function (d) {
+                    return data.del.indexOf(d.id) >= 0;
+                });
+            }
+            this.resortData();
+        }
+        resortData() {
+            this.data.sort(function (a, b) {
+                return a.push_order - b.push_order;
+            });
+        }
+        loadData(datas) {
+            this.data.length = 0;
+            this.data.push(...datas);
+            this.resortData();
+            SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Data, this.data);
+            SpreadJsObj.loadTopAndSelect(this.sheet, this.ckSpread);
+        }
+        // 事件
+        selectionChanged(e, info) {
+            if (info.newSelections) {
+                if (!info.oldSelections || info.newSelections[0].row !== info.oldSelections[0].row) {
+                    pushObj.loadRelaData();
+                }
+            }
+        }
+        topRowChanged(e, info) {
+            SpreadJsObj.saveTopAndSelect(info.sheet, pushObj.ckBillsSpread);
+        }
+        editEnded(e, info) {
+            if (!info.sheet.zh_setting || !info.sheet.zh_data) return;
+
+            const node = info.sheet.zh_data[info.row];
+            const col = info.sheet.zh_setting.cols[info.col];
+            const data = {};
+
+            if (node) {
+                data.update = {};
+                data.update.id = node.id;
+
+                const oldValue = node ? node[col.field] : null;
+                const newValue = trimInvalidChar(info.editingText);
+                if (oldValue == info.editingText || ((!oldValue || oldValue === '') && (newValue === ''))) {
+                    SpreadJsObj.reLoadRowData(info.sheet, info.row);
+                    return;
+                }
+                data.update[col.field] = newValue;
+            } else {
+                data.add = {};
+                data.add.push_order = info.sheet.zh_data.length + 1;
+                data.add[col.field] = trimInvalidChar(info.editingText);
+            }
+            // 更新至服务器
+            postData('push/update', data, function (result) {
+                pushObj.refreshData(result);
+                SpreadJsObj.reLoadSheetData(pushObj.sheet);
+                if (data.add) pushObj.loadRelaData();
+            }, function () {
+                SpreadJsObj.reLoadRowData(info.sheet, info.row, 1);
+            });
+        }
+        deletePress (sheet) {
+            if (!sheet.zh_setting) return;
+            const sel = sheet.getSelections()[0], datas = [];
+            for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
+                let bDel = false;
+                const node = sheet.zh_tree.nodes[iRow];
+                const data = sheet.zh_tree.getNodeKeyData(node);
+                for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
+                    const col = sheet.zh_setting.cols[iCol];
+                    const style = sheet.getStyle(iRow, iCol);
+                    if (style.locked) continue;
+
+                    data[col.field] = col.type === 'Number' ? 0 : '';
+                    bDel = true;
+                }
+                if (bDel) datas.push(data);
+            }
+            if (datas.length > 0) {
+                postData('push/update', {update: datas}, function (result) {
+                    pushObj.refreshData(result);
+                    SpreadJsObj.reLoadSheetData(pushObj.sheet);
+                }, function () {
+                    SpreadJsObj.reLoadRowData(info.sheet, sel.row, sel.rowCount);
+                });
+            }
+        }
+        clipboardPasting(e, info) {
+            info.cancel = true;
+            const setting = info.sheet.zh_setting, sortData = info.sheet.zh_data;
+            if (!setting || !sortData) return;
+
+            const pasteData = info.pasteData.html
+                ? SpreadJsObj.analysisPasteHtml(info.pasteData.html)
+                : (info.pasteData.text === ''
+                    ? SpreadJsObj.Clipboard.getAnalysisPasteText()
+                    : SpreadJsObj.analysisPasteText(info.pasteData.text));
+            const uDatas = [], iDatas = [];
+            for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
+                const curRow = info.cellRange.row + iRow;
+                const node = sortData[curRow];
+
+                let bPaste = false;
+                const data = {};
+                for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
+                    const curCol = info.cellRange.col + iCol;
+                    const colSetting = setting.cols[curCol];
+                    const value = trimInvalidChar(pasteData[iRow][iCol]);
+
+                    if (colSetting.type === 'Number') {
+                        const num = _.toNumber(value);
+                        if (num) {
+                            data[colSetting.field] = num;
+                            bPaste = true;
+                        }
+                    } else {
+                        data[colSetting.field] = value || '';
+                        bPaste = true;
+                    }
+                }
+                if (bPaste) {
+                    if (node) {
+                        data.id = node.id;
+                        uDatas.push(data);
+                    } else {
+                        data.push_order = curRow + 1;
+                        iDatas.push(data);
+                    }
+                }
+            }
+            const updateData = {};
+            if (uDatas.length > 0) updateData.update = uDatas;
+            if (iDatas.length > 0) updateData.add = iDatas;
+            if (uDatas.length > 0 || iDatas.length > 0) {
+                postData('push/update', updateData, function (result) {
+                    pushObj.refreshData(result);
+                    SpreadJsObj.reLoadSheetData(info.sheet);
+                    if (updateData.add && !updateData.update) pushObj.loadRelaData();
+                });
+            } else {
+                SpreadJsObj.reLoadSheetData(info.sheet);
+            }
+        }
+        // 操作
+        insert () {
+            const sheet = this.sheet;
+            const node = SpreadJsObj.getSelectObject(sheet);
+            const push_order = node ? node.push_order : sheet.getRowCount() - 2;
+            const add = { push_order };
+            // 更新至服务器
+            postData('push/update', { add }, function (result) {
+                pushObj.refreshData(result);
+                SpreadJsObj.reLoadSheetData(pushObj.sheet);
+            }, function () {
+                SpreadJsObj.reLoadRowData(info.sheet, info.row, 1);
+            });
+        }
+        delete () {
+            const sortData = this.sheet.zh_data;
+            const datas = [];
+            const sels = this.sheet.getSelections();
+            if (!sels || !sels[0]) return;
+
+            for (let iRow = sels[0].row, iLen = sels[0].row + sels[0].rowCount; iRow < iLen; iRow++) {
+                const node = sortData[iRow];
+                datas.push(node.id);
+            }
+            if (datas.length > 0) {
+                postData('push/update', {del: datas}, function (result) {
+                    pushObj.refreshData(result);
+                    SpreadJsObj.reLoadSheetData(pushObj.sheet);
+                    pushFile.deleteFileByNodeId(result.del);
+                    pushObj.loadRelaData();
+                }, function () {
+                    SpreadJsObj.reLoadSheetData(pushObj.sheet);
+                });
+            }
+        }
+        upMove () {
+            const sels = this.sheet.getSelections(), sortData = this.sheet.zh_data;
+            const node = sortData[sels[0].row];
+            const preNode = sortData[sels[0].row - 1];
+            const data = [
+                {id: node.id, push_order: preNode.push_order},
+                {id: preNode.id, push_order: node.push_order}
+            ];
+            postData('push/update', {update: data}, function (result) {
+                pushObj.refreshData(result);
+                SpreadJsObj.reLoadRowsData(pushObj.sheet, [sels[0].row, sels[0].row - 1]);
+                pushObj.sheet.setSelection(sels[0].row - 1, sels[0].col, sels[0].rowCount, sels[0].colCount);
+            });
+        }
+        downMove () {
+            const sels = this.sheet.getSelections(), sortData = this.sheet.zh_data;
+            const node = sortData[sels[0].row];
+            const nextNode = sortData[sels[0].row + 1];
+            const data = [
+                {id: node.id, push_order: nextNode.push_order},
+                {id: nextNode.id, push_order: node.push_order}
+            ];
+            postData('push/update', {update: data}, function (result) {
+                pushObj.refreshData(result);
+                SpreadJsObj.reLoadRowsData(pushObj.sheet, [sels[0].row, sels[0].row + 1]);
+                pushObj.sheet.setSelection(sels[0].row + 1, sels[0].col, sels[0].rowCount, sels[0].colCount);
+            });
+        }
+    }
+    const pushObj = new PushObj();
+
+    const pushFile = $.ledger_att({
+        selector: '#fujian',
+        key: 'id',
+        masterKey: 'rela_id',
+        uploadUrl: 'push/file/upload',
+        deleteUrl: 'push/file/delete',
+        checked: false,
+        zipName: `推进记录-附件.zip`,
+        readOnly: false,
+        fileIdType: 'string',
+        fileInfo: {
+            user_name: 'user_name',
+            user_id: 'user_id',
+            create_time: 'create_time',
+        },
+        getCurHint: function(node) { return ''; },
+        locate: function (att) {
+            if (!att) return;
+            SpreadJsObj.locateDataBy(pushObj.sheet, function(x) { return x.id === att.node.id; });
+            pushFile.getCurAttHtml(att.node);
+        }
+    });
+    // 展开收起标准清单
+    $('a', '#side-menu').bind('click', function (e) {
+        e.preventDefault();
+        const tab = $(this), tabPanel = $(tab.attr('content'));
+        // 展开工具栏、切换标签
+        if (!tab.hasClass('active')) {
+            // const close = $('.active', '#side-menu').length === 0;
+            $('a', '#side-menu').removeClass('active');
+            $('.tab-content .tab-select-show.tab-pane.active').removeClass('active');
+            tab.addClass('active');
+            tabPanel.addClass('active');
+            // $('.tab-content .tab-pane').removeClass('active');
+            showSideTools(tab.hasClass('active'));
+        } else { // 收起工具栏
+            tab.removeClass('active');
+            tabPanel.removeClass('active');
+            showSideTools(tab.hasClass('active'));
+        }
+        pushObj.spread.refresh();
+    });
+
+    postData('load', { filter: 'push;push_file'}, function(result) {
+        pushObj.loadData(result.push);
+        for (const f of result.push_file) {
+            f.node = pushObj.data.find(x => { return x.id === f.rela_id; });
+        }
+        pushFile.loadDatas(result.push_file);
+        pushFile.getCurAttHtml(SpreadJsObj.getSelectObject(pushObj.sheet));
+    });
+
+    // 工具栏spr
+    $.divResizer({
+        select: '#right-spr',
+        callback: function () {
+            pushObj.spread.refresh();
+        }
+    });
+    // 导航Menu
+    $.subMenu({
+        menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
+        toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
+        key: 'menu.1.0.0',
+        miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
+        callback: function (info) {
+            if (info.mini) {
+                $('.panel-title').addClass('fluid');
+                $('#sub-menu').removeClass('panel-sidebar');
+            } else {
+                $('.panel-title').removeClass('fluid');
+                $('#sub-menu').addClass('panel-sidebar');
+            }
+            autoFlashHeight();
+            pushObj.spread.refresh();
+        }
+    });
 });

+ 8 - 7
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -795,22 +795,23 @@ const SpreadJsObj = {
             // 设置总行数
             const totalRow = sortData.length + sheet.zh_setting.emptyRows;
             sheet.setRowCount(totalRow, spreadNS.SheetArea.viewport);
-            // 控制空白行
-            const emptyRows = sheet.getRange(sortData.length, -1, sheet.zh_setting.emptyRows, -1);
-            emptyRows.locked(sheet.zh_dataType === 'tree' || sheet.zh_setting.readOnly);
             if (sortData) {
                 // 单元格写入数据
                 sortData.forEach(function (data, i) {
                     self._loadRowData(sheet, data, i);
                     sheet.setRowVisible(i, data.visible);
                 });
-                // for (let iRow = sortData.length - 1; iRow < totalRow; iRow++) {
-                //     self._loadRowStyle(sheet, iRow);
-                // }
+            }
+            // 控制空白行
+            const emptyRows = sheet.getRange(sortData.length, -1, sheet.zh_setting.emptyRows, -1);
+            emptyRows.locked(sheet.zh_dataType === 'tree' || sheet.zh_setting.readOnly);
+            if (sheet.zh_setting.forceLoadEmpty) {
+                for (let iRow = emptyRows.row; iRow < emptyRows.row + emptyRows.rowCount; iRow++) {
+                    self._loadRowData(sheet, {}, iRow);
+                }
             }
             // 设置列单元格格式
             sheet.zh_setting.cols.forEach(function (col, j) {
-                //if (!col.cellType) { return; }
                 self._defineColCellType(sheet, j, col);
             });
             this.endMassOperation(sheet);

+ 6 - 0
app/service/sub_proj_progress.js

@@ -156,6 +156,12 @@ module.exports = app => {
             }
         }
 
+        async _deleteRelaData(spid, deleteData) {
+            if (!this.transaction) throw '删除相关数据错误';
+            await this.transaction.update(this.ctx.service.subProjFile.tableName, {is_deleted: 1},
+                { where: { spid, type: 'progress', rela_id: deleteData.map(x => { return x.id; })} });
+        }
+
         async updateInfos(spid, data) {
             if (!spid) throw '数据错误';
 

+ 124 - 1
app/service/sub_proj_push.js

@@ -6,4 +6,127 @@
  * @author Mai
  * @date
  * @version
- */
+ */
+
+module.exports = app => {
+    class SubProjPush extends app.BaseService {
+        /**
+         * 构造函数
+         *
+         * @param {Object} ctx - egg全局变量
+         * @return {void}
+         */
+        constructor(ctx) {
+            super(ctx);
+            this.tableName = 'sub_project_push';
+        }
+
+        async getData(spid) {
+            const data = await this.getAllDataByCondition({where: { spid }, orders: [['push_order', 'asc']]});
+            return data;
+        }
+
+        async _addDatas(data) {
+            const spid = this.ctx.subProject.id;
+            const datas = data instanceof Array ? data : [data];
+            const insertData = [];
+            for (const d of datas) {
+                if (!d.push_order) throw '提交的数据错误';
+                const nd = {
+                    id: this.uuid.v4(),
+                    spid: this.ctx.subProject.id,
+                    user_id: this.ctx.session.sessionUser.accountId,
+                    update_user_id: this.ctx.session.sessionUser.accountId,
+                    push_order: d.push_order,
+                };
+                if (d.push_date !== undefined) nd.push_date = d.push_date;
+                if (d.push_content !== undefined) nd.push_content = d.push_content;
+                if (d.memo !== undefined) nd.memo = d.memo;
+                insertData.push(nd);
+            }
+            const push_order = this.ctx.helper._.min(insertData.map(x => { return x.push_order}));
+
+            const conn = await this.db.beginTransaction();
+            try {
+                await conn.query(`UPDATE ${this.tableName} SET push_order = push_order + ? WHERE spid = ? AND push_order >= ?`, [insertData.length, spid, push_order]);
+                await conn.insert(this.tableName, insertData);
+                await conn.commit();
+            } catch(err) {
+                await conn.rollback();
+                throw err;
+            }
+            const add = await this.getAllDataByCondition({ where: { spid: this.ctx.subProject.id, id: this.ctx.helper._.map(insertData, 'id') } });
+            const update = await this.db.query(`SELECT * FROM ${this.tableName} WHERE spid = ? AND push_order >= ?`, [spid, push_order + insertData.length]);
+            return { add, update };
+        }
+
+        async _delDatas (data) {
+            const spid = this.ctx.subProject.id;
+            const datas = data instanceof Array ? data : [data];
+            const orgDatas = await this.getAllDataByCondition({ where: { id: datas }});
+            const push_order = this.ctx.helper._.min(orgDatas.map(x => { return x.push_order}));
+
+            const conn = await this.db.beginTransaction();
+            try {
+                await conn.delete(this.tableName, {id: datas});
+                await conn.update(this.ctx.service.subProjFile.tableName, { is_deleted: 1}, { where: { spid: this.ctx.subProject.id, type: 'push', rela_id: datas } });
+                await conn.query(`UPDATE ${this.tableName} SET push_order = push_order - ? WHERE spid = ? AND push_order >= ?`, [datas.length, spid, push_order + datas.length]);
+                await conn.commit();
+            } catch(err) {
+                await conn.rollback();
+                throw err;
+            }
+            const update = await this.db.query(`SELECT * FROM ${this.tableName} WHERE spid = ? AND push_order >= ?`, [spid, push_order]);
+            return { del: datas, update };
+        }
+
+        async _updateDatas (data) {
+            const datas = data instanceof Array ? data : [data];
+
+            const uDatas = [];
+            for (const d of datas) {
+                const nd = { id: d.id };
+                if (d.push_order !== undefined) nd.push_order = d.push_order;
+                if (d.push_date !== undefined) nd.push_date = d.push_date;
+                if (d.push_content !== undefined) nd.push_content = d.push_content;
+                if (d.memo !== undefined) nd.memo = d.memo;
+                uDatas.push(nd);
+            }
+            if (uDatas.length > 0) {
+                await this.db.updateRows(this.tableName, uDatas);
+                return uDatas;
+            } else {
+                return [];
+            }
+        }
+
+        async updateDatas(data) {
+            const result = {add: [], del: [], update: []};
+            try {
+                if (data.add) {
+                    const addResult = await this._addDatas(data.add);
+                    result.add.push(...addResult.add);
+                    result.update.push(...addResult.update);
+                }
+                if (data.update) {
+                    result.update = await this._updateDatas(data.update);
+                }
+                if (data.del) {
+                    const delResult = await this._delDatas(data.del);
+                    result.del.push(...delResult.del);
+                    result.update.push(...delResult.update);
+                }
+                return result;
+            } catch (err) {
+                if (err.stack) {
+                    throw err;
+                } else {
+                    result.err = err.toString();
+                    return result;
+                }
+            }
+        }
+    }
+
+    return SubProjPush;
+};

+ 60 - 6
app/view/sub_proj/push.ejs

@@ -14,18 +14,72 @@
             </div>
         </div>
     </div>
-    <div class="content-wrap row">
+    <div class="content-wrap row pr-46">
         <div class="c-header p-0 col-12">
         </div>
         <!--核心内容(两栏)-->
         <div class="row w-100 sub-content">
             <!--左栏-->
             <div class="c-body" id="left-view" style="width: 100%">
-                <div id="bills-spread" class="sjs-height-1"></div>
+                <div id="push-spread" class="sjs-height-1"></div>
+                <div z-index="0" style="display: none;">
+                    <input class="datepicker-here form-control form-control-sm" data-date-format="yyyy-MM-DD" data-language="zh" type="text" autocomplete="off" id="dp-input">
+                </div>
+            </div>
+            <div class="c-body" id="right-view" style="display: none; width: 33%;">
+                <div class="resize-x" id="right-spr" r-Type="width" div1="#left-view" div2="#right-view" title="调整大小" a-type="percent"><!--调整左右高度条--></div>
+                <div class="tab-content">
+                    <div id="fujian" class="tab-pane tab-select-show">
+                        <div class="sjs-bar">
+                            <ul class="nav nav-tabs">
+                                <li class="nav-item">
+                                    <a class="nav-link active" data-toggle="tab" href="#cur-att" role="tab" fujian-content="cur-att">当前节点</a>
+                                </li>
+                                <li class="nav-item">
+                                    <a class="nav-link" data-toggle="tab" href="#all-att" role="tab" fujian-content="all-att">所有附件</a>
+                                </li>
+                                <li class="nav-item ml-auto pt-1">
+                                    <button  id="batch-download-att" class="btn btn-sm btn-primary" type="curr">批量下载</button>
+                                    <!--所有附件 翻页-->
+                                    <span id="showPage" style="display: none"><a href="javascript:void(0);" class="page-select ml-3" 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 mr-3" content="next"><i class="fa fa-chevron-right"></i></a></span>
+                                    <a href="#upload" data-toggle="modal" data-target="#upload" class="btn btn-sm btn-outline-primary ml-3">上传</a>
+                                </li>
+                            </ul>
+                        </div>
+                        <div class="tab-content">
+                            <div class="tab-pane active" id="cur-att">
+                                <div class="sjs-sh-3" style="overflow:auto; overflow-x:hidden;">
+                                    <table class="table table-sm table-bordered table-hover" style="word-break:break-all; table-layout: fixed">
+                                        <tr><th width="25"><input type="checkbox" class="check-all-file"><th>文件名</th><th width="80">上传</th></tr>
+                                        <tbody id="cur-att-list" class="list-table">
+                                        </tbody>
+                                    </table>
+                                </div>
+                            </div>
+                            <div class="tab-pane" id="all-att">
+                                <div class="sjs-sh-3" style="overflow:auto; overflow-x:hidden;">
+                                    <table class="table table-sm table-bordered table-hover" style="word-break:break-all; table-layout: fixed">
+                                        <tr><th width="25"><input type="checkbox" class="check-all-file"></th><th>文件名</th><th width="80">上传</th></tr>
+                                        <tbody id="all-att-list" class="list-table">
+                                        </tbody>
+                                    </table>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
             </div>
         </div>
+        <!--右侧菜单-->
+        <div class="side-menu">
+            <ul class="nav flex-column right-nav" id="side-menu">
+                <li class="nav-item">
+                    <a class="nav-link" content="#fujian" href="javascript: void(0);">附件</a>
+                </li>
+            </ul>
+        </div>
+    </div>
+    <div style="display: none">
+        <img src="/public/images/ellipsis_horizontal.png" id="ellipsis-icon" />
     </div>
-</div>
-<script>
-    const whiteList = JSON.parse('<%- JSON.stringify(ctx.app.config.multipart.whitelist) %>');
-</script>
+</div>

+ 1 - 0
app/view/sub_proj/push_modal.ejs

@@ -0,0 +1 @@
+<% include ../shares/upload_att.ejs %>

+ 1 - 0
config/web.js

@@ -1186,6 +1186,7 @@ const JsFiles = {
             },
             push: {
                 files: [
+                    '/public/js/datepicker/datepicker.min.js', '/public/js/datepicker/datepicker.zh.js',
                     '/public/js/axios/axios.min.js', '/public/js/file-saver/FileSaver.js', '/public/js/js-xlsx/jszip.min.js',
                     '/public/js/shares/aliyun-oss-sdk.min.js', '/public/js/component/menu.js',
                     '/public/js/spreadjs/sheets/v11/gc.spread.sheets.all.11.2.2.min.js',