浏览代码

标段合同管理成员管理功能

ellisran 3 月之前
父节点
当前提交
56cc9908f0

+ 4 - 1
app/controller/sub_proj_setting_controller.js

@@ -635,13 +635,16 @@ module.exports = app => {
                         }
                         responseData.data.tourists = tourists;
                         responseData.data.scheduleAuditList = ctx.session.sessionProject.page_show.xxjd ? await ctx.service.scheduleAudit.getAllDataByCondition({ where: { tid: tender.id } }) : [];
-                        responseData.data.constructionAuditList = ctx.session.sessionProject.page_show.openConstruction ? await ctx.service.constructionAudit.getList(tender.id) : [];
+                        responseData.data.contractAuditList = ctx.subProject.page_show.openContract ? await ctx.service.contractAudit.getList({ tid: tender.id }) : [];
+                        responseData.data.constructionAuditList = ctx.subProject.page_show.openConstruction ? await ctx.service.constructionAudit.getList(tender.id) : [];
                         break;
                     case 'copy2otu':
                         if (data.userType === 'tourist') {
                             await ctx.service.tenderTourist.setOtherTender(data.tidList, data.auditList);
                         } else if (data.userType === 'schedule') {
                             await ctx.service.scheduleAudit.setOtherTender(data.tidList, data.auditList);
+                        } else if (data.userType === 'contract') {
+                            await ctx.service.contractAudit.setOtherTender(data.tidList, data.auditList);
                         } else if (data.userType === 'construction') {
                             await ctx.service.constructionAudit.setOtherTender(data.tidList, data.auditList);
                         } else {

+ 89 - 20
app/public/js/setting_manage.js

@@ -132,6 +132,14 @@ $(document).ready(() => {
     const cHeader = getObjHeight($(".c-header"));
     $('.tab-content').height($(window).height()-cHeader-90+53-46);
 
+    const tabTypes = {
+        tourist: '游客',
+        schedule: '投资进度',
+        contract: '合同管理',
+        construction: '施工日志',
+    };
+    const tabTypeKeys = ['tourist', 'schedule', 'contract', 'construction'];
+
     $('body').on('click', '.c-body .tender-info', function () {
         $('.c-body .tender-info').removeClass('table-warning');
         $(this).addClass('table-warning');
@@ -151,6 +159,7 @@ $(document).ready(() => {
             setShenpiHtml(result.shenpi, result.tender, result.revising);
             setTouristHtml(result.tourists);
             setScheduleHtml(result.scheduleAuditList);
+            setContractHtml(result.contractAuditList);
             setConstructionHtml(result.constructionAuditList);
             resetAddUserHtml();
         });
@@ -170,6 +179,8 @@ $(document).ready(() => {
                 $('#add_user_dropdownMenuButton').attr('data-type', 'tourist');
             } else if ($(this).attr('href') === '#tzpro') {
                 $('#add_user_dropdownMenuButton').attr('data-type', 'schedule');
+            } else if ($(this).attr('href') === '#htgl') {
+                $('#add_user_dropdownMenuButton').attr('data-type', 'contract');
             } else if ($(this).attr('href') === '#sgrz') {
                 $('#add_user_dropdownMenuButton').attr('data-type', 'construction');
             }
@@ -228,6 +239,17 @@ $(document).ready(() => {
     });
 
     // 权限更改
+    $('body').on('click', '#contract-users input[type="checkbox"]', function () {
+        const type = $(this).attr('data-type');
+        const value = $(this).is(':checked') ? 1 : 0;
+        const id = parseInt($(this).val());
+        const updateInfo = { id };
+        updateInfo[type] = value;
+        postData(`/sp/${spid}/contract/tender/${cur_tenderid}/audit/save`, { type: 'save-permission', updateData: updateInfo }, function (result) {
+        })
+    });
+
+    // 权限更改
     $('body').on('click', '#construction-users input[type="checkbox"]', function () {
         const id = parseInt($(this).data('id'));
         const prop = {
@@ -242,33 +264,27 @@ $(document).ready(() => {
         });
     });
 
-    // 移除游客用户
-    $('body').on('click', '#tourist-users .remove-tourist-user', function () {
-        $('#remove_user_type').val('tourist');
-        $('#remove_user_id').val($(this).data('id'));
-    });
-
-    // 移除投资进度用户
-    $('body').on('click', '#schedule-users .remove-schedule-user', function () {
-        $('#remove_user_type').val('schedule');
-        $('#remove_user_id').val($(this).data('id'));
-    });
-
-    // 移除施工日志用户
-    $('body').on('click', '#construction-users .remove-construction-user', function () {
-        $('#remove_user_type').val('construction');
-        $('#remove_user_id').val($(this).data('id'));
-    });
+    for (const key of tabTypeKeys) {
+        $('body').on('click', `#${key}-users .remove-${key}-user`, function () {
+            $('#remove_user_type').val(key);
+            $('#remove_user_id').val($(this).data('id'));
+        });
+    }
 
     // 移除用户确定
     $('#remove_user_btn').click(function () {
         const type = $('#remove_user_type').val();
-        if (type !== 'tourist' && type !== 'schedule' && type !== 'construction') {
+        if (tabTypeKeys.indexOf(type) === -1) {
             toastr.error('参数有误');
             return;
         }
         const id = parseInt($('#remove_user_id').val());
-        if (type === 'construction') {
+        if (type === 'contract') {
+            postData('/sp/' + spid + '/contract/tender/' + cur_tenderid + '/audit/save', { type: 'del-audit', id }, function (data) {
+                $('#'+ type + '-users').find('tr[data-id="'+ id +'"]').remove();
+                $('#remove-user').modal('hide');
+            });
+        } else if (type === 'construction') {
             postData('/sp/' + spid + '/construction/' + cur_tenderid + '/audit/save', { type: 'del-audit', id }, function (data) {
                 $('#'+ type + '-users').find('tr[data-id="'+ id +'"]').remove();
                 $('#remove-user').modal('hide');
@@ -437,6 +453,26 @@ $(document).ready(() => {
                                 </tr>`;
                     $('#schedule-users').append(html);
                 });
+            } else if (type === 'contract') {
+                const user = _.find(accountList, function (item) {
+                    return item.id === id;
+                });
+                const saIdList = [];
+                for (let i = 0; i < $('#contract-users tr').length; i++) {
+                    saIdList.push(parseInt($('#contract-users tr').eq(i).data('uid')));
+                }
+                if (_.includes(saIdList, id)) {
+                    toastr.error('该用户已存在列表中,无需重复添加');
+                    return;
+                }
+
+                const prop = {
+                    id: id,
+                    type: 'add-audit',
+                };
+                postData('/sp/' + spid + '/contract/tender/' + cur_tenderid + '/audit/save', prop, function (datas) {
+                    setContractHtml(datas);
+                });
             } else if (type === 'construction') {
                 const user = _.find(accountList, function (item) {
                     return item.id === id;
@@ -475,7 +511,7 @@ $(document).ready(() => {
         if (saIdList.length > 0) {
             $('#bdcopy').modal('show');
         } else {
-            toastr.warning('未存在'+ (userType === 'tourist' ? '游客' : userType === 'schedule' ? '投资进度' : userType === 'construction' ? '施工日志' : '') +'用户账号,无法应用至其他标段');
+            toastr.warning('未存在'+ tabTypes[userType] +'用户账号,无法应用至其他标段');
             return;
         }
     });
@@ -593,6 +629,13 @@ $(document).ready(() => {
                     permission = scPermission.show;
                 }
                 userData.permission = permission;
+            } else if (userType === 'contract') {
+                userData.permission = {
+                    add: $('#contract-users tr').eq(i).find('input[data-type="permission_add"]').eq(0).is(':checked') ? 1 : 0,
+                    edit: $('#contract-users tr').eq(i).find('input[data-type="permission_edit"]').eq(0).is(':checked') ? 1 : 0,
+                    showUnit: $('#contract-users tr').eq(i).find('input[data-type="permission_show_unit"]').eq(0).is(':checked') ? 1 : 0,
+                    showNode: $('#contract-users tr').eq(i).find('input[data-type="permission_show_node"]').eq(0).is(':checked') ? 1 : 0,
+                }
             } else if (userType === 'construction') {
                 userData.is_report = $('#construction-users tr').eq(i).find('input[type="checkbox"]').eq(0).is(':checked') ? 1 : 0;
             }
@@ -837,6 +880,32 @@ function setScheduleHtml(scheduleAuditList) {
     $('#schedule-users').html(html);
 }
 
+function setContractHtml(datas) {
+    let list = '';
+    for (const ca of datas) {
+        list += `<tr data-uid="${ca.uid}" data-id="${ca.id}">
+                            <td>${ca.name}</td>
+                            <td>${ca.role}</td>
+                            <td class="text-center">
+                                <input type="checkbox" class="permission-checkbox" data-type="permission_edit" value="${ca.id}" ${ca.permission_edit ? 'checked' : ''}>
+                            </td>
+                            <td class="text-center">
+                                <input type="checkbox" class="permission-checkbox" data-type="permission_add" value="${ca.id}" ${ca.permission_add ? 'checked' : ''}>
+                            </td>
+                            <td class="text-center">
+                                <input type="checkbox" class="permission-checkbox" data-type="permission_show_unit" value="${ca.id}" ${ca.permission_show_unit ? 'checked' : ''}>
+                            </td>
+                            <td class="text-center">
+                                <input type="checkbox" class="permission-checkbox" data-type="permission_show_node" value="${ca.id}" ${ca.permission_show_node ? 'checked' : ''}>
+                            </td>
+                            <td class="text-center">
+                                <a href="#remove-user1" data-toggle="modal" data-target="#remove-user" class="btn btn-outline-danger btn-sm ml-1 remove-contract-user" data-id="${ca.id}">移除</a>
+                            </td>
+                        </tr>`;
+    }
+    $('#contract-users').html(list);
+}
+
 function setConstructionHtml(constructionAuditList) {
     let html = '';
     if (constructionAuditList.length > 0) {

+ 6 - 2
app/service/contract_audit.js

@@ -112,10 +112,14 @@ module.exports = app => {
                         if (delId) deleteIdData.push(delId.id);
                         if (user.uid !== t.user_id) {
                             insertData.push({
+                                spid: null,
                                 tid: t.id,
                                 uid: user.uid,
-                                is_report: user.is_report,
-                                in_time: new Date(),
+                                permission_add: user.permission.add,
+                                permission_edit: user.permission.edit,
+                                permission_show_unit: user.permission.showUnit,
+                                permission_show_node: user.permission.showNode,
+                                create_time: new Date(),
                             });
                         }
                     }

+ 33 - 5
app/view/sp_setting/manage.ejs

@@ -23,7 +23,10 @@
                     <% if (ctx.session.sessionProject.page_show.xxjd) { %>
                     <a class="nav-item nav-link" data-toggle="tab" href="#tzpro" role="tab">投资进度</a>
                     <% } %>
-                    <% if (ctx.session.sessionProject.page_show.openConstruction) { %>
+                    <% if (ctx.subProject.page_show.openContract) { %>
+                    <a class="nav-item nav-link" data-toggle="tab" href="#htgl" role="tab">合同管理</a>
+                    <% } %>
+                    <% if (ctx.subProject.page_show.openConstruction) { %>
                     <a class="nav-item nav-link" data-toggle="tab" href="#sgrz" role="tab">施工日志</a>
                     <% } %>
 <!--                    <a class="nav-item nav-link" data-toggle="tab" href="#subadmin" role="tab">标段管理员</a>-->
@@ -64,7 +67,7 @@
                     </div>
                     <!--游客账号 -->
                     <div id="guest" class="tab-pane">
-                        <div class="col-8" style="max-width: 500px">
+                        <div class="col-8" style="max-width: 800px">
                             <table class="table table-hover table-bordered table-sm">
                                 <thead>
                                 <tr>
@@ -83,7 +86,7 @@
                     <% if (ctx.session.sessionProject.page_show.xxjd) { %>
                     <!--投资进度 -->
                     <div id="tzpro" class="tab-pane">
-                        <div class="col-8" style="max-width: 500px">
+                        <div class="col-8" style="max-width: 800px">
                             <table class="table table-hover table-bordered table-sm">
                                 <thead>
                                 <tr>
@@ -157,10 +160,35 @@
                         </div>
                     </div>
                     <% } %>
-                    <% if (ctx.session.sessionProject.page_show.openConstruction) { %>
+                    <% if (ctx.subProject.page_show.openContract) { %>
+                    <!--合同管理 -->
+                    <div id="htgl" class="tab-pane">
+                        <div class="col-8" style="max-width: 800px">
+                            <table class="table table-hover table-bordered table-sm">
+                                <thead class="text-center">
+                                <tr>
+                                    <th rowspan="2" class="align-middle">用户名</th>
+                                    <th rowspan="2" class="align-middle">角色/职位</th>
+                                    <th rowspan="2" class="align-middle">编辑节点</th>
+                                    <th rowspan="2" class="align-middle">添加合同</th>
+                                    <th colspan="2">授权节点合同查看范围</th>
+                                    <th rowspan="2" class="align-middle">操作</th>
+                                </tr>
+                                <tr>
+                                    <th>本单位</th>
+                                    <th>本节点</th>
+                                </tr>
+                                </thead>
+                                <tbody id="contract-users">
+                                </tbody>
+                            </table>
+                        </div>
+                    </div>
+                    <% } %>
+                    <% if (ctx.subProject.page_show.openConstruction) { %>
                     <!--施工日志 -->
                     <div id="sgrz" class="tab-pane">
-                        <div class="col-8" style="max-width: 500px">
+                        <div class="col-8" style="max-width: 800px">
                             <table class="table table-hover table-bordered table-sm">
                                 <thead>
                                 <tr>

+ 1 - 1
app/view/sp_setting/manage_modal.ejs

@@ -221,7 +221,7 @@
                 <input type="hidden" id="remove_user_type">
                 <input type="hidden" id="remove_user_id">
                 <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
-                <button type="button" class="btn btn-sm btn-sm btn-primary" id="remove_user_btn">确定移除</button>
+                <button type="button" class="btn btn-sm btn-sm btn-danger" id="remove_user_btn">确定移除</button>
             </div>
         </div>
     </div>