浏览代码

变更令修改

laiguoran 4 年之前
父节点
当前提交
c0cdbf0010

+ 66 - 0
app/controller/change_controller.js

@@ -821,6 +821,72 @@ module.exports = app => {
             }
         }
 
+        // 审批相关
+        /**
+         * 添加审批人
+         * @param ctx
+         * @return {Promise<void>}
+         */
+        async addAudit(ctx) {
+            try {
+                const data = JSON.parse(ctx.request.body.data);
+                const id = this.app._.toInteger(data.auditorId);
+                if (isNaN(id) || id <= 0) {
+                    throw '参数错误';
+                }
+                // 检查权限等
+                if (ctx.change.uid !== ctx.session.sessionUser.accountId) {
+                    throw '您无权添加审核人';
+                }
+                if (ctx.change.status === audit.flow.status.checking || ctx.change.status === audit.flow.status.checked) {
+                    throw '当前不允许添加审核人';
+                }
+
+                const auditorList = await ctx.service.changeAudit.getAuditors(ctx.change.cid, ctx.change.times);
+                // 检查审核人是否已存在
+                const exist = this.app._.find(auditorList, { uid: id });
+                if (exist) {
+                    throw '该审核人已存在,请勿重复添加';
+                }
+                const is_gdzs = ctx.tender.info.shenpi.change === shenpiConst.sp_status.gdzs ? 1 : 0;
+                const result = await ctx.service.changeAudit.addAuditor(ctx.change.cid, id, ctx.change.times, is_gdzs);
+                if (!result) {
+                    throw '添加审核人失败';
+                }
+
+                // const auditors = await ctx.service.changeAudit.getAuditorsWithOwner(ctx.change.id, ctx.change.times);
+                const auditors = null;
+                ctx.body = { err: 0, msg: '', data: auditors };
+            } catch (err) {
+                this.log(err);
+                ctx.body = { err: 1, msg: err.toString(), data: null };
+            }
+        }
+        /**
+         * 移除审批人
+         * @param ctx
+         * @return {Promise<void>}
+         */
+        async deleteAudit(ctx) {
+            try {
+                const data = JSON.parse(ctx.request.body.data);
+                const id = data.auditorId instanceof Number ? data.auditorId : this.app._.toNumber(data.auditorId);
+                if (isNaN(id) || id <= 0) {
+                    throw '参数错误';
+                }
+
+                const result = await ctx.service.changeAudit.deleteAuditor(ctx.change.cid, id, ctx.change.times);
+                if (!result) {
+                    throw '移除审核人失败';
+                }
+
+                const auditors = null;
+                ctx.body = { err: 0, msg: '', data: auditors };
+            } catch (err) {
+                ctx.body = { err: 1, msg: err.toString(), data: null };
+            }
+        }
+
         async defaultBills(ctx) {
             try {
                 const ledgerData = await ctx.service.ledger.getData(ctx.tender.id);

+ 212 - 0
app/public/js/change_audit.js

@@ -0,0 +1,212 @@
+'use strict';
+
+/**
+ *
+ *
+ * @author Mai
+ * @date 2019/2/27
+ * @version
+ */
+
+$(document).ready(function () {
+    let timer = null;
+    let oldSearchVal = null;
+    // 获取审核相关url
+    function getUrlPre () {
+        const path = window.location.pathname.split('/');
+        return _.take(path, 6).join('/');
+    }
+
+    $('#gr-search').bind('input propertychange', function(e) {
+        oldSearchVal = e.target.value;
+        timer && clearTimeout(timer);
+        timer = setTimeout(() => {
+            const newVal = $('#gr-search').val();
+            let html = '';
+            if (newVal && newVal === oldSearchVal) {
+                accountList.filter(item => item && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
+                    html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
+                        <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
+                                class="ml-auto">${item.mobile || ''}</span></p>
+                        <span class="text-muted">${item.role || ''}</span>
+                    </dd>`;
+                });
+                $('.book-list').empty();
+                $('.book-list').append(html);
+            } else {
+                if (!$('.acc-btn').length) {
+                    accountGroup.forEach((group, idx) => {
+                        if (!group) return;
+                        html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
+                        </a> ${group.groupName}</dt>
+                        <div class="dd-content" data-toggleid="${idx}">`;
+                        group.groupList.forEach(item => {
+                            // if (item.id !== changesUid) {
+                            html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
+                                    <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
+                                            class="ml-auto">${item.mobile || ''}</span></p>
+                                    <span class="text-muted">${item.role || ''}</span>
+                                </dd>`;
+                            // }
+                        });
+                        html += '</div>';
+                    });
+                    $('.book-list').empty();
+                    $('.book-list').append(html);
+                }
+            }
+        }, 400);
+    });
+
+    // 添加审批流程按钮逻辑
+    $('.book-list').on('click', 'dt', function () {
+        const idx = $(this).find('.acc-btn').attr('data-groupid');
+        const type = $(this).find('.acc-btn').attr('data-type');
+        if (type === 'hide') {
+            $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
+                $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o')
+                $(this).find('.acc-btn').attr('data-type', 'show')
+
+            })
+        } else {
+            $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
+                $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square')
+                $(this).find('.acc-btn').attr('data-type', 'hide')
+            })
+        }
+        return false
+    });
+
+    $('#hideSp').click(function () {
+        $('#sub-sp2').modal('hide');
+    });
+
+    // 添加到审批流程中
+    $('dl').on('click', 'dd', function () {
+        const id = parseInt($(this).data('id'));
+        if (id) {
+            const auditListIdData = [];
+            $('#auditList li').each(function () {
+                const aid = $(this).data('auditid');
+                auditListIdData.push(aid);
+            });
+            if (!in_array(auditListIdData, id)) {
+                postData(getUrlPre() + '/audit/add', { auditorId: id }, (datas) => {
+                    if (shenpi_status === shenpiConst.sp_status.gdzs) {
+                        auditListIdData.splice(-1,0,id);
+                    } else {
+                        auditListIdData.push(id);
+                    }
+                    const html = [];
+                    const auditorshtml = [];
+                    auditListIdData.unshift(changesUid);
+                    for (const [index,ids] of auditListIdData.entries()) {
+                        const accountInfo = _.find(accountList, { 'id': ids });
+                        if (index !== 0) {
+                            const user = accountInfo.id + '/%/' + accountInfo.name + '/%/' + accountInfo.role + '/%/' + accountInfo.company;
+                            html.push('<li class="list-group-item" data-auditmsg="' + user + '" data-auditid="'+ ids +'">');
+                            if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== auditListIdData.length)) {
+                                html.push('<a href="javascript:void(0);" class="text-danger pull-right remove_audit_btn">移除</a>');
+                            }
+                            html.push('<span>');
+                            html.push(index + ' ');
+                            html.push('</span> ');
+                            html.push(accountInfo.name + ' ');
+                            html.push('<small class="text-muted">');
+                            html.push(accountInfo.role);
+                            html.push('</small>');
+                            html.push('<p class="m-0 ml-2"><small class="text-muted">' + accountInfo.company + '</small></p>');
+                            html.push('</li>');
+                        }
+                        // 添加新审批人流程修改
+                        auditorshtml.push('<li class="list-group-item" ' + (index !== 0 ? 'data-auditid="' + accountInfo.id + '"' : '') + '>');
+                        auditorshtml.push('<i class="fa ' + (index+1 === auditListIdData.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i> ');
+                        auditorshtml.push(accountInfo.name + ' <small class="text-muted">' + accountInfo.role + '</small>');
+                        if (index === 0) {
+                            auditorshtml.push('<span class="pull-right">原报</span>');
+                        } else if (index+1 === auditListIdData.length) {
+                            auditorshtml.push('<span class="pull-right">终审</span>');
+                        } else {
+                            auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
+                        }
+                        auditorshtml.push('</li>');
+                    }
+                    $('#auditList').html(html.join(''));
+                    $('#shenpi-audit-list').html(auditorshtml.join(''));
+                });
+            } else {
+                toastr.error('审批流程中已存在该用户!');
+            }
+        }
+    });
+
+    // 移除审批流程的审批人
+    $('body').on('click', '.remove_audit_btn', function () {
+        const uid = $(this).parents('li').attr('data-auditid');
+        const li = $(this).parent();
+        const data = {
+            auditorId: uid,
+        };
+        postData(getUrlPre() + '/audit/delete', data, (result) => {
+            li.remove();
+            let index = 1;
+            $('#auditList li').each(function () {
+                $(this).children('span').text(index);
+                index++;
+            });
+            if (index === 1) {
+                $('#account_list').val(0);
+            }
+
+            // 重新上报时。移除审批流程
+            // 令最后一个图标转换
+            $('#shenpi-audit-list li[data-auditid="' + uid + '"]').remove();
+            if ($('#shenpi-audit-list li').length !== 0 && !$('#shenpi-audit-list li i').hasClass('fa-stop-circle')) {
+                $('#shenpi-audit-list li').eq($('#shenpi-audit-list li').length-1).children('i')
+                    .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle');
+            }
+            for (let i = 0; i < $('#shenpi-audit-list li').length; i++) {
+                $('#shenpi-audit-list li').eq(i).find('.pull-right').text(i === 0 ? '原报' : (i+1 === $('#shenpi-audit-list li').length ? '终' : transFormToChinese(i)) + '审');
+            }
+            $('#shenpi-audit-list li i').eq(0).removeClass('fa-chevron-circle-down').addClass('fa-play-circle');
+        });
+    });
+
+    $('a[f-target]').click(function () {
+        $($(this).attr('f-target')).modal('show');
+    });
+
+    // 多层modal关闭后的滚动bug修复
+    $('#sp-list').on('hidden.bs.modal', function (e) {
+        $(document.body).addClass('modal-open');
+    });
+});
+// 检查上报情况
+function checkAuditorFrom () {
+    if ($('#auditors li').length === 0) {
+        if(shenpi_status === shenpiConst.sp_status.gdspl) {
+            toastr.error('请联系管理员添加审批人');
+        } else {
+            toastr.error('请先选择审批人,再上报数据');
+        }
+        return false;
+    }
+    $('#hide-all').show();
+}
+// texterea换行
+function auditCheck(i) {
+    const inlineRadio1 = $('#inlineRadio1:checked').val()
+    const inlineRadio2 = $('#inlineRadio2:checked').val()
+    const opinion = $('textarea[name="opinion"]').eq(i).val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
+    $('textarea[name="opinion"]').eq(i).val(opinion);
+    if (i === 1) {
+        if (!inlineRadio1 && !inlineRadio2) {
+            if (!$('#warning-text').length) {
+                $('#reject-process').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
+            }
+            return false;
+        }
+        if ($('#warning-text').length) $('#warning-text').remove()
+    }
+    return true;
+}

+ 15 - 6
app/public/js/change_information.js

@@ -23,6 +23,16 @@ $(document).ready(() => {
         changeSpreadSheet.setColumnVisible(3,$(this).is(':checked'), GC.Spread.Sheets.SheetArea.viewport);
     });
 
+    //tab change
+    $('a[data-toggle="tab"]').on('shown.bs.tab', function () {
+        const tab = $(this).data('tab');
+        if (tab === 'bgfujian') {
+            $('#fujian_btn').show();
+        } else {
+            $('#fujian_btn').hide();
+        }
+    });
+
     $('#add-bj').on('click', 'input[type="checkbox"]', function () {
         const isCheck = $(this).prop('checked');
         if (isCheck) {
@@ -71,15 +81,14 @@ $(document).ready(() => {
             let index = $('#attList tr').length + 1;
             for (const fileInfo of data) {
                 html += '<tr> ' +
-                    `<td width="25"><input type="checkbox" class="check-file" file-id=${fileInfo.id}></td>` +
+                    `<td width="20"><input type="checkbox" class="check-file" file-id=${fileInfo.id}></td>` +
                     '<td>' + index + '</td> ' +
                     `<td><a href="javascript: void(0);" class="file-atn" f-id="${fileInfo.id}">${fileInfo.filename}${fileInfo.fileext}</a></td>`+
-                    '<td>' + fileInfo.filesize + '</td> ' +
-                    '<td>' + fileInfo.in_time + '</td> ' +
-                    `<td><a href="/change/download/file/${fileInfo.id}" class="btn btn-light btn-sm" title="下载"><span class="fa fa-download text-primary"></span></a>`+
+                    '<td>' + fileInfo.in_time + '<br>' + fileInfo.filesize + '</td> ' +
+                    `<td><a href="/change/download/file/${fileInfo.id}" class="mr-2" title="下载"><span class="fa fa-download text-primary"></span></a>`+
                     ( auditStatus === 4 ?
-                        fileInfo.extra_upload ? `<a class="btn btn-light btn-sm delete-file" data-attid="${fileInfo.id}"  title="删除附件"><span class="fa fa-trash text-danger"></span></a>` : ''
-                        : ` <a class="btn btn-light btn-sm delete-file" data-attid="${fileInfo.id}"  title="删除附件"><span class="fa fa-trash text-danger"></span></a>`)+
+                        fileInfo.extra_upload ? `<a class="mr-2 delete-file" data-attid="${fileInfo.id}"  title="删除附件"><span class="fa fa-trash text-danger"></span></a>` : ''
+                        : ` <a href="javascript:void(0);" class="mr-2 delete-file" data-attid="${fileInfo.id}"  title="删除附件"><span class="fa fa-trash text-danger"></span></a>`)+
                     `</td>`+
                     // '<td> <a class="btn btn-light btn-sm delete-file" data-attid="' + fileInfo.id + '"  title="删除附件"><span class="fa fa-trash text-danger"></span></a> </td> ' +
                     '</tr>';

+ 17 - 7
app/public/js/change_information_set.js

@@ -407,7 +407,7 @@ $(document).ready(() => {
         const isCheck = $(this).hasClass('table-success') ? true : false;
         const data_bwmx = $(this).attr('data-bwmx').split('$#$');
         const isDeal = $(this).data('gcl') !== undefined ? true : false;
-        let codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id="0"><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox"></td></tr>';
+        let codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id=""><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox"></td></tr>';
         if (isDeal) {
             const lid = $(this).data('lid');
             let gcl = _.find(gclGatherData, function (item) {
@@ -419,7 +419,7 @@ $(document).ready(() => {
             codeHtml = '';
             for (const leaf of gcl.leafXmjs) {
                 const quantity = leaf.quantity !== undefined && leaf.quantity !== null ? leaf.quantity : 0;
-                const gcl_id = leaf.gcl_id ? leaf.gcl_id : '0';
+                const gcl_id = leaf.gcl_id ? leaf.gcl_id : '';
                 const bwmx = leaf.bwmx !== undefined ? leaf.bwmx : '';
                 const isChecked = data_bwmx.indexOf(leaf.code + '!_!' + (leaf.jldy ? leaf.jldy : '') + '!_!' + (leaf.gcl_id ? leaf.gcl_id : '0') + '!_!' + (bwmx !== '' ? bwmx : leaf.jldy ? leaf.jldy : '') + '*;*' + quantity) !== -1 && isCheck ? 'checked' : '';
                 codeHtml += '<tr quantity="' + quantity + '" gcl_id="' + gcl_id + '"><td>' + leaf.code + '</td>' +
@@ -433,7 +433,7 @@ $(document).ready(() => {
                     '></td></tr>';
             }
         } else if (!isDeal && isCheck) {
-            codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id="0"><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox" checked></td></tr>';
+            codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id=""><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox" checked></td></tr>';
         }
         $('#code-list').attr('data-index', $(this).children('td').eq(0).text());
         $('#code-input').val('');
@@ -558,7 +558,7 @@ $(document).ready(() => {
         } else {
             makeCodeTable();
         }
-    })
+    });
 });
 function findDecimal(unit) {
     let value = precision.other.value;
@@ -600,7 +600,7 @@ function tableDataRemake(changeListData) {
                         });
                         console.log(leafInfo);
                         if (leafInfo) {
-                            pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' + (leafInfo.gcl_id ? leafInfo.gcl_id : '0') + '!_!' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : '') + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
+                            pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' + (leafInfo.gcl_id ? leafInfo.gcl_id : '') + '!_!' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : '') + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
                         } else {
                             toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
                             changeList.splice(index, 1);
@@ -625,7 +625,7 @@ function tableDataRemake(changeListData) {
                             return (item.bwmx === undefined || item.bwmx === clinfo.bwmx || item.jldy === clinfo.bwmx) && (item.quantity !== null ? item.quantity === parseFloat(clinfo.oamount) : 0 === parseFloat(clinfo.oamount));
                         });
                         if (leafInfo) {
-                            pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' + (leafInfo.gcl_id ? leafInfo.gcl_id : '0') + '!_!' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (leafInfo.jldy ? leafInfo.jldy : '')) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
+                            pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' + (leafInfo.gcl_id ? leafInfo.gcl_id : '') + '!_!' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (leafInfo.jldy ? leafInfo.jldy : '')) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
                         } else {
                             toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
                             changeList.splice(index, 1);
@@ -721,7 +721,7 @@ function remakeChangeSpread() {
                 gcl_id,
             };
             const radionInfo = changeList.find(function (info) {
-                return info.code === code && (info.lid == lid || parseInt(info.lid) === parseInt(lindex)) && info.bwmx === bwmx;
+                return info.code === code && (info.lid == lid || parseInt(info.lid) === parseInt(lindex)) && gcl_id == info.gcl_id && info.bwmx === bwmx;
             });
             if (radionInfo) {
                 trlist.camount = radionInfo.camount;
@@ -737,3 +737,13 @@ function remakeChangeSpread() {
     // changeList = newTableList.concat(changeWhiteList);
     return newTableList;
 }
+//判断元素是否在数组中,相当于php的in_array();
+function in_array(arr, obj) {
+    let i = arr.length;
+    while (i--) {
+        if (arr[i] == obj) {
+            return true;
+        }
+    }
+    return false;
+}

+ 10 - 10
app/public/js/change_set.js

@@ -404,7 +404,7 @@ $(document).ready(() => {
         const isCheck = $(this).hasClass('table-success') ? true : false;
         const data_bwmx = $(this).attr('data-bwmx').split('$#$');
         const isDeal = $(this).data('gcl') !== undefined ? true : false;
-        let codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id="0"><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox"></td></tr>';
+        let codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id=""><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox"></td></tr>';
         if (isDeal) {
             const lid = $(this).data('lid');
             let gcl = _.find(gclGatherData, function (item) {
@@ -416,9 +416,9 @@ $(document).ready(() => {
             codeHtml = '';
             for (const leaf of gcl.leafXmjs) {
                 const quantity = leaf.quantity !== undefined && leaf.quantity !== null ? leaf.quantity : 0;
-                const gcl_id = leaf.gcl_id ? leaf.gcl_id : '0';
+                const gcl_id = leaf.gcl_id ? leaf.gcl_id : '';
                 const bwmx = leaf.bwmx !== undefined ? leaf.bwmx : '';
-                const isChecked = data_bwmx.indexOf(leaf.code + '!_!' + (leaf.jldy ? leaf.jldy : '') + '!_!' + (leaf.gcl_id ? leaf.gcl_id : '0') + '!_!' + (bwmx !== '' ? bwmx : leaf.jldy ? leaf.jldy : '') + '*;*' + quantity) !== -1 && isCheck ? 'checked' : '';
+                const isChecked = data_bwmx.indexOf(leaf.code + '!_!' + (leaf.jldy ? leaf.jldy : '') + '!_!' + (leaf.gcl_id ? leaf.gcl_id : '') + '!_!' + (bwmx !== '' ? bwmx : leaf.jldy ? leaf.jldy : '') + '*;*' + quantity) !== -1 && isCheck ? 'checked' : '';
                 codeHtml += '<tr quantity="' + quantity + '" gcl_id="' + gcl_id + '"><td>' + leaf.code + '</td>' +
                     '<td>' + (leaf.jldy ? leaf.jldy: '') + '</td>' +
                     '<td>' + (leaf.dwgc ? leaf.dwgc : '') + '</td>' +
@@ -430,7 +430,7 @@ $(document).ready(() => {
                     '></td></tr>';
             }
         } else if (!isDeal && isCheck) {
-            codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id="0"><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox" checked></td></tr>';
+            codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'" gcl_id=""><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox" checked></td></tr>';
         }
         $('#code-list').attr('data-index', $(this).children('td').eq(0).text());
         $('#code-input').val('');
@@ -539,7 +539,7 @@ $(document).ready(() => {
         const lid = $(this).parents('tr').data('lid');
         const xmj_code = $(this).parents('tr').data('xmjcode') || '';
         const xmj_jldy = $(this).parents('tr').data('xmjjldy') || '';
-        const gcl_id = $(this).parents('tr').data('gclid') || '0';
+        const gcl_id = $(this).parents('tr').data('gclid') || '';
         const isWhite = !isNaN(lid) ? true : false;
         const tr = $('#list tr[data-lid="' + lid + '"]').eq(0);
         const site = parseInt($(this).parents('td').data('site'));
@@ -609,7 +609,7 @@ $(document).ready(() => {
         tr.children('td[data-site="6"]').children('input').attr('onkeyup','RegNum(this,event,'+ numdecimal +')');
         tr.children('td[data-site="8"]').children('input').val(scnum);
         tr.children('td[data-site="8"]').children('input').attr('onkeyup','RegNum(this,event,'+ numdecimal +')');
-        const trlist = [code,name,bwmx,unit,price,oamount,scnum,detail,0,'',''];
+        const trlist = [code,name,bwmx,unit,price,oamount,scnum,detail,0,'','',''];
         let changelist = $('#change-whitelist').val().split('^_^');
         changelist.splice(index, 1, trlist.join('*;*'));
         $('#change-whitelist').val(changelist.join('^_^'));
@@ -726,7 +726,7 @@ function tableDataRemake(changeListData) {
                     });
                     console.log(leafInfo);
                     if (leafInfo) {
-                        pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' + (leafInfo.gcl_id ? leafInfo.gcl_id : '0') + '!_!' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : '') + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
+                        pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' + (leafInfo.gcl_id ? leafInfo.gcl_id : '') + '!_!' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : '') + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
                     } else {
                         toastr.warning('台账清单列表已不存在'+ clinfo[0] +',已更新变更清单列表');
                         changeList.splice(index, 1);
@@ -751,7 +751,7 @@ function tableDataRemake(changeListData) {
                         return (item.bwmx === undefined || item.bwmx === clinfo[2] || item.jldy === clinfo[2]) && (item.quantity !== null ? item.quantity === parseFloat(clinfo[5]) : 0 === parseFloat(clinfo[5]));
                     });
                     if (leafInfo) {
-                        pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' + (leafInfo.gcl_id ? leafInfo.gcl_id : '0') + '!_!' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (leafInfo.jldy ? leafInfo.jldy : '')) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
+                        pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' + (leafInfo.gcl_id ? leafInfo.gcl_id : '') + '!_!' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (leafInfo.jldy ? leafInfo.jldy : '')) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
                     } else {
                         toastr.warning('台账清单列表已不存在'+ clinfo[0] +',已更新变更清单列表');
                         changeList.splice(index, 1);
@@ -903,7 +903,7 @@ function maketablelist(status){
             let bwmx = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[3] : '';
             let xmj_code = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[0] : '';
             let xmj_jldy = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[1] : '';
-            let gcl_id = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[2] : '0';
+            let gcl_id = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[2] : '';
             let trlist = [code, name, bwmx, unit, price, oamount, scnum, '', lid, xmj_code, xmj_jldy, gcl_id];
             const radionInfo = radionList.find(function (item) {
                 const info = item.split('*;*');
@@ -959,7 +959,7 @@ function maketablelist(status){
     let radionWhiteList = $('#change-whitelist').val() !== '' ? $('#change-whitelist').val().split('^_^') : [];
     //判断是否添加空白清单
     if(status == 'addwhite'){
-        let trlist = ['','','','','',makedecimalzero(findDecimal(3)),makedecimalzero(findDecimal(3)),'',0, '', '', '0'];
+        let trlist = ['','','','','',makedecimalzero(findDecimal(3)),makedecimalzero(findDecimal(3)),'',0, '', '', ''];
         radionWhiteList.push(trlist.join('*;*'));
     }
 

+ 5 - 1
app/router.js

@@ -335,7 +335,11 @@ module.exports = app => {
     // 变更令 - 新版本
     app.get('/tender/:id/change/:cid/information', sessionAuth, tenderCheck, uncheckTenderCheck, changeCheck, changeAuditCheck, 'changeController.information');
     app.post('/tender/:id/change/:cid/information/save', sessionAuth, tenderCheck, uncheckTenderCheck, changeCheck, 'changeController.saveListsData');
-
+    app.post('/tender/:id/change/:cid/information/file/upload', sessionAuth, 'changeController.uploadFile');
+    app.post('/tender/:id/change/:cid/information/file/delete', sessionAuth, 'changeController.deleteFile');
+    app.post('/tender/:id/change/:cid/information/copy', sessionAuth, tenderCheck, uncheckTenderCheck, 'changeController.copyChange');
+    app.post('/tender/:id/change/:cid/information/audit/add', sessionAuth, tenderCheck, uncheckTenderCheck, changeCheck, 'changeController.addAudit');
+    app.post('/tender/:id/change/:cid/information/audit/delete', sessionAuth, tenderCheck, uncheckTenderCheck, changeCheck, 'changeController.deleteAudit');
     // 材料调差
     app.get('/tender/:id/measure/material', sessionAuth, tenderCheck, uncheckTenderCheck, 'materialController.index');
     app.post('/tender/:id/measure/material/add', sessionAuth, tenderCheck, uncheckTenderCheck, 'materialController.add');

+ 1 - 1
app/service/change.js

@@ -459,7 +459,7 @@ module.exports = app => {
                             spamount: clInfo[6],
                             xmj_code: clInfo[9] !== '' ? clInfo[9] : null,
                             xmj_jldy: clInfo[10] !== '' ? clInfo[10] : null,
-                            gcl_id: clInfo[11] !== '' ? clInfo[11] : '0',
+                            gcl_id: clInfo[11] !== '' ? clInfo[11] : '',
                         };
                         if (clInfo[4] === '') {
                             delete clArray.unit_price;

+ 74 - 0
app/service/change_audit.js

@@ -468,6 +468,80 @@ module.exports = app => {
             return await this.db.queryOne(sql, sqlParam);
         }
 
+        /**
+         * 获取 审核人列表(除去原报)
+         *
+         * @param {Number} cid - 变更id
+         * @param {Number} times - 第几次审批
+         * @return {Promise<*>}
+         */
+        async getAuditors(cid, times = 1) {
+            const sql = 'SELECT * FROM ?? WHERE `cid` = ? and `times` = ? and usite != 0';
+            const sqlParam = [this.tableName, cid, times];
+            return await this.db.query(sql, sqlParam);
+        }
+
+        /**
+         * 新增审核人
+         *
+         * @param {Number} cid - 变更令id
+         * @param {Number} auditorId - 审核人id
+         * @param {Number} times - 第几次审批
+         * @return {Promise<number>}
+         */
+        async addAuditor(cid, auditorId, times = 1, is_gdzs = 0) {
+            const transaction = await this.db.beginTransaction();
+            try {
+                const auditList = await this.getAllDataByCondition({ where: { cid, times } });
+                const idList = this._.map(auditList, 'uid');
+                let newOrder = idList.length + 1;
+                let uSort = await transaction.count(this.tableName, { cid });
+                // 判断是否存在固定终审,存在则newOrder - 1并使终审order+1
+                newOrder = is_gdzs === 1 ? newOrder - 1 : newOrder;
+                uSort = is_gdzs === 1 ? uSort : uSort + 1;
+                if (is_gdzs) await this._syncOrderByDelete(transaction, cid, newOrder, uSort, times, '+');
+                const userInfo = await this.ctx.service.projectAccount.getDataById(auditorId);
+                const newAuditor = {
+                    tid: this.ctx.tender.id, cid: cid, uid: auditorId,
+                    name: userInfo.name, jobs: userInfo.role, company: userInfo.company,
+                    times: times, usite: newOrder, usort: uSort, status: audit.flow.auditStatus.uncheck,
+                };
+                const result = await transaction.insert(this.tableName, newAuditor);
+                await transaction.commit();
+                return result.effectRows = 1;
+            } catch (err) {
+                await transaction.rollback();
+                throw err;
+            }
+            return false;
+        }
+
+        /**
+         * 移除审核人
+         *
+         * @param {Number} cid - 变更令id
+         * @param {Number} auditorId - 审核人id
+         * @param {Number} times - 第几次审批
+         * @return {Promise<boolean>}
+         */
+        async deleteAuditor(cid, auditorId, times = 1) {
+            const transaction = await this.db.beginTransaction();
+            try {
+                const sql = 'SELECT * FROM ?? WHERE `cid` = ? and `times` = ? and `uid` = ? and `usite` != 0 ORDER BY `usort` DESC';
+                const sqlParam = [this.tableName, cid, times, auditorId];
+                const auditor = await transaction.queryOne(sql, sqlParam);
+                if (!auditor) {
+                    throw '该审核人不存在';
+                }
+                await this._syncOrderByDelete(transaction, cid, auditor.usite, auditor.usort, times);
+                await transaction.delete(this.tableName, { id: auditor.id });
+                await transaction.commit();
+            } catch (err) {
+                await transaction.rollback();
+                throw err;
+            }
+            return true;
+        }
     }
 
     return ChangeAudit;

+ 0 - 1
app/service/change_audit_list.js

@@ -160,7 +160,6 @@ module.exports = app => {
                     data.samount = '';
                     insertDatas.push(data);
                 }
-                console.log(insertDatas);
                 if (insertDatas.length > 0) await transaction.insert(this.tableName, insertDatas);
                 await this.calcCamountSum(transaction);
                 await transaction.commit();

+ 18 - 15
app/view/change/information.ejs

@@ -66,18 +66,21 @@
         <div class="w-100 sub-content row">
             <div class="c-body col-4">
                 <div class="sjs-bar-1">
+                    <input type="hidden" id="tenderId" value="<%- ctx.tender.id %>">
+                    <input type="hidden" id="changeId" value="<%- ctx.change.cid %>">
                     <ul class="nav nav-tabs">
                         <li class="nav-item">
-                            <a class="nav-link active" data-toggle="tab" href="#bgxinxi" role="tab">变更信息</a>
+                            <a class="nav-link active" data-toggle="tab" data-tab="bgxinxi" href="#bgxinxi" role="tab">变更信息</a>
                         </li>
                         <li class="nav-item">
-                            <a class="nav-link" data-toggle="tab" href="#bgfujian" role="tab">附件</a>
+                            <a class="nav-link" data-toggle="tab" data-tab="bgfujian" href="#bgfujian" role="tab">附件</a>
                         </li>
-                        <li class="nav-item ml-auto pt-1" style="display:none;">
+                        <li class="nav-item ml-auto pt-1" id="fujian_btn" style="display:none;">
                             <!--所有附件 翻页-->
                             <a href="javascript: void(0);" data-toggle="modal" class="btn btn-sm btn-primary" id="bach-download"><i class="fa fa-download "></i> 批量下载</a>
-                            <a href="#" class=" ml-3"><i class="fa fa-chevron-left"></i></a> 1/10 <a href="#" class="mr-3"><i class="fa fa-chevron-right"></i></a>
+                            <!--<a href="#" class=" ml-3"><i class="fa fa-chevron-left"></i></a> 1/10 <a href="#" class="mr-3"><i class="fa fa-chevron-right"></i></a>-->
                             <a href="#addfujian" data-toggle="modal" class="btn btn-sm btn-light text-primary" data-placement="bottom" title="" data-original-title="上传附件"><i class="fa fa-cloud-upload" aria-hidden="true"></i> 上传附件</a>
+                            <a href="" id="downloadZip" style="display: none;" download></a>
                         </li>
                     </ul>
                 </div>
@@ -304,27 +307,25 @@
                                 <table class="table table-bordered">
                                     <thead>
                                     <tr>
-                                        <td width="25" style="background-color: #e9ecef;"><input type="checkbox" id="check-all-file" ></td>
-                                        <th width="50">序号</th>
+                                        <td width="20" style="background-color: #e9ecef;"><input type="checkbox" id="check-all-file" ></td>
+                                        <th width="40">序号</th>
                                         <th>名称</th>
-                                        <th width="90">大小</th>
-                                        <th width="100">上传时间</th>
-                                        <th width="100">操作</th>
+                                        <th width="100">上传时间/大小</th>
+                                        <th width="60">操作</th>
                                     </tr>
                                     </thead>
                                     <tbody id="attList">
                                     <% if (attList !== undefined && attList !== '') { %>
                                         <% for (const [index,att] of attList.entries()) { %>
                                             <tr>
-                                                <td width="25"><input type="checkbox" class="check-file" file-id=<%- att.id %>></td>
+                                                <td width="20"><input type="checkbox" class="check-file" file-id=<%- att.id %>></td>
                                                 <td><%- index+1 %></td>
                                                 <td><a href="javascript: void(0);" class="file-atn" f-id="<%- att.id %>"><%- att.filename %><%- att.fileext %></a></td>
-                                                <td><%- ctx.helper.bytesToSize(att.filesize) %></td>
-                                                <td><%- moment(att.in_time * 1000).format('YYYY-MM-DD') %></td>
+                                                <td><%- moment(att.in_time * 1000).format('YYYY-MM-DD') %><br><%- ctx.helper.bytesToSize(att.filesize) %></td>
                                                 <td>
-                                                    <a href="/change/download/file/<%- att.id %>" class="btn btn-light btn-sm" title="下载"><span class="fa fa-download text-primary"></span></a>
-                                                    <% if (att.uid === uid && (auditStatus === 4 ? Boolean(att.extra_upload) : true )) { %>
-                                                        <a class="btn btn-light btn-sm delete-file" data-attid="<%- att.id %>" title="删除附件"><span class="fa fa-trash text-danger"></span></a>
+                                                    <a href="/change/download/file/<%- att.id %>" class="mr-2" title="下载"><span class="fa fa-download text-primary"></span></a>
+                                                    <% if (att.uid === ctx.session.sessionUser.accountId && (auditStatus === 4 ? Boolean(att.extra_upload) : true )) { %>
+                                                        <a href="javascript:void(0)" class="mr-2 delete-file" data-attid="<%- att.id %>" title="删除附件"><span class="fa fa-trash text-danger"></span></a>
                                                     <% } %>
                                                 </td>
                                             </tr>
@@ -332,6 +333,7 @@
                                     <% } %>
                                     </tbody>
                                 </table>
+                                <a href="" id="file-upload" target="_blank" style="display: none;"></a>
                             </div>
                         </div>
                     </div>
@@ -424,6 +426,7 @@
     };
 </script>
 <script src="/public/js/change_information_set.js"></script>
+<script src="/public/js/change_audit.js"></script>
 <% } else if (auditStatus === 3 || auditStatus === 4 || auditStatus === 5 || auditStatus === 7) { %>
 <!--<script src="/public/js/change_show.js"></script>-->
 <% } else if (auditStatus === 6) { %>

+ 0 - 3
app/view/change/information_modal.ejs

@@ -93,9 +93,6 @@
                     </div>
                 </div>
                 <div class="modal-footer">
-                    <% if (ctx.tender.info.shenpi.change !== shenpiConst.sp_status.gdspl) { %>
-                    <button type="button" class="btn btn-success btn-sm save_change_btn">保存审批流程</button>
-                    <% } %>
                     <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
                     <button type="button" data-sumbit="sumbit_change" data-category="up_change" class="btn btn-primary btn-sm up-change">确认上报</button>
                     <!--<button type="button" data-sumbit="sumbit_change" data-category="save_change" class="btn btn-success btn-sm save-change">保存修改</button>-->

+ 2 - 2
sql/update.sql

@@ -2,5 +2,5 @@ ALTER TABLE `zh_tender`
 ADD COLUMN `copy_id` INT(10) NULL COMMENT '被拷贝标段id' AFTER `uuid`;
 
 
-ALTER TABLE `zh_change_audit_list` ADD `gcl_id` VARCHAR(255) NOT NULL DEFAULT '0' COMMENT '台账对应id(非准确)' AFTER `xmj_jldy`;
-UPDATE `zh_change_audit_list` SET `gcl_id`=`lid`;
+ALTER TABLE `zh_change_audit_list` ADD `gcl_id` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '台账对应id(非准确)' AFTER `xmj_jldy`;
+UPDATE `zh_change_audit_list` SET `gcl_id`=`lid` WHERE `lid` != '0';