Selaa lähdekoodia

阶段进度,列显示

MaiXinRong 4 tuntia sitten
vanhempi
commit
96aea8071a

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

@@ -10,6 +10,100 @@ $(document).ready(() => {
     autoFlashHeight();
     let datepicker, fileReference;
 
+    class SppColSet {
+        constructor() {
+            this.cacheKey = 'zh.subProjProgressColSet';
+            this.colSetDatas = [
+                { id: 1, pid: -1, level: 1, order: 1, is_leaf: 0, full_path: '1', name: '成果编制', field: '', show: 1},
+                { id: 2, pid: 1, level: 2, order: 1, is_leaf: 1, full_path: '1-2', name: '进度', field: 'edit_progress', show: 1},
+                { id: 3, pid: 1, level: 2, order: 2, is_leaf: 1, full_path: '1-3', name: '日期', field: 'edit_date', show: 1},
+                { id: 4, pid: 1, level: 2, order: 3, is_leaf: 1, full_path: '1-4', name: '部门', field: 'edit_department', show: 1},
+                { id: 5, pid: -1, level: 1, order: 2, is_leaf: 0, full_path: '5', name: '报审情况', field: '', show: 1},
+                { id: 6, pid: 5, level: 2, order: 1, is_leaf: 1, full_path: '5-6', name: '进度', field: 'submit_progress', show: 1},
+                { id: 7, pid: 5, level: 2, order: 2, is_leaf: 1, full_path: '5-7', name: '日期', field: 'submit_date', show: 1},
+                { id: 8, pid: 5, level: 2, order: 3, is_leaf: 1, full_path: '5-8', name: '部门', field: 'submit_department', show: 1},
+                { id: 9, pid: -1, level: 1, order: 3, is_leaf: 0, full_path: '9', name: '批复情况', field: '', show: 1},
+                { id: 10, pid: 9, level: 2, order: 1, is_leaf: 1, full_path: '9-10', name: '进度', field: 'reply_progress', show: 1},
+                { id: 11, pid: 9, level: 2, order: 2, is_leaf: 1, full_path: '9-11', name: '日期', field: 'reply_date', show: 1},
+                { id: 12, pid: 9, level: 2, order: 3, is_leaf: 1, full_path: '9-12', name: '部门', field: 'reply_department', show: 1},
+                { id: 13, pid: 9, level: 2, order: 4, is_leaf: 1, full_path: '9-13', name: '文号', field: 'reply_code', show: 1},
+            ];
+            this.cache = this.colSetDatas.filter(x => { return x.field; }).map(x => { return {field: x.field, show: x.show}; });
+            this.tree = createNewPathTree('ledger', { id: 'id', pid: 'pid', order: 'order', level: 'level', isLeaf: 'is_leaf', fullPath: 'full_path', rootId: -1 });
+            this.tree.loadDatas(this.colSetDatas);
+            const cacheStr = getLocalCache(this.cacheKey);
+            if (cacheStr) this.cache = JSON.parse(cacheStr);
+        }
+        reInitTreeData() {
+            this.tree.nodes.forEach(x => {
+                if (!x.field) return;
+                const csd = this.cache.find(d => { return x.field === d.field; });
+                if (csd) x.show = csd.show;
+            });
+            this.tree.nodes.forEach(x => {
+                if (!x.children || x.children.length === 0) return;
+                x.show = x.children.filter(c => { return !!c.show; }).length > 0 ? 1 : 0;
+            })
+        }
+        spreadButtonClick(e, info) {
+            if (!info.sheet.zh_setting) return;
+
+            const select = SpreadJsObj.getSelectObject(info.sheet);
+            const col = info.sheet.zh_setting.cols[info.col];
+            if (col.field !== 'show') return;
+            if (info.sheet.isEditing()) info.sheet.endEdit(true);
+
+            let refreshRow = 1;
+            select.show = select.show ? 0 : 1;
+            if (select.children && select.children.length > 0) {
+                refreshRow = refreshRow + select.children.length;
+                select.children.forEach(x => { x.show = select.show; });
+            }
+            SpreadJsObj.reLoadRowData(info.sheet, info.row, refreshRow);
+        }
+        initSpread() {
+            if (!this.spread) {
+                const spread = SpreadJsObj.createNewSpread($('#spp-col-set-spread')[0]);
+                this.spread = spread;
+                this.sheet = this.spread.getActiveSheet();
+                SpreadJsObj.initSheet(this.sheet, {
+                    cols: [
+                        {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 215, formatter: '@', cellType: 'tree'},
+                        {title: '显示', colSpan: '1', rowSpan: '1', field: 'show', hAlign: 1, width: 50, formatter: '@', cellType: 'checkbox'},
+                    ],
+                    emptyRows: 0,
+                    headRows: 1,
+                    headRowHeight: [32],
+                    defaultRowHeight: 21,
+                    headerFont: '12px 微软雅黑',
+                    font: '12px 微软雅黑',
+                    readOnly: true,
+                });
+                $('#spp-col-set').on('shown.bs.modal', function() {
+                    spread.refresh();
+                });
+                spread.bind(spreadNS.Events.ButtonClicked, this.spreadButtonClick)
+            }
+            SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Tree, this.tree, true);
+        }
+        loadColSet2SpreadSetting(spreadSetting){
+            this.cache.forEach(c => {
+                const ssc = spreadSetting.cols.find(x => { return c.field === x.field; });
+                if (ssc) ssc.visible = c.show ? true : false;
+            });
+        }
+        saveCache() {
+            this.cache = this.tree.nodes.filter(x => { return x.field; }).map(x => { return {field: x.field, show: x.show}; });
+            setLocalCache(this.cacheKey, JSON.stringify(this.cache));
+        }
+        show() {
+            this.initSpread();
+            this.reInitTreeData();
+            $('#spp-col-set').modal('show');
+        }
+    }
+    const sppColSet = new SppColSet();
+
     class ProgressObj {
         constructor() {
             this.spread = SpreadJsObj.createNewSpread($('#progress-spread')[0]);
@@ -116,6 +210,7 @@ $(document).ready(() => {
             };
             this.ckSpread = window.location.pathname + '-progressSelect';
 
+            this.refreshSpreadCol();
             this.initSpread();
             this.initOtherEvent();
         }
@@ -139,6 +234,10 @@ $(document).ready(() => {
                 self.baseOpr(this.getAttribute('type'));
             });
         }
+        refreshSpreadCol() {
+            sppColSet.loadColSet2SpreadSetting(this.spreadSetting);
+            SpreadJsObj.refreshColumnVisible(this.sheet);
+        }
         refreshOperationValid() {
             const setObjEnable = function (obj, enable) {
                 if (enable) {
@@ -622,6 +721,14 @@ $(document).ready(() => {
         progressFile.getCurAttHtml(SpreadJsObj.getSelectObject(progressObj.sheet));
     });
 
+    $('#progress-col-set').click(function() {
+        sppColSet.show();
+    });
+    $('#spp-col-set-ok').click(function() {
+        sppColSet.saveCache();
+        progressObj.refreshSpreadCol();
+        $('#spp-col-set').modal('hide');
+    });
     // 工具栏spr
     $.divResizer({
         select: '#right-spr',

+ 1 - 1
app/service/stage_bills.js

@@ -270,7 +270,7 @@ module.exports = app => {
 
             if (insertData.qc_minus_qty !== undefined) {
                 d.qc_minus_qty = insertData.qc_minus_qty ? this.round(insertData.qc_minus_qty, precision.value) : 0;
-                data.contract_tp = await this.calcContractTp(info, this.ctx.stage, ledgerData, insertData);
+                insertData.contract_tp = await this.calcContractTp(info, this.ctx.stage, ledgerData, insertData);
             }
             if (insertData.contract_qty !== undefined) {
                 d.contract_qty = this.round(insertData.contract_qty, precision.value);

+ 3 - 0
app/view/sub_proj/progress.ejs

@@ -34,6 +34,9 @@
                     <a href="javascript: void(0);" name="base-opr" type="up-move" class="btn btn-sm btn-light text-primary" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                 </div>
             </div>
+            <div class="ml-auto">
+                <button class="btn btn-sm btn-primary" id="progress-col-set">列显示</button>
+            </div>
         </div>
     </div>
     <div class="content-wrap row pr-46">

+ 17 - 0
app/view/sub_proj/progress_modal.ejs

@@ -25,4 +25,21 @@
             </div>
         </div>
     </div>
+</div>
+<div class="modal fade" id="spp-col-set" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">列显示</h5>
+            </div>
+            <div class="modal-body">
+                <div class="modal-height-400" id="spp-col-set-spread">
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
+                <button type="button" class="btn btn-primary btn-sm" id="spp-col-set-ok">确定</button>
+            </div>
+        </div>
+    </div>
 </div>