Quellcode durchsuchen

1. 通用用户自定义列设置
2. 计量管理-金额汇总,列设置

MaiXinRong vor 2 Wochen
Ursprung
Commit
048331a31a

+ 40 - 0
app/public/js/spss_gather_stage_info.js

@@ -18,6 +18,7 @@ $(document).ready(() => {
             {title: '截止本期应付', colSpan: '1', rowSpan: '1', field: 'end_yf_tp', hAlign: 2, width: 80, type: 'Number'},
             {title: '本期实付', colSpan: '1', rowSpan: '1', field: 'sf_tp', hAlign: 2, width: 80, type: 'Number'},
             {title: '截止本期实付', colSpan: '1', rowSpan: '1', field: 'end_sf_tp', hAlign: 2, width: 80, type: 'Number'},
+            {title: '待应付', colSpan: '1', rowSpan: '1', field: 'df_tp', hAlign: 2, width: 80, type: 'Number'},
         ],
         emptyRows: 0,
         headRows: 1,
@@ -30,6 +31,41 @@ $(document).ready(() => {
 
     const infoSpread = SpreadJsObj.createNewSpread($('#info-spread')[0]);
     const infoSheet = infoSpread.getActiveSheet();
+    const colSetSetting = {
+        key: 'zh.spss.info',
+        colSet: [
+            { name: '名称', field: 'name', fixed: ['show'], },
+            { name: '计量模式', field: 'measure_type_str', fixed: ['show'], },
+            { name: '标段状态',  field: 'progress_str', fixed: ['show'], },
+            { name: '汇总', field: 'stage_filter', fixed: ['show'],},
+            { name: '签约合同价', field: 'contract_price', },
+            { name: '0号台账', field: 'total_price', },
+            { name: '本期合同',field: 'contract_tp', },
+            { name: '本期变更', field: 'qc_tp', },
+            { name: '本期完成', field: 'gather_tp',},
+            { name: '截止本期合同', field: 'end_contract_tp', },
+            { name: '截止本期变更', field: 'end_qc_tp',},
+            { name: '截止本期完成',field: 'end_gather_tp', },
+            { name: '本期应付', field: 'yf_tp',},
+            { name: '截止本期应付', field: 'end_yf_tp', },
+            { name: '本期实付', field: 'sf_tp', },
+            { name: '截止本期实付',  field: 'end_sf_tp', },
+            { name: '待应付', field: 'df_tp', },
+        ],
+        refreshColSetSetting: function(colSettings) {
+            if (!colSettings) colSettings = customColSet.loadLocalColSet(colSetSetting);
+            for (const col of infoSpreadSetting.cols) {
+                const colCache = colSettings.find(x => { return x.field === col.field; });
+                if (colCache) col.visible = colCache.show;
+            }
+        },
+        afterSet: function(colSetting) {
+            colSetSetting.refreshColSetSetting(colSetting);
+            SpreadJsObj.refreshColumnVisible(infoSheet);
+        }
+    };
+    colSetSetting.refreshColSetSetting();
+
     SpreadJsObj.initSheet(infoSheet, infoSpreadSetting);
     let infoTree;
 
@@ -53,6 +89,7 @@ $(document).ready(() => {
                 node.end_yf_tp = tender.info.end_yf_tp;
                 node.sf_tp = tender.info.sf_tp;
                 node.end_sf_tp = tender.info.end_sf_tp;
+                node.df_tp = ZhCalc.sub(node.end_yf_tp, node.end_sf_tp);
             }, categoryLevel, true);
             infoTree.setting.calcFields = ['total_price', 'contract_price', 'contract_tp', 'qc_tp', 'gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'yf_tp', 'end_yf_tp', 'sf_tp', 'end_sf_tp'];
             treeCalc.calculateAll(infoTree);
@@ -310,4 +347,7 @@ $(document).ready(() => {
         },
         defaultCategoryLevel: selfCategoryLevel,
     });
+    $('#spss-info-col-set').click(() => {
+        customColSet.show(colSetSetting);
+    })
 });

+ 79 - 0
app/view/shares/col_set_modal.ejs

@@ -0,0 +1,79 @@
+
+<!--弹出列设置-->
+<div class="modal fade" id="custom-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">
+                <table class="table table-hover table-bordered" id="custom-col-set-table">
+                </table>
+            </div>
+            <form 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="custom-col-set-ok">确定修改</button>
+            </form>
+        </div>
+    </div>
+</div>
+<script>
+    const customColSet = (function () {
+        const loadLocalColSet = function(setting, cache) {
+            if (!cache) {
+                const cacheStr = setting.key ? getLocalCache(setting.key) : '';
+                cache = cacheStr ? JSON.parse(cacheStr) : [];
+            }
+            for (const col of setting.colSet) {
+                if (col.fixed && col.fixed.indexOf(col.field) > 0) {
+                    col.show = 1;
+                } else {
+                    const selfSet = cache.find(x => { return x.field === col.field; });
+                    col.show = selfSet ? selfSet.show : 1;
+                }
+            }
+            return setting.colSet;
+        }
+        const getColSetTableHtml = function(setting) {
+            const html  = [];
+            html.push('<tr class="text-center"><th>列名</th><th width="50px">显示</th></tr>');
+            for (const col of setting.colSet) {
+                html.push(`<tr class="text-center" code="${col.field}">`);
+                html.push(`<td>${col.name}</td>`);
+                if (col.fixed && col.fixed.indexOf('show') >= 0) {
+                    html.push(`                        <td>
+                            <div class="form-check form-check-inline">
+                                <input class="form-check-input" type="checkbox" id="inlineCheckbox-${col.field}" checked="" disabled="">
+                                <label class="form-check-label" for="inlineCheckbox-${col.field}"></label>
+                            </div>
+                        </td>`);
+                } else {
+                    html.push(`                        <td>
+                            <div class="form-check form-check-inline">
+                                <input class="form-check-input" type="checkbox" id="inlineCheckbox-${col.field}" ${ (col.show ? 'checked' : '') } >
+                                <label class="form-check-label" for="inlineCheckbox-${col.field}"></label>
+                            </div>
+                        </td>`)
+                }
+                html.push('</tr>');
+            }
+            $('#custom-col-set-table').html(html.join(''));
+        }
+        const show = function(setting) {
+            loadLocalColSet(setting);
+            getColSetTableHtml(setting);
+            $('#custom-col-set-ok').bind('click', function() {
+                const trs = $('tr[code]', '#custom-col-set');
+                const colSet = [];
+                for (const tr of trs) {
+                    colSet.push({ field: $(tr).attr('code'), show: $('input[type=checkbox]', tr)[0].checked});
+                }
+                setLocalCache(setting.key, JSON.stringify(colSet));
+                if (setting.afterSet) setting.afterSet(loadLocalColSet(setting, colSet));
+                $('#custom-col-set').modal('hide');
+            });
+            $('#custom-col-set').modal('show');
+        }
+        return { show, loadLocalColSet }
+    })();
+</script>

+ 1 - 0
app/view/spss/gather_info.ejs

@@ -22,6 +22,7 @@
                     <div class="d-inline-block">
                         <button class="btn btn-primary btn-sm mr-2" id="export-excel">导出Excel</button>
                         <button class="btn btn-sm btn-primary" id="gather-select">汇总标段</button>
+                        <button class="btn btn-sm btn-primary" id="spss-info-col-set">列设置</button>
                     </div>
                 </div>
             </div>

+ 1 - 0
app/view/spss/gather_info_modal.ejs

@@ -1,4 +1,5 @@
 <% include ./spss_select_modal.ejs %>
+<% include ../shares/col_set_modal.ejs %>
 <div class="modal fade" id="info-cate" data-backdrop="static">
     <div class="modal-dialog" role="document">
         <div class="modal-content">