Przeglądaj źródła

1. 资料归集相关
2. 计量台账、关联台账,完成率计算调整

MaiXinRong 3 tygodni temu
rodzic
commit
cc4b9e0530

+ 1 - 1
app/controller/file_controller.js

@@ -61,7 +61,7 @@ module.exports = app => {
                 renderData.categoryData = await ctx.service.category.getAllCategory(ctx.subProject);
                 renderData.canFiling = ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.filing.value) >= 0;
                 renderData.canUpload = ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.upload.value) >= 0;
-                renderData.canDelete = ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.delete.value) >= 0;
+                renderData.canEdit = ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.editfile.value) >= 0;
                 renderData.fileReferenceList = await ctx.service.subProject.getFileReference(ctx.subProject, ctx.service.subProject.FileReferenceType.file);
                 await this.layout('file/file.ejs', renderData, 'file/file_modal.ejs');
             } catch (err) {

+ 36 - 27
app/public/js/file_detail.js

@@ -94,11 +94,11 @@ $(document).ready(function() {
             this.refreshFileCountHint();
         }
         _getFileNameHtml(file) {
-            const moveHtml = file.canEdit ? `<a href="javascript: void(0);" class="mr-1" name="move-file" fid="${file.id}"><i class="fa fa-exchange fa-fw"></i></a>` : '';
-            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 moveHtml = file.canEdit || canEdit ? `<a href="javascript: void(0);" class="mr-1" name="move-file" fid="${file.id}"><i class="fa fa-exchange fa-fw"></i></a>` : '';
+            const editHtml = file.canEdit || 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 || canDelete ? `<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>` : '';
+            const delHtml = file.canEdit || 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>` : '';
             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;">${moveHtml}${editHtml}${viewHtml}${downHtml}${delHtml}</div></div>`;
         }
         _getEditFileNameHtml(file) {
@@ -295,24 +295,31 @@ $(document).ready(function() {
             });
 
         }
-        delFiles(files, callback) {
-            postData('file/del', { del: files }, async function(data) {
-                const relaFiling = data.filing.id === filingObj.curFiling.source_node.id
-                    ? filingObj.curFiling : filingObj.findFiling(data.filing.id);
-                for (const id of data.del) {
-                    const fIndex = relaFiling.source_node.files.findIndex(x => { return x.id === id });
-                    if (fIndex >= 0) relaFiling.source_node.files.splice(fIndex, 1);
-                    fileSearch.removeSearchFile(id);
-                }
-                filingObj.updateFilingFileCount(relaFiling, data.filing.file_count);
-                await filingObj.loadFiles(relaFiling, filingObj.curPage);
-                if (data.filing.id === filingObj.curFiling.source_node.id) {
-                    filingObj.refreshPages();
-                    filingObj.refreshFilesTable();
-                    filingObj.refreshFileCountHint();
-                }
-                if (callback) callback();
-            });
+        delFiles(files, callback, hint = '') {
+            const del = function() {
+                postData('file/del', { del: files }, async function(data) {
+                    const relaFiling = data.filing.id === filingObj.curFiling.source_node.id
+                        ? filingObj.curFiling : filingObj.findFiling(data.filing.id);
+                    for (const id of data.del) {
+                        const fIndex = relaFiling.source_node.files.findIndex(x => { return x.id === id });
+                        if (fIndex >= 0) relaFiling.source_node.files.splice(fIndex, 1);
+                        fileSearch.removeSearchFile(id);
+                    }
+                    filingObj.updateFilingFileCount(relaFiling, data.filing.file_count);
+                    await filingObj.loadFiles(relaFiling, filingObj.curPage);
+                    if (data.filing.id === filingObj.curFiling.source_node.id) {
+                        filingObj.refreshPages();
+                        filingObj.refreshFilesTable();
+                        filingObj.refreshFileCountHint();
+                    }
+                    if (callback) callback();
+                });
+            };
+            if (hint) {
+                deleteAfterHint(del, hint);
+            } else {
+                del();
+            }
         }
         renameFile(file, filename) {
             const self = this;
@@ -724,7 +731,8 @@ $(document).ready(function() {
     });
     $('body').on('click', "a[name=del-file]", function() {
         const del = [this.getAttribute('fid')];
-        filingObj.delFiles(del);
+        const filename = $('[name=filename]', $(this).closest('td'))[0].innerHTML;
+        filingObj.delFiles(del, null, `确认删除「${filename}」?`);
     });
     $('body').on('click', "a[name=edit-file]", function() {
         const check = $('[name=filename] input[fid]');
@@ -911,7 +919,7 @@ $(document).ready(function() {
                 const file = filingObj.curFiling.source_node.files.find(x => { return x.id === fid });
                 if (!file) continue;
 
-                if (file.user_id !== userID) {
+                if (file.user_id !== userID && !canEdit) {
                     toastr.error(`文件【${file.filename + file.fileext}】不是您上传的文件,请勿删除`);
                     return;
                 }
@@ -1655,16 +1663,16 @@ $(document).ready(function() {
         }
         getOperateHtml(file) {
             const locateHtml = `<a href="javascript: void(0);" class="mr-1" name="locate-search-file" fid="${file.id}"><i class="fa fa-crosshairs"></i></a>`;
-            const editHtml = file.canEdit ? `<a href="javascript: void(0);" class="mr-1" name="edit-search-file" fid="${file.id}"><i class="fa fa-pencil fa-fw"></i></a>` : '';
+            const editHtml = file.canEdit || canEdit ? `<a href="javascript: void(0);" class="mr-1" name="edit-search-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-search-file" fid="${file.id}"><i class="fa fa-trash-o fa-fw"></i></a>` : '';
+            const delHtml = file.canEdit || canEdit ? `<a href="javascript: void(0);" class="mr-1 text-danger" name="del-search-file" fid="${file.id}"><i class="fa fa-trash-o fa-fw"></i></a>` : '';
             return `<div class="d-flex justify-content-between align-items-center table-file">${locateHtml}${editHtml}${viewHtml}${downHtml}${delHtml}</div>`
         }
         getFileHtml(file) {
             const html = [];
             html.push(`<tr fid="search_${file.id}">`);
-            html.push(`<td fid="search_${file.id}">${file.filename}${file.fileext}</td>`);
+            html.push(`<td name="filename" fid="search_${file.id}">${file.filename}${file.fileext}</td>`);
             html.push(`<td class="text-center">${file.user_name}</td>`);
             html.push(`<td class="text-center">${this.getOperateHtml(file)}</td>`);
             html.push('</tr>');
@@ -1738,7 +1746,8 @@ $(document).ready(function() {
             $('button', '#search').bind('click', () => { self.search(); });
             $('body').on('click', "a[name=del-search-file]", function() {
                 const del = [this.getAttribute('fid')];
-                filingObj.delFiles(del);
+                const filename = $('[name=filename]', $(this).closest('tr'))[0].innerHTML;
+                filingObj.delFiles(del, null, `确认删除「${filename}」?`);
             });
             $('body').on('click', "a[name=locate-search-file]", function() {
                 const fid = this.getAttribute('fid');

+ 9 - 4
app/public/js/sr_detail.js

@@ -189,11 +189,16 @@ $(document).ready(() => {
                 node.end_correct_tp = node.end_gather_tp;
             }
         }
-        node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_tp), 100, 2);
-        node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_tp), 100, 2);
+        // node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_tp), 100, 2);
+        // node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_tp), 100, 2);
         node.final_dgn_price = ZhCalc.round(ZhCalc.div(node.end_gather_tp, ZhCalc.add(node.deal_dgn_qty1, node.c_dgn_qty1)), tenderInfo.decimal.up);
-        node.end_final_1_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_1_tp), 100, 2);
-        node.end_correct_1_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_1_tp), 100, 2);
+        // node.end_final_1_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_1_tp), 100, 2);
+        // Task #5256要求修改
+        node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.tz2_tp), 100, 2);
+        node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.tz2_tp), 100, 2);
+        node.end_final_1_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.tz2_tp), 100, 2);
+        node.end_correct_1_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.tz2_tp), 100, 2);
+        // node.end_correct_1_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_1_tp), 100, 2);
     };
     const stageTree = createNewPathTree('stage', stageTreeSetting);
     // 初始化 计量单元 数据结构

+ 9 - 4
app/public/js/stage.js

@@ -344,11 +344,16 @@ $(document).ready(() => {
         } else if (tenderInfo.calc_type === 'up') {
             node.tz2_tp = ZhCalc.sum([node.total_price, node.tz_qc_tp, node.tz_qc_minus_tp]);
         }
-        node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_tp), 100, 2);
-        node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_tp), 100, 2);
+        // node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_tp), 100, 2);
+        // node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_tp), 100, 2);
         node.final_dgn_price = ZhCalc.round(ZhCalc.div(node.end_gather_tp, ZhCalc.add(node.deal_dgn_qty1, node.c_dgn_qty1)), tenderInfo.decimal.up);
-        node.end_final_1_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_1_tp), 100, 2);
-        node.end_correct_1_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_1_tp), 100, 2);
+        // node.end_final_1_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_1_tp), 100, 2);
+        // node.end_correct_1_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_1_tp), 100, 2);
+        // Task #5256要求修改
+        node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.tz2_tp), 100, 2);
+        node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.tz2_tp), 100, 2);
+        node.end_final_1_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.tz2_tp), 100, 2);
+        node.end_correct_1_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.tz2_tp), 100, 2);
     };
     const stageTree = createNewPathTree('stage', stageTreeSetting);
     // 初始化 计量单元 数据结构

+ 1 - 1
app/service/file.js

@@ -80,7 +80,7 @@ module.exports = app => {
 
             const fileDatas = await this.getAllDataByCondition({ where: { id: files } });
             const filing = await this.ctx.service.filing.getDataById(fileDatas[0].filing_id);
-            if (this.ctx.subProject.permission.file_permission.indexOf(this.ctx.service.subProjPermission.PermissionConst.file.delete.value) < 0) {
+            if (this.ctx.subProject.permission.file_permission.indexOf(this.ctx.service.subProjPermission.PermissionConst.file.editfile.value) < 0) {
                 for (const file of fileDatas) {
                     if (file.user_id !== this.ctx.session.sessionUser.accountId) throw '无权删除文件';
                 }

+ 1 - 1
app/service/sub_proj_permission.js

@@ -33,7 +33,7 @@ module.exports = app => {
                 file: {
                     view: { title: '查看', value: 1 },
                     upload: { title: '上传/引用', value: 2 },
-                    delete: { title: '删除文件', value: 4 },
+                    editfile: { title: '编辑文件', value: 4 },
                     filing: { title: '文件类别编辑', value: 3 },
                 },
                 manage: {

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

@@ -112,6 +112,6 @@
     const filing = JSON.parse(unescape('<%- escape(JSON.stringify(filing)) %>'));
     const category = JSON.parse(unescape('<%- escape(JSON.stringify(categoryData)) %>'));
     const whiteList = JSON.parse('<%- JSON.stringify(ctx.app.config.multipart.whitelist) %>');
-    const canDelete = <%- canDelete %>;
+    const canEdit = <%- canEdit %>;
     const fileReferenceList = JSON.parse('<%- JSON.stringify(fileReferenceList) %>');
 </script>

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

@@ -221,4 +221,5 @@
             </div>
         </div>
     </div>
-</div>
+</div>
+<% include ../shares/delete_hint_modal.ejs %>