MaiXinRong пре 2 година
родитељ
комит
60dc3b321c

+ 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) {

+ 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 - 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>