laiguoran 4 лет назад
Родитель
Сommit
1301adb42d

+ 8 - 0
app/controller/change_controller.js

@@ -803,6 +803,14 @@ module.exports = app => {
                             orders: [['lid', 'desc'], ['id', 'asc']],
                         });
                         break;
+                    case 'ledger_list':
+                        await ctx.service.changeAuditList.saveLedgerListDatas(data.updateData);
+                        // 取所有工料表
+                        responseData.data = await ctx.service.changeAuditList.getAllDataByCondition({
+                            where: { cid: ctx.change.cid },
+                            orders: [['lid', 'desc'], ['id', 'asc']],
+                        });
+                        break;
                     default: throw '参数有误';
                 }
 

+ 33 - 20
app/public/js/change_information_set.js

@@ -159,7 +159,7 @@ $(document).ready(() => {
                     return;
                 }
                 // 未改变值则不提交
-                let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
+                let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
                 const orgValue = select[col.field];
                 if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
@@ -190,6 +190,7 @@ $(document).ready(() => {
 
                 // 更新至服务器
                 postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
+                    changeList.splice(info.row, 1, select);
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
                     changeSpreadObj.countSum();
                 }, function () {
@@ -406,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() +'"><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="0"><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) {
@@ -418,9 +419,10 @@ $(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 bwmx = leaf.bwmx !== undefined ? leaf.bwmx : '';
-                const isChecked = data_bwmx.indexOf(leaf.code + '!_!' + (leaf.jldy ? leaf.jldy : '') + '!_!' + (bwmx !== '' ? bwmx : leaf.jldy ? leaf.jldy : '') + '*;*' + quantity) !== -1 && isCheck ? 'checked' : '';
-                codeHtml += '<tr quantity="' + quantity + '"><td>' + leaf.code + '</td>' +
+                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>' +
                     '<td>' + (leaf.jldy ? leaf.jldy: '') + '</td>' +
                     '<td>' + (leaf.dwgc ? leaf.dwgc : '') + '</td>' +
                     '<td>' + (leaf.fbgc ? leaf.fbgc : '') + '</td>' +
@@ -431,7 +433,7 @@ $(document).ready(() => {
                     '></td></tr>';
             }
         } else if (!isDeal && isCheck) {
-            codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'"><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="0"><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('');
@@ -453,7 +455,8 @@ $(document).ready(() => {
             $('#code-list input:checked').each(function () {
                 const tr = $(this).parents('tr');
                 const length = tr.children('td').length;
-                const bwmx = length === 8 ? tr.children('td').eq(0).text() + '!_!' + tr.children('td').eq(1).text() + '!_!' + (tr.children('td').eq(5).text() !== '' ? tr.children('td').eq(5).text() : tr.children('td').eq(1).text()) : '0';
+                const gcl_id = tr.attr('gcl_id');
+                const bwmx = length === 8 ? tr.children('td').eq(0).text() + '!_!' + tr.children('td').eq(1).text() + '!_!' + gcl_id + '!_!' + (tr.children('td').eq(5).text() !== '' ? tr.children('td').eq(5).text() : tr.children('td').eq(1).text()) : '0';
                 const quantity = tr.attr('quantity');
                 const de_qu = bwmx + '*;*' + quantity;
                 data_bwmx.push(de_qu);
@@ -468,7 +471,8 @@ $(document).ready(() => {
                 $('#code-list input:checked').each(function () {
                     const tr = $(this).parents('tr');
                     const length = tr.children('td').length;
-                    const bwmx = length === 8 ? tr.children('td').eq(0).text() + '!_!'+ tr.children('td').eq(1).text() + '!_!' + (tr.children('td').eq(5).text() !== '' ? tr.children('td').eq(5).text() : tr.children('td').eq(1).text()) : '0';
+                    const gcl_id = tr.attr('gcl_id');
+                    const bwmx = length === 8 ? tr.children('td').eq(0).text() + '!_!'+ tr.children('td').eq(1).text() + '!_!' + gcl_id + '!_!' + (tr.children('td').eq(5).text() !== '' ? tr.children('td').eq(5).text() : tr.children('td').eq(1).text()) : '0';
                     const quantity = tr.attr('quantity');
                     const de_qu = bwmx + '*;*' + quantity;
                     data_bwmx.push(de_qu);
@@ -484,10 +488,17 @@ $(document).ready(() => {
 
     // 添加空白清单or签约清单
     $('.add-list-btn').on('click', function () {
-        remakeChangeSpread();
-        SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
-        changeSpreadObj.makeSjsFooter();
-        $('#addlist').modal('hide');
+        const newLedgerList = remakeChangeSpread();
+        // 更新至服务器
+        postData(window.location.pathname + '/save', { type:'ledger_list', updateData: newLedgerList }, function (result) {
+            changeList = result;
+            SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
+            changeSpreadObj.makeSjsFooter();
+            $('#addlist').modal('hide');
+        }, function () {
+            $('#addlist').modal('hide');
+        });
+
     });
 
     // 选中input所有值
@@ -589,7 +600,7 @@ function tableDataRemake(changeListData) {
                         });
                         console.log(leafInfo);
                         if (leafInfo) {
-                            pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' + (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 : '0') + '!_!' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : '') + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
                         } else {
                             toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
                             changeList.splice(index, 1);
@@ -614,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.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 : '0') + '!_!' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (leafInfo.jldy ? leafInfo.jldy : '')) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
                         } else {
                             toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
                             changeList.splice(index, 1);
@@ -660,7 +671,6 @@ function makeCodeTable(search = '') {
             const code = $('#code-list tr').eq(i).children('td').eq(0).text();
             const name = $('#code-list tr').eq(i).children('td').eq(1).text();
             const jldy = $('#code-list tr').eq(i).children('td').eq(5).text();
-            console.log(code, name, jldy, search, code.indexOf(search) !== -1 || name.indexOf(search) !== -1 || jldy.indexOf(search) !== -1);
             const isShow = code.indexOf(search) !== -1 || name.indexOf(search) !== -1 || jldy.indexOf(search) !== -1;
             $('#code-list tr').eq(i).css('display', (isShow ? 'table-row' : 'none'));
         } else {
@@ -692,9 +702,10 @@ function remakeChangeSpread() {
 
         for (const b of data_bwmx) {
             const oamount = b.split('*;*')[1] != '' ? b.split('*;*')[1] : 0;
-            let bwmx = b.split('*;*')[0] != 0 ? b.split('*;*')[0].split('!_!')[2] : '';
+            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] : '';
             let trlist = {
                 code,
                 name,
@@ -707,6 +718,7 @@ function remakeChangeSpread() {
                 lid,
                 xmj_code,
                 xmj_jldy,
+                gcl_id,
             };
             const radionInfo = changeList.find(function (info) {
                 return info.code === code && (info.lid == lid || parseInt(info.lid) === parseInt(lindex)) && info.bwmx === bwmx;
@@ -718,9 +730,10 @@ function remakeChangeSpread() {
             newTableList.push(trlist);
         }
     });
-    const changeWhiteList = _.filter(changeList, function (item) {
-        return item.lid == 0;
-    });
-    console.log(newTableList);
-    changeList = newTableList.concat(changeWhiteList);
+    // const changeWhiteList = _.filter(changeList, function (item) {
+    //     return item.lid == 0;
+    // });
+    // console.log(newTableList);
+    // changeList = newTableList.concat(changeWhiteList);
+    return newTableList;
 }

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

@@ -907,7 +907,7 @@ function maketablelist(status){
             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('*;*');
-                return info[0] === code && (info[8] == lid || parseInt(info[8]) === parseInt(lindex)) && info[2] === bwmx;
+                return info[0] === code && (info[8] == lid || parseInt(info[8]) === parseInt(lindex)) && gcl_id == info[11] && info[2] === bwmx;
             });
             if (radionInfo) {
                 trlist[6] = radionInfo.split('*;*')[6];
@@ -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, '', ''];
+        let trlist = ['','','','','',makedecimalzero(findDecimal(3)),makedecimalzero(findDecimal(3)),'',0, '', '', '0'];
         radionWhiteList.push(trlist.join('*;*'));
     }
 

+ 37 - 0
app/service/change_audit_list.js

@@ -47,6 +47,7 @@ module.exports = app => {
                 spamount: 0,
                 xmj_code: null,
                 xmj_jldy: null,
+                gcl_id: '0',
             };
             // 新增工料
             const result = await this.db.insert(this.tableName, insertData);
@@ -134,6 +135,42 @@ module.exports = app => {
             }
         }
 
+        /**
+         * 台账数据清单 重新选择
+         * @param {Object} datas 内容
+         * @return {void}
+         */
+        async saveLedgerListDatas(datas) {
+            if (!this.ctx.tender || !this.ctx.change) {
+                throw '数据错误';
+            }
+            // 判断是否可修改
+            // 判断t_type是否为费用
+            const transaction = await this.db.beginTransaction();
+            try {
+                // 先删除原本的台账清单数据
+                const sql = 'DELETE FROM ?? WHERE cid = ? and lid != "0"';
+                const sqlParam = [this.tableName, this.ctx.change.cid];
+                await transaction.query(sql, sqlParam);
+                const insertDatas = [];
+                for (const data of datas) {
+                    data.tid = this.ctx.tender.id;
+                    data.cid = this.ctx.change.cid;
+                    data.spamount = data.camount;
+                    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();
+                return true;
+            } catch (err) {
+                await transaction.rollback();
+                throw err;
+            }
+        }
+
         async calcCamountSum(transaction) {
             // const sql = 'SELECT SUM(ROUND(`camount`*`unit_price`, )) as total_price FROM ?? WHERE cid = ?';
             // const sqlParam = [this.tableName, this.change.cid];

+ 1 - 1
app/view/change/information.ejs

@@ -73,7 +73,7 @@
                         <li class="nav-item">
                             <a class="nav-link" data-toggle="tab" href="#bgfujian" role="tab">附件</a>
                         </li>
-                        <li class="nav-item ml-auto pt-1">
+                        <li class="nav-item ml-auto pt-1" 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>