فهرست منبع

标段管理增加施工日志用户管理

ellisran 1 سال پیش
والد
کامیت
6aa6392127
4فایلهای تغییر یافته به همراه159 افزوده شده و 10 حذف شده
  1. 3 0
      app/controller/setting_controller.js
  2. 86 10
      app/public/js/setting_manage.js
  3. 35 0
      app/service/construction_audit.js
  4. 35 0
      app/view/setting/manage.ejs

+ 3 - 0
app/controller/setting_controller.js

@@ -1314,12 +1314,15 @@ 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) : [];
                         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 === 'construction') {
+                            await ctx.service.constructionAudit.setOtherTender(data.tidList, data.auditList);
                         } else {
                             throw '参数有误';
                         }

+ 86 - 10
app/public/js/setting_manage.js

@@ -145,6 +145,7 @@ $(document).ready(() => {
             setShenpiHtml(result.shenpi, result.tender, result.revising);
             setTouristHtml(result.tourists);
             setScheduleHtml(result.scheduleAuditList);
+            setConstructionHtml(result.constructionAuditList);
             resetAddUserHtml();
         });
     });
@@ -163,6 +164,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') === '#sgrz') {
+                $('#add_user_dropdownMenuButton').attr('data-type', 'construction');
             }
         }
     });
@@ -218,6 +221,21 @@ $(document).ready(() => {
         });
     });
 
+    // 权限更改
+    $('body').on('click', '#construction-users input[type="checkbox"]', function () {
+        const id = parseInt($(this).data('id'));
+        const prop = {
+            type: 'save-report',
+            updateData: {
+                id,
+                is_report: $(this).is(':checked') ? 1 : 0,
+            }
+        };
+        const _self = $(this);
+        postData('/construction/' + cur_tenderid + '/audit/save', prop, function (data) {
+        });
+    });
+
     // 移除游客用户
     $('body').on('click', '#tourist-users .remove-tourist-user', function () {
         $('#remove_user_type').val('tourist');
@@ -230,22 +248,36 @@ $(document).ready(() => {
         $('#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'));
+    });
+
     // 移除用户确定
     $('#remove_user_btn').click(function () {
         const type = $('#remove_user_type').val();
-        if (type !== 'tourist' && type !== 'schedule') {
+        if (type !== 'tourist' && type !== 'schedule' && type !== 'construction') {
             toastr.error('参数有误');
             return;
         }
         const id = parseInt($('#remove_user_id').val());
-        const prop = {
-            id: id,
-            type: 'del',
-        };
-        postData('/tender/' + cur_tenderid + '/' + type + '/audit/save', prop, function (data) {
-            $('#'+ type + '-users').find('tr[data-id="'+ id +'"]').remove();
-            $('#remove-user').modal('hide');
-        });
+        if (type === 'construction') {
+            postData('/construction/' + cur_tenderid + '/audit/save', { type: 'del-audit', id }, function (data) {
+                $('#'+ type + '-users').find('tr[data-id="'+ id +'"]').remove();
+                $('#remove-user').modal('hide');
+            });
+        } else {
+            const prop = {
+                id: id,
+                type: 'del',
+            };
+            postData('/tender/' + cur_tenderid + '/' + type + '/audit/save', prop, function (data) {
+                $('#'+ type + '-users').find('tr[data-id="'+ id +'"]').remove();
+                $('#remove-user').modal('hide');
+            });
+        }
+
     });
 
     // 投资进度
@@ -399,6 +431,26 @@ $(document).ready(() => {
                                 </tr>`;
                     $('#schedule-users').append(html);
                 });
+            } else if (type === 'construction') {
+                const user = _.find(accountList, function (item) {
+                    return item.id === id;
+                });
+                const saIdList = [];
+                for (let i = 0; i < $('#construction-users tr').length; i++) {
+                    saIdList.push(parseInt($('#construction-users tr').eq(i).data('uid')));
+                }
+                if (_.includes(saIdList, id)) {
+                    toastr.error('该用户已存在列表中,无需重复添加');
+                    return;
+                }
+
+                const prop = {
+                    id: id,
+                    type: 'add-audit',
+                };
+                postData('/construction/' + cur_tenderid + '/audit/save', prop, function (datas) {
+                    setConstructionHtml(datas);
+                });
             }
         }
     });
@@ -417,7 +469,7 @@ $(document).ready(() => {
         if (saIdList.length > 0) {
             $('#bdcopy').modal('show');
         } else {
-            toastr.warning('未存在'+ (userType === 'tourist' ? '游客' : '投资进度') +'用户账号,无法应用至其他标段');
+            toastr.warning('未存在'+ (userType === 'tourist' ? '游客' : userType === 'schedule' ? '投资进度' : userType === 'construction' ? '施工日志' : '') +'用户账号,无法应用至其他标段');
             return;
         }
     });
@@ -535,6 +587,8 @@ $(document).ready(() => {
                     permission = scPermission.show;
                 }
                 userData.permission = permission;
+            } else if (userType === 'construction') {
+                userData.is_report = $('#construction-users tr').eq(i).find('input[type="checkbox"]').eq(0).is(':checked') ? 1 : 0;
             }
             saIdList.push(userData);
         }
@@ -727,3 +781,25 @@ function setScheduleHtml(scheduleAuditList) {
     }
     $('#schedule-users').html(html);
 }
+
+function setConstructionHtml(constructionAuditList) {
+    let html = '';
+    if (constructionAuditList.length > 0) {
+        for (const sa of constructionAuditList) {
+            html += `<tr data-uid="${sa.uid}" data-id="${sa.id}">
+                                    <td>${sa.name}</td>
+                                    <td>${sa.role}</td>
+                                    <td class="text-center">
+                                        <div class="custom-control custom-checkbox mb-2">
+                                            <input type="checkbox" data-id="${sa.id}" id="${sa.id}_construction" name="customCheckbox" class="custom-control-input" ${sa.is_report ? 'checked' : ''}>
+                                            <label class="custom-control-label" for="${sa.id}_construction"></label>
+                                        </div>
+                                    </td>
+                                    <td class="text-center">
+                                        <a href="#remove-user1" data-id="${sa.id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-construction-user">移除</a>
+                                    </td>
+                                </tr>`;
+        }
+    }
+    $('#construction-users').html(html);
+}

+ 35 - 0
app/service/construction_audit.js

@@ -87,6 +87,41 @@ module.exports = app => {
             const params = [this.tableName, this.ctx.service.projectAccount.tableName, tid];
             return await this.db.query(sql, params);
         }
+
+        async setOtherTender(tidList, userList) {
+            // 根据标段找出创建人去除,已存在的先删除再插入
+            const transaction = await this.db.beginTransaction();
+            try {
+                const tenderList = await this.ctx.service.tender.getAllDataByCondition({
+                    columns: ['id', 'user_id'],
+                    where: { id: tidList.split(',') },
+                });
+                const oldTouristList = await this.getAllDataByCondition({ where: { tid: tidList.split(',') } });
+                const insertData = [];
+                const deleteIdData = [];
+                for (const user of userList) {
+                    for (const t of tenderList) {
+                        const delId = this._.find(oldTouristList, { tid: t.id, uid: user.uid });
+                        if (delId) deleteIdData.push(delId.id);
+                        if (user.uid !== t.user_id) {
+                            insertData.push({
+                                tid: t.id,
+                                uid: user.uid,
+                                is_report: user.is_report,
+                                in_time: new Date(),
+                            });
+                        }
+                    }
+                }
+                if (deleteIdData.length > 0) await transaction.delete(this.tableName, { id: deleteIdData });
+                if (insertData.length > 0) await transaction.insert(this.tableName, insertData);
+                await transaction.commit();
+                return true;
+            } catch (err) {
+                await transaction.rollback();
+                throw err;
+            }
+        }
     }
     return ConstructionAudit;
 };

+ 35 - 0
app/view/setting/manage.ejs

@@ -22,6 +22,9 @@
                     <% 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) { %>
+                    <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>-->
                     <div class="ml-auto" id="user-set" style="display: none">
                         <div class="row">
@@ -153,6 +156,38 @@
                         </div>
                     </div>
                     <% } %>
+                    <% if (ctx.session.sessionProject.page_show.openConstruction) { %>
+                    <!--施工日志 -->
+                    <div id="sgrz" class="tab-pane">
+                        <div class="col-8" style="max-width: 500px">
+                            <table class="table table-hover table-bordered table-sm">
+                                <thead>
+                                <tr>
+                                    <th class="text-center" width="100px">用户</th>
+                                    <th class="text-center" width="120px">职位/角色</th>
+                                    <th class="text-center" width="60px">填报人</th>
+                                    <th class="text-center" >操作</th>
+                                </tr>
+                                </thead>
+                                <tbody id="construction-users">
+                                <tr>
+                                    <td>陈特</td>
+                                    <td>业主</td>
+                                    <td class="text-center">
+                                        <div class="custom-control custom-checkbox mb-2">
+                                            <input type="checkbox" id="customRadio301" name="customCheckbox" class="custom-control-input">
+                                            <label class="custom-control-label" for="customRadio301"></label>
+                                        </div>
+                                    </td>
+                                    <td class="text-center">
+                                        <a href="#remove-user1" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger">移除</a>
+                                    </td>
+                                </tr>
+                                </tbody>
+                            </table>
+                        </div>
+                    </div>
+                    <% } %>
                     <!--标段管理员 -->
                     <div id="subadmin" class="tab-pane">
                         <div class="col-6">