|
@@ -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,17 +1322,16 @@ $(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');
|
|
|
+ self.permissionTree.nodes.forEach(x => { x.check = false; });
|
|
|
+ SpreadJsObj.reloadColData(self.sheet, 1);
|
|
|
$('#filing-select-all')[0].checked = false;
|
|
|
});
|
|
|
$('#batch-del-filing').click(() => {
|
|
@@ -1286,6 +1345,27 @@ $(document).ready(function() {
|
|
|
self.delFiling(self.curFiling, userId);
|
|
|
self.loadCurFiling();
|
|
|
});
|
|
|
+ $('#batch-add-filing').click(() => {
|
|
|
+ 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 selectUser = $('[name=ftu-check]:checked');
|
|
|
+ if (selectUser.length === 0) {
|
|
|
+ toastr.warning('请先选择用户');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const userId = [];
|
|
|
+ selectUser.each((i, x) => { userId.push(x.getAttribute('uid')); });
|
|
|
+ self.batchAddFiling(selectFilingId, userId);
|
|
|
+ self.loadCurFiling();
|
|
|
+ toastr.success('批量添加成功');
|
|
|
+ self.permissionTree.nodes.forEach(x => { x.check = false; });
|
|
|
+ SpreadJsObj.reloadColData(self.sheet, 1);
|
|
|
+ $('#filing-select-all')[0].checked = false;
|
|
|
+ });
|
|
|
$('body').on('click', '[name=del-filing]', function() {
|
|
|
const id = this.getAttribute('uid');
|
|
|
self.delFiling(self.curFiling, id);
|
|
@@ -1295,7 +1375,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) {
|
|
@@ -1327,11 +1410,25 @@ $(document).ready(function() {
|
|
|
$(this.setting.list).html(html.join(''));
|
|
|
$('#user-select-all')[0].checked = false;
|
|
|
}
|
|
|
+ refreshBtn() {
|
|
|
+ const self = this;
|
|
|
+ const filing = this.permissionTree.nodes.find(x => { return x.filing_type === self.curFiling; });
|
|
|
+ if (!filing || (filing.children && filing.children.length > 0)) {
|
|
|
+ $('#filing-add-user').hide();
|
|
|
+ $('#batch-del-filing').hide();
|
|
|
+ $('#batch-add-filing').hide();
|
|
|
+ $('#sync-filing').hide();
|
|
|
+ } else {
|
|
|
+ $('#filing-add-user').show();
|
|
|
+ $('#batch-del-filing').show();
|
|
|
+ $('#batch-add-filing').show();
|
|
|
+ $('#sync-filing').show();
|
|
|
+ }
|
|
|
+ }
|
|
|
setCurFiling(filingType) {
|
|
|
this.curFiling = filingType;
|
|
|
- $('[name=ftName]').removeClass('bg-warning-50');
|
|
|
- $(`[ftid=${filingType}]`).addClass('bg-warning-50');
|
|
|
this.loadCurFiling();
|
|
|
+ this.refreshBtn();
|
|
|
}
|
|
|
loadPermissionUser() {
|
|
|
const html = [];
|
|
@@ -1349,12 +1446,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();
|
|
|
}
|
|
@@ -1382,6 +1505,15 @@ $(document).ready(function() {
|
|
|
if (pu.filing_type.indexOf(filingId) >= 0) pu.filing_type.splice(pu.filing_type.indexOf(filingId), 1);
|
|
|
}
|
|
|
}
|
|
|
+ batchAddFiling(filingIds, userId) {
|
|
|
+ for (const pu of this.permissionUser) {
|
|
|
+ if (userId.indexOf(pu.id) < 0) continue;
|
|
|
+
|
|
|
+ filingIds.forEach(fid => {
|
|
|
+ if (pu.filing_type.indexOf(fid) < 0) pu.filing_type.push(fid);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
savePermission() {
|
|
|
const self = this;
|
|
|
const data = this.permissionUser.map(x => {
|
|
@@ -1395,6 +1527,7 @@ $(document).ready(function() {
|
|
|
const filingPermission = new FilingPermission({
|
|
|
modal: '#filing-permission',
|
|
|
list: '#filing-valid',
|
|
|
+ spread: '#permission-spread',
|
|
|
});
|
|
|
|
|
|
class FileSearch {
|
|
@@ -1576,9 +1709,8 @@ $(document).ready(function() {
|
|
|
spreadSetting: {
|
|
|
cols: [
|
|
|
{title: '名称', field: 'name', hAlign: 0, width: 300, formatter: '@', cellType: 'tree', wordWrap: true},
|
|
|
- {title: '备注', field: 'remark', hAlign: 1, width: 150, formatter: '@', wordWrap: true}
|
|
|
+ {title: '备注', field: 'remark', hAlign: 1, width: 150, formatter: '@'}
|
|
|
],
|
|
|
- treeCol: 0,
|
|
|
emptyRows: 0,
|
|
|
headRows: 1,
|
|
|
headRowHeight: [32],
|