浏览代码

1. 拷贝分项模板库,按钮位置调整
2. 资料归集,授权用户相关

MaiXinRong 5 月之前
父节点
当前提交
9e0a273024
共有 4 个文件被更改,包括 103 次插入31 次删除
  1. 0 1
      app/controller/file_controller.js
  2. 99 13
      app/public/js/file_detail.js
  3. 3 16
      app/view/file/file_modal.ejs
  4. 1 1
      app/view/file/template.ejs

+ 0 - 1
app/controller/file_controller.js

@@ -62,7 +62,6 @@ module.exports = app => {
                 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.filingTypes = ctx.service.filing.analysisFilingType(renderData.filing);
                 renderData.fileReferenceList = await ctx.service.subProject.getFileReference(ctx.subProject);
                 await this.layout('file/file.ejs', renderData, 'file/file_modal.ejs');
             } catch (err) {

+ 99 - 13
app/public/js/file_detail.js

@@ -1218,16 +1218,76 @@ $(document).ready(function() {
         constructor (setting) {
             this.setting = setting;
             const self = this;
+            this.spread = SpreadJsObj.createNewSpread($(`${setting.spread}`)[0]);
+            this.sheet = this.spread.getActiveSheet();
+            this.spreadSetting = {
+                cols: [
+                    { title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 200, formatter: '@', cellType: 'tree'},
+                    { title: '选择', colSpan: '1', rowSpan: '1', field: 'check', hAlign: 1, width: 45, cellType: 'checkbox' },
+                ],
+                emptyRows: 0,
+                headRows: 1,
+                headRowHeight: [32],
+                defaultRowHeight: 21,
+                headColWidth: [25],
+                headerFont: '12px 微软雅黑',
+                font: '12px 微软雅黑',
+                readOnly: true,
+                selectedBackColor: '#fffacd',
+            };
+            SpreadJsObj.initSheet(this.sheet, this.spreadSetting);
+            this.permissionTree = createNewPathTree('base', {
+                id: 'tree_id',
+                pid: 'tree_pid',
+                order: 'order',
+                level: 'level',
+                isLeaf: 'is_leaf',
+                fullPath: 'full_path',
+                rootId: -1,
+            });
+            this.spread.bind(spreadNS.Events.ButtonClicked, function(e, info) {
+                if (!info.sheet.zh_setting) return;
+                const sheet = info.sheet, cellType = sheet.getCellType(info.row, info.col);
+                if (cellType instanceof  spreadNS.CellTypes.CheckBox) {
+                    if (sheet.isEditing()) sheet.endEdit(true);
+                }
+                const col = info.sheet.zh_setting.cols[info.col];
+                if (col.field !== 'check') return;
+                const tree = self.permissionTree;
+                const node = tree.nodes[info.row];
+
+                const row = [info.row];
+                node.check = !node.check;
+                if (node.children && node.children.length > 0) {
+                    const posterity = tree.getPosterity(node);
+                    for (const p of posterity) {
+                        p.check = node.check;
+                        row.push(tree.nodes.indexOf(p));
+                    }
+                }
+                if (!node.check) {
+                    const parent = tree.getAllParents(node);
+                    for (const p of parent) {
+                        p.check = node.check;
+                        row.push(tree.nodes.indexOf(p));
+                    }
+                }
+                SpreadJsObj.reLoadRowsData(info.sheet, row);
+            });
+            this.spread.bind(spreadNS.Events.SelectionChanged, function (e, info) {
+                const node = SpreadJsObj.getSelectObject(info.sheet);
+                self.setCurFiling(node.filing_type);
+            });
+
             $(setting.modal).on('show.bs.modal', () => {
                 self.loadPermission();
             });
+            $(setting.modal).on('shown.bs.modal', () => {
+                self.spread.refresh();
+            });
             $(`${setting.modal}-ok`).click(() => {
                 self.savePermission();
             });
-            $('[name=ftName]').click(function () {
-                const filingId = this.getAttribute('ftid');
-                self.setCurFiling(filingId);
-            });
 
             $('.book-list').on('click', 'dt', function () {
                 const idx = $(this).find('.acc-btn').attr('data-groupid');
@@ -1262,14 +1322,12 @@ $(document).ready(function() {
                 self.loadCurFiling();
             });
             $('#sync-filing').click(function() {
-                const selectFiling = $('[name=cbft]:checked');
-                if (selectFiling.length === 0) {
+                const selectFilingId = [];
+                self.permissionTree.nodes.forEach(x => { if (x.check && (!x.children || x.children.length === 0)) selectFilingId.push(x.filing_type); });
+                if (selectFilingId.length === 0) {
                     toastr.warning('请先选择文档类别');
                     return;
                 }
-
-                const selectFilingId = [];
-                selectFiling.each((i, x) => { selectFilingId.push(x.value); });
                 self.syncFiling(self.curFiling, selectFilingId);
                 toastr.success('同步成功');
                 $('[name=cbft]').removeAttr('checked');
@@ -1295,7 +1353,10 @@ $(document).ready(function() {
                 $('input[uid]').attr('checked', this.checked);
             });
             $('#filing-select-all').click(function(){
-                $('input[name=cbft]').attr('checked', this.checked);
+                self.permissionTree.nodes.forEach(x => {
+                    x.check = this.checked;
+                });
+                SpreadJsObj.reloadColData(self.sheet, 1);
             });
         }
         analysisFiling(data) {
@@ -1329,8 +1390,6 @@ $(document).ready(function() {
         }
         setCurFiling(filingType) {
             this.curFiling = filingType;
-            $('[name=ftName]').removeClass('bg-warning-50');
-            $(`[ftid=${filingType}]`).addClass('bg-warning-50');
             this.loadCurFiling();
         }
         loadPermissionUser() {
@@ -1349,12 +1408,38 @@ $(document).ready(function() {
             }
             $('#puList').html(html.join(''));
         }
+        _convertData(sourceTree) {
+            const data = [];
+            for (const node of sourceTree.nodes) {
+                if (!node.is_fixed) continue;
+                const parent = node.tree_pid === '-1' ? undefined : data.find(x => { return x.id === node.tree_pid; });
+                const child = sourceTree.nodes.find(x => { return x.tree_pid === node.id; });
+                data.push({
+                    id: node.id,
+                    tree_id: data.length + 1,
+                    tree_pid: parent ? parent.tree_id : -1,
+                    order: node.tree_order + 1,
+                    level: node.tree_level,
+                    is_leaf: !child || !child.is_fixed,
+                    full_path: '',
+                    name: node.name,
+                    is_fixed: node.is_fixed,
+                    filing_type: node.filing_type + '',
+                    tips: node.tips,
+                    file_count: node.file_count,
+                });
+            }
+            return data;
+        }
         loadPermission() {
+            this.permissionTree.loadDatas(this._convertData(filingObj.dragTree));
+            SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Tree, this.permissionTree);
             const self = this;
             postData('permission', {}, function(result) {
                 self.analysisFiling(result);
                 if (!self.curFiling) {
-                    self.setCurFiling($('[name=ftName]').attr('ftid'));
+                    const node = SpreadJsObj.getSelectObject(self.sheet);
+                    self.setCurFiling(node.filing_type);
                 } else {
                     self.loadCurFiling();
                 }
@@ -1395,6 +1480,7 @@ $(document).ready(function() {
     const filingPermission = new FilingPermission({
         modal: '#filing-permission',
         list: '#filing-valid',
+        spread: '#permission-spread',
     });
 
     class FileSearch {

+ 3 - 16
app/view/file/file_modal.ejs

@@ -7,27 +7,14 @@
             </div>
             <div class="modal-body">
                 <div class="row">
-                    <div class="col-4">
+                    <div class="col-5">
                         <div class="d-flex justify-content-center bg-graye">
                             <div class="p-2 vertical-middle"><input class="mr-1" type="checkbox" id="filing-select-all">文档类别</div>
                         </div>
-                        <div class="modal-height-400 scroll-y">
-                            <div class="category">
-                                <ul style="list-style: none">
-                                    <% for (const ft of filingTypes) { %>
-                                    <li>
-                                        <div class="form-check">
-                                            <input class="form-check-input" name="cbft" type="checkbox" value="<%- ft.value %>" id="ftCheck<%- ft.value %>">
-                                            <label class="form-check-label" for="ftCheck<%- ft.value %>"></label>
-                                            <span name="ftName" ftid="<%- ft.value %>" title="<%- ft.parentsName %>"><%- ft.name %></span>
-                                        </div>
-                                    </li>
-                                    <% } %>
-                                </ul>
-                            </div>
+                        <div class="modal-height-400" id="permission-spread">
                         </div>
                     </div>
-                    <div class="col-8">
+                    <div class="col-7">
                         <div class="d-flex flex-row bg-graye">
                             <div class="p-2">
                                 <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="dropdown-up" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

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

@@ -12,6 +12,7 @@
                         <form class="ml-2 p-2" method="POST" action="/file/template/save">
                             <input type="hidden" name="_csrf_j" value="<%= ctx.csrf %>" />
                             <button class="btn btn-sm btn-light text-primary"><i class="fa fa-plus" aria-hidden="true" type="submit"></i> 新增模板库</button>
+                            <a href="javascript: void(0);" class="btn btn-sm btn-primary" id="import-share-template">拷贝分享模板库</a>
                         </form>
                     </div>
                     <div>
@@ -55,7 +56,6 @@
                         </form>
                         <div class="ml-auto p-2">
                             <a href="javascript: void(0);" class="btn btn-sm btn-primary" id="import-template">导入</a>
-                            <a href="javascript: void(0);" class="btn btn-sm btn-primary" id="import-share-template">拷贝分享模板库</a>
                             <a href="javascript: void(0);" class="btn btn-sm btn-primary" id="export-template">导出</a>
                             <a href="javascript: void(0);" class="btn btn-sm btn-primary" id="multi-setting">附加配置</a>
                         </div>