MaiXinRong 5 дней назад
Родитель
Сommit
c6cded0b78
2 измененных файлов с 137 добавлено и 3 удалено
  1. 123 3
      app/public/js/shares/tools_att.js
  2. 14 0
      app/public/js/sp_progress.js

+ 123 - 3
app/public/js/shares/tools_att.js

@@ -17,6 +17,9 @@
         const fileInfo = setting.fileInfo || { user_name: 'username', user_id: 'uid', create_time: 'in_time' };
         const pageLength = 20;
         let curNode = null, curPage = 0;
+        let ctrlLength = 80;
+        if (setting.saveUrl) ctrlLength = ctrlLength + 15;
+        if (setting.moveUrl) ctrlLength = ctrlLength + 15;
         obj.html(
             '<div class="sjs-bar">\n' +
             '    <ul class="nav nav-tabs">\n' +
@@ -36,7 +39,7 @@
             '        <div style="overflow:auto; overflow-x:hidden; height: 100%">\n' +
             '            <div class="mt-1 mb-1" id="att-cur-hint"></div>\n' +
             '            <table class="table table-sm table-bordered table-hover" style="word-break:break-all; table-layout: fixed">\n' +
-            '                <thead><tr><th width="25"><input type="checkbox" class="check-all-file"><th>文件名</th><th width="80">上传</th><th width="100">操作</th></tr></thead>\n' +
+            '                <thead><tr><th width="25"><input type="checkbox" class="check-all-file"><th>文件名</th><th width="80">上传</th><th width="' + ctrlLength + '">操作</th></tr></thead>\n' +
             '                <tbody id="cur-att-list" class="list-table"></tbody>\n' +
             '            </table>\n' +
             '        </div>\n' +
@@ -44,7 +47,7 @@
             '    <div class="tab-pane" id="att-all" style="height: 100%">\n' +
             '        <div style="overflow:auto; overflow-x:hidden; height: 100%">\n' +
             '            <table class="table table-sm table-bordered table-hover" style="word-break:break-all; table-layout: fixed">\n' +
-            '                <thead><tr><th width="25"><input type="checkbox" class="check-all-file"></th><th>文件名</th><th width="80">上传</th><th width="100">操作</th></tr></thead>\n' +
+            '                <thead><tr><th width="25"><input type="checkbox" class="check-all-file"></th><th>文件名</th><th width="80">上传</th><th width="' + ctrlLength + '">操作</th></tr></thead>\n' +
             '                <tbody id="all-att-list" class="list-table"></tbody>\n' +
             '           </table>\n' +
             '        </div>\n' +
@@ -56,7 +59,7 @@
             '                <div class="input-group-append"><button id="att-search-btn" class="btn btn-outline-secondary" type="button">搜索</button></div>\n' +
             '            </div>\n' +
             '            <table class="table table-sm table-bordered table-hover" style="word-break:break-all; table-layout: fixed">\n' +
-            '                <thead><tr><th width="25"><input type="checkbox" class="check-all-file"></th><th>文件名</th><th width="80">上传</th><th width="100">操作</th></tr></thead>\n' +
+            '                <thead><tr><th width="25"><input type="checkbox" class="check-all-file"></th><th>文件名</th><th width="80">上传</th><th width="' + ctrlLength + '">操作</th></tr></thead>\n' +
             '                <tbody id="search-att-list" class="list-table"></tbody>\n' +
             '           </table>\n' +
             '        </div>\n' +
@@ -166,6 +169,100 @@
                 return `<div class="d-flex"><a href="javascript:void(0)" ${tipType}"${tipHtml}" class="pl-0 col-11" file-id=${att.id}>${att.filename}${att.fileext}</a></div>`;
             }
         };
+        const moveObj = {
+            initMoveModal: function() {
+                if (this.initModal) return;
+                const html = '<div class="modal fade" id="move-att2" data-backdrop="static">\n' +
+                    '    <div class="modal-dialog" role="document">\n' +
+                    '        <div class="modal-content">\n' +
+                    '            <div class="modal-header">\n' +
+                    '                <h5 class="modal-title">选择</h5>\n' +
+                    '            </div>\n' +
+                    '            <div class="modal-body">\n' +
+                    '                <div class="btn-group">\n' +
+                    '                    <button type="button" class="btn btn-sm  text-primary dropdown-toggle" data-toggle="dropdown" id="mf2-zhankai" aria-expanded="false">显示层级</button>\n' +
+                    '                    <div class="dropdown-menu" aria-labelledby="mf2-zhankai" x-placement="bottom-start" style="position: absolute; transform: translate3d(0px, 21px, 0px); top: 0px; left: 0px; will-change: transform;">\n' +
+                    '                        <a class="dropdown-item" name="ma2-showLevel" tag="1" href="javascript: void(0);">第一层</a>\n' +
+                    '                        <a class="dropdown-item" name="ma2-showLevel" tag="2" href="javascript: void(0);">第二层</a>\n' +
+                    '                        <a class="dropdown-item" name="ma2-showLevel" tag="3" href="javascript: void(0);">第三层</a>\n' +
+                    '                        <a class="dropdown-item" name="ma2-showLevel" tag="4" href="javascript: void(0);">第四层</a>\n' +
+                    '                        <a class="dropdown-item" name="ma2-showLevel" tag="last" href="javascript: void(0);">最底层</a>\n' +
+                    '                    </div>\n' +
+                    '                </div>\n' +
+                    '                <div class="modal-height-500 mt-2" id="move-att2-tree">\n' +
+                    '                </div>\n' +
+                    '            </div>\n' +
+                    '            <div class="modal-footer">\n' +
+                    '                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>\n' +
+                    '                <button type="button" class="btn btn-primary btn-sm" id="move-att2-ok">确定移动</button>\n' +
+                    '            </div>\n' +
+                    '        </div>\n' +
+                    '    </div>\n' +
+                    '</div>';
+                $('body').append(html);
+                this.initModal = true;
+            },
+            initLoadCol: function() {
+                if (this.loadCol) return;
+                const loadCol = [setting.key];
+                if (setting.relaTree) {
+                    const treeSetting = setting.relaTree.setting;
+                    loadCol.push(treeSetting.id, treeSetting.pid, treeSetting.order, treeSetting.level, treeSetting.isLeaf, treeSetting.fullPath);
+                }
+                if (setting.relaTreeSpreadSetting) setting.relaTreeSpreadSetting.cols.forEach(c => { loadCol.push(c.field); });
+                this.loadCol = loadCol;
+            },
+            initMoveTree: function() {
+                if (!setting.relaTree) {
+                    this.moveTree = null;
+                    return;
+                }
+                if (!this.moveTree) this.moveTree = createNewPathTree('base', JSON.parse(JSON.stringify(setting.relaTree.setting)));
+                const fields = this.loadCol;
+                const datas = setting.relaTree.nodes.map(n => {
+                    const nn = {};
+                    for (const f of fields) {
+                        nn[f] = n[f];
+                    }
+                    return nn;
+                });
+                this.moveTree.loadDatas(datas);
+            },
+            showMoveTree: function() {
+                if (!this.moveTree) return;
+                if (!this.spread) {
+                    const spread = SpreadJsObj.createNewSpread($('#move-att2-tree')[0]);
+                    this.spread = spread;
+                    this.sheet = this.spread.getActiveSheet();
+                    SpreadJsObj.initSheet(this.sheet, setting.relaTreeSpreadSetting);
+                    $('#move-att2').on('shown.bs.modal', function() {
+                        spread.refresh();
+                    })
+                }
+                SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Tree, this.moveTree, true);
+            },
+            show: function(file) {
+                this.file = file;
+                this.initMoveModal();
+                this.initLoadCol();
+                this.initMoveTree();
+                this.showMoveTree();
+                $('#move-att2').modal('show');
+            },
+            moveoNodeIndex: function(data) {
+                const oxi = nodeIndexes[this.file[setting.masterKey]];
+                if (oxi) {
+                    const oxii = findFileIndex(oxi, this.file.id);
+                    if (oxii) oxi.splice(oxii, 1);
+                }
+                if (!nodeIndexes[data[setting.masterKey]]) {
+                    nodeIndexes[data[setting.masterKey]] = [this.file];
+                } else {
+                    nodeIndexes[data[setting.masterKey]].unshift(this.file);
+                }
+                this.file[setting.masterKey] = data[setting.masterKey];
+            }
+        };
         const findFile = setting.fileIdType === 'string'
             ? function (list, id) { return list.find(item => item.id === id); }
             : function (list, id) { return list.find(item => item.id === parseInt(id)); };
@@ -388,6 +485,29 @@
 
             td.html(searchObj.getFileNameHtml(att));
         });
+        $('body').on('click', "a[name=att-move]", function() {
+            const id = this.getAttribute('file-id');
+            const att = findFile(allAtts, id);
+            moveObj.show(att);
+        });
+        $('body').on('click', '#move-att2-ok', function() {
+            const select = SpreadJsObj.getSelectObject(moveObj.sheet);
+            if (!select) {
+                toastr.warning('请选择要移动至的节点');
+                return;
+            }
+            if (select[setting.key] === moveObj.file[setting.masterKey]) {
+                toastr.warning('请勿移动至原所属节点下');
+                return;
+            }
+            const updateData = { id: moveObj.file.id };
+            updateData[setting.masterKey] = select[setting.key];
+            postData(setting.moveUrl, updateData, function (result) {
+                moveObj.moveoNodeIndex(result);
+                refreshCurAttHtml();
+                $('#move-att2').modal('hide');
+            });
+        });
         // 监听附件check是否选中
         $('.list-table').on('click', '.check-file', function() {
             const checkedList = $(this).parents('.list-table').children().find('input:checked');

+ 14 - 0
app/public/js/sp_progress.js

@@ -516,6 +516,20 @@ $(document).ready(() => {
             create_time: 'create_time',
         },
         search: true,
+        relaTree: progressObj.tree,
+        relaTreeSpreadSetting: {
+            cols: [
+                {title: '序号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 165, formatter: '@', cellType: 'tree'},
+                {title: '阶段/项目名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 210, formatter: '@', cellType: 'autoTip'},
+            ],
+            emptyRows: 0,
+            headRows: 1,
+            headRowHeight: [32],
+            defaultRowHeight: 21,
+            headerFont: '12px 微软雅黑',
+            font: '12px 微软雅黑',
+            readOnly: true,
+        },
         locate: function (att) {
             if (!att) return;
             SpreadJsObj.locateTreeNode(progressObj.sheet, att.node.tree_id, true);