MaiXinRong 4 лет назад
Родитель
Сommit
97e0609530

+ 14 - 80
app/public/js/ledger.js

@@ -1218,11 +1218,10 @@ $(document).ready(function() {
     //     const $obj = $('<div>' + item.name +)
     // };
     // 右键菜单
-    let addTagShare = true;
+    const addTag = newTag({ledgerSheet: ledgerSpread.getActiveSheet(), billsTag});
     const billsContextMenuOptions = {
         selector: '#ledger-spread',
         build: function ($trigger, e) {
-            addTagShare = true;
             const target = SpreadJsObj.safeRightClickSelection($trigger, e, ledgerSpread);
             return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
         },
@@ -1295,7 +1294,7 @@ $(document).ready(function() {
                 return !readOnly;
             }
         };
-        billsContextMenuOptions.items.sprBase = '-----------';
+        billsContextMenuOptions.items.sprBase = '----';
     }
     billsContextMenuOptions.items.copyBlock = {
         name: '复制整块',
@@ -1411,7 +1410,7 @@ $(document).ready(function() {
                 return !readOnly;
             }
         };
-        billsContextMenuOptions.items.sprBlock = '-----------';
+        billsContextMenuOptions.items.sprBlock = '----';
     }
     if (!readOnly) {
         billsContextMenuOptions.items.sortChildren = {
@@ -1441,7 +1440,7 @@ $(document).ready(function() {
                 }
             };
         }
-        billsContextMenuOptions.items.sprSort = '-----------';
+        billsContextMenuOptions.items.sprSort = '----';
     }
     if (!readOnly) {
         billsContextMenuOptions.items.batchInsert = {
@@ -1520,7 +1519,7 @@ $(document).ready(function() {
                 return !readOnly;
             }
         };
-        billsContextMenuOptions.items.sprBatch = '-----------';
+        billsContextMenuOptions.items.sprBatch = '----';
     }
     if (!readOnly) {
         billsContextMenuOptions.items.importExcel = {
@@ -1605,83 +1604,18 @@ $(document).ready(function() {
                 return !readOnly;
             }
         };
-        billsContextMenuOptions.items.sprImport = '-----------';
+        billsContextMenuOptions.items.sprImport = '----';
     }
     billsContextMenuOptions.items.tag = {
         name: '书签',
-        items: {
-            tagShare: {
-                name: '参与人可见',
-                type: 'checkbox',
-                selected: true,
-                events: {
-                    change: function () {
-                        addTagShare = this.checked;
-                    }
-                }
-            },
-            tagSpr: '--------------',
-            tagPrimary: {
-                icon: 'fa-tag text-primary mt-2 mb-2',
-                name: '靛青',
-                callback: function (key, opt, menu, e) {
-                    const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
-                    postData(window.location.pathname + '/tag', {add: { color: '#007bff', lid: node.id, share: addTagShare }}, function (data) {
-                        if (data.add) data.add.node = node;
-                        billsTag.updateDatasAndShow(data);
-                        SpreadJsObj.repaintNodesRowHeader(ledgerSpread.getActiveSheet(), node);
-                    });
-                },
-            },
-            tagSuccess: {
-                icon: 'fa-tag text-success mt-2 mb-2',
-                name: '果绿',
-                callback: function (key, opt) {
-                    const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
-                    postData(window.location.pathname + '/tag', {add: { color: '#28a745', lid: node.id, share: addTagShare }}, function (data) {
-                        if (data.add) data.add.node = node;
-                        billsTag.updateDatasAndShow(data);
-                        SpreadJsObj.repaintNodesRowHeader(ledgerSpread.getActiveSheet(), node);
-                    });
-                },
-            },
-            tagDanger: {
-                icon: 'fa-tag text-danger mt-2 mb-2',
-                name: '朱砂',
-                callback: function (key, opt) {
-                    const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
-                    postData(window.location.pathname + '/tag', {add: { color: '#dc3545', lid: node.id, share: addTagShare }}, function (data) {
-                        if (data.add) data.add.node = node;
-                        billsTag.updateDatasAndShow(data);
-                        SpreadJsObj.repaintNodesRowHeader(ledgerSpread.getActiveSheet(), node);
-                    });
-                },
-            },
-            tagWarning: {
-                icon: 'fa-tag text-warning mt-2 mb-2',
-                name: '姜黄',
-                callback: function (key, opt) {
-                    const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
-                    postData(window.location.pathname + '/tag', {add: { color: '#da9500', lid: node.id, share: addTagShare }}, function (data) {
-                        if (data.add) data.add.node = node;
-                        billsTag.updateDatasAndShow(data);
-                        SpreadJsObj.repaintNodesRowHeader(ledgerSpread.getActiveSheet(), node);
-                    });
-                },
-            },
-            tagInfo: {
-                icon: 'fa-tag text-info mt-2 mb-2',
-                name: '天蓝',
-                callback: function (key, opt) {
-                    const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
-                    postData(window.location.pathname + '/tag', {add: { color: '#17a2b8', lid: node.id, share: addTagShare }}, function (data) {
-                        if (data.add) data.add.node = node;
-                        billsTag.updateDatasAndShow(data);
-                        SpreadJsObj.repaintNodesRowHeader(ledgerSpread.getActiveSheet(), node);
-                    });
-                },
-            }
+        callback: function (key, opt, menu, e) {
+            const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
+            addTag.do(node);
         },
+        disabled: function (key, opt) {
+            const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
+            return !node;
+        }
     };
 
     $.contextMenu(billsContextMenuOptions);
@@ -2767,7 +2701,7 @@ $(document).ready(function() {
                                 self.OprObj.delete(self.sheet);
                             },
                         },
-                        sprEdit: '---------',
+                        sprEdit: '----',
                         apply: {
                             name: '应用全部清单单价至台账',
                             icon: 'fa-magic',

+ 3 - 3
app/public/js/revise.js

@@ -1049,7 +1049,7 @@ $(document).ready(() => {
                 return !(valid && first && sameParent && !(first.level === 1 && first.node_type) && !nodeUsed);
             }
         };
-        billsContextMenuOptions.items.sprBase = '-----------';
+        billsContextMenuOptions.items.sprBase = '----';
     }
     billsContextMenuOptions.items.copyBlock = {
         name: '复制整块',
@@ -1159,7 +1159,7 @@ $(document).ready(() => {
                 return !readOnly;
             }
         };
-        billsContextMenuOptions.items.sprBlock = '-----------';
+        billsContextMenuOptions.items.sprBlock = '----';
     }
     if (!readOnly) {
         billsContextMenuOptions.items.batchInsert = {
@@ -1217,7 +1217,7 @@ $(document).ready(() => {
                 $('#batch').modal('show');
             }
         };
-        billsContextMenuOptions.items.sprBatch = '-----------';
+        billsContextMenuOptions.items.sprBatch = '----';
         billsContextMenuOptions.items.importGclBills2Xmj = {
             name: '导入工程量清单至项目节',
             icon: 'fa-file-excel-o',

+ 3 - 3
app/public/js/shares/cs_tools.js

@@ -635,7 +635,7 @@ const showSelectTab = function(select, spread, afterShow) {
         };
 
         const getTagEditHtml = function(tag) {
-            const tagClass = classIndexes.find(x => {return x.color === tag.color});
+            const tagClass = classIndexes.find(x => {return x.color === tag.color}) || {};
             const tagHtml = [];
             tagHtml.push('<div name="tag-edit">');
             tagHtml.push('<div class="card-header p-2"><div class="dropdown">');
@@ -673,7 +673,7 @@ const showSelectTab = function(select, spread, afterShow) {
         };
 
         const getTagDisplayHtml = function (tag) {
-            const tagClass = classIndexes.find(x => {return x.color === tag.color});
+            const tagClass = classIndexes.find(x => {return x.color === tag.color}) || {};
             const tagHtml = [];
             tagHtml.push('<div name="tag-view">');
             tagHtml.push('<div class="card-header p-2"><div class="dropdown">');
@@ -834,7 +834,7 @@ const showSelectTab = function(select, spread, afterShow) {
         const getBillsTagsInfo = function (id) {
             const billsTags = billsIndexes[id] || [];
             return billsTags.length > 0 ? billsTags.map(x => {
-                const tagClass = classIndexes.find(tc => {return tc.color === x.color});
+                const tagClass = classIndexes.find(tc => {return tc.color === x.color}) || {};
                 return {color: x.color, comment: x.comment, tagClass: tagClass.tagClass};
             }) : undefined;
         };

+ 34 - 0
app/public/js/shares/new_tag.js

@@ -0,0 +1,34 @@
+const newTag = function (setting) {
+    const billsTag = setting.billsTag;
+    const billsSheet = setting.ledgerSheet;
+    let relaNode;
+
+    const addTag = function (node) {
+        relaNode = node;
+        const code = (node.code || '') + (node.b_code || '');
+        $('#addtag-info').html(code + ' / ' + node.name);
+        $('#addtag').modal('show');
+        $('#addtag-content').val('');
+    };
+    $('[name=addtag-color]').click(function () {
+        $('[name=addtag-color]').removeClass('active');
+        $(this).addClass('active');
+    });
+    $('#addtag-ok').click(function () {
+        const data = {
+            add: {
+                color: $('.active[name=addtag-color]').attr('tag-color'),
+                lid: relaNode.id,
+                share: $('#addtag-share')[0].checked,
+                comment: $('#addtag-content').val(),
+            }
+        };
+        postData(window.location.pathname + '/tag', data, result => {
+            if (result.add) result.add.node = relaNode;
+            billsTag.updateDatasAndShow(result);
+            SpreadJsObj.repaintNodesRowHeader(billsSheet, relaNode);
+            $('#addtag').modal('hide');
+        });
+    });
+    return {do: addTag}
+}

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

@@ -1317,11 +1317,10 @@ $(document).ready(() => {
         });
     }
     stageTreeSpreadObj.loadExprToInput(slSpread.getActiveSheet());
-    let addTagShare = true;
+    const addTag = newTag({ledgerSheet: slSpread.getActiveSheet(), billsTag});
     $.contextMenu({
         selector: '#stage-ledger',
         build: function ($trigger, e) {
-            addTagShare = true;
             const target = SpreadJsObj.safeRightClickSelection($trigger, e, slSpread);
             return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
         },
@@ -1358,81 +1357,17 @@ $(document).ready(() => {
                     }
                 },
             },
+            tagSpr: '----',
             tag: {
                 name: '书签',
-                items: {
-                    tagShare: {
-                        name: '参与人可见',
-                        type: 'checkbox',
-                        selected: true,
-                        events: {
-                            change: function () {
-                                addTagShare = this.checked;
-                            }
-                        }
-                    },
-                    tagSpr: '--------------',
-                    tagPrimary: {
-                        icon: 'fa-tag text-primary mt-2 mb-2',
-                        name: '靛青',
-                        callback: function (key, opt, menu, e) {
-                            const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
-                            postData(window.location.pathname + '/tag', {add: { color: '#007bff', lid: node.id, share: addTagShare }}, function (data) {
-                                if (data.add) data.add.node = node;
-                                billsTag.updateDatasAndShow(data);
-                                SpreadJsObj.repaintNodesRowHeader(slSpread.getActiveSheet(), node);
-                            });
-                        },
-                    },
-                    tagSuccess: {
-                        icon: 'fa-tag text-success mt-2 mb-2',
-                        name: '果绿',
-                        callback: function (key, opt) {
-                            const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
-                            postData(window.location.pathname + '/tag', {add: { color: '#28a745', lid: node.id, share: addTagShare }}, function (data) {
-                                if (data.add) data.add.node = node;
-                                billsTag.updateDatasAndShow(data);
-                                SpreadJsObj.repaintNodesRowHeader(slSpread.getActiveSheet(), node);
-                            });
-                        },
-                    },
-                    tagDanger: {
-                        icon: 'fa-tag text-danger mt-2 mb-2',
-                        name: '朱砂',
-                        callback: function (key, opt) {
-                            const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
-                            postData(window.location.pathname + '/tag', {add: { color: '#dc3545', lid: node.id, share: addTagShare }}, function (data) {
-                                if (data.add) data.add.node = node;
-                                billsTag.updateDatasAndShow(data);
-                                SpreadJsObj.repaintNodesRowHeader(slSpread.getActiveSheet(), node);
-                            });
-                        },
-                    },
-                    tagWarning: {
-                        icon: 'fa-tag text-warning mt-2 mb-2',
-                        name: '姜黄',
-                        callback: function (key, opt) {
-                            const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
-                            postData(window.location.pathname + '/tag', {add: { color: '#da9500', lid: node.id, share: addTagShare }}, function (data) {
-                                if (data.add) data.add.node = node;
-                                billsTag.updateDatasAndShow(data);
-                                SpreadJsObj.repaintNodesRowHeader(slSpread.getActiveSheet(), node);
-                            });
-                        },
-                    },
-                    tagInfo: {
-                        icon: 'fa-tag text-info mt-2 mb-2',
-                        name: '天蓝',
-                        callback: function (key, opt) {
-                            const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
-                            postData(window.location.pathname + '/tag', {add: { color: '#17a2b8', lid: node.id, share: addTagShare }}, function (data) {
-                                if (data.add) data.add.node = node;
-                                billsTag.updateDatasAndShow(data);
-                                SpreadJsObj.repaintNodesRowHeader(slSpread.getActiveSheet(), node);
-                            });
-                        },
-                    }
+                callback: function (key, opt, menu, e) {
+                    const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
+                    addTag.do(node);
                 },
+                disabled: function (key, opt) {
+                    const node = SpreadJsObj.getSelectObject(slSpread.getActiveSheet());
+                    return !node;
+                }
             },
         }
     });

+ 1 - 0
app/view/ledger/explode_modal.ejs

@@ -403,3 +403,4 @@
 <% include ../shares/delete_hint_modal.ejs %>
 <% include ../shares/check_data_modal.ejs %>
 <% include ../shares/check_modal2.ejs %>
+<% include ../shares/new_tag_modal.ejs %>

+ 55 - 0
app/view/shares/new_tag_modal.ejs

@@ -0,0 +1,55 @@
+<!--添加书签-->
+<div class="modal fade" id="addtag" data-backdrop="static">
+    <div class="modal-dialog" role="document">
+        <div class="modal-content">
+            <div class="modal-header">
+                <h5 class="modal-title">添加书签</h5>
+            </div>
+            <div class="modal-body">
+                <div class="card border-danger my-2 ">
+                    <div class="card-header p-2" id="addtag-info">
+                        403-1-b / 带肋钢筋(HRB335、HRB400)
+                    </div>
+                    <div class="card-body p-2">
+                        <div class="form-group">
+                            <div class="btn-group btn-group-sm">
+                                <button type="button" class="btn btn-light" name="addtag-color" tag-color="#007bff">
+                                    <i class="fa fa-tint text-primary"></i>
+                                </button>
+                                <button type="button" class="btn btn-light" name="addtag-color" tag-color="#28a745">
+                                    <i class="fa fa-tint text-success"></i>
+                                </button>
+                                <button type="button" class="btn btn-light active" name="addtag-color" tag-color="#dc3545">
+                                    <i class="fa fa-tint text-danger"></i>
+                                </button>
+                                <button type="button" class="btn btn-light" name="addtag-color" tag-color="#da9500">
+                                    <i class="fa fa-tint text-warning"></i>
+                                </button>
+                                <button type="button" class="btn btn-light" name="addtag-color" tag-color="#17a2b8">
+                                    <i class="fa fa-tint text-info"></i>
+                                </button>
+                            </div>
+                        </div>
+                        <div class="form-group">
+                            <textarea name="" class="form-control" id="addtag-content"></textarea>
+                        </div>
+                        <div class="form-group">
+                            <div class="custom-control custom-switch">
+                                <input type="checkbox" class="custom-control-input custom-control-warning-input"
+                                    id="addtag-share">
+                                <label class="custom-control-label" for="addtag-share" data-toggle="tooltip"
+                                    data-placement="bottom" title="" data-original-title="所有参与计量审批管理的用户都可以看到这条书签"><i
+                                        class="fa fa-users"></i> 参与者可见</label>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+            <div class="modal-footer">
+                <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
+                <button type="button" class="btn btn-sm btn-primary" id="addtag-ok">确认添加</button>
+            </div>
+        </div>
+    </div>
+</div>
+<!-- 需引入/shares/new_tag.js -->

+ 1 - 0
app/view/stage/modal.ejs

@@ -511,3 +511,4 @@
 <% include ./audit_modal.ejs %>
 <% include ../shares/merge_peg_modal.ejs %>
 <% include ../shares/check_modal2.ejs %>
+<% include ../shares/new_tag_modal.ejs %>

+ 3 - 1
config/web.js

@@ -136,15 +136,16 @@ const JsFiles = {
                     '/public/js/decimal.min.js',
                     '/public/js/math.min.js',
                     '/public/js/file-saver/FileSaver.js',
-                    '/public/js/shares/export_excel.js',
                 ],
                 mergeFiles: [
                     '/public/js/sub_menu.js',
                     '/public/js/div_resizer.js',
                     '/public/js/spreadjs_rela/spreadjs_zh.js',
                     '/public/js/shares/sjs_setting.js',
+                    '/public/js/shares/export_excel.js',
                     '/public/js/shares/cs_tools.js',
                     '/public/js/shares/merge_peg.js',
+                    '/public/js/shares/new_tag.js',
                     '/public/js/zh_calc.js',
                     '/public/js/path_tree.js',
                     '/public/js/ledger_tree_col.js',
@@ -321,6 +322,7 @@ const JsFiles = {
                     '/public/js/shares/export_excel.js',
                     '/public/js/shares/cs_tools.js',
                     '/public/js/shares/merge_peg.js',
+                    '/public/js/shares/new_tag.js',
                     '/public/js/zh_calc.js',
                     '/public/js/path_tree.js',
                     '/public/js/stage_im.js',