|
|
@@ -4,13 +4,17 @@ const reportFormatSetupObj = {
|
|
|
canvas: null,
|
|
|
fieldParamOptions: null,
|
|
|
maxFieldID: -1,
|
|
|
+ currentRptId: -1,
|
|
|
onCheck: (event, treeId, treeNode) => {
|
|
|
//
|
|
|
},
|
|
|
onClick: (event,treeId,treeNode) => {
|
|
|
const me = reportFormatSetupObj;
|
|
|
if (treeNode.nodeType === RT.NodeType.TEMPLATE) {
|
|
|
+ me.currentRptId = treeNode.refId;
|
|
|
me.initialize(treeNode);
|
|
|
+ } else {
|
|
|
+ me.currentRptId = -1;
|
|
|
}
|
|
|
},
|
|
|
onDeleteInfo: (dom) => {
|
|
|
@@ -88,21 +92,35 @@ const reportFormatSetupObj = {
|
|
|
me.maxFieldID++;
|
|
|
const newSignature = [];
|
|
|
newSignature.push('<li class="d-flex justify-content-start align-items-center mb-3">');
|
|
|
- newSignature.push(`<span class="col-auto"><input class="form-control form-control-sm" FID="${me.maxFieldID}" value="" type="text"></span>`);
|
|
|
+ newSignature.push(`<span class="col-auto"><input class="form-control form-control-sm" FID="${me.maxFieldID}" value="" type="text" onchange="reportFormatSetupObj.onSignNameChange(this)"></span>`);
|
|
|
newSignature.push('<span><a href="#" onclick="reportFormatSetupObj.onRemoveSignature(this)" class="btn-sm text-danger px-1" title="移除"><i class="fa fa-remove"></i></a></span>');
|
|
|
newSignature.push('</li>');
|
|
|
$(dom.parentElement).before(newSignature.join(''));
|
|
|
+ me.fieldParamOptions.fields_collection.push({ FID: me.maxFieldID, name: '' });
|
|
|
+ },
|
|
|
+ onSignNameChange: (dom) => {
|
|
|
+ const me = reportFormatSetupObj;
|
|
|
+ const fid = +dom.attributes[1].value;
|
|
|
+ for (const opt of me.fieldParamOptions.fields_collection) {
|
|
|
+ if (opt.FID === fid) {
|
|
|
+ opt.name = dom.value;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
onRemoveSignature: (dom) => {
|
|
|
$(dom.parentElement.parentElement).remove();
|
|
|
},
|
|
|
+ refreshFieldOptions: () => {
|
|
|
+ // 重新更新已存在页面的指标选择下拉项
|
|
|
+ },
|
|
|
initialize: (rptNode) => {
|
|
|
const me = reportFormatSetupObj;
|
|
|
me.canvas = document.getElementById("rptSetupPreviewCanvas");
|
|
|
// 1. 先清理
|
|
|
me.clearTplProperties();
|
|
|
// 2. 再加表标题、表眉、表脚、电子签名内容
|
|
|
- const params = { rpt_tpl_id: rptNode.refId };
|
|
|
+ const params = { rpt_tpl_id: rptNode.refId, tender_id: TENDER_ID };
|
|
|
const url = '/report_api/getReportTemplate';
|
|
|
$.bootstrapLoading.start();
|
|
|
CommonAjax.postXsrfEx(url, params, 300000, true, getCookie('csrfToken_j'),
|
|
|
@@ -126,6 +144,9 @@ const reportFormatSetupObj = {
|
|
|
me.initialHeader(result.data);
|
|
|
me.initialFooter(result.data);
|
|
|
me.initialSignature(result.data);
|
|
|
+ reportPermissionObj.permissions = result.permissions;
|
|
|
+ reportPermissionObj.iniReportPermission();
|
|
|
+ reportPermissionObj.updateSelectedMarks();
|
|
|
$.bootstrapLoading.end();
|
|
|
}, function(err){
|
|
|
console.log(err);
|
|
|
@@ -313,6 +334,9 @@ const reportFormatSetupObj = {
|
|
|
for (const fd of rptTpl['指标_数据_映射']['离散指标_集合']) {
|
|
|
rst.fields_collection.push({ FID: +fd.ID, name: fd.Name });
|
|
|
}
|
|
|
+ for (const fd of rptTpl['电子签名离散指标_集合']) {
|
|
|
+ rst.fields_collection.push({ FID: +fd.ID, name: fd.Name });
|
|
|
+ }
|
|
|
const collectAdhocFields = (hfBandInfo) => {
|
|
|
if (hfBandInfo && hfBandInfo.discrete_field_s) {
|
|
|
for (const field of hfBandInfo.discrete_field_s) {
|
|
|
@@ -717,4 +741,224 @@ const reportFormatSetupObj = {
|
|
|
rptTpl['电子签名审核意见指标_集合'] = signatureInfo[2];
|
|
|
}
|
|
|
},
|
|
|
-};
|
|
|
+};
|
|
|
+
|
|
|
+const reportPermissionObj = {
|
|
|
+ permissions: [],
|
|
|
+ selectedIdsArray: [],
|
|
|
+ treeObj: null,
|
|
|
+ iniReportPermission: () => {
|
|
|
+ const me = reportPermissionObj;
|
|
|
+ const jDom = $("#report-permission-div");
|
|
|
+ jDom.empty();
|
|
|
+ const permissionsHtml = [];
|
|
|
+ permissionsHtml.push('<table class="table table-hover table-bordered table-sm mt-3">');
|
|
|
+ permissionsHtml.push('<thead>');
|
|
|
+ permissionsHtml.push('<tr>');
|
|
|
+ permissionsHtml.push('<th class="text-center" width="25%">用户</th>');
|
|
|
+ permissionsHtml.push('<th class="text-center" width="35%">职位/角色</th>');
|
|
|
+ permissionsHtml.push('<th class="text-center" width="25%">添加时间</th>');
|
|
|
+ permissionsHtml.push('<th class="text-center" width="15%">操作</th>');
|
|
|
+ permissionsHtml.push('</tr>');
|
|
|
+ permissionsHtml.push('</thead>');
|
|
|
+ permissionsHtml.push('<tbody class="text-center"></tbody>');
|
|
|
+ // ...内容
|
|
|
+ me.selectedIdsArray.splice(0, me.selectedIdsArray.length);
|
|
|
+ me.permissions.forEach((permission) => {
|
|
|
+ const id = parseInt(permission.user_id);
|
|
|
+ if (!me.selectedIdsArray.includes(id)) me.selectedIdsArray.push(id);
|
|
|
+ });
|
|
|
+ const permissionStrs = [];
|
|
|
+ me.permissions.forEach(permission => {
|
|
|
+ if (permission.rpt_id === reportFormatSetupObj.currentRptId) {
|
|
|
+ permissionStrs.push(me.createPermissionTbStr(permission));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (permissionStrs.length > 0) permissionsHtml.push(permissionStrs.join(''));
|
|
|
+ permissionsHtml.push('</tbody>');
|
|
|
+ permissionsHtml.push('</table>');
|
|
|
+ jDom.append(permissionsHtml.join(''));
|
|
|
+ },
|
|
|
+ beforeRemove: (dom, user_id) => {
|
|
|
+ $('#remove_user_id').val(user_id);
|
|
|
+ },
|
|
|
+ removeUser: (dom) => {
|
|
|
+ const me = reportPermissionObj;
|
|
|
+ const curNodes = reportFormatSetupObj.treeObj.getSelectedNodes();
|
|
|
+ if (curNodes.length > 0) {
|
|
|
+ const id = parseInt($('#remove_user_id').val());
|
|
|
+ const params = { user_id: id, rpt_id: curNodes[0].ID, tid: TENDER_ID };
|
|
|
+ const url = '/report_api/removeReportPermission';
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ CommonAjax.postXsrfEx(url, params, 300000, true, getCookie('csrfToken_j'),
|
|
|
+ async function(result){
|
|
|
+ console.log(result);
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ // after remove
|
|
|
+ const uId = me.selectedIdsArray.indexOf(id);
|
|
|
+ if (uId >= 0) {
|
|
|
+ me.selectedIdsArray.splice(uId, 1);
|
|
|
+ }
|
|
|
+ for (let idx = me.permissions.length - 1; idx >= 0; idx--) {
|
|
|
+ if (parseInt(me.permissions[idx].user_id) === id) {
|
|
|
+ me.permissions.splice(idx, 1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ me.iniReportPermission();
|
|
|
+ }, function(err){
|
|
|
+ console.log(err);
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ }, function(ex){
|
|
|
+ console.log(ex);
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
+ createPermissionTbStr: (permission) => {
|
|
|
+ const rstArr = [];
|
|
|
+ rstArr.push('<tr>');
|
|
|
+ rstArr.push(`<td class="text-center">${permission.user_name || permission.name}</td>`);
|
|
|
+ rstArr.push(`<td class="text-center">${permission.user_role || permission.role}</td>`);
|
|
|
+ rstArr.push(`<td class="text-center">${(new Date(permission.create_time)).Format('yyyy-MM-dd hh:mm:ss')}</td>`);
|
|
|
+ rstArr.push(`<td class="text-center"><a onclick="reportPermissionObj.beforeRemove(this, ${permission.user_id})" href="#remove-user1" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger">移除</a></td>`);
|
|
|
+ rstArr.push('</tr>');
|
|
|
+ return rstArr.join('');
|
|
|
+ },
|
|
|
+ addUser: (userId) => {
|
|
|
+ const me = reportPermissionObj;
|
|
|
+ let b = false;
|
|
|
+ for (let grp of ACCOUNT_LIST) {
|
|
|
+ for (let user of grp.groupList) {
|
|
|
+ if (user.id === userId) {
|
|
|
+ b = true;
|
|
|
+ const newPermission = { tid: TENDER_ID, user_id: userId, rpt_id: -1, name: user.name, role: user.role, create_time: new Date() };
|
|
|
+ me.permissions.push(newPermission);
|
|
|
+ // me.createPermissionTbStr(user);
|
|
|
+ me.iniReportPermission();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (b) break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ updateSelectedMarks: (userId = null) => {
|
|
|
+ // 此方法是更新下拉菜单的勾选符号(根据permissions列表)
|
|
|
+ const me = reportPermissionObj;
|
|
|
+ // const selectedIdsArray = [];
|
|
|
+ // if (userId) selectedIdsArray.push(userId);
|
|
|
+ if ($('#format-setup-add-user .book-list').length > 0) {
|
|
|
+ $('.user-item').each(function() {
|
|
|
+ const userIdStr = $(this).data('id');
|
|
|
+ const userId = parseInt(userIdStr, 10);
|
|
|
+ const $mark = $(this).find('.selected-mark');
|
|
|
+ if (!isNaN(userId) && me.selectedIdsArray.includes(userId)) {
|
|
|
+ $mark.show();
|
|
|
+ $(this).addClass('bg-light');
|
|
|
+ } else {
|
|
|
+ $mark.hide();
|
|
|
+ $(this).removeClass('bg-light');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //
|
|
|
+ },
|
|
|
+ iniPermissionRpts: () => {
|
|
|
+ const me = reportPermissionObj;
|
|
|
+ if (!me.treeObj) {
|
|
|
+ zTreeHelper.createTreeDirectly(INDI_TOP_TREE_NODES, rpt_permission_setting, "rptFormatSetupTplTree2", reportPermissionObj);
|
|
|
+ refreshNodes(reportPermissionObj);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ batchApplyPermissions: () => {
|
|
|
+ const me = reportPermissionObj;
|
|
|
+ // 1. 收集用户列表
|
|
|
+ const userIds = [];
|
|
|
+ me.permissions.forEach(permission => {
|
|
|
+ if (permission.rpt_id === reportFormatSetupObj.currentRptId) {
|
|
|
+ userIds.push(permission.user_id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 2. 收集报表模板列表
|
|
|
+ const rptIds = [];
|
|
|
+ const curNodes = me.treeObj.getCheckedNodes(true);
|
|
|
+ // if (treeNode.nodeType === RT.NodeType.TEMPLATE) {
|
|
|
+ curNodes.forEach(node => {
|
|
|
+ if (node.nodeType === RT.NodeType.TEMPLATE && reportFormatSetupObj.currentRptId !== node.ID) rptIds.push(node.ID);
|
|
|
+ });
|
|
|
+ if (userIds.length > 0 && rptIds.length > 0) {
|
|
|
+ const params = { tid: TENDER_ID, userIds, rptIds };
|
|
|
+ const url = '/report_api/batchApplyReportPermission';
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ CommonAjax.postXsrfEx(url, params, 300000, true, getCookie('csrfToken_j'),
|
|
|
+ async function(result){
|
|
|
+ console.log(result);
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ }, function(err){
|
|
|
+ console.log(err);
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ }, function(ex){
|
|
|
+ console.log(ex);
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
+};
|
|
|
+
|
|
|
+const rpt_format_setting = {
|
|
|
+ view: {
|
|
|
+ selectedMulti: false
|
|
|
+ },
|
|
|
+ check: {
|
|
|
+ enable: true
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ keep: {
|
|
|
+ parent:true,
|
|
|
+ leaf:true
|
|
|
+ },
|
|
|
+ key: {
|
|
|
+ children: "items",
|
|
|
+ title: "title",
|
|
|
+ isHidden: "hidden"
|
|
|
+ },
|
|
|
+ simpleData: {
|
|
|
+ enable: true,
|
|
|
+ rootPId: -1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ callback: {
|
|
|
+ onCheck: reportFormatSetupObj.onCheck,
|
|
|
+ onClick: reportFormatSetupObj.onClick
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const rpt_permission_setting = {
|
|
|
+ view: {
|
|
|
+ selectedMulti: false
|
|
|
+ },
|
|
|
+ check: {
|
|
|
+ enable: true
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ keep: {
|
|
|
+ parent:true,
|
|
|
+ leaf:true
|
|
|
+ },
|
|
|
+ key: {
|
|
|
+ children: "items",
|
|
|
+ title: "title",
|
|
|
+ isHidden: "hidden"
|
|
|
+ },
|
|
|
+ simpleData: {
|
|
|
+ enable: true,
|
|
|
+ rootPId: -1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ callback: {
|
|
|
+ // onCheck: reportFormatSetupObj.onCheck,
|
|
|
+ // onClick: reportFormatSetupObj.onClick
|
|
|
+ }
|
|
|
+};
|