Просмотр исходного кода

项目列表,列设置相关

MaiXinRong 8 часов назад
Родитель
Сommit
c82a8bb6bb

+ 20 - 0
app/const/project_setting.js

@@ -58,6 +58,16 @@ const colSet = {
         { field: 'end_sf_tp', name: '截止本期实付', fixed: [] },
         { field: 'wf_tp', name: '未付金额', fixed: [], hint:'截止本期应付-截止本期实付' },
     ],
+    projectList: [
+        { field: 'name', name: '项目名称', fixed: ['show'] },
+        { field: 'budget_std', name: '概预算标准', fixed: ['show'] },
+        { field: 'tender_count', name: '标段个数', fixed: [] },
+        { field: 'file_count', name: '文件个数', fixed: [] },
+        { field: 'contract_count', name: '合同个数', fixed: [] },
+        { field: 'management', name: '管理单位', fixed: ['show'] },
+        { field: 'create_time', name: '创建时间', fixed: [] },
+        { field: 'control', name: '操作', fixed: ['show'] },
+    ],
 };
 const defaultProjectColSet = {
     info: [
@@ -76,6 +86,16 @@ const defaultProjectColSet = {
         { field: 'end_sf_tp', show: 0, alias: '' },
         { field: 'wf_tp', show: 0, alias: '' },
     ],
+    list: [
+        { field: 'name', show: 1 },
+        { field: 'budget_std', show: 1, alias: '' },
+        { field: 'tender_count', show: 1, alias: '' },
+        { field: 'file_count', show: 1, alias: '' },
+        { field: 'contract_count', show: 1, alias: '' },
+        { field: 'management', show: 1, alias: '' },
+        { field: 'create_time', show: 1, alias: '' },
+        { field: 'control', show: 1, alias: '' },
+    ],
 };
 const defaultColSet = {
     info: [

+ 3 - 0
app/controller/sub_proj_controller.js

@@ -54,6 +54,9 @@ module.exports = app => {
                 renderData.permissionConst = ctx.service.subProjPermission.PermissionConst;
                 renderData.companys = await this.ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                 renderData.templates = await this.ctx.service.filingTemplateList.getAllTemplate(ctx.session.sessionProject.id);
+
+                const projectColSet = await ctx.service.projectColSet.getProjectColSet(ctx.session.sessionProject.id);
+                renderData.colSet = ctx.service.projectColSet.analysisColSetWithDefine(projectSetting.colSet.projectList, projectColSet.list, projectSetting.defaultProjectColSet.list);
                 await this.layout('sub_proj/index.ejs', renderData, 'sub_proj/modal.ejs');
             } catch (err) {
                 ctx.log(err);

+ 64 - 31
app/public/js/sub_project.js

@@ -12,59 +12,90 @@ $(document).ready(function() {
         const ProjectTree = createDragTree(setting.treeSetting);
         ProjectTree.loadDatas(setting.source);
         const TableObj = $(setting.table);
+        const TableHeaderObj = $(setting.tableHeader);
         let tenderTreeShowLevel;
+        let colSetCache;
 
         const Utils = {
+            generateColSetCache: function() {
+                const result = {};
+                colSet.forEach(x => {
+                    result[x.field] = { show: x.show, alias: x.alias || x.name };
+                });
+                return result;
+            },
+            getHeaderHtml: function() {
+                colSetCache = this.generateColSetCache();
+                const html = [];
+                html.push('<tr class="text-center">');
+                if (colSetCache.name.show) html.push('<th style="min-width: 300px">', colSetCache.name.alias, '</th>');
+                if (colSetCache.budget_std.show) html.push('<th width="8%">', colSetCache.budget_std.alias, '</th>');
+                if (colSetCache.tender_count.show) html.push('<th width="5%">', colSetCache.tender_count.alias, '</th>');
+                if (colSetCache.file_count.show) html.push('<th width="5%">', colSetCache.file_count.alias, '<i class="fa fa-question-circle text-primary" data-placement="bottom" data-toggle="tooltip" data-original-title="指资料归集的所有文件个数"></i>', '</th>');
+                if (colSetCache.contract_count.show) html.push('<th width="5%">', colSetCache.contract_count.alias, '<i class="fa fa-question-circle text-primary" data-placement="bottom" data-toggle="tooltip" data-original-title="项目支出合同个数"></i>', '</th>');
+                if (colSetCache.management.show) html.push('<th width="20%">', colSetCache.management.alias, '</th>');
+                if (colSetCache.create_time.show) html.push('<th width="8%">', colSetCache.create_time.alias, '</th>');
+                if (colSetCache.control.show && canEdit) html.push('<th width="20%">', colSetCache.control.alias, '</th>');
+                html.push('</tr>');
+                console.log(html);
+                return html.join('');
+            },
             getRowTdHtml: function (node, tree) {
                 const html = [];
                 // 名称
-                html.push('<td width="20%" class="in-' + node.tree_level + '">');
-                if (node.is_folder) {
-                    if (node.children.length > 0) {
-                        html.push('<span onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1" title="收起" id="'+ node.id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ', node.name);
+                if (colSetCache.name.show) {
+                    html.push('<td width="20%" class="in-' + node.tree_level + '">');
+                    if (node.is_folder) {
+                        if (node.children.length > 0) {
+                            html.push('<span onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1" title="收起" id="'+ node.id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ', node.name);
+                        } else {
+                            html.push('<i class="fa fa-folder-o"></i> ', node.name);
+                        }
                     } else {
-                        html.push('<i class="fa fa-folder-o"></i> ', node.name);
+                        html.push(`<span class="text-muted mr-2">${tree.isLastSibling(node) ? '└' : '├'}</span>`);
+                        html.push(`<a href="sp/${node.id}/dashboard" name="name" id="${node.id}">`, node.name, '</a>');
                     }
-                } else {
-                    html.push(`<span class="text-muted mr-2">${tree.isLastSibling(node) ? '└' : '├'}</span>`);
-                    html.push(`<a href="sp/${node.id}/dashboard" name="name" id="${node.id}">`, node.name, '</a>');
+                    html.push('</td>');
                 }
-                html.push('</td>');
                 // 概预算标准
-                if (node.is_folder) {
-                    html.push(`<td class="text-center"></td>`);
-                } else {
-                    if (node.std_name) {
-                        html.push(`<td class="text-center">${node.std_name}</td>`);
-                    } else if (canEdit) {
-                        html.push(`<td class="text-center"><button class="btn btn-outline-primary btn-sm ml-1" name="set-std">选择</button></td>`);
-                    } else {
+                if (colSetCache.budget_std.show) {
+                    if (node.is_folder) {
                         html.push(`<td class="text-center"></td>`);
+                    } else {
+                        if (node.std_name) {
+                            html.push(`<td class="text-center">${node.std_name}</td>`);
+                        } else if (canEdit) {
+                            html.push(`<td class="text-center"><button class="btn btn-outline-primary btn-sm ml-1" name="set-std">选择</button></td>`);
+                        } else {
+                            html.push(`<td class="text-center"></td>`);
+                        }
                     }
                 }
                 // 创建时间
                 if (node.is_folder) {
-                    html.push(`<td class="text-center"></td>`);
-                    html.push(`<td class="text-center"></td>`);
-                    html.push(`<td class="text-center"></td>`);
-                    html.push(`<td class="text-center"></td>`);
-                    html.push(`<td class="text-center"></td>`);
+                    if (colSetCache.tender_count.show) html.push(`<td class="text-center"></td>`);
+                    if (colSetCache.file_count.show) html.push(`<td class="text-center"></td>`);
+                    if (colSetCache.contract_count.show) html.push(`<td class="text-center"></td>`);
+                    if (colSetCache.management.show) html.push(`<td class="text-center"></td>`);
+                    if (colSetCache.create_time.show) html.push(`<td class="text-center"></td>`);
                 } else {
                     // 标段个数
-                    html.push(`<td class="text-center">${node.tender_count}</td>`);
+                    if (colSetCache.tender_count.show) html.push(`<td class="text-center">${node.tender_count}</td>`);
                     // 文件个数
-                    html.push(`<td class="text-center">${node.file_count}</td>`);
+                    if (colSetCache.file_count.show) html.push(`<td class="text-center">${node.file_count}</td>`);
                     // 合同个数
-                    html.push(`<td class="text-center">${node.contract_count}</td>`);
-                    if (canEdit) {
-                        html.push(`<td class="text-center">${node.management || ''}<a class="ml-2" href="javascript: void(0)" name="set-management"><i class="fa fa-pencil-square-o "></i></a>${node.management ? '<a class="ml-2" href="javascript: void(0)" name="refresh-management"><i class="fa fa-refresh "></i></a>': ''}</td>`);
-                    } else {
-                        html.push(`<td class="text-center">${node.management || ''}</td>`);
+                    if (colSetCache.contract_count.show) html.push(`<td class="text-center">${node.contract_count}</td>`);
+                    if (colSetCache.management.show) {
+                        if (canEdit) {
+                            html.push(`<td class="text-center">${node.management || ''}<a class="ml-2" href="javascript: void(0)" name="set-management"><i class="fa fa-pencil-square-o "></i></a>${node.management ? '<a class="ml-2" href="javascript: void(0)" name="refresh-management"><i class="fa fa-refresh "></i></a>': ''}</td>`);
+                        } else {
+                            html.push(`<td class="text-center">${node.management || ''}</td>`);
+                        }
                     }
-                    html.push(`<td class="text-center">${moment(node.create_time).format('YYYY-MM-DD')}</td>`);
+                    if (colSetCache.create_time.show) html.push(`<td class="text-center">${moment(node.create_time).format('YYYY-MM-DD')}</td>`);
                 }
                 // 操作
-                if (canEdit) {
+                if (canEdit && colSetCache.control.show) {
                 html.push(`<td>`);
                     html.push('<button class="btn btn-outline-primary btn-sm ml-1" name="edit">编辑</button>');
                     html.push('<button class="btn btn-outline-primary btn-sm ml-1" name="up"><i class="fa fa-arrow-up"></i></button>');
@@ -94,6 +125,7 @@ $(document).ready(function() {
                 return html.join('');
             },
             reloadTable: function () {
+                TableHeaderObj.html(Utils.getHeaderHtml());
                 const html = [];
                 for (const node of ProjectTree.nodes) {
                     html.push(Utils.getNodeTrHtml(node, ProjectTree));
@@ -346,6 +378,7 @@ $(document).ready(function() {
         treeSetting: { id: 'id', pid: 'tree_pid', level: 'tree_level', order: 'tree_order', rootId: '-1' },
         source: projectList,
         table: '#projectList',
+        tableHeader: '#projectListHeader',
     });
 
     $('#add-folder').on('show.bs.modal', function(e) {

+ 10 - 4
app/service/project_col_set.js

@@ -8,7 +8,7 @@
  * @version
  */
 
-const JsonFields = [ 'info' ];
+const JsonFields = [ 'info', 'list' ];
 const ProjectSetting = require('../const/project_setting');
 
 module.exports = app => {
@@ -28,7 +28,13 @@ module.exports = app => {
 
         _analysisData(data) {
             if (!data) return;
-            JsonFields.forEach(jf => { if(data[jf]) data[jf] = JSON.parse(data[jf]); });
+            JsonFields.forEach(jf => {
+                if (data[jf]) {
+                    data[jf] = JSON.parse(data[jf]);
+                } else {
+                    data[jf] = JSON.parse(JSON.stringify(data.spid ? ProjectSetting.defaultColSet[jf] : ProjectSetting.defaultProjectColSet[jf]));
+                }
+            });
         }
 
         async loadProjectColSet(pid, spid = '') {
@@ -48,8 +54,8 @@ module.exports = app => {
         async getProjectColSet(pid, spid) {
             const curSet = await this.loadProjectColSet(pid, spid);
             if (curSet) return curSet;
-            await this.initProjectColSet(pid, spid);
-            return await this.loadProjectColSet(pid, spid);
+            await this.initProjectColSet(pid, spid, colSetType);
+            return await this.loadProjectColSet(pid, spid, colSetType);
         }
 
         async setProjectColSet(pid, spid, colSetType, colSet) {

+ 4 - 9
app/view/sub_proj/index.ejs

@@ -13,6 +13,7 @@
                 <a href="#add-folder" name="add" data-toggle="modal" data-target="#add-folder" class="btn btn-sm btn-primary">新建文件夹</a>
                 <a href="#add-project" name="add" data-toggle="modal" data-target="#add-project" class="btn btn-sm btn-primary ml-2">新建项目</a>
                 <a href="/file/template" class="btn btn-sm btn-primary ml-2">资料模板库</a>
+                <a href="#col-set" class="btn btn-sm btn-primary ml-1" data-toggle="modal" data-target="#col-set">列设置</a>
                 <% } %>
             </div>
         </div>
@@ -26,15 +27,8 @@
                 </div>
                 <% } else { %>
                 <table class="table table-bordered">
-                    <tr class="text-center">
-                        <th style="min-width: 300px">项目名称</th>
-                        <th width="8%">概预算标准</th>
-                        <th width="5%">标段个数</th>
-                        <th width="5%">文件个数<i class="fa fa-question-circle text-primary" data-placement="bottom" data-toggle="tooltip" data-original-title="指资料归集的所有文件个数"></i></th>
-                        <th width="5%">合同个数<i class="fa fa-question-circle text-primary" data-placement="bottom" data-toggle="tooltip" data-original-title="项目支出合同个数"></i></th>
-                        <th width="20%">管理单位</th>
-                        <th width="8%">创建时间</th><% if (ctx.session.sessionUser.is_admin) { %><th width="20%">操作</th><% } %>
-                    </tr>
+                    <thead id="projectListHeader">
+                    </thead>
                     <tbody id="projectList">
                     </tbody>
                 </table>
@@ -47,4 +41,5 @@
     autoFlashHeight();
     const projectList = JSON.parse(unescape('<%- escape(JSON.stringify(projectList)) %>'));
     const canEdit = <%- !!ctx.session.sessionUser.is_admin %>;
+    const colSet = JSON.parse('<%- JSON.stringify(colSet) %>');
 </script>

+ 57 - 0
app/view/sub_proj/modal.ejs

@@ -220,8 +220,65 @@
             </div>
         </div>
     </div>
+</div><!--弹出列设置-->
+<div class="modal fade" id="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">
+                    <thead><tr class="text-center">
+                        <th width="150px">列名</th>
+                        <th width="50px">显示</th>
+                    </tr></thead>
+                    <tbody class="text-center">
+                    <% for (const cs of colSet) { %>
+                    <tr code="<%- cs.field %>">
+                        <td><%- cs.name %><% if (cs.hint) { %><i class="fa fa-question-circle text-primary ml-1" data-placement="bottom" data-toggle="tooltip" data-original-title="<%- cs.hint %>"></i><% } %></td>
+                        <% if (cs.fixed.indexOf('show') >= 0 ) { %>
+                        <td>
+                            <div class="form-check form-check-inline">
+                                <input class="form-check-input" type="checkbox" id="inlineCheckbox-<%- cs.code %>" checked="" disabled="">
+                                <label class="form-check-label" for="inlineCheckbox-<%- cs.code %>"></label>
+                            </div>
+                        </td>
+                        <% } else { %>
+                        <td>
+                            <div class="form-check form-check-inline">
+                                <input class="form-check-input" type="checkbox" id="inlineCheckbox-<%- cs.code %>" <% if (cs.show) { %> checked <% } %> >
+                                <label class="form-check-label" for="inlineCheckbox-<%- cs.code %>"></label>
+                            </div>
+                        </td>
+                        <% } %>
+                    </tr>
+                    <% } %>
+                    </tbody>
+                </table>
+                <div class="text-danger">请勿全选(页面显示不下);谨慎修改别名(修改后,各页面概念将不一致)</div>
+            </div>
+            <form class="modal-footer" action="/subproj/col-set" method="post" onsubmit="return onSetCol();">
+                <input type="hidden" name="_csrf_j" value="<%= ctx.csrf %>">
+                <input type="hidden" name="col_set" value="">
+                <input type="hidden" name="col_type" value="list">
+                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
+                <button type="submit" class="btn btn-primary btn-sm" id="add-bd-ok">确定修改</button>
+            </form>
+        </div>
+    </div>
 </div>
 <script>
+    const onSetCol = function() {
+        const trs = $('tr[code]', '#col-set');
+        const colSet = [];
+        for (const tr of trs) {
+            colSet.push({ field: $(tr).attr('code'), show: $('input[type=checkbox]', tr)[0].checked, alias: ''});
+        }
+        $('input[name=col_set]').val(JSON.stringify(colSet));
+    };
+</script>
+<script>
     const accountList = JSON.parse('<%- JSON.stringify(accountList) %>');
     const accountGroup = JSON.parse('<%- JSON.stringify(accountGroup) %>');
     const permissionConst = JSON.parse('<%- JSON.stringify(permissionConst) %>');

+ 3 - 0
sql/update.sql

@@ -26,6 +26,9 @@ ADD COLUMN `settle_price` decimal(30, 8) NOT NULL DEFAULT 0 COMMENT '结算金
 ALTER TABLE `zh_contract_pay`
 ADD COLUMN `rela_stage` varchar(255) NULL DEFAULT NULL COMMENT '关联的标段期id或者独立支付期id' AFTER `remark`;
 
+ALTER TABLE `zh_project_col_set`
+ADD COLUMN `list` json NULL COMMENT '列表页列设置(见/const/project_setting)' AFTER `info`;
+
 ------------------------------------
 -- 表数据
 ------------------------------------