瀏覽代碼

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

Tony Kang 2 年之前
父節點
當前提交
e112350617

+ 0 - 1
app/controller/deal_bills_controller.js

@@ -111,7 +111,6 @@ module.exports = app => {
                 });
                 ctx.body = {err: 0, msg: '', data: dealBills};
             } catch (err) {
-                console.log(err);
                 this.log(err);
                 // 失败需要消耗掉stream 以防卡死
                 if (stream) {

+ 5 - 5
app/controller/stage_controller.js

@@ -1517,11 +1517,11 @@ module.exports = app => {
                         ? await ctx.helper.loadLedgerDataFromOss(ctx.stage.ledgerHis.bills_file)
                         : await ctx.service.ledger.getData(ctx.tender.id);
                     const bpcData = await ctx.service.stageBillsPc.getAllDataByCondition({ where: { sid: ctx.stage.id } });
-                    if (bpcData.length > 0) {
-                        this.ctx.helper.assignRelaData(result.main.ledger, [
-                            { data: bpcData, fields: ['pc_tp', 'org_price'], prefix: '', relaId: 'lid' },
-                        ]);
-                    }
+                    const extraData = await ctx.service.ledgerExtra.getData(ctx.tender.id, ['id', 'is_tp']);
+                    this.ctx.helper.assignRelaData(result.main.ledger, [
+                        { data: bpcData, fields: ['pc_tp', 'org_price'], prefix: '', relaId: 'lid' },
+                        { data: extraData, fields: ['is_tp'], prefix: '', relaId: 'id' },
+                    ]);
 
                     result.main.pos = ctx.stage.ledgerHis
                         ? await ctx.helper.loadLedgerDataFromOss(ctx.stage.ledgerHis.pos_file)

+ 10 - 0
app/middleware/material_check.js

@@ -112,6 +112,16 @@ module.exports = options => {
                 material.curTimes = material.status === status.checkNo ? material.times - 1 : material.times;
                 material.curOrder = material.status === status.checked ? _.max(_.map(material.auditors, 'order')) : material.curAuditor.order - 1;
                 material.filePermission = false;
+            } else if (this.session.sessionUser.is_admin) {
+                material.curTimes = material.times;
+                if (material.status === status.uncheck || material.status === status.checkNo) {
+                    material.curOrder = 0;
+                } else if (material.status === status.checked) {
+                    material.curOrder = _.max(_.map(material.auditors, 'order'));
+                } else {
+                    material.curOrder = material.curAuditor.order;
+                }
+                material.filePermission = true;
             } else { // 其他不可见
                 throw '您无权查看该数据';
             }

+ 1 - 1
app/middleware/stage_check.js

@@ -119,7 +119,7 @@ module.exports = options => {
             }
 
             const permission = this.session.sessionUser.permission;
-            if (stage.users.indexOf(accountId) >= 0) {
+            if (stage.users.indexOf(accountId) >= 0 || this.session.sessionUser.is_admin) {
                 stage.filePermission = true;
             } else {
                 if (shareIds.indexOf(accountId) !== -1 || (permission !== null && permission.tender !== undefined && permission.tender.indexOf('2') !== -1)) {// 分享人

+ 3 - 0
app/public/css/main.css

@@ -2087,4 +2087,7 @@ animation:shake 1s .2s ease both;}
 }
 .span-green{
     background: #62DAAB;
+}
+.form-control-width{
+    min-width: 450px;
 }

+ 42 - 18
app/public/js/file_detail.js

@@ -52,15 +52,23 @@ $(document).ready(function() {
                 filingObj.setCurFiling(curNode);
             }
         }
-        _getFileHtml(file) {
-            const html = [];
-            html.push(`<tr fid="${file.id}">`);
-            html.push(`<td><input type="checkbox" name="bd-check" fid="${file.id}"></td>`);
+        _getFileNameHtml(file) {
             const editHtml = file.canEdit ? `<a href="javascript: void(0);" class="mr-1" name="edit-file" fid="${file.id}"><i class="fa fa-pencil fa-fw"></i></a>` : '';
             const viewHtml = file.viewpath ? `<a href="${file.viewpath}" class="mr-1" target="_blank"><i class="fa fa-eye fa-fw"></i></a>` : '';
             const downHtml = `<a href="javascript: void(0);" onclick="AliOss.downloadFile('${file.filepath}', '${file.filename + file.fileext}')" class="mr-1"><i class="fa fa-download fa-fw"></i></a>`;
             const delHtml = file.canEdit ? `<a href="javascript: void(0);" class="mr-1 text-danger" name="del-file" fid="${file.id}"><i class="fa fa-trash-o fa-fw"></i></a>` : '';
-            html.push(`<td><div class="d-flex justify-content-between align-items-center table-file"><div name="filename" fid="${file.id}">${file.filename}${file.fileext}</div><div class="btn-group-table" style="display: none;">${editHtml}${viewHtml}${downHtml}${delHtml}</div></div></td>`);
+            return `<div class="d-flex justify-content-between align-items-center table-file"><div name="filename" fid="${file.id}">${file.filename}${file.fileext}</div><div class="btn-group-table" style="display: none;">${editHtml}${viewHtml}${downHtml}${delHtml}</div></div>`;
+        }
+        _getEditFileNameHtml(file) {
+            const inputHtml = `<input type="text" class="form-control form-control-sm form-control-width" maxlength="100" value="${file.filename + file.fileext}" fid="${file.id}">`;
+            const btnHtml = `<div class="btn-group-table" style="display: none;"><a href="javascript: void(0)" class="mr-1" name="edit-file-ok"><i class="fa fa-check fa-fw"></i></a><a href="javascript: void(0)" class="mr-1" name="edit-file-cancel"><i class="fa fa-remove fa-fw"></i></a></div>`;
+            return `<div class="d-flex justify-content-between align-items-center table-file"><div>${inputHtml}</div>${btnHtml}</div>`;
+        }
+        _getFileHtml(file) {
+            const html = [];
+            html.push(`<tr fid="${file.id}">`);
+            html.push(`<td><input type="checkbox" name="bd-check" fid="${file.id}"></td>`);
+            html.push(`<td fid="${file.id}">${this._getFileNameHtml(file)}</td>`);
             html.push(`<td>${file.user_name}</td>`);
             html.push(`<td>${moment(file.create_time).format('YYYY-MM-DD HH:mm:ss')}</td>`);
             html.push(`<td>${file.fileext_str}</td>`);
@@ -204,21 +212,22 @@ $(document).ready(function() {
             });
         }
         renameFile(fileId, filename) {
+            const self = this;
             const file = filingObj.curFiling.source_node.files.find(x => { return x.id === fileId });
             if (!file) return;
 
-            const filenameDiv = $(`[name=filename][fid=${fileId}]`);
+            const td = $(`td[fid=${fileId}]`);
             if (filename === file.filename + file.fileext) {
-                filenameDiv.html(file.filename + file.fileext);
+                td.html(this._getFileNameHtml(file));
                 return;
             }
 
             postData('file/save', { id: fileId, filename }, function(data) {
                 file.filename = data.filename;
                 file.fileext = data.fileext;
-                filenameDiv.html(file.filename + file.fileext);
+                td.html(self._getFileNameHtml(file));
             }, function() {
-                filenameDiv.html(file.filename + file.fileext);
+                td.html(self._getFileNameHtml(file));
             });
         }
         relaFiles(files, callback) {
@@ -418,18 +427,33 @@ $(document).ready(function() {
         if (check.length > 0 && check[0].getAttribute('fid') === this.getAttribute('fid')) return;
 
         const id = this.getAttribute('fid');
-        const filename = $(`[name=filename][fid=${id}]`);
         const file = filingObj.curFiling.source_node.files.find(x => { return x.id === id });
-        filename.html(`<input type="text" class="form-control form-control-sm" maxlength="100" value="${file.filename + file.fileext}" fid="${id}">`);
+        $(`td[fid=${id}]`).html(filingObj._getEditFileNameHtml(file));
     });
-    $('body').on('blur', "[name=filename] input[fid]", function() {
-        filingObj.renameFile(this.getAttribute('fid'), this.value);
+    $('body').on('click', "a[name=edit-file-ok]", function() {
+        const td = $(this).parent().parent().parent();
+        const fid = td.attr('fid');
+        const file = filingObj.curFiling.source_node.files.find(x => { return x.id === fid });
+        if (!file) return;
+
+        filingObj.renameFile(fid, $('input', td).val());
     });
-    $('body').on('keypress', "[name=filename] input[fid]", function(e) {
-        if (e.keyCode == 13) {
-            filingObj.renameFile(this.getAttribute('fid'), this.value);
-        }
+    $('body').on('click', "a[name=edit-file-cancel]", function() {
+        const td = $(this).parent().parent().parent();
+        const fid = td.attr('fid');
+        const file = filingObj.curFiling.source_node.files.find(x => { return x.id === fid });
+        if (!file) return;
+
+        td.html(filingObj._getFileNameHtml(file));
     });
+    // $('body').on('blur', "[name=filename] input[fid]", function() {
+    //     filingObj.renameFile(this.getAttribute('fid'), this.value);
+    // });
+    // $('body').on('keypress', "[name=filename] input[fid]", function(e) {
+    //     if (e.keyCode == 13) {
+    //         filingObj.renameFile(this.getAttribute('fid'), this.value);
+    //     }
+    // });
     $('.page-select').click(function() {
         const content = this.getAttribute('content');
         switch(content) {
@@ -738,7 +762,7 @@ $(document).ready(function() {
         async _loadAdvanceFile() {
             const rfType = this.rfType;
             const advance = this.curTender.source_node.advance.find(x => {
-                return x.id === rfType.stage;
+                return x.id == rfType.stage;
             });
             if (!advance) {
                 this.curFiles = [];

+ 2 - 1
app/service/tender_cache.js

@@ -170,7 +170,7 @@ module.exports = app => {
                     name: auditor.name, company: auditor.company, role: auditor.role, mobile: auditor.mobile, telephone: auditor.telephone,
                 });
                 await transaction.update(this.tableName, {
-                    id: delStage.tid, stage_count: preStage.order, stage_status: preStage.status,
+                    id: delStage.tid, stage_count: preStage.order, stage_complete_count: preStage.order, stage_status: preStage.status,
                     stage_flow_cur_uid: 0, stage_flow_cur_info: '', stage_flow_cur_tp: '',
                     stage_flow_pre_uid: auditor.aid, stage_flow_pre_info: user_info, stage_flow_pre_tp: tp,
                 });
@@ -230,6 +230,7 @@ module.exports = app => {
                 info.status = status;
                 data.stage_flow_cur_info = JSON.stringify(info);
             }
+            if (status === auditConst.stage.status.checked && !auditor) data.stage_complete_count = data.stage_count;
             data.stage_flow_cur_tp = JSON.stringify(tp);
             await transaction.update(this.tableName, data);
         }

+ 2 - 2
app/view/file/file.ejs

@@ -43,9 +43,9 @@
                     </div>
                     <table class="table table-bordered">
                         <thead>
-                        <tr>
+                        <tr class="text-center">
                             <th>选择</th>
-                            <th width="40%">文件名称</th>
+                            <th width="45%">文件名称</th>
                             <th>上传人</th>
                             <th>上传时间</th>
                             <th>文件类型</th>