Pārlūkot izejas kodu

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

TonyKang 4 gadi atpakaļ
vecāks
revīzija
9002d7e30d

+ 3 - 3
app/controller/measure_controller.js

@@ -142,9 +142,9 @@ module.exports = app => {
                 if (!stage) {
                     throw '提交数据错误';
                 }
-                if (stage.status === auditConst.status.checked) {
-                    throw '该计量期当前不可编辑';
-                }
+                // if (stage.status === auditConst.status.checked) {
+                //     throw '该计量期当前不可编辑';
+                // }
                 if (ctx.session.sessionUser.accountId !== stage.user_id) {
                     throw '您无权修改该数据';
                 }

+ 1 - 2
app/public/js/change_detail.js

@@ -49,7 +49,6 @@ $(document).ready(() => {
             $('#bills').removeClass('first-bill-pane');
         }
     });
-    console.log(auditList)
     // 上传附件
     $('#upload-file-btn').click(function () {
         const files = $('#upload-file')[0].files;
@@ -74,7 +73,7 @@ $(document).ready(() => {
             formData.append('size', filesize);
             formData.append('file[]', file);
         }
-        if (auditList.findIndex(item => item.uid === accountId) === -1) {
+        if (auditList.findIndex(item => item.uid === parseInt(accountId)) === -1) {
             return toastr.error('暂无权限上传!')
         }
         postDataWithFile(window.location.pathname + '/file/upload', formData, function (data) {

+ 32 - 2
app/public/js/material.js

@@ -232,8 +232,9 @@ $(document).ready(() => {
             postData(window.location.pathname + '/save', {type: 'add'}, function (result) {
                 if (result) {
                     materialBillsData.push(result);
-                    sheet.addRows(materialBillsData.length - 1, 1);
-                    SpreadJsObj.reLoadRowData(sheet, materialBillsData.length - 1);
+                    // sheet.addRows(materialBillsData.length - 1, 1);
+                    // SpreadJsObj.reLoadRowData(sheet, materialBillsData.length - 1);
+                    SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
                     sheet.setSelection(materialBillsData.length - 1, 0, 1, 1);
                     materialSpreadObj.refreshActn();
                     // 月信息价需要同时添加空白的list
@@ -710,6 +711,35 @@ $(document).ready(() => {
             }
         },
         deletePress: function (sheet) {
+            // if (sheet.zh_setting && sheet.zh_data) {
+            //     const sel = sheet.getSelections()[0];
+            //     if (!sel) return;
+            //
+            //     const col = sheet.zh_setting.cols[sel.col];
+            //     const select = SpreadJsObj.getSelectObject(sheet);
+            //     const orgValue = select[col.field];
+            //     if (sel.colCount > 1 || sel.rowCount > 1) {
+            //         toastr.warning('请勿同时删除多行或多列数据');
+            //     }
+            //     console.log(sel, select, col);
+                // if (orgValue === null || col.field === 'type' || col.field === 'is_summary') {
+                //     return;
+                // }
+                // select[col.field] = null;
+                // select.calc_num = materialExponentCol.getValue.calc_num(select);
+                // console.log(select);
+                // 更新至服务器
+                // postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
+                //     ex_tp = result.ex_tp;
+                //     ex_expr = result.ex_expr;
+                //     resetExTpTable();
+                //     SpreadJsObj.reLoadRowData(sheet, sel.row);
+                //     materialExponentData.splice(sel.row, 1, select);
+                // }, function () {
+                //     select[col.field] = orgValue;
+                //     SpreadJsObj.reLoadRowData(sheet, sel.row);
+                // });
+            // }
             return;
         },
         clipboardPasted(e, info) {

+ 1 - 1
app/public/js/material_file.js

@@ -282,7 +282,7 @@ $(document).ready(function () {
     function calcCount() {
         // 附件总数
         let total = fileData && fileData.length;
-        if(!$('#dropdownMenuButton').attr('btn-type') === 'all') {
+        if($('#dropdownMenuButton').attr('btn-type') === 'curr') {
             total = fileData && fileData.filter(file => file.mid === parseInt(mid) && file.tid === parseInt(tid)).length
         }
         return total

+ 3 - 18
app/public/js/stage.js

@@ -3440,41 +3440,26 @@ $(document).ready(() => {
         if (status === 'pre' && lastPageNum > 1) {
             getAllList(lastPageNum-1);
             $('#showAttachment').hide();
+            $('#syfujian .check-all-file').prop('checked', false)
         } else if (status === 'next' && lastPageNum < totalPageNum) {
             getAllList(lastPageNum+1);
             $('#showAttachment').hide();
+            $('#syfujian .check-all-file').prop('checked', false)
         }
     });
 
     // 批量下载
     $('#bach-download').click(function() {
         const fileIds = []
-        $('.tab-pane.active .list-table .check-file:checked').each(function() {
+        $('.tab-pane.active.show .list-table .check-file:checked').each(function() {
             const fileId = $(this).attr('file-id')
             fileId && fileIds.push(fileId)
         })
-        console.log('fileIds', fileIds)
 
         if (fileIds.length) {
             const url = `/tender/${tender.id}/measure/stage/${stage.order}/download/compresse-file?fileIds=${JSON.stringify(fileIds)}`
             $('#zipDown').attr('href', url)
             $("#zipDown")[0].click()
-            // 执行请求
-            // postData('/tender/' + tender.id + '/measure/stage/' + stage.order + '/download/compresse-file', { fileIds }, function(data) {
-            //     console.log(data)
-            // })
-            // $.ajax({
-            //     type:"get",
-            //     // url: '/tender/' + tender.id + '/measure/stage/' + stage.order + '/download/compresse-file',
-            //     url: `/tender/${tender.id}/measure/stage/${stage.order}/download/compresse-file?fileids=${JSON.stringify(fileids)}`,
-            //     dataType: 'json',
-            //     cache: false,
-            //     // 告诉jQuery不要去设置Content-Type请求头
-            //     contentType: false,
-            //     // 告诉jQuery不要去处理发送的数据
-            //     processData: false,
-            //     timeout: 60000,
-            // })
         }
     });
 

+ 3 - 5
app/service/change_att.js

@@ -88,7 +88,7 @@ module.exports = app => {
             });
             const [sql, sqlParam] = this.sqlBuilder.build(this.tableName);
             const files = await this.db.query(sql, sqlParam);
-            return new Promise(resolve => {
+            return new Promise((resolve, reject) => {
                 // 每次开一个新的archiver
                 const ziparchiver = archiver('zip');
                 const outputPath = fs.createWriteStream(path.resolve(this.app.baseDir, zipPath));
@@ -99,18 +99,16 @@ module.exports = app => {
 
                 // 存档警告
                 ziparchiver.on('warning', function(err) {
-                    console.log(err);
                     if (err.code === 'ENOENT') {
                         console.warn('stat故障和其他非阻塞错误');
-                    } else {
-                        throw err;
                     }
+                    reject(err);
                 });
 
                 // 存档出错
                 ziparchiver.on('error', function(err) {
                     console.log(err);
-                    throw err;
+                    reject(err);
                 });
                 ziparchiver.finalize();
                 outputPath.on('close', () => {

+ 3 - 4
app/service/material_file.js

@@ -89,7 +89,7 @@ module.exports = app => {
             // const paths = files.map(item => {
             //     return { name: item.filename + item.fileext, path: item.filepath }
             // })
-            return new Promise(resolve => {
+            return new Promise((resolve, reject) => {
                 // 每次开一个新的archiver
                 const ziparchiver = archiver('zip');
                 const outputPath = fs.createWriteStream(path.resolve(this.app.baseDir, zipPath));
@@ -102,15 +102,14 @@ module.exports = app => {
                 ziparchiver.on('warning', function(err) {
                     if (err.code === 'ENOENT') {
                         console.warn('stat故障和其他非阻塞错误');
-                    } else {
-                        throw err;
                     }
+                    reject(err);
                 });
 
                 // 存档出错
                 ziparchiver.on('error', function(err) {
                     console.log(err);
-                    throw err;
+                    reject(err);
                 });
                 ziparchiver.finalize();
                 outputPath.on('close', () => {

+ 5 - 4
app/service/stage_att.js

@@ -109,7 +109,7 @@ module.exports = app => {
             // const paths = files.map(item => {
             //     return { name: item.filename + item.fileext, path: item.filepath }
             // })
-            return new Promise(resolve => {
+            return new Promise((resolve, reject) => {
                 // 每次开一个新的archiver
                 const ziparchiver = archiver('zip');
                 const outputPath = fs.createWriteStream(path.resolve(this.app.baseDir, zipPath));
@@ -122,16 +122,17 @@ module.exports = app => {
                 ziparchiver.on('warning', function(err) {
                     if (err.code === 'ENOENT') {
                         console.warn('stat故障和其他非阻塞错误');
-                    } else {
-                        throw err;
                     }
+                    reject(err);
+
                 });
 
                 // 存档出错
                 ziparchiver.on('error', function(err) {
                     console.log(err);
-                    throw err;
+                    reject(err);
                 });
+
                 ziparchiver.finalize();
                 outputPath.on('close', () => {
                     resolve(ziparchiver.pointer());

+ 3 - 3
app/view/measure/stage.ejs

@@ -38,12 +38,12 @@
                     </tr>
                     </thead>
                     <tbody>
-                    <% for (const s of stages) { %>
+                    <% for (const [i,s] of stages.entries()) { %>
                     <tr>
                         <td>
                             <a href="<%- '/tender/' + ctx.tender.id + '/measure/stage/' + s.order %>" target="_blank">第 <%- s.order %> 期</a>
-                            <% if (s.status !== auditConst.status.checked && s.user_id === ctx.session.sessionUser.accountId) { %>
-                            <a href="#edit" data-toggle="modal" data-target="#edit"><i class="fa fa-pencil-square-o "></i></a>
+                            <% if ((s.status !== auditConst.status.checked || (stages[i-1] && stages[i-1].status !== auditConst.status.checked)) && s.user_id === ctx.session.sessionUser.accountId) { %>
+                            <a href="#edit" class="edit-stage" data-index="<%- i %>" data-toggle="modal" data-target="#edit"><i class="fa fa-pencil-square-o "></i></a>
                             <% } %>
                         </td>
                         <td class="text-center"><%- s.s_time %></td>

+ 23 - 16
app/view/measure/stage_modal.ejs

@@ -83,7 +83,7 @@
             <div class="modal-body">
                 <div class="form-group">
                     <label>期</label>
-                    <input class="form-control form-control-sm" value="第 <%- stages[0].order %> 期" type="text" readonly="" name="name">
+                    <input class="form-control form-control-sm" id="edit-name" value="第 <%- stages[0].order %> 期" type="text" readonly="" name="name">
                 </div>
                 <div class="form-group">
                     <label>计量年月<b class="text-danger">*</b></label>
@@ -96,7 +96,7 @@
             </div>
             <div class="modal-footer">
                 <input type="hidden" name="_csrf" value="<%= ctx.csrf %>" />
-                <input type="hidden" name="order" value="<%- stages[0].order %>">
+                <input type="hidden" name="order" id="edit-order" value="<%- stages[0].order %>">
                 <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
                 <button type="submit" class="btn btn-primary btn-sm" id="edit-ok" >确定修改</button>
             </div>
@@ -108,20 +108,27 @@
 <script src="/public/js/datepicker/datepicker.zh.js"></script>
 <script>
     <% if (stages.length > 0 && stages[0].status !== auditConst.status.checked && stages[0].user_id === ctx.session.sessionUser.accountId) { %>
-    const editDate = $('#edit-date').datepicker().data('datepicker');
-    if ('<%- stages[0].s_time %>' && '<%- stages[0].s_time %>' !== '') {
-        editDate.selectDate(new Date('<%- stages[0].s_time %>'));
-    }
-    const period = [];
-    for (const p of'<%- stages[0].period %>'.split('~')) {
-        if (p && p !== '') {
-            period.push(new Date(p));
-        }
-    }
-    const editPeriod = $('#edit-period').datepicker().data('datepicker');
-    if (period.length > 0) {
-        editPeriod.selectDate(period);
-    }
+    $(function () {
+       $('.edit-stage').on('click', function () {
+           const index = parseInt($(this).data('index'));
+           const editDate = $('#edit-date').datepicker().data('datepicker');
+           $('#edit-name').val('第 ' + stages[index].order + ' 期');
+           $('#edit-order').val(stages[index].order);
+           if (stages[index].s_time && stages[index].s_time !== '') {
+               editDate.selectDate(new Date(stages[index].s_time));
+           }
+           const period = [];
+           for (const p of stages[index].period.split('~')) {
+               if (p && p !== '') {
+                   period.push(new Date(p));
+               }
+           }
+           const editPeriod = $('#edit-period').datepicker().data('datepicker');
+           if (period.length > 0) {
+               editPeriod.selectDate(period);
+           }
+       })
+    });
 
     function checkForm () {
         if ($('#edit-date').val() == '') {