12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631 |
- <!--********************************************************************
- * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
- *********************************************************************-->
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title data-i18n="resources.title_iPortalQueryMyResources"></title>
- <style>
- .container-wrap {
- padding-left: 200px!important;
- }
- .gallery-item {
- margin-bottom: 30px;
- }
- .gallery-item-border {
- border: 1px solid #dadada;
- -webkit-box-shadow: 0px 2px 3px #dcdcdc;
- box-shadow: 0px 2px 3px #dcdcdc;
- background: white;
- }
- .gallery-item-img {
- height: 170px !important;
- width: 262px !important;
- }
- .resourcesDetails {
- height: 21px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- font-size: 14px !important;
- color: #7c7c7c;
- }
- .title-checkbox-container p{
- max-width: 160px;
- float: left;
- }
- .title-checkbox-container input{
- float: right;
- }
- .operate-btn-container , .title-checkbox-container{
- width: 100%;
- height: 33px;
- padding: 0 17px;
- }
- .operate-btn-container a:nth-child(1){
- float: left;
- }
- .operate-btn-container a:nth-child(2){
- float: right;
- }
- #plottingPanel {
- float: left;
- background: #ffffff;
- width: 250px;
- height: 100%;
- border: 1px solid #3473b7;
- }
- .datagrid-cell {
- word-break: break-all;
- white-space: normal!important;
- }
- .tabs-container ,.tabs-panels,.panel-body{
- height: auto!important;
- }
- .panel-title {
- margin-top: 0!important;
- margin-bottom: 0!important;
- font-size: 16px!important;
- color: inherit!important;
- }
- .input-group-addon {
- cursor: pointer;
- }
- .tab-content {
- max-height: 500px;
- overflow-y: auto;
- }
- .tab-pane {
- margin-top: 12px;
- }
- .choose {
- display: block;
- margin: 12px 0;
- }
- </style>
- </head>
- <body style=" margin: 0;overflow: auto;background: #F2F2F2;width: 100%;height:100%;position: absolute;top: 0;">
- <!-- 删除资源模态框(Modal) -->
- <div class="modal fade" tabindex="-1" role="dialog" id="deleteModel">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
- <h4 class="modal-title" data-i18n="resources.title_delete_resources"></h4>
- </div>
- <div class="modal-body">
- <p data-i18n="resources.title_confirm_delete_resources"></p>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal" data-i18n="resources.text_close"></button>
- <button type="button" class="btn btn-primary" onclick="requestDeleteUrl()" data-i18n="resources.text_confirm"></button>
- </div>
- </div>
- </div>
- </div>
- <!-- 共享资源模态框(Modal) -->
- <div class="modal fade" id="shareModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="removeUser()"><span aria-hidden="true">×</span></button>
- <h4 class="modal-title" data-i18n="resources.title_share_setting"></h4>
- </div>
- </div>
- <table class="table table-bordered col-md-6">
- <tbody>
- <!--共享设置-->
- <tr>
- <td>
- <div class="col-md-10 col-md-offset-1">
- <form class="form-horizontal">
- <fieldset>
- <ul class="nav nav-tabs" role="tablist">
- <li role="presentation" class="active">
- <a href="#public" aria-controls="public" role="tab" data-toggle="tab" data-i18n="resources.title_iPortalQueryResourcesPublic"></a>
- </li>
- <li role="presentation">
- <a href="#group" aria-controls="group" role="tab" data-toggle="tab" data-i18n="resources.title_iPortalQueryResourcesGroup"></a>
- </li>
- <li role="presentation">
- <a href="#department" aria-controls="department" role="tab" data-toggle="tab" data-i18n="resources.title_iPortalQueryResourcesDepartment"></a>
- </li>
- <li role="presentation">
- <a href="#user" aria-controls="user" role="tab" data-toggle="tab" data-i18n="resources.title_iPortalQueryResourcesUser"></a>
- </li>
- </ul>
- <div class="tab-content">
- <div role="tabpanel" class="tab-pane active" id="public">
-
- </div>
- <div role="tabpanel" class="tab-pane" id="group">
- <table border="1" bordercolor="black" width="100%">
- <thead id="group_thead">
-
- </thead>
- <tbody id="group_tbody">
-
- </tbody>
- </table>
- </div>
- <div role="tabpanel" class="tab-pane" id="user">
- <div class="input-group" style="margin-top: 12px;width: 100%;">
- <input type="text" class="form-control" data-i18n="[placeholder]resources.text_input_user_name" id="add-user-val">
- <span class="input-group-addon" onclick="searchUser()" data-i18n="resources.btn_add"></span>
- </div>
- <span data-i18n="resources.text_choose_user" class="choose"></span>
- <table border="1" bordercolor="black" width="100%">
- <thead id="user_thead">
-
- </thead>
- <tbody id="user_tbody">
-
- </tbody>
- </table>
- </div>
- <div role="tabpanel" class="tab-pane" id="department">
- <span data-i18n="resources.text_choose_department" class="choose"></span>
- <table border="1" bordercolor="black" width="100%">
- <thead id="department_thead">
-
- </thead>
- <tbody id="department_tbody">
-
- </tbody>
- </table>
- </div>
- </div>
- </fieldset>
- </form>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal" data-i18n="resources.text_close" onclick="removeUser()">
- </button>
- <button type="button" class="btn btn-primary" onclick="requestShareUrl()" data-i18n="resources.btn_save">
- </button>
- </div>
- </div>
- </div>
- </div>
- <!-- 详情 属性面板Dom -->
- <div id="plottingPanel">
- <div class="easyui-panel" style="position:absolute;top:0px;bottom:0px;left:0px;right:0px;padding:5px; width: 100%;">
- <div class="easyui-tabs" style="width: 100%;height: 100%" id="edit-and-detail-plot">
- <div id="iPortalDetailPanel" data-i18n="[title]resources.text_detailPanel" style="overflow: hidden"></div>
- <div id="plotPanel" data-i18n="[title]resources.text_attributePanel" style="overflow: hidden"></div>
- </div>
- </div>
- </div>
- <!-- 资源过滤 and 资源展示 -->
- <div style="margin-bottom: 100px">
- <div id="toolbar" class="panel panel-primary" style="position: absolute;top: 10px;right: 70px;text-align: center;z-index: 800;border-radius: 4px;">
- <div class='panel-heading' id="panelheading">
- <h5 class='panel-title text-center' data-i18n="resources.title_iPortalQueryMyResources"></h5>
- </div>
- <div class='panel-body content' id="panelbodycontent">
- <!-- 资源类型选择 -->
- <div class='input-group' style="width: 220px">
- <span class='input-group-addon' data-i18n="resources.title_iPortalQueryResourcesType"></span>
- <select class='form-control' id='typeSelect' onchange="onSelectResourcesType()">
- <option value="MAP" data-i18n="resources.title_iPortalQueryResourcesMap"></option>
- <option value="SERVICE" data-i18n="resources.title_iPortalQueryResourcesService"></option>
- <option value="SCENE" data-i18n="resources.title_iPortalQueryResourcesScene"></option>
- <option value="DATA" data-i18n="resources.title_iPortalQueryResourcesData"></option>
- <option value="INSIGHTS_WORKSPACE" data-i18n="resources.title_iPortalQueryResourcesInsights"></option>
- <option value="MAP_DASHBOARD" data-i18n="resources.title_iPortalQueryResourcesDashboards"></option>
- </select>
- </div>
- </div>
- </div>
- <br />
- <div class="container container-wrap">
- <div class="col-md-10">
- <div class="row">
- <div class="col-md-12">
- <div class="operate-list">
- <input type='button' class="btn btn-default" onclick="deleteResource()" data-i18n="[value]resources.text_input_value_delete"/>
- <input type='button' class="btn btn-default" onclick="shareResource()" data-i18n="[value]resources.title_share_setting"/>
- </div>
- <!--所有资源的承载DIV-->
- <div class="row" id="resourcesList">
- <!--单个资源数据的可视化承载DIV 添加在此位置中-->
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script type="text/javascript" include="jquery,bootstrap,plottingPanel,widgets" src="../js/include-web.js"></script>
- <script type="text/javascript" include="iclient-plot-leaflet" src="../../dist/leaflet/include-leaflet.js"></script>
- <script type="text/javascript" include="iPortalStylePanel" src="../js/plottingPanel/PlottingPanel.Include.js"></script>
- <script>
- //iportal的URL地址 或根据情况添加自己的本地iportal地址:http://localhost:8091/iportal
- var iPortalUrl = "https://iportal.supermap.io/iportal";
- var token = "MFEKl8kVmkvEDrDFcgnjodlPCudIO83mBSwvdjiUlWNnySGD-FCEyYEk4CsY2WnSCujfAs8HI0ZkSL6Vxa-njg..";
- //默认请求资源类型
- var resourceType = "MAP";
- //全局变量,承载请求后,一共有多少页数
- var queryParams = new SuperMap.iPortalQueryParam({
- resourceType: resourceType,
- pageSize: 15,
- currentPage: 1,
- searchType:'MY_RES'
- });
- //资源查询初始化工作
- var iPortal;
- var isShowLogin = true;
- var deleteIds = [];//批量删除id
- var shareIds = [];//批量共享设置id
- var itemData = {};//某条资源的详细信息
- //公开权限共享实体参数
- var publicSettingEntity = {
- "permissionType": "",
- "entityType": "USER",
- "entityName": "GUEST",
- "entityId": null,
- "authorizeList": []
- }
- // 用户权限共享实体参数
- var usersSettingEntities = [];
- // 部门权限共享实体参数
- var departmentSettingEntities = [];
- // 群组权限共享实体参数
- var groupsSettingEntities = [];
- // 用户的登陆信息对象
- var userStateObj = {};
- // 群组列表
- var groupList = [];
- $(document).ready(function () {
- generatePortalToken();
- });
- // 申请,注册token并查询
- function generatePortalToken() {
- var serverInfo = new SuperMap.ServerInfo(SuperMap.ServerType.IPORTAL, {
- server: iPortalUrl
- });
- SuperMap.SecurityManager.registerServers([serverInfo]);
- SuperMap.SecurityManager.destroyToken(iPortalUrl);
- SuperMap.SecurityManager.registerToken(iPortalUrl, token);
- //加载完DOM后,开始资源数据查询并添加
- iPortal = new SuperMap.iPortal(iPortalUrl);
- queryResouces(queryParams);
- }
- //获取用户的登陆信息
- function getLoginUserInfos() {
- var url = iPortalUrl + "/web/config/userprofile.json?token=" + token;
- $.get(url,(res)=>{
- userStateObj = res;
- })
- }
- // 查询iPortal中的资源
- function queryResouces(queryParams) {
- iPortal.queryResources(queryParams).then(function (resourcesReslut) {
- //返回的结果集,需要查看可打开下行代码
- // console.log(resourcesReslut);
- // 切换资源类型 清空之前的资源DOM
- $("#resourcesList").children().remove();
- //将结果集进行遍历,并添加到HTML中
- $.each(resourcesReslut.content, function (i) {
- var resourceItem = resourcesReslut.content[i];
- var thumbnail = resourceItem.thumbnail;
- // 此判断获取部分相对路径的default图片
- if(thumbnail.indexOf("./") === 0){
- thumbnail = iPortalUrl + thumbnail.replace("./","/");
- }
- var resourcesDOM = $("<div class='col-xs-10 col-md-6 col-lg-4 gallery-item' id='map'>" +
- "<div class='gallery-item-border'>" +
- "<a class='thumbnail' style='margin-bottom: 10px'>" +
- "<img class='gallery-item-img' src='" + thumbnail + "' alt=''>" +
- "</a>" +
- "<div>" +
- "<div class='title-checkbox-container'>"+
- "<p class='resourcesDetails'>" + resourceItem.name + "</p>" +
- "<input type='checkbox' class='floatLeft' id='preferenceCheck' name='checkbox' value='"+resourceItem.resourceId+"'/>" +
- "</div>"+
- "<div>" +
- "<div class='operate-btn-container'>"+
- "<a href='#' class='delete' onclick='deleteResource("+resourceItem.resourceId +")'>"+resources.text_input_value_delete+"</a>" +
- "<a href='#' id='detail' onclick='viewResource("+resourceItem.resourceId+")'>"+resources.title_view_detail+"</a>"+
- "</div>"+
- "<div class='operate-btn-container'>"+
- "<a href='#' class='edit' onclick='editResource("+resourceItem.resourceId+","+resourceItem.resourceId+")'>"+resources.title_edit_attr+"</a>"+
- "<a href='#' class='edit' onclick='shareResource("+resourceItem.resourceId+")'>"+resources.title_share_setting+"</a>"+
- "</div>"+
- "</div>" +
- "</div>")
- $("#resourcesList").append(resourcesDOM);
- });
- }).catch (()=>{
- widgets.alert.showAlert(resources.msg_query_failed, false);
- })
- };
- //获取多选CheckBox资源的id值 给(删除 和 共享资源 使用)
- function getDeleteAndShareCheckArr(){
- var checkDataEle = document.getElementsByName("checkbox");
- var check_val = [];
- for(k in checkDataEle) {
- if(checkDataEle[k].checked){
- check_val.push(checkDataEle[k].value);
- }
- }
- return check_val;
- }
- //删除资源代码块
- //点击删除前 确认弹框
- function deleteResource(ids){
- deleteIds = ids ? [ids] : getDeleteAndShareCheckArr();
- if(deleteIds.length<=0) {
- widgets.alert.showAlert(resources.msg_choise_resources_delete, false);
- }else {
- $('#deleteModel').modal('show');
- }
- }
- //发送删除请求
- function requestDeleteUrl(){
- var resourceIds = deleteIds;
- var deleteParams = {
- resourceType: resourceType,
- ids: resourceIds
- };
- new SuperMap.iPortalUser(iPortalUrl).deleteResources(deleteParams).then(result=>{
- $('#deleteModel').modal('hide');
- widgets.alert.showAlert(resources.text_deleteSuccess, true);
- deleteIds = [];
- }).catch(err => {
- widgets.alert.showAlert(resources.msg_deleteFailure, false);
- })
- }
- //编辑资源属性参数对象
- var attributes = {
- title: '',
- tags: [''],
- description: '',
- tokenRefreshUrl: '',
- refSysInfo: {
- refSysID: 0,
- projection: ''
- },
- identifier: {
- region:''
- },
- bounds: {
- west:0.0,
- east:0.0,
- south:0.0,
- north:0.0
- },
- contact: {
- personName: '',
- orgName: '',
- address: '',
- email: '',
- voiceNum: '',
- faxNum:''
- },
- dataMetaInfo: {},
- filePostfix: ''
- }
- //点击查看详情按钮
- function viewResource(ids){
- $("#edit-and-detail-plot").tabs('select',0);
- var item = new SuperMap.iPortalResource(iPortalUrl,{resourceId:ids,resourceType:resourceType});
- item.load().then(()=>{
- //创建详情面板
- L.supermap.plotting.initIportalStylePanel("iPortalDetailPanel",resourceType,item.sourceJSON,'detail');
- });
- }
- //点击编辑属性按钮
- function editResource(ids){
- viewResource(ids)
- $("#edit-and-detail-plot").tabs('select',1);
- var item = new SuperMap.iPortalResource(iPortalUrl,{resourceId:ids,resourceType:resourceType});
- item.load().then(()=>{
- //创建属性面板
- L.supermap.plotting.initIportalStylePanel("plotPanel", resourceType, item.sourceJSON,'edit');
- itemData = item.sourceJSON;
- //填充attributes对象
- switch (resourceType) {
- case 'MAP':
- attributes.title = itemData.title!=null?itemData.title:'';
- break;
- case 'SERVICE':
- attributes.title = itemData.resTitle!=null?itemData.resTitle:'';
- attributes.tokenRefreshUrl = itemData.tokenRefreshUrl!=null?itemData.tokenRefreshUrl:'';
- attributes.refSysInfo.refSysID = itemData.metadata.refSysInfo!=null?itemData.metadata.refSysInfo.refSysID:'';
- attributes.refSysInfo.projection = itemData.metadata.refSysInfo!=null?itemData.metadata.refSysInfo.mdCoRefSys.projection:'';
- attributes.identifier.region = itemData.metadata.dataIdInfo!=null?itemData.metadata.dataIdInfo.dataIdent.dataExt.exDesc:'';
- attributes.bounds.west = itemData.metadata.dataIdInfo!=null?itemData.metadata.dataIdInfo.dataIdent.dataExt.geoEle.geoBndBox.westBL:'';
- attributes.bounds.east = itemData.metadata.dataIdInfo!=null?itemData.metadata.dataIdInfo.dataIdent.dataExt.geoEle.geoBndBox.eastBL:'';
- attributes.bounds.south = itemData.metadata.dataIdInfo!=null?itemData.metadata.dataIdInfo.dataIdent.dataExt.geoEle.geoBndBox.southBL:'';
- attributes.bounds.north = itemData.metadata.dataIdInfo!=null?itemData.metadata.dataIdInfo.dataIdent.dataExt.geoEle.geoBndBox.northBL:'';
- attributes.contact.personName = itemData.metadata.mdContact!=null?itemData.metadata.mdContact.rpIndName:'';
- attributes.contact.orgName = itemData.metadata.mdContact!=null?itemData.metadata.mdContact.rpOrgName:'';
- attributes.contact.address = itemData.metadata.mdContact!=null?itemData.metadata.mdContact.rpCntInfo.cntAddress.delPoint:'';
- attributes.contact.email = itemData.metadata.mdContact!=null?itemData.metadata.mdContact.rpCntInfo.cntAddress.EMailAdd:'';
- attributes.contact.voiceNum = itemData.metadata.mdContact!=null?itemData.metadata.mdContact.rpCntInfo.voiceNum:'';
- attributes.contact.faxNum = itemData.metadata.mdContact!=null?itemData.metadata.mdContact.rpCntInfo.faxNum:'';
- break;
- case 'SCENE':
- attributes.title = itemData.name!=null?itemData.name:'';
- break
- case 'DATA':
- attributes.title = itemData.fileName!=null?itemData.fileName.substring(0,itemData.fileName.lastIndexOf(".")):'';
- attributes.filePostfix = itemData.fileName!=null?itemData.fileName.substr(itemData.fileName.lastIndexOf(".")):'';
- attributes.dataMetaInfo = itemData.dataMetaInfo!=null?itemData.dataMetaInfo:{};
- break;
- case 'INSIGHTS_WORKSPACE':
- attributes.title = itemData.name!=null?itemData.name:'';
- break;
- case 'MAP_DASHBOARD':
- attributes.title = itemData.name!=null?itemData.name:'';
- break;
- }
- attributes.tags = itemData.tags!=null?itemData.tags.join(" "):[];
- attributes.description = itemData.description!=null?itemData.description:'';
- });
- }
- //修改表格属性值后 则会立刻调用此函数 {rowIndex:改变属性的数据索引 rowData:改变属性后的数据对象 changes:改变的属性值}
- function afterModifySelectFeature(rowIndex, rowData, changes){
- if(rowData.length !== 0 ){
- new Promise(() => {
- if(rowData.length !== 0) {
- updateSelectFeature(rowData,itemData);
- }
- return;
- })
- }
- }
- //调用资源update接口,模拟服务metadata对象(所有字段) 提交后端 防止因为后端返回metadata对象为空 造成属性提交报错的问题(如果有变化 就替换 否则提交默认值)
- var entity = {
- metadata: {
- dataIdInfo: {
- dataIdent: {
- idCitation: {
- resTitle: ""
- },
- idAbs: "",
- dataExt: {
- exDesc: "",
- geoEle: {
- geoBndBox: {
- westBL: "",
- eastBL: "",
- southBL: "",
- northBL: "",
- },
- },
- },
- },
- },
- refSysInfo: {
- refSysID: "",
- mdCoRefSys: {
- projection: ""
- }
- },
- mdContact: {
- rpIndName: "",
- rpOrgName: "",
- rpCntInfo: {
- cntAddress: {
- delPoint: "",
- EMailAdd: ""
- },
- voiceNum: "",
- faxNum: ""
- }
- }
- },
- }
- //构造属性对象 提交参数 更改属性值
- function updateSelectFeature(updated,data) {
- switch (updated.key){
- case "title":
- if(attributes.title === updated.value) {
- return;
- }
- attributes.title = updated.value;
- break;
- case "tags":
- if(attributes.tags === updated.value) {
- return;
- }
- attributes.tags = updated.value.split(",");
- break;
- case "description":
- if(attributes.description === updated.value) {
- return;
- }
- attributes.description = updated.value;
- break;
- case "tokenRefreshUrl":
- if(attributes.tokenRefreshUrl === updated.value) {
- return;
- }
- attributes.tokenRefreshUrl = updated.value;
- break;
- case "refSysID":
- if(attributes.refSysInfo.refSysID === updated.value) {
- return;
- }
- attributes.refSysInfo.refSysID = updated.value;
- break;
- case "projection":
- if(attributes.refSysInfo.projection === updated.value) {
- return;
- }
- attributes.refSysInfo.projection = updated.value;
- break;
- case "region":
- if(attributes.identifier.region === updated.value) {
- return;
- }
- attributes.identifier.region = updated.value;
- break;
- case "west":
- if(attributes.bounds.west === updated.value) {
- return;
- }
- attributes.bounds.west = updated.value;
- break;
- case "east":
- if(attributes.bounds.east === updated.value) {
- return;
- }
- attributes.bounds.east = updated.value;
- break;
- case "south":
- if(attributes.bounds.south === updated.value) {
- return;
- }
- attributes.bounds.south = updated.value;
- break;
- case "north":
- if(attributes.bounds.north === updated.value) {
- return;
- }
- attributes.bounds.north = updated.value;
- break;
- case "personName":
- if(attributes.contact.personName === updated.value) {
- return;
- }
- attributes.contact.personName = updated.value;
- break;
- case "orgName":
- if(attributes.contact.orgName === updated.value) {
- return;
- }
- attributes.contact.orgName = updated.value;
- break;
- case "address":
- if(attributes.contact.address === updated.value) {
- return;
- }
- attributes.contact.address = updated.value;
- break;
- case "email":
- if(attributes.contact.email === updated.value) {
- return;
- }
- attributes.contact.email = updated.value;
- break;
- case "voiceNum":
- if(attributes.contact.voiceNum === updated.value) {
- return;
- }
- attributes.contact.voiceNum = updated.value;
- break;
- case "faxNum":
- if(attributes.contact.faxNum === updated.value) {
- return;
- }
- attributes.contact.faxNum = updated.value;
- break;
-
- case "bounds":
- if(attributes.dataMetaInfo) {
- var bounds = attributes.dataMetaInfo.bounds!=null?attributes.dataMetaInfo.bounds:'';
- if(bounds === updated.value) {
- return;
- }
- }
- attributes.dataMetaInfo.bounds = updated.value;
- break;
- case "epsgCode":
- if(attributes.dataMetaInfo) {
- var epsgCode = attributes.dataMetaInfo.epsgCode!=null?attributes.dataMetaInfo.epsgCode:'';
- if(epsgCode === updated.value) {
- return;
- }
- }
- attributes.dataMetaInfo.epsgCode = updated.value;
- break;
- case "previewURL":
- if(attributes.dataMetaInfo) {
- var previewURL = attributes.dataMetaInfo.previewURL!=null?attributes.dataMetaInfo.previewURL:'';
- if( previewURL=== updated.value) {
- return;
- }
- }
- attributes.dataMetaInfo.previewURL = updated.value;
- break;
- case "providers":
- if(attributes.dataMetaInfo) {
- var providers = attributes.dataMetaInfo.providers!=null?attributes.dataMetaInfo.providers:'';
- if(providers === updated.value) {
- return;
- }
- }
- attributes.dataMetaInfo.providers = updated.value;
- break;
- }
- var item = new SuperMap.iPortalResource(iPortalUrl,{resourceId:data.id,resourceType:resourceType});
- item.load().then(()=>{
- switch (resourceType) {
- case 'MAP':
- item.sourceJSON.title = attributes.title;
- break;
- case 'SERVICE':
- entity.metadata.dataIdInfo.dataIdent.idCitation.resTitle = attributes.title;
- item.sourceJSON.tokenRefreshUrl = attributes.tokenRefreshUrl;
- entity.metadata.refSysInfo.refSysID = attributes.refSysInfo.refSysID;
- entity.metadata.refSysInfo.mdCoRefSys.projection = attributes.refSysInfo.projection;
- entity.metadata.dataIdInfo.dataIdent.dataExt.exDesc = attributes.identifier.region;
- entity.metadata.dataIdInfo.dataIdent.dataExt.geoEle.geoBndBox.westBL = attributes.bounds.west;
- entity.metadata.dataIdInfo.dataIdent.dataExt.geoEle.geoBndBox.eastBL = attributes.bounds.east;
- entity.metadata.dataIdInfo.dataIdent.dataExt.geoEle.geoBndBox.southBL = attributes.bounds.south;
- entity.metadata.dataIdInfo.dataIdent.dataExt.geoEle.geoBndBox.northBL = attributes.bounds.north;
- entity.metadata.mdContact.rpIndName = attributes.contact.personName;
- entity.metadata.mdContact.rpOrgName = attributes.contact.orgName;
- entity.metadata.mdContact.rpCntInfo.cntAddress.delPoint = attributes.contact.address;
- entity.metadata.mdContact.rpCntInfo.cntAddress.EMailAdd = attributes.contact.email;
- entity.metadata.mdContact.rpCntInfo.voiceNum = attributes.contact.voiceNum;
- entity.metadata.mdContact.rpCntInfo.faxNum = attributes.contact.faxNum;
- item.sourceJSON.metadata = entity.metadata;
- break;
- case "DATA":
- item.sourceJSON.fileName = attributes.title + attributes.filePostfix;
- item.sourceJSON.dataMetaInfo = attributes.dataMetaInfo;
- break
- case "SCENE":
- item.sourceJSON.name = attributes.title;
- break;
- case "INSIGHTS_WORKSPACE":
- item.sourceJSON.name = attributes.title;
- break;
- case "MAP_DASHBOARD":
- item.sourceJSON.name = attributes.title;
- break;
- }
- item.sourceJSON.tags = attributes.tags;
- item.sourceJSON.description = attributes.description;
- item.update().then(res => {
- if(res.succeed) {
- widgets.alert.showAlert(resources.msg_updateSuccess, true);
- }else {
- widgets.alert.showAlert(resources.msg_updateFailure+","+res.error.errorMsg, false);
- }
- }).catch(()=>{
- });
- })
- }
-
- //共享设置代码块
- //搜索添加用户
- function searchUser(){
- var userName = $("#add-user-val").val();
- var nicknameInfosUrl = iPortalUrl+"/web/users/nicknameinfos.json?name="+userName + "&token=" + token;
- $.get(nicknameInfosUrl,(res)=>{
- if(res.length === 0){
- widgets.alert.showAlert(resources.msg_user_not_exist,false);
- }
- for(var item of res){
- if(item.roles.includes("ADMIN")){
- widgets.alert.showAlert(resources.msg_not_share_admin,false);
- break;
- }else if(!checkUser(true, item.name)){
- break;
- }
- putUserToSettingEntities(item.name,item.nickname,null);
- }
- })
- }
- // 检查选择的用户是否符合分享条件
- function checkUser(enableTips,username){
- //验证分享的用户列表中是否已存在该用户
- for(var user of usersSettingEntities){
- if(user.entityName === username || user.aliasName === username){
- if(enableTips) {
- widgets.alert.showAlert(resources.msg_user_added,false);
- }
- return false;
- }
- }
- return true;
- }
- // 构造用户实体参数对象
- function putUserToSettingEntities(name,nickname,id){
- var authorizeList = getAuthorizeList("SEARCH");//添加的用户默认具有搜索权限
- var entity = {
- "permissionType": null,
- "aliasName": nickname,
- "entityRoles": [],
- "entityType": "USER",
- "entityName": name,
- "entityId": id,
- "authorizeList": authorizeList
- };
- usersSettingEntities.push(entity);
- showUserShare();
- }
- // 根据查询的用户记录,渲染页面,进行共享设置
- function showUserShare() {
- $("#user_tbody").empty();
- var cloneUsersList = Object.assign([],usersSettingEntities);
- for (var i = 0; i < cloneUsersList.length; i++) {
- switch (resourceType) {
- case 'MAP':
- case 'SCENE':
- case 'INSIGHTS_WORKSPACE':
- var shareMapDOM = $("<tr>" +
- "<td>" + cloneUsersList[i].entityName + "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='search-user"+i+"'" +
- "onclick='clickSearchCheckBox("+JSON.stringify(cloneUsersList[i])+","+JSON.stringify("user")+")'"+
- "/>" +
- "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='view-user"+i+"'" +
- "onclick='clickViewCheckBox("+JSON.stringify(cloneUsersList[i])+","+JSON.stringify("user")+")'"+
- "/>" +
- "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='edit-user"+i+"'" +
- "onclick='clickEditCheckBox("+JSON.stringify(cloneUsersList[i])+","+JSON.stringify("user")+")'"+
- "/>" +
- "</td>" +
- "<td onclick='removeUsersSettingEntity("+i+")'>"+resources.text_input_value_delete+"</td>" +
- "</tr>")
- $("#user_tbody").append(shareMapDOM);
- break;
- case 'SERVICE':
- case 'MAP_DASHBOARD':
- var shareMapDOM = $("<tr>" +
- "<td>" + cloneUsersList[i].entityName + "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='search-user"+i+"'" +
- "onclick='clickSearchCheckBox("+JSON.stringify(cloneUsersList[i])+","+JSON.stringify("user")+")'"+
- "/>" +
- "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='view-user"+i+"'" +
- "onclick='clickViewCheckBox("+JSON.stringify(cloneUsersList[i])+","+JSON.stringify("user")+")'"+
- "/>" +
- "</td>" +
- "<td onclick='removeUsersSettingEntity("+i+")'>"+resources.text_input_value_delete+"</td>" +
- "</tr>")
- $("#user_tbody").append(shareMapDOM);
- break;
- case 'DATA':
- var shareMapDOM = $("<tr>" +
- "<td>" + cloneUsersList[i].entityName + "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='search-user"+i+"'" +
- "onclick='clickSearchCheckBox("+JSON.stringify(cloneUsersList[i])+","+JSON.stringify("user")+")'"+
- "/>" +
- "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='download-user"+i+"'" +
- "onclick='clickDownloadCheckBox("+JSON.stringify(cloneUsersList[i])+","+JSON.stringify("user")+")'"+
- "/>" +
- "</td>" +
- "<td onclick='removeUsersSettingEntity("+i+")'>"+resources.text_input_value_delete+"</td>" +
- "</tr>")
- $("#user_tbody").append(shareMapDOM);
- break;
- }
- cloneUsersList[i].authorizeList.forEach((authorizeListItem,index)=>{
- $("input[value='"+authorizeListItem+"-user"+i+"']").prop("checked", true);
- })
- }
- }
- //删除用户的共享权限设置
- function removeUsersSettingEntity(index) {
- var obj = this.usersSettingEntities[index];
- this.usersSettingEntities.splice(index,1);
- this.showUserShare();
- }
- // 根据查询的部门记录,渲染页面,进行共享设置
- function showDepartmentShare() {
- $("#department_tbody").empty();
- var cloneDepartmentList = Object.assign([],departmentSettingEntities);
- for (var i = 0; i < cloneDepartmentList.length; i++) {
- switch (resourceType) {
- case 'MAP':
- case 'SCENE':
- case 'INSIGHTS_WORKSPACE':
- var shareMapDOM = $("<tr>" +
- "<td>" + cloneDepartmentList[i].entityName + "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='search-department"+i+"'" +
- "onclick='clickSearchCheckBox("+JSON.stringify(cloneDepartmentList[i])+","+JSON.stringify("department")+")'"+
- "/>" +
- "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='view-department"+i+"'" +
- "onclick='clickViewCheckBox("+JSON.stringify(cloneDepartmentList[i])+","+JSON.stringify("department")+")'"+
- "/>" +
- "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='edit-department"+i+"'" +
- "onclick='clickEditCheckBox("+JSON.stringify(cloneDepartmentList[i])+","+JSON.stringify("department")+")'"+
- "/>" +
- "</td>" +
- "<td onclick='removeDepartmentSettingEntity("+i+")'>"+resources.text_input_value_delete+"</td>" +
- "</tr>")
- $("#department_tbody").append(shareMapDOM);
- break;
- case 'SERVICE':
- case 'MAP_DASHBOARD':
- var shareMapDOM = $("<tr>" +
- "<td>" + cloneDepartmentList[i].entityName + "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='search-department"+i+"'" +
- "onclick='clickSearchCheckBox("+JSON.stringify(cloneDepartmentList[i])+","+JSON.stringify("department")+")'"+
- "/>" +
- "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='view-department"+i+"'" +
- "onclick='clickViewCheckBox("+JSON.stringify(cloneDepartmentList[i])+","+JSON.stringify("department")+")'"+
- "/>" +
- "</td>" +
- "<td onclick='removeDepartmentSettingEntity("+i+")'>"+resources.text_input_value_delete+"</td>" +
- "</tr>")
- $("#department_tbody").append(shareMapDOM);
- break;
- case 'DATA':
- var shareMapDOM = $("<tr>" +
- "<td>" + cloneDepartmentList[i].entityName + "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='search-department"+i+"'" +
- "onclick='clickSearchCheckBox("+JSON.stringify(cloneDepartmentList[i])+","+JSON.stringify("department")+")'"+
- "/>" +
- "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='download-department"+i+"'" +
- "onclick='clickDownloadCheckBox("+JSON.stringify(cloneDepartmentList[i])+","+JSON.stringify("department")+")'"+
- "/>" +
- "</td>" +
- "<td onclick='removeDepartmentSettingEntity("+i+")'>"+resources.text_input_value_delete+"</td>" +
- "</tr>")
- $("#department_tbody").append(shareMapDOM);
- break;
- }
- cloneDepartmentList[i].authorizeList.forEach((authorizeListItem,index)=>{
- $("input[value='"+authorizeListItem+"-department"+i+"']").prop("checked", true);
- })
- }
- }
- // 检查输入的部门是否存在
- function checkDepartmentIsExist(name,departments) {
- var department = null;
- for(var dep of departments){
- if(dep.name === name){
- department = dep;
- break;
- }else {
- if(dep.childs){
- department = this.checkDepartmentIsExist(name,dep.childs);
- if(department){
- break;
- }
- }
- }
- }
- return department;
- }
- // 获取群组列表数据函数
- function getGroupList() {
- var groupUrl = iPortalUrl + "/web/groups/sharegroups.json?token=" + token;
- $.get(groupUrl,(res)=>{
- if(res.length>0) {
- groupList = res;
- return;
- }
- })
- }
- // 根据群组列表数据,渲染页面,进行共享设置
- function showGroupShare() {
- $("#group_tbody").empty();
- var cloneGroupsList = Object.assign([],groupsSettingEntities);
- for (var i = 0; i < cloneGroupsList.length; i++) {
- switch (resourceType) {
- case 'MAP':
- case 'SCENE':
- case 'INSIGHTS_WORKSPACE':
- var shareMapDOM = $("<tr>" +
- "<td>" + cloneGroupsList[i].entityName + "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='search-group"+i+"'" +
- "onclick='clickSearchCheckBox("+JSON.stringify(cloneGroupsList[i])+","+JSON.stringify("group")+")'"+
- "/>" +
- "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='view-group"+i+"'" +
- "onclick='clickViewCheckBox("+JSON.stringify(cloneGroupsList[i])+","+JSON.stringify("group")+")'"+
- "/>" +
- "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='edit-group"+i+"'" +
- "onclick='clickEditCheckBox("+JSON.stringify(cloneGroupsList[i])+","+JSON.stringify("group")+")'"+
- "/>" +
- "</td>" +
- "</tr>")
- $("#group_tbody").append(shareMapDOM);
- break;
- case 'SERVICE':
- case 'MAP_DASHBOARD':
- var shareMapDOM = $("<tr>" +
- "<td>" + cloneGroupsList[i].entityName + "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='search-group"+i+"'" +
- "onclick='clickSearchCheckBox("+JSON.stringify(cloneGroupsList[i])+","+JSON.stringify("group")+")'"+
- "/>" +
- "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='view-group"+i+"'" +
- "onclick='clickViewCheckBox("+JSON.stringify(cloneGroupsList[i])+","+JSON.stringify("group")+")'"+
- "/>" +
- "</td>" +
- "</tr>")
- $("#group_tbody").append(shareMapDOM);
- break;
- case 'DATA':
- var shareMapDOM = $("<tr>" +
- "<td>" + cloneGroupsList[i].entityName + "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='search-group"+i+"'" +
- "onclick='clickSearchCheckBox("+JSON.stringify(cloneGroupsList[i])+","+JSON.stringify("group")+")'"+
- "/>" +
- "</td>" +
- "<td>" +
- "<input type='checkbox'" +
- "value='download-group"+i+"'" +
- "onclick='clickDownloadCheckBox("+JSON.stringify(cloneGroupsList[i])+","+JSON.stringify("group")+")'"+
- "/>" +
- "</td>" +
- "</tr>")
- $("#group_tbody").append(shareMapDOM);
- break;
- }
- cloneGroupsList[i].authorizeList.forEach((authorizeListItem,index)=>{
- $("input[value='"+authorizeListItem+"-group"+i+"']").prop("checked", true);
- })
- }
- }
- //删除部门的共享权限设置
- function removeDepartmentSettingEntity(index){
- let obj = this.departmentSettingEntities[index];
- this.departmentSettingEntities.splice(index,1);
- this.showDepartmentShare();
- }
- //点击共享设置前,确认弹框(初始化弹框内容)
- function shareResource(ids){
- // 获取群组列表数据
- getGroupList();
- // 获取登录用户信息数据
- getLoginUserInfos();
- groupsSettingEntities = [];
- for(let group of groupList){
- let settingEntity = {
- "permissionType": "",
- "aliasName": null,
- "entityRoles": [],
- "entityType": "IPORTALGROUP",
- "entityName": group.groupName,
- "entityId": group.id,
- "authorizeList": []
- };
- groupsSettingEntities.push(settingEntity);
- }
- $('#shareModal').modal('show');
- shareIds = ids ? [ids] : getDeleteAndShareCheckArr();
- if(shareIds.length<=0) {
- widgets.alert.showAlert(resources.msg_choise_resources_share, false);
- return;
- }
- $("#public").empty();
- $("#user_thead").empty();
- $("#user_tbody").empty();
- $("#group_thead").empty();
- $("#group_tbody").empty();
- $("#department_thead").empty();
- $("#department_tbody").empty();
- $("#add-user-val").val("");
- $("#add-department-val").val("");
- //公开
- switch (resourceType) {
- case 'MAP':
- case 'SCENE':
- case 'INSIGHTS_WORKSPACE':
- sharePublicDOM = $("<div class='col-md-4 col-xl-4 gallery-item' id='shareCheckboxs'>" +
- "<div class='publicPane sub-font' id='search'>" +
- "<input type='checkbox'" +
- "value='search'" +
- "onchange='clickSearchCheckBox("+JSON.stringify(publicSettingEntity).replace(/\“/g,"'")+","+JSON.stringify("public")+")'"+
- "/>" +
- " <span>"+resources.text_user_search+"</span>" +
- "</div>" +
- "<div class='publicPane sub-font' id='view'>" +
- "<input type='checkbox'" +
- "value='view'" +
- "onchange='clickViewCheckBox("+JSON.stringify(publicSettingEntity).replace(/\“/g,"'")+","+JSON.stringify("public")+")'"+
- "/>" +
- " <span>"+resources.text_user_view+"</span>" +
- "</div>" +
- "<div class='publicPane sub-font' id='edit'>" +
- "<input type='checkbox'" +
- "value='edit'" +
- "onchange='clickEditCheckBox("+JSON.stringify(publicSettingEntity).replace(/\“/g,"'")+","+JSON.stringify("public")+")'"+
- "/>" +
- " <span>"+resources.text_user_editor+"</span>" +
- "</div>" +
- "</div>")
- break;
- case 'SERVICE':
- case 'MAP_DASHBOARD':
- sharePublicDOM = $("<div class='col-md-4 col-xl-4 gallery-item' id='shareCheckboxs'>" +
- "<div class='publicPane sub-font' id='search'>" +
- "<input type='checkbox'" +
- "value='search'" +
- "onchange='clickSearchCheckBox("+JSON.stringify(publicSettingEntity).replace(/\“/g,"'")+","+JSON.stringify("public")+")'"+
- "/>" +
- " <span>"+resources.text_user_search+"</span>" +
- "</div>" +
- "<div class='publicPane sub-font' id='view'>" +
- "<input type='checkbox'" +
- "value='view'" +
- "onchange='clickViewCheckBox("+JSON.stringify(publicSettingEntity).replace(/\“/g,"'")+","+JSON.stringify("public")+")'"+
- "/>" +
- " <span>"+resources.text_user_view+"</span>" +
- "</div>" +
- "</div>")
- break;
- case 'DATA':
- sharePublicDOM = $("<div class='col-md-4 col-xl-4 gallery-item' id='shareCheckboxs'>" +
- "<div class='publicPane sub-font' id='search'>" +
- "<input type='checkbox'" +
- "value='search'" +
- "onchange='clickSearchCheckBox("+JSON.stringify(publicSettingEntity).replace(/\“/g,"'")+","+JSON.stringify("public")+")'"+
- "/>" +
- " <span>"+resources.text_user_search+"</span>" +
- "</div>" +
- "<div class='publicPane sub-font' id='download'>" +
- "<input type='checkbox'" +
- "value='download'" +
- "onchange='clickDownloadCheckBox("+JSON.stringify(publicSettingEntity).replace(/\“/g,"'")+","+JSON.stringify("public")+")'"+
- "/>" +
- " <span>"+resources.text_user_download+"</span>" +
- "</div>" +
- "</div>")
- break;
- }
- initDepartmentUserGroupThead("user",resources.text_nickname);
- initDepartmentUserGroupThead("department",resources.text_department);
- initDepartmentUserGroupThead("group",resources.text_group);
- $("#public").append(sharePublicDOM)
- var item = new SuperMap.iPortalResource(iPortalUrl,{resourceId:shareIds[0],resourceType:resourceType});
- item.load().then(()=>{
- if(item.sourceJSON.authorizeSetting && item.sourceJSON.authorizeSetting.length > 0){
- for(let entity of item.sourceJSON.authorizeSetting){
- let permissionType = entity.permissionType || entity.dataPermissionType;
- switch(entity.entityType) {
- case "USER":
- if(entity.entityName === "GUEST") {
- //为其增加一权限属性,用于处理复选框数据双向绑定
- var entityObj = Object.assign({},entity);
- entityObj["authorizeList"] = getAuthorizeList(permissionType);
- publicSettingEntity = entityObj;
- }else {
- if(!entity.entityName || userStateObj.userName === entity.entityName){
- break;
- }
- var entityObj = Object.assign({},entity);
- entityObj["authorizeList"] = getAuthorizeList(permissionType);
- usersSettingEntities.push(entityObj);
- }
- break;
- case "IPORTALGROUP":
- var cloneGroupsEntities = Object.assign([],groupsSettingEntities)
- for(var groupItem of cloneGroupsEntities){
- if(groupItem.entityId === entity.entityId){
- groupItem.authorizeList = getAuthorizeList(permissionType);
- groupItem.permissionType = entity.permissionType;
- break;
- }
- }
- groupsSettingEntities = cloneGroupsEntities;
- break;
- case "DEPARTMENT":
- var entityObj = Object.assign({},entity);
- entityObj["authorizeList"] = getAuthorizeList(permissionType);
- departmentSettingEntities.push(entityObj);
- break;
- }
- }
- }
- publicSettingEntity.authorizeList.forEach((authorizeListItem,index)=>{
- $("input[value='"+authorizeListItem+"']").prop("checked", true);
- })
- if(departmentSettingEntities.length>0) {
- showDepartmentShare();
- }
- if(usersSettingEntities.length>0) {
- showUserShare();
- }
- if(groupsSettingEntities.length>0) {
- showGroupShare();
- }
- })
- }
- //初始化部门用户群组的表格头部内容
- function initDepartmentUserGroupThead(renderDOMType,name){
- var tr = document.createElement("tr");
- //添加昵称(用户名)
- var td_Name = document.createElement("th");
- var text_Name = document.createTextNode(name);
- td_Name.append(text_Name);
- tr.append(td_Name);
- $("#"+renderDOMType+"_thead").append(tr);
- //添加可检索
- var td_Name = document.createElement("th");
- var text_Name = document.createTextNode(resources.text_is_search);
- td_Name.append(text_Name);
- tr.append(td_Name);
- $("#"+renderDOMType+"_thead").append(tr);
- switch (resourceType) {
- case 'MAP':
- case 'SCENE':
- case 'INSIGHTS_WORKSPACE':
- //可查看
- var td_Value = document.createElement("th");
- var text_Value = document.createTextNode(resources.text_is_view);
- td_Value.append(text_Value);
- tr.append(td_Value);
- $("#"+renderDOMType+"_thead").append(tr);
- //可编辑
- var td_Value = document.createElement("th");
- var text_Value = document.createTextNode(resources.text_is_edit);
- td_Value.append(text_Value);
- tr.append(td_Value);
- $("#"+renderDOMType+"_thead").append(tr);
- break;
- case 'SERVICE':
- case 'MAP_DASHBOARD':
- //可查看
- var td_Value = document.createElement("th");
- var text_Value = document.createTextNode(resources.text_is_view);
- td_Value.append(text_Value);
- tr.append(td_Value);
- $("#"+renderDOMType+"_thead").append(tr);
- break;
- case 'DATA':
- //可下载
- var td_Value = document.createElement("th");
- var text_Value = document.createTextNode(resources.text_is_download);
- td_Value.append(text_Value);
- tr.append(td_Value);
- $("#"+renderDOMType+"_thead").append(tr);
- break;
- }
- if(renderDOMType === 'group') {
- return;
- }
- var td_Value = document.createElement("th");
- var text_Value = document.createTextNode(resources.btn_operate);
- td_Value.append(text_Value);
- tr.append(td_Value);
- $("#"+renderDOMType+"_thead").append(tr);
- }
- //发送共享设置请求
- function requestShareUrl(){
- var resourceIds = shareIds;
- var entities = getShareEntities();
- queryShareParams = new SuperMap.iPortalShareParam({
- ids:resourceIds,
- entities:entities,
- resourceType:resourceType
- });
- iPortal.updateResourcesShareSetting(queryShareParams).then(result=>{
- $('#shareModal').modal('hide');
- usersSettingEntities = [];
- departmentSettingEntities = [];
- groupsSettingEntities = [];
- widgets.alert.showAlert(resources.msg_shareSuccess, true);
- }).catch(err => {
- widgets.alert.showAlert(resources.msg_shareFailed, false);
- })
- }
-
- //关闭弹框后 清空实体参数对象 防止重复渲染
- function removeUser(){
- usersSettingEntities = [];
- departmentSettingEntities = [];
- groupsSettingEntities = [];
- }
- //获取共享的实体参数
- function getShareEntities(){
- shareSettingList = [];
- //公开
- addSettingEntity(publicSettingEntity);
- //用户
- for(var user of usersSettingEntities){
- addSettingEntity(user);
- }
- //部门
- for(var department of departmentSettingEntities){
- addSettingEntity(department);
- }
- //群组
- for(var group of groupsSettingEntities){
- addSettingEntity(group);
- }
- return shareSettingList;
- }
- //生成分享的entities参数
- function addSettingEntity(obj){
- var settingEntity = dealShareSettingParam(obj);
- if(settingEntity){
- shareSettingList.push(settingEntity);
- }
- }
- //处理共享设置的参数
- function dealShareSettingParam(obj) {
- var authorize = "";
- if(!obj.authorizeList){
- return null;
- }
- if(obj.authorizeList.includes("edit")){
- authorize = obj.entityName === userStateObj.userName ? "DELETE" : "READWRITE";
- }else if(obj.authorizeList.includes("view")){
- authorize = "READ";
- }else if(obj.authorizeList.includes("download")){
- authorize = "DOWNLOAD";
- }else if(obj.authorizeList.includes("search")){
- authorize = "SEARCH";
- }
- if(authorize){
- if(resourceType === "DATA") {
- obj.dataPermissionType = authorize;
- }
- obj.permissionType = authorize;
- let targetPermissionEntity = Object.assign({},obj);
- delete targetPermissionEntity.authorizeList;
- delete targetPermissionEntity.aliasName;
- delete targetPermissionEntity.entityRoles;
- return targetPermissionEntity;
- }else {
- return null;
- }
- }
- //根据已有的权限生成authorizeList,用于复选框双向绑定
- function getAuthorizeList(permissionType){
- let authorizeList = [];
- switch(permissionType){
- case "SEARCH":
- authorizeList = ["search"];
- break;
- case "READ":
- authorizeList = ["search","view"];
- break;
- case "DOWNLOAD":
- authorizeList = ["search","download"];
- break;
- case "READWRITE":
- authorizeList = ["search","view","edit"];
- break;
- case "DELETE":
- authorizeList = ["search","view","edit"];
- break;
- default:
- break;
- }
- return authorizeList;
- }
-
- //点击可检索逻辑
- function clickSearchCheckBox(obj,type){
- if(!obj.authorizeList || (obj.authorizeList).indexOf("search") === -1){
- obj.authorizeList = ["search"];
- }else {
- obj.authorizeList = [];
- }
- if(type === 'public') {
- publicSettingEntity = obj;
- if($("input[value='search']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"']").prop("checked", true);
- $("input[value='view']").prop("checked", false);
- $("input[value='edit']").prop("checked", false);
- $("input[value='download']").prop("checked", false);
- })
- }else {
- $("input[value='search']").prop("checked", false);
- $("input[value='view']").prop("checked", false);
- $("input[value='edit']").prop("checked", false);
- $("input[value='download']").prop("checked", false);
- }
- }else if(type === 'user') {
- usersSettingEntities.forEach((item,index)=>{
- if(item.entityName === obj.entityName) {
- usersSettingEntities[index] = obj;
- }
- if($("input[value='search-user"+index+"']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"-user"+index+"']").prop("checked", true);
- $("input[value='view-user"+index+"']").prop("checked", false);
- $("input[value='edit-user"+index+"']").prop("checked", false);
- $("input[value='download-user"+index+"']").prop("checked", false);
- })
- }else {
- $("input[value='search-user"+index+"']").prop("checked", false);
- $("input[value='view-user"+index+"']").prop("checked", false);
- $("input[value='edit-user"+index+"']").prop("checked", false);
- $("input[value='download-user"+index+"']").prop("checked", false);
- }
- })
- }else if(type === 'department') {
- departmentSettingEntities.forEach((item,index)=>{
- if(item.entityName === obj.entityName) {
- departmentSettingEntities[index] = obj;
- }
- if($("input[value='search-department"+index+"']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"-department"+index+"']").prop("checked", true);
- $("input[value='view-department"+index+"']").prop("checked", false);
- $("input[value='edit-department"+index+"']").prop("checked", false);
- $("input[value='download-department"+index+"']").prop("checked", false);
- })
- }else {
- $("input[value='search-department"+index+"']").prop("checked", false);
- $("input[value='view-department"+index+"']").prop("checked", false);
- $("input[value='edit-department"+index+"']").prop("checked", false);
- $("input[value='download-department"+index+"']").prop("checked", false);
- }
- })
- }else if(type === 'group') {
- groupsSettingEntities.forEach((item,index)=>{
- if(item.entityName === obj.entityName) {
- groupsSettingEntities[index] = obj;
- }
- if($("input[value='search-group"+index+"']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"-group"+index+"']").prop("checked", true);
- $("input[value='view-group"+index+"']").prop("checked", false);
- $("input[value='edit-group"+index+"']").prop("checked", false);
- $("input[value='download-group"+index+"']").prop("checked", false);
- })
- }else {
- $("input[value='search-group"+index+"']").prop("checked", false);
- $("input[value='view-group"+index+"']").prop("checked", false);
- $("input[value='edit-group"+index+"']").prop("checked", false);
- $("input[value='download-group"+index+"']").prop("checked", false);
- }
- })
- }
- }
- //点击可下载逻辑
- function clickDownloadCheckBox(obj,type){
- if(!obj.authorizeList || (obj.authorizeList).indexOf("download") === -1){
- obj.authorizeList = ["search","download"];
- }else if((obj.authorizeList).indexOf("search") !== -1){
- obj.authorizeList = ["search"];
- }
- if(type === 'public') {
- publicSettingEntity = obj;
- }else if(type === 'user') {
- usersSettingEntities.forEach((item,index)=>{
- if(item.entityName === obj.entityName) {
- usersSettingEntities[index] = obj;
- if($("input[value='download-user"+index+"']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"-user"+index+"']").prop("checked", true);
- })
- }
- }
- })
- }else if(type === 'department') {
- departmentSettingEntities.forEach((item,index)=>{
- if(item.entityName === obj.entityName) {
- departmentSettingEntities[index] = obj;
- if($("input[value='download-department"+index+"']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"-department"+index+"']").prop("checked", true);
- })
- }
- }
- })
- }else if(type === 'group') {
- groupsSettingEntities.forEach((item,index)=>{
- if(item.entityName === obj.entityName) {
- groupsSettingEntities[index] = obj;
- if($("input[value='download-group"+index+"']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"-group"+index+"']").prop("checked", true);
- })
- }
- }
- })
- }
- }
- //点击可查看逻辑
- function clickViewCheckBox(obj,type){
- if(!obj.authorizeList || (obj.authorizeList).indexOf("view") === -1){
- obj.authorizeList = ["search","view"];
- }else if((obj.authorizeList).indexOf("search") !== -1){
- obj.authorizeList = ["search"];
- }
- if(type === 'public') {
- publicSettingEntity = obj;
- if($("input[value='view']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"']").prop("checked", true);
- })
- }else {
- $("input[value='edit']").prop("checked", false);
- }
- }else if(type === 'user') {
- usersSettingEntities.forEach((item,index)=>{
- if(item.entityName === obj.entityName) {
- usersSettingEntities[index] = obj;
- if($("input[value='view-user"+index+"']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"-user"+index+"']").prop("checked", true);
- $("input[value='edit-user"+index+"']").prop("checked", false);
- })
- }else {
- $("input[value='edit-user"+index+"']").prop("checked", false);
- }
- }
- })
- }else if(type === 'department') {
- departmentSettingEntities.forEach((item,index)=>{
- if(item.entityName === obj.entityName) {
- departmentSettingEntities[index] = obj;
- if($("input[value='view-department"+index+"']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"-department"+index+"']").prop("checked", true);
- $("input[value='edit-department"+index+"']").prop("checked", false);
- })
- }else {
- $("input[value='edit-department"+index+"']").prop("checked", false);
- }
- }
- })
- }else if(type === 'group') {
- groupsSettingEntities.forEach((item,index)=>{
- if(item.entityName === obj.entityName) {
- groupsSettingEntities[index] = obj;
- if($("input[value='view-group"+index+"']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"-group"+index+"']").prop("checked", true);
- $("input[value='edit-group"+index+"']").prop("checked", false);
- })
- }else {
- $("input[value='edit-group"+index+"']").prop("checked", false);
- }
- }
- })
- }
- }
- //点击可编辑逻辑
- function clickEditCheckBox(obj,type){
- if(!obj.authorizeList || (obj.authorizeList).indexOf("edit") === -1){
- obj.authorizeList = ["search","view","edit"];
- }else if((obj.authorizeList).indexOf("view") !== -1){
- obj.authorizeList = ["search","view"];
- }
- if(type === 'public') {
- publicSettingEntity = obj;
- if($("input[value='edit']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"']").prop("checked", true);
- })
- }
- }else if(type === 'user') {
- usersSettingEntities.forEach((item,index)=>{
- if(item.entityName === obj.entityName) {
- usersSettingEntities[index] = obj;
- }
- if($("input[value='edit-user"+index+"']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"-user"+index+"']").prop("checked", true);
- })
- }
- })
- }else if(type === 'department') {
- departmentSettingEntities.forEach((item,index)=>{
- if(item.entityName === obj.entityName) {
- departmentSettingEntities[index] = obj;
- }
- if($("input[value='edit-department"+index+"']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"-department"+index+"']").prop("checked", true);
- })
- }
- })
- }else if(type === 'group') {
- groupsSettingEntities.forEach((item,index)=>{
- if(item.entityName === obj.entityName) {
- groupsSettingEntities[index] = obj;
- }
- if($("input[value='edit-group"+index+"']").is(':checked')){
- obj.authorizeList.forEach(authorizeListItem=>{
- $("input[value='"+authorizeListItem+"-group"+index+"']").prop("checked", true);
- })
- }
- })
- }
- }
-
- // 选择资源类型 查询资源
- function onSelectResourcesType(){
- iPortal = new SuperMap.iPortal(iPortalUrl);
- let type = $("#typeSelect").val();
- resourceType = type;
- queryParams = new SuperMap.iPortalQueryParam({
- resourceType: type,
- searchType:'MY_RES',
- pageSize: 15,
- currentPage: 1
- });
- queryResouces(queryParams);
- }
- </script>
- </body>
- </html>
|