teamTemplateDetails.js 4.0 KB
Newer Older
doc_wei's avatar
doc_wei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104

layui.config({
	base: basePath, 
	version: skyeyeVersion
}).extend({
    window: 'js/winui.window'
}).define(['window', 'jquery', 'winui', 'tableTreeDj', 'form'], function (exports) {
	winui.renderColor();
	var index = parent.layer.getFrameIndex(window.name);
	var $ = layui.$,
		tableTree = layui.tableTreeDj,
		form = layui.form;
	var treeTableData = [];
	// 已经选中的权限对应关系
	var checkTrueList = [];

	showGrid({
		id: "showForm",
		url: reqBasePath + "queryTeamTemplateById",
		params: {id: parent.rowId},
		pagination: false,
		method: "GET",
		template: $("#showTemplate").html(),
		ajaxSendLoadBefore: function(hdb, json) {
			json.bean.enabled = skyeyeClassEnumUtil.getEnumDataNameByClassName('commonEnable', 'id', json.bean.enabled, 'name');
			json.bean.objectTypeName = skyeyeClassEnumUtil.getEnumDataNameByClassName('teamObjectType', 'id', json.bean.objectType, 'name');
			json.bean.remark = stringManipulation.textAreaShow(json.bean.remark);
		},
		ajaxSendAfter: function (json) {
			loadTreeTable();
			// 解析成员信息
			$.each(json.bean.teamRoleList, function (i, item) {
				treeTableData.push({
					id: item.roleId,
					pId: '0',
					name: item.name
				});
				$.each(item.teamRoleUserList, function (j, bean) {
					treeTableData.push({
						id: bean.userId,
						pId: item.roleId,
						name: bean.userMation.name,
						departmentName: bean.userMation.departmentName,
						phone: bean.userMation.phone,
						email: bean.userMation.email
					});
				});
			});

			// 解析权限信息
			$.each(json.bean.teamObjectPermissionList, function (i, item) {
				var authGroupKey = item.permissionKey;
				var authKey = item.permissionValue;
				var checkParams = getInPoingArr(treeTableData, "id", item.ownerId);
				if (checkParams != null) {
					var roleId = checkParams.pId == '0' ? checkParams.id : checkParams.pId;
					var userId = checkParams.pId == '0' ? '' : checkParams.id;
					var id = authGroupKey + '_' + authKey + '_' + roleId + '_' + userId;
					checkTrueList.push(id);
				}
			});

			reloadTreeTable(json.bean.objectType);
			matchingLanguage();
			form.render();
		}
	});

	function loadTreeTable() {
		tableTree.render({
			id: 'messageTable',
			elem: '#messageTable',
			data: [],
			// 该参数不能删除,分页参数无效,目前只能通过设置10000来保证当前页最大的数据量
			limit: 10000,
			cols: [[
				{ field: 'name', title: '名称', width: 160 },
				{ field: 'departmentName', title: '部门', width: 120 },
				{ field: 'phone', title: '联系方式', width: 140 },
				{ field: 'email', title: '邮箱', width: 200 }
			]],
			done: function(json) {
				matchingLanguage();
			}
		}, {
			keyId: 'id',
			keyPid: 'pId',
			title: 'name',
			defaultShow: true,
		});
	}

	// 刷新成员树表格
	function reloadTreeTable(objectType) {
		var data = $.extend(true, [], treeTableData);
		tableTree.reload("messageTable", {data: data});
		loadAuthList(objectType);
	}

	function loadAuthList(objectType) {
		// 加载该受用类型的团队可以设置哪些权限
		var colsList = teamObjectPermissionUtil.getAuthColsDetails(objectType);
		$('#authList').html(getDataUseHandlebars($('#authTableTemplate').html(), {list: colsList}));
		$.each(colsList, function (i, item) {
doc_wei's avatar
doc_wei 已提交
105
			var data = $.extend(true, [], treeTableData);
doc_wei's avatar
doc_wei 已提交
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
			// 给数据设置权限组的key,
			$.each(data, function (j, bean) {
				bean.authGroupKey = item.id;
			});
			loadAuthTreeTable(item.id, item.cols, data);
		});

		$.each(checkTrueList, function (i, id) {
			$(`div[id='${id}']`).html(`<i class="fa fa-check" style="color: green"></i>`);
		});
	}

	function loadAuthTreeTable(id, cols, data) {
		tableTree.render({
			id: id,
			elem: '#' + id,
			data: data,
			// 该参数不能删除,分页参数无效,目前只能通过设置10000来保证当前页最大的数据量
			limit: 10000,
			cols: [cols],
		}, {
			keyId: 'id',
			keyPid: 'pId',
			title: 'name',
			defaultShow: true,
		});
	}

	$("body").on("click", "#cancle", function() {
		parent.layer.close(index);
	});
});