|
@@ -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 {
|