teamBusinessDetails.js 4.2 KB
Newer Older
doc_wei's avatar
doc_wei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13

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 objectKey = GetUrlParam("objectKey");
14 15
	var objectId = GetUrlParam("objectId");
	var objectType = GetUrlParam("objectType");
doc_wei's avatar
doc_wei 已提交
16 17 18 19 20 21 22 23

	var treeTableData = [];
	// 已经选中的权限对应关系
	var checkTrueList = [];

	showGrid({
		id: "showForm",
		url: reqBasePath + "queryTeamBusiness",
24
		params: {objectId: objectId},
doc_wei's avatar
doc_wei 已提交
25 26 27 28 29
		pagination: false,
		method: "GET",
		template: $("#showTemplate").html(),
		ajaxSendLoadBefore: function(hdb, json) {},
		ajaxSendAfter: function (json) {
doc_wei's avatar
doc_wei 已提交
30 31 32 33 34
			systemCommonUtil.getSysCurrentLoginUserMation(function (data) {
				if (data.bean.id != json.bean.chargeUser) {
					$("#teamAuthEdit").remove();
				}
			});
doc_wei's avatar
doc_wei 已提交
35 36
			loadTreeTable();
			// 解析成员信息
37 38
			if (!isNull(json.bean.teamRoleList)) {
				$.each(json.bean.teamRoleList, function (i, item) {
doc_wei's avatar
doc_wei 已提交
39
					treeTableData.push({
40 41 42 43 44 45 46 47 48 49 50 51 52
						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
						});
doc_wei's avatar
doc_wei 已提交
53 54
					});
				});
55
			}
doc_wei's avatar
doc_wei 已提交
56 57 58 59 60 61 62 63 64 65 66 67 68 69

			// 解析权限信息
			$.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);
				}
			});

70
			reloadTreeTable();
doc_wei's avatar
doc_wei 已提交
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
			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,
		});
	}

	// 刷新成员树表格
101
	function reloadTreeTable() {
doc_wei's avatar
doc_wei 已提交
102 103 104 105 106
		var data = $.extend(true, [], treeTableData);
		tableTree.reload("messageTable", {data: data});
		loadAuthList(objectType);
	}

107
	function loadAuthList() {
doc_wei's avatar
doc_wei 已提交
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 138 139 140
		// 加载该受用类型的团队可以设置哪些权限
		var colsList = teamObjectPermissionUtil.getAuthColsDetails(objectType);
		$('#authList').html(getDataUseHandlebars($('#authTableTemplate').html(), {list: colsList}));
		$.each(colsList, function (i, item) {
			var data = $.extend(true, [], treeTableData);
			// 给数据设置权限组的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,
		});
	}

141 142 143 144 145
	$("body").on("click", "#edit", function() {
		location.href = "../../tpl/teamBusiness/teamBusinessEdit.html?objectId=" + objectId + "&objectKey=" + objectKey
			+ "&objectType=" + objectType;
	});

doc_wei's avatar
doc_wei 已提交
146 147 148 149
	$("body").on("click", "#cancle", function() {
		parent.layer.close(index);
	});
});