### Initialize Diagram Viewer with Progress Bar and Event Handlers Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/flow-editor/diagram-viewer/index.html This script parses URL parameters for processDefinitionId and processInstanceId, initializes a progress bar that triggers diagram highlighting on completion, and configures ProcessDiagramGenerator options for click, right-click, over, and out events. It also sets ActivitiRest API URLs and draws the diagram if processDefinitionId is present, otherwise alerts the user. ```javascript var DiagramGenerator = {}; var pb1; $(document).ready(function(){ var query_string = {}; var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i 日程参与者详细信息 参与者名字完成比例提交注释实际开始时间实际完成时间 {{item.participantorName}} {{item.rateProgress}} {{item.submitComment}} {{item.actualStartTime |date :'yyyy-MM-dd hh:mm:ss'}} {{item.completeTime |date :'yyyy-MM-dd hh:mm:ss'}} ``` -------------------------------- ### Resource-Role Assignment Script (sysResourceRole.html) Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/sys/sysResource/sysResourceRole.html This script initializes a Ztree for resource-role assignment, loads the system dropdown, and saves selected resource IDs for a role. It uses __ctx for context path and expects the server endpoints /sys/resRole/getTreeData, /sys/subsystem/getUserSystem, and /sys/resRole/save. The save function collects checked nodes and posts them; success shows a success dialog, failure shows an error dialog with the server message. ```javascript var ztreeObject ; var roleId = $.getParam("roleId"); function loadTree() { var url = __ctx + "/sys/resRole/getTreeData"; var systemId = $("systemId").val() || "1"; var params = {systemId:systemId,roleId:roleId}; var ztreeCreator = new ZtreeCreator('sysztreeObject',url) .setCallback({}) .setCheckboxType({ "Y": "ps", "N": "s" }) .initZtree(params,2,function(treeObj){ztreeObject=treeObj}); }; function laodSystem(){ var url = __ctx + "/sys/subsystem/getUserSystem"; $.post(url, {}, function(result) { var result = eval("("+result+")"); if (result.isOk) {//成功 for(var i =0,system;system= result.data[i++];){ $("#systemId").append(""); } } else { $.Dialog.alert(result.msg,2); } }); } function saveResRole(data){ var nodes = ztreeObject.getCheckedNodes(); var systemId = $("systemId").val() || "1"; var resIds = []; for(var i=0,node;node=nodes[i++];){ resIds.push(node.id); } resIds = resIds.join(","); var data = {resIds:resIds,roleId:roleId,systemId:systemId}; var url=__ctx +"/sys/resRole/save"; $.post(url,data, function(result){ var result=JSON.parse(result); if(result.isOk){ $.Dialog.success("资源授权成功!"); } else{ $.Dialog.error("资源授权失败!"+result.msg); } }) } $(function() { laodSystem(); loadTree(); }); ``` -------------------------------- ### UEditor word image uploader initialization with Flash options and callbacks Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/assets/js/plugins/ueditor/dialogs/wordimage/wordimage.html Initializes the UEditor word image uploader. Sets upload options, builds the Flash uploader configuration (including URL, file type restrictions, and compression settings), and defines callbacks for file selection, deletion, upload completion, errors, and all-complete. The upload button is disabled until files are selected. ```javascript editor.setOpt({ wordImageFieldName:"upfile", compressSide:0, maxImageSideLength:900 }); //全局变量 var imageUrls = [], //用于保存从服务器返回的图片信息数组 selectedImageCount = 0, //当前已选择的但未上传的图片数量 optImageUrl = editor.getActionUrl(editor.getOpt('imageActionName')), optImageFieldName = editor.getOpt('imageFieldName'), optImageCompressBorder = editor.getOpt('imageCompressEnable') ? editor.getOpt('imageCompressBorder'):null, maxSize = editor.getOpt('imageMaxSize') / 1024, extension = editor.getOpt('imageAllowFiles').join(';').replace(/\./g, '*.'); /* 添加额外的GET参数 */ var params = utils.serializeParam(editor.queryCommandValue('serverparam')) || '', urlWidthParams = optImageUrl + (optImageUrl.indexOf('?') == -1 ? '?':'&') + params; utils.domReady(function(){ //创建Flash相关的参数集合 var flashOptions = { container:"flashContainer", //flash容器id url:urlWidthParams, // 上传处理页面的url地址 ext:editor.queryCommandValue('serverParam') || {}, //可向服务器提交的自定义参数列表 fileType:'{"description":"'+lang.fileType+'", "extension":"' + extension + '"}', //上传文件格式限制 flashUrl:'imageUploader.swf', //上传用的flash组件地址 width:600, //flash的宽度 height:272, //flash的高度 gridWidth:120, // 每一个预览图片所占的宽度 gridHeight:120, // 每一个预览图片所占的高度 picWidth:100, // 单张预览图片的宽度 picHeight:100, // 单张预览图片的高度 uploadDataFieldName: optImageFieldName, // POST请求中图片数据的key picDescFieldName:'pictitle', // POST请求中图片描述的key maxSize: maxSize, // 文件的最大体积,单位M compressSize:1, // 上传前如果图片体积超过该值,会先压缩,单位M maxNum:32, // 单次最大可上传多少个文件 compressSide: 0, //等比压缩的基准,0为按照最长边,1为按照宽度,2为按照高度 compressLength: optImageCompressBorder //能接受的最大边长,超过该值Flash会自动等比压缩 }; //回调函数集合,支持传递函数名的字符串、函数句柄以及函数本身三种类型 var callbacks={ selectFileCallback: function(selectFiles){ // 选择文件的回调 selectedImageCount += selectFiles.length; if(selectedImageCount) baidu.g("upload").style.display = ""; dialog.buttons[0].setDisabled(true); //初始化时置灰确定按钮 }, deleteFileCallback: function(delFiles){ // 删除文件的回调 selectedImageCount -= delFiles.length; if (!selectedImageCount) { baidu.g("upload").style.display = "none"; dialog.buttons[0].setDisabled(false); //没有选择图片时重新点亮按钮 } }, uploadCompleteCallback: function(data){ // 单个文件上传完成的回调 try{var info = eval("(" + data.info + ")"); info && imageUrls.push(info); selectedImageCount--; }catch(e){} }, uploadErrorCallback: function (data){ // 单个文件上传失败的回调, console && console.log(data); }, allCompleteCallback: function(){ // 全部上传完成时的回调 dialog.buttons[0].setDisabled(false); //上传完毕后点亮按钮 } //exceedFileCallback: 'exceedFileCallback', // 文件超出限制的最大体积时的回调 //startUploadCallback: startUploadCallback // 开始上传某个文件时的回调 }; wordImage.init(flashOptions,callbacks); }); ``` -------------------------------- ### getResult Function for User Selection Validation Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/bpm/nodeDef/userSelector.html Retrieves the Angular scope and sets the description based on the source type. For 'spec' source, it validates that a user is selected, showing an error toast if not, and sets the description to the user name. For 'start' source, it sets the description to '发起人'. ```javascript function getResult() { var scope = AngularUtil.getScope(); //指定人员 if (scope.data.source == 'spec') { scope.data.userName = scope.user.name; scope.data.account = scope.user.account; } if (scope.data.source == 'start') { scope.data.description="发起人"; }else if (scope.data.source == 'spec') { if(!scope.user.name){ $.Toast.error("请选择用户!"); return false; } scope.data.description=""+scope.user.name; } return scope.data; } ``` -------------------------------- ### Directory structure of Web Uploader distribution files Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/assets/js/plugins/webuploader/README.md Lists the files included in the Web Uploader distribution, with comments indicating the purpose of each file, such as the Flash runtime SWF, the full version, minified versions, and special builds for Flash-only, HTML5-only, no-image, and custom packaging. ```bash ├── Uploader.swf # SWF文件,当使用Flash运行时需要引入。 ├ ├── webuploader.js # 完全版本。 ├── webuploader.min.js # min版本 ├ ├── webuploader.flashonly.js # 只有Flash实现的版本。 ├── webuploader.flashonly.min.js # min版本 ├ ├── webuploader.html5only.js # 只有Html5实现的版本。 ├── webuploader.html5only.min.js # min版本 ├ ├── webuploader.noimage.js # 去除图片处理的版本,包括HTML5和FLASH. ├── webuploader.noimage.min.js # min版本 ├ ├── webuploader.custom.js # 自定义打包方案,请查看 Gruntfile.js,满足移动端使用。 └── webuploader.custom.min.js # min版本 ``` -------------------------------- ### 初始化工作日历函数 init() Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/sys/holidayConf/holidayConfList.html 从输入框获取年份,若为空则弹出错误提示;否则通过POST请求调用后端接口初始化工作日历,并根据返回结果弹出相应提示。 ```javascript function init(){ var year = $("#year").val(); if(!year){ $.topCall.error("数字年份不能为空"); return ; } $.post(__ctx+"/calendar/holidayConf/initWorkCalenDar?year="+year, function(data){ var result = JSON.parse(data); if(result.isOk){ $.Dialog.error(result.msg+result.cause); } else { $.Dialog.success(result.message); } }); } ``` -------------------------------- ### JavaScript for Google Map initialization and geocoding Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/assets/js/plugins/ueditor/dialogs/gmap/gmap.html Initializes the map, handles address search via geocoder, and inserts a static map image into the editor on OK. ```javascript domUtils.on(window,"load",function(){ var map = new google.maps.Map(document.getElementById('container'), { zoom: 3, streetViewControl: false, scaleControl: true, mapTypeId: google.maps.MapTypeId.ROADMAP }); var imgcss; var marker = new google.maps.Marker({ map: map, draggable: true }); function doSearch(){ var address = document.getElementById('address').value; var geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': address}, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { var bounds = results[0].geometry.viewport; map.fitBounds(bounds); marker.setPosition(results[0].geometry.location); marker.setTitle(address); } else alert(lang.searchError); } ); } $G('address').onkeydown = function (evt){ evt = evt || event; if (evt.keyCode == 13) { doSearch(); } }; $G("doSearch").onclick = doSearch; dialog.onok = function (){ var center = map.getCenter(); var point = marker.getPosition(); var url = "http://maps.googleapis.com/maps/api/staticmap?center=" + center.lat() + ',' + center.lng() + "&zoom=" + map.zoom + "&size=520x340&maptype=" + map.getMapTypeId() + "&markers=" + point.lat() + ',' + point.lng() + "&sensor=false"; editor.execCommand('inserthtml', ''); }; function getPars(str,par){ var reg = new RegExp(par+"=((\\d+|[.,])*)","g"); return reg.exec(str)[1]; } var img = editor.selection.getRange().getClosedNode(); if(img && img.src.indexOf("http://maps.googleapis.com/maps/api/staticmap")!=-1){ var url = img.getAttribute("src"); var centers = getPars(url,"center").split(","); point = new google.maps.LatLng(Number(centers[0]),Number(centers[1])); map.setCenter(point); map.setZoom(Number(getPars(url,"zoom"))); centers = getPars(url,"markers").split(","); marker.setPosition(new google.maps.LatLng(Number(centers[0]),Number(centers[1]))); imgcss = img.style.cssText; }else{ setTimeout(function(){ doSearch(); },30) } }); ``` -------------------------------- ### Initialize org tree on page load Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/org/group/groupList.html Calls loadTree() when the document is ready to populate the organization tree. ```JavaScript $(function() { loadTree(); }); ``` -------------------------------- ### 测试数据源连接 (checkConnection) Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/sys/sysDataSource/sysDataSourceList.html 发送POST请求到 /sys/sysDataSource/checkConnection,根据返回结果弹出成功或错误提示。 ```javascript /** * 测试连接 */ function checkConnection(key) { var url = __ctx + "/sys/sysDataSource/checkConnection"; //3 发请求 jQuery.post(url, { key : key }, function(result) { if (result.data) { $.Toast.success(result.msg); } else { $.Toast.error(result.msg); } }, "json"); }; ``` -------------------------------- ### JavaScript for Baidu app search integration Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/assets/js/plugins/ueditor/dialogs/webapp/webapp.html Configures the Baidu app search with the provided API key, sets up the search configuration, and handles the callback to insert the selected app into the editor. If the API key is invalid, displays an error message. ```javascript //此处配置您在百度上申请到的appkey。 var apikey = editor.options.webAppKey; if ( apikey && apikey.length == 24 ) { var searchConfig = { container:'appShow', //容器ID tips:"", //该值用于自动清空 search:1, //是否显示搜索框 ps:12, //每页显示的条数 suggest:1, //是否开启搜索自动完成 limit:0, //搜索结果显示条数,0表示无限制 searchNow:0, //是否在初始化完成时立即搜索 apikey:apikey, //每人得 pager:1, cid:7134562, outputHTML:1 },baiduApp; function clickCallback() { baiduApp.addEventListener( 'getAppHTML', function ( e, data ) { var url = 'http://app.baidu.com/app/enter?appid='+data.data\['app\_id'\] +'&tn=app\_canvas&app\_spce\_id=1&apikey='+apikey+'&api\_key=' + apikey; editor.execCommand( "webapp", {url:url,width:data.uniWidth,height:data.uniHeight+60,logo:data.data\['app\_logo'\],title:data.data\['app\_name'\]}); dialog.close(); } ); } var script = document.createElement( "script" ); script.type = "text/javascript"; script.src = "http://app.baidu.com/appweb/api/search?auto=yes&container=container&apikey=" + apikey + "&instanceName=baiduApp&callback=clickCallback&config=searchConfig"; document.body.appendChild( script ); } else { $G( "appShow" ).innerHTML = "

"+lang.tip1+""+lang.applyFor+"

"+lang.tip2+"

" ; } ``` -------------------------------- ### Initialize group tabs with iframes Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/org/group/groupTabs.html Initializes three iframes with URLs based on the groupId parameter from the URL. The commented code shows an alternative approach to load iframes on tab click. ```javascript $(function(){ var groupId = $.getParam("id"); $("#listFrame").attr("src","groupGet.html?id="+groupId); $("#listFrame2").attr("src","groupUserList.html?groupId="+groupId); $("#listFrame3").attr("src","groupRelationList.html?groupId="+groupId); // 可以在点击的时候再加载 /* $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { var iframe = $("iframe", e.target); if(iframe.attr("url")) }) */ }) ``` -------------------------------- ### 刷新节点 Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/sys/sysResource/sysResourceList.html 重新加载资源树。 ```javascript function refreshNode() { loadTree(); }; ``` -------------------------------- ### AngularJS控制器初始化子表数据 Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/bus/buinessObject/childrenDialog.html 控制器初始化时调用editAndDialogCommon.init,复制传入数据,添加子表详情,并加载关系类型和外键类型的枚举。 ```javascript var app = angular.module('app', [ 'baseDirective' ]); app.controller("ctrl", [ '$scope', 'baseService', 'ArrayToolService', function($scope, baseService, ArrayToolService) { $scope.ArrayTool = ArrayToolService; $scope.init = function() { editAndDialogCommon.init($scope, baseService);//初始化公用js $scope.data = angular.copy(window.passData); $scope.addTableDetail($scope.data.tableKey); if (!$scope.data.children) { $scope.data.children = []; } else { angular.forEach($scope.data.children, function(item) { $scope.addTableDetail(item.tableKey); }); } ToolsController.getEnum("com.dstz.bus.api.constant.BusTableRelType").then(function(data) { $scope.$apply(function() { $scope.BusTableRelType = data; }); }); ToolsController.getEnum("com.dstz.bus.api.constant.BusTableRelFkType").then(function(data) { $scope.$apply(function() { $scope.BusTableRelFkType = data; }); }); }; } ]); ``` -------------------------------- ### Preview dialog CSS for full-size layout Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/assets/js/plugins/ueditor/dialogs/preview/preview.html Sets html, body, and the #preview element to fill the viewport with no padding or margin, and applies a sans-serif font at 16px to all preview content. ```css html,body{ height:100%; width:100%; padding:0; margin:0; } #preview{ width:100%; height:100%; padding:0; margin:0; } #preview \*{font-family:sans-serif;font-size:16px;} ``` -------------------------------- ### showDialog function to preview custom dialog by alias Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/form/custDialog/custDialogList.html Fetches custom dialog details by alias via POST to '/form/custDialog/getByAlias'. Parses the conditionfield JSON, collects fields with defaultType '4' into a param object, and if no such fields exist, opens the dialog directly using CustUtil.openCustDialog. Otherwise, opens a parameter dialog (paramDialog.html) to collect values, then opens the custom dialog with the collected data. ```javascript function showDialog(alias) { var url = __ctx + '/form/custDialog/getByAlias?alias=' + alias; $.ajax({ url : url, type : 'POST', dataType : 'json', success : function(customDialog) { var list = JSON.parse(customDialog.conditionfield); var param = {}; $(list).each(function() { if (this.defaultType == "4") { param[this.field] = this.comment; } }); if($.isEmptyObject(param)){//没有动态传入的字段 CustUtil.openCustDialog(alias); return; } var url = "../../form/custDialog/paramDialog.html"; var conf = { height:400, width:600, url:url, title:"设置参数", btn:true, passData:param }; conf.ok = function(index,innerWindow){ var data = innerWindow.getResult().map; $.Dialog.close(innerWindow); CustUtil.openCustDialog(alias,data); } $.Dialog.open(conf); } }); } ``` -------------------------------- ### Baidu Map API: Custom Map Initialization and Controls Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/assets/js/plugins/ueditor/dialogs/map/show.html This snippet contains the full JavaScript code for initializing a Baidu Map with custom parameters, creating the map, setting events, adding controls, and handling map changes in an editor. It includes functions like initMap, createMap, setMapEvent, addMapControl, and setMapListener. ```javascript html, body { margin: 0; padding: 0; overflow: hidden; } function getParam(name) { return location.href.match(new RegExp('\[?#&\]' + name + '=([^?#&]+)', 'i')) ? RegExp.$1 : ''; } var map, marker; var centerParam = getParam('center'); var zoomParam = getParam('zoom'); var widthParam = getParam('width'); var heightParam = getParam('height'); var markersParam = getParam('markers'); var markerStylesParam = getParam('markerStyles'); //创建和初始化地图函数: function initMap() { // \[FF\]切换模式后报错 if (!window.BMap) { return; } var dituContent = document.getElementById('dituContent'); dituContent.style.width = widthParam + 'px'; dituContent.style.height = heightParam + 'px'; createMap();//创建地图 setMapEvent();//设置地图事件 addMapControl();//向地图添加控件 // 创建标注 var markersArr = markersParam.split(','); var point = new BMap.Point(markersArr[0], markersArr[1]); marker = new BMap.Marker(point); marker.enableDragging(); map.addOverlay(marker); // 将标注添加到地图中 if(parent.editor && parent.document.body.contentEditable=="true") { //在编辑状态下 setMapListener();//地图改变修改外层的iframe标签src属性 } } //创建地图函数: function createMap() { map = new BMap.Map("dituContent");//在百度地图容器中创建一个地图 var centerArr = centerParam.split(','); var point = new BMap.Point(parseFloat(centerArr[0]), parseFloat(centerArr[1]));//定义一个中心点坐标 map.centerAndZoom(point, parseInt(zoomParam));//设定地图的中心点和坐标并将地图显示在地图容器中 } //地图事件设置函数: function setMapEvent() { map.enableDragging();//启用地图拖拽事件,默认启用(可不写) map.enableScrollWheelZoom();//启用地图滚轮放大缩小 map.enableDoubleClickZoom();//启用鼠标双击放大,默认启用(可不写) map.enableKeyboard();//启用键盘上下左右键移动地图 } //地图控件添加函数: function addMapControl() { //向地图中添加缩放控件 var ctrl_nav = new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_LEFT, type: BMAP_NAVIGATION_CONTROL_LARGE}); map.addControl(ctrl_nav); //向地图中添加缩略图控件 var ctrl_ove = new BMap.OverviewMapControl({anchor: BMAP_ANCHOR_BOTTOM_RIGHT, isOpen: 1}); map.addControl(ctrl_ove); //向地图中添加比例尺控件 var ctrl_sca = new BMap.ScaleControl({anchor: BMAP_ANCHOR_BOTTOM_LEFT}); map.addControl(ctrl_sca); } function setMapListener() { var editor = parent.editor, containerIframe, iframes = parent.document.getElementsByTagName('iframe'); for (var key in iframes) { if (iframes[key].contentWindow == window) { containerIframe = iframes[key]; break; } } if (containerIframe) { map.addEventListener('moveend', mapListenerHandler); map.addEventListener('zoomend', mapListenerHandler); marker.addEventListener('dragend', mapListenerHandler); } function mapListenerHandler() { var zoom = map.getZoom(), center = map.getCenter(), marker = window.marker.getPoint(); containerIframe.src = containerIframe.src. replace(new RegExp('([?#&])center=([^?#&]+)', 'i'), '$1center=' + center.lng + ',' + center.lat). replace(new RegExp('([?#&])markers=([^?#&]+)', 'i'), '$1markers=' + marker.lng + ',' + marker.lat). replace(new RegExp('([?#&])zoom=([^?#&]+)', 'i'), '$1zoom=' + zoom); editor.fireEvent('saveScene'); } } ``` -------------------------------- ### managerFormatter 函数生成编辑和删除操作链接 Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/sys/script/scriptList.html 该函数用于在脚本列表表格中生成操作列的内容,包含编辑和删除按钮。编辑按钮打开 scriptEdit.html 页面,删除按钮发送删除请求到 /sys/script/remove。 ```javascript function managerFormatter(value, row, index) { var bts =""; bts += ""; return bts; } ``` -------------------------------- ### Schedule creation controller with participant selection and save events Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/sys/schedule/scheduleCreate.html AngularJS controller for the schedule creation page. It initializes start/end times from URL parameters, opens a user selector dialog to choose multiple participants, deletes participants via AJAX, and listens for after-save events to reload the page. The before-save and after-load event handlers are commented out. ```javascript //------------用户选择框可选多人设置-----------------// var app = angular.module('app', ['baseDirective']); app.controller("ctrl", [ '$scope', 'baseService', function($scope, baseService) { $scope.data = {type:"single"}; $scope.data.startTime =parseInt($.getParam("startTime")); $scope.data.endTime = parseInt($.getParam("endTime")); //-------------选择参与者-----------------------// $scope.openCustom = function() { $scope.data.scheduleParticipantList = new Array(); CustUtil.openCustDialog('userSelector',function(data,dialog){ var participants = ""; for(var i = 0; i < data.length; i++) { participants += data[i].name; var a = new Object(); a.participantorName = data[i].name; a.participantor = data[i].id; $scope.data.scheduleParticipantList.push(a); if(i < data.length - 1) { participants+=','; } } $scope.data.participantNames = participants; //$("#participant").val(participants); document.getElementById("participant").value=participants; $.Dialog.close(dialog);//关闭弹出框 }); } //----------------删除参与者-----------------// $scope.itemDelete = function(itemId) { $.ajax({ url: __ctx+'/calendar/schedule/itemDelete', data: { id: itemId, }, success: function() { location.reload(); } }); } //-------------------保存前监听事件------------------// /* $scope.$on("beforeSaveEvent",function(event,data){ if(Date.parse($scope.data.endTime) <= $scope.data.startTime || $scope.data.endTime <= $scope.data.startTime) { data.pass = false; $.topCall.error("结束日期不能小于开始日期"); } }); */ //-----------------保存后监听事件-----------------// $scope.$on("afterSaveEvent",function(event,data){ if(data.r == false) { parent.location.reload(); } if(data.r == true) { location.reload(); } }); //初始化选中时间:若选中一天,将开始时间改为早上9点,结束时间改为下午6点 /* $scope.$on("afterLoadEvent",function(event,data){ if("${param.startTime}") { var start = ${param.startTime}-8*60*60*1000; if(start%86400000 == 57600000) { start += 9*60*60*1000; } data.startTime = new Date(start); } if("${param.endTime}") { var end = ${param.endTime}-8*60*60*1000; if(end%86400000 == 57600000) { end -= 6*60*60*1000; } data.endTime = new Date(end); } }); */ }]); ``` -------------------------------- ### 打开摄像头链接函数 openCamera() Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/sys/holidayConf/holidayConfList.html 打开一个全屏窗口,链接到摄像头设备页面,参数包括id、type和num。 ```javascript function openCamera() { //debugger $.openFullWindow(__ctx+"/componets/equipment/camera?id=1&type=jyb&num=1"); } ``` -------------------------------- ### JavaScript for insert frame dialog Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/assets/js/plugins/ueditor/dialogs/insertframe/insertframe.html Initializes the dialog by reading properties from an existing iframe, and defines the 'queding' function to validate input and insert a new iframe into the editor. Also sets up keyboard and focus handlers. ```javascript var iframe = editor._iframe; if(iframe){ $G("url").value = iframe.getAttribute("src")||""; $G("width").value = iframe.getAttribute("width")||iframe.style.width.replace("px","")||""; $G("height").value = iframe.getAttribute("height") || iframe.style.height.replace("px","") ||""; $G("scroll").checked = (iframe.getAttribute("scrolling") == "yes") ? true : false; $G("frameborder").checked = (iframe.getAttribute("frameborder") == "1") ? true : false; $G("align").value = iframe.align ? iframe.align : ""; } function queding(){ var url = $G("url").value.replace(/^\s*|\s*$/ig,""), width = $G("width").value, height = $G("height").value, scroll = $G("scroll"), frameborder = $G("frameborder"), float = $G("align").value, newIframe = editor.document.createElement("iframe"), div; if(!url){ alert(lang.enterAddress); return false; } newIframe.setAttribute("src",/http:\/\/|https:\/\//ig.test(url) ? url : "http://"+url); /^[1-9]+[.]?\d*$/g.test( width ) ? newIframe.setAttribute("width",width) : ""; /^[1-9]+[.]?\d*$/g.test( height ) ? newIframe.setAttribute("height",height) : ""; scroll.checked ? newIframe.setAttribute("scrolling","yes") : newIframe.setAttribute("scrolling","no"); frameborder.checked ? newIframe.setAttribute("frameborder","1",0) : newIframe.setAttribute("frameborder","0",0); float ? newIframe.setAttribute("align",float) : newIframe.setAttribute("align",""); if(iframe){ iframe.parentNode.insertBefore(newIframe,iframe); domUtils.remove(iframe); }else{ div = editor.document.createElement("div"); div.appendChild(newIframe); editor.execCommand("inserthtml",div.innerHTML); } editor._iframe = null; dialog.close(); } dialog.onok = queding; $G("url").onkeydown = function(evt){ evt = evt || event; if(evt.keyCode == 13){ queding(); } }; $focus($G( "url" )); ``` -------------------------------- ### JavaScript for map search and initialization Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/assets/js/plugins/ueditor/dialogs/map/map.html Defines the map object, search function, parameter parsing, initialization, and dialog OK handler for inserting map content. ```javascript var map = new BMap.Map("container"),marker,point,styleStr; map.enableScrollWheelZoom(); map.enableContinuousZoom(); function doSearch(){ if (!document.getElementById('city').value) { alert(lang.cityMsg); return; } var search = new BMap.LocalSearch(document.getElementById('city').value, { onSearchComplete: function (results){ if (results && results.getNumPois()) { var points = []; for (var i=0; i 1) { map.setViewport(points); } else { map.centerAndZoom(points[0], 13); } point = map.getCenter(); marker.setPoint(point); } else { alert(lang.errorMsg); } } }); search.search(document.getElementById('address').value || document.getElementById('city').value); } //获得参数 function getPars(str,par){ var reg = new RegExp(par+"=((\\d+|[.,])*)","g"); return reg.exec(str)[1]; } function init(){ var mapNode = editor.selection.getRange().getClosedNode(), isMapImg = mapNode && /api[.]map[.]baidu[.]com/ig.test(mapNode.getAttribute("src")), isMapIframe = mapNode && domUtils.hasClass(mapNode, 'ueditor_baidumap'); if(isMapImg || isMapIframe){ var url, centerPos, markerPos; if(isMapIframe) { url = decodeURIComponent(mapNode.getAttribute("src")); $G('is_dynamic').checked = true; styleStr = mapNode.style.cssText; } else { url = mapNode.getAttribute("src"); styleStr = mapNode.style.cssText; } centerPos = getPars(url,"center").split(","); markerPos = getPars(url, "markers").split(","); point = new BMap.Point(Number(centerPos[0]),Number(centerPos[1])); marker = new BMap.Marker(new BMap.Point(Number(markerPos[0]), Number(markerPos[1]))); map.addControl(new BMap.NavigationControl()); map.centerAndZoom(point, Number(getPars(url,"zoom"))); }else{ point = new BMap.Point(116.404, 39.915); // 创建点坐标 marker = new BMap.Marker(point); map.addControl(new BMap.NavigationControl()); map.centerAndZoom(point, 10); // 初始化地图,设置中心点坐标和地图级别。 } marker.enableDragging(); map.addOverlay(marker); } init(); document.getElementById('address').onkeydown = function (evt){ evt = evt || event; if (evt.keyCode == 13) { doSearch(); } }; dialog.onok = function (){ var center = map.getCenter(); var zoom = map.zoomLevel; var size = map.getSize(); var mapWidth = size.width; var mapHeight = size.height; var point = marker.getPoint(); if($G('is_dynamic').checked) { var URL = editor.options.UEDITOR_HOME_URL, url = [URL + (/\/$/.test(URL) ? '':'/') + "dialogs/map/show.html" + '#center=' + center.lng + ',' + center.lat, '&zoom=' + zoom, '&width=' + mapWidth, '&height=' + mapHeight, '&markers=' + point.lng + ',' + point.lat, '&markerStyles=' + 'l,A'].join(''); editor.execCommand('inserthtml', ''); } else { var url = "http://api.map.baidu.com/staticimage?center=" + center.lng + ',' + center.lat + "&zoom=" + zoom + "&width=" + size.width + '&height=' + size.height + "&markers=" + point.lng + ',' + point.lat; editor.execCommand('inserthtml', ''); } }; document.getElementById("address").focus(); ``` -------------------------------- ### Link Dialog JavaScript Logic Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/assets/js/plugins/ueditor/dialogs/link/link.html Handles the link dialog's initialization, including populating fields from the current selection, validating the URL input, and processing the OK action to insert or update the link. ```javascript var range = editor.selection.getRange(), link = range.collapsed ? editor.queryCommandValue( "link" ) : editor.selection.getStart(), url, text = $G('text'), rangeLink = domUtils.findParentByTagName(range.getCommonAncestor(),'a',true), orgText; link = domUtils.findParentByTagName( link, "a", true ); if(link){ url = utils.html(link.getAttribute( '\_href' ) || link.getAttribute( 'href', 2 )); if(rangeLink === link && !link.getElementsByTagName('img').length){ text.removeAttribute('disabled'); orgText = text.value = link[browser.ie ? 'innerText':'textContent']; }else{ text.setAttribute('disabled','true'); text.value = lang.validLink; } }else{ if(range.collapsed){ text.removeAttribute('disabled'); text.value = ''; }else{ text.setAttribute('disabled','true'); text.value = lang.validLink; } } $G("title").value = url ? link.title : ""; $G("href").value = url ? url: ''; $G("target").checked = url && link.target == "\_blank" ? true : false; $focus($G("href")); function handleDialogOk(){ var href =$G('href').value.replace(/^\s+|\s+$/g, ''); if(href){ if(!hrefStartWith(href,["http","/","ftp://",'#"])) { href = "http://" + href; } var obj = { 'href' : href, 'target' : $G("target").checked ? "\_blank" : '\_self', 'title' : $G("title").value.replace(/^\s+|\s+$/g, ''), '\_href':href }; //修改链接内容的情况太特殊了,所以先做到这里了 //todo:情况多的时候,做到command里 if(orgText && text.value != orgText){ link[browser.ie ? 'innerText' : 'textContent'] = obj.textValue = text.value; range.selectNode(link).select() } if(range.collapsed){ obj.textValue = text.value; } editor.execCommand('link',utils.clearEmptyAttrs(obj) ); dialog.close(); } } dialog.onok = handleDialogOk; $G('href').onkeydown = $G('title').onkeydown = function(evt){ evt = evt || window.event; if (evt.keyCode == 13) { handleDialogOk(); return false; } }; $G('href').onblur = function(){ if(!hrefStartWith(this.value,["http","/","ftp://",'#"])){ $G("msg").innerHTML = ""+lang.httpPrompt+""; }else{ $G("msg").innerHTML = ""; } }; function hrefStartWith(href,arr){ href = href.replace(/^\s+|\s+$/g, ''); for(var i=0,ai;ai=arr[i++];){ if(href.indexOf(ai)==0){ return true; } } return false; } ``` -------------------------------- ### 获取节点消息数据函数 Source: https://github.com/agilebpm/agilebpm-spring-boot/blob/master/agilebpm-ui/src/main/resources/static/agilebpm-ui/bpm/definition/definitionNodeMessageDialog.html 定义getData函数,用于校验表单并返回节点消息数据。 ```javascript function getData(){ if (!AngularUtil.getScope().form.$valid){ $.Dialog.warning("表单校验未通过!"); return false; } var nodeMessage = AngularUtil.getScope().nodeMessage; return nodeMessage; } ```