其他分享
首页 > 其他分享> > UAP Resource

UAP Resource

作者:互联网

原文链接:http://www.cnblogs.com/yefengmeander/p/3466762.html

UAP Readme:

上机考试开发步骤:

1.建立uap项目
配置数据库连接

2.配置server地址
http://localhost:8080/sguap-server/environment/platform/Version1.0.0

3.白名单开启相关功能:
client_include_modules.properties (bpm)

4.建立模块项目exam
如需后台调用bpm,在META-INF\MAINFEST.MF文件的Dependencies的Imported Packages中添加
com.sgcc.uap.bpm.api,com.sgcc.uap.bpm.exception,org.sotower.bpm.api.data;version="3.5.0"

5.在uap项目的policy.xml文件中开启exam模块项目
<module-repository id="workspace" path="F:\\UAP\\uapspace">
    <module>exam</module>       
</module-repository>

6.建立后缀pm的文件,导入持久化模型,设置主键,建立表关系

7.建立名为main的ui文件,画出主布局,生成主weblet页面代码

8.通过场景生成相关页面的weblet

9.在main的weblet使用WebletContainer容器加载场景weblet

10.通过主页面的事件,向子页面传值,完成联动

备注:
1.业务系统和ISC集成:配置platformconfig.properties文件

ISC_APPID=4028818b4217576a01421777dfc40007
ISC_ADAPTER_URL=http://127.0.0.1:9898/isc_sm

1.业务系统和BPM集成:配置platformconfig.properties文件
#####################################流程集成配置##########################################
#BPM连接ID
BPM_UDDI_ADDRESS_ID=default
#BPM连接名称
BPM_UDDI_ADDRESS_NAME=BPM
#BPM连接描述
BPM_UDDI_ADDRESS_DESCRIPTION=
#BPM服务器的地址,对应BPM default应用下的WEB-INF\_srv\config\uddi-config.xml中的<host>
BPM_UDDI_ADDRESS_UUDIHOST=127.0.0.1
#BPM服务器端口,对应BPM default应用下的WEB-INF\_srv\config\uddi-config.xml中的<port>
BPM_UDDI_ADDRESS_UUDIPORT=12000
#BPM应用上下文名称,对应BPM default应用下的WEB-INF\_srv\config\uddi-config.xml中的<context>
BPM_UDDI_ADDRESS_UUDIWEBCONTEXT=default
#BPM远程端口,对应BPM default应用下的WEB-INF\web.xml中的<param-name>AdminPort</param-name>的param-value
BPM_UDDI_ADDRESS_UUDIADMINPORT=6200

3.BPM和ISC集成:
BPM\apache-tomcat-5.5.20\webapps\default\WEB-INF\lib
isc_bpm2.0_20130726.jar中的system.properties添加systemID=4028818b4217576a01421777dfc40007
isc_sm_agent.jar中的iscservicesadapter.properties添加uri=http://isc.sm.com:9898/isc_sm


4.修改hosts文件,本机使用:C:\Windows\System32\drivers\etc
127.0.0.1   isc.sm.com
127.0.0.1   isc.mp.com
127.0.0.1   isc.manage.com
127.0.0.1   sso.isc.com
127.0.0.1   isc.ora_db.com
127.0.0.1   isc.jms.com
127.0.0.1   isc.sguap.com
127.0.0.1  isc.frontmvserv.com

5.开启调试工具
IE F12
Chrome Ctrl+Shift+i
FireFox Ctrl+Shift+s


UAP Java Code:

package com.sgcc.uap.common.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.sotower.bpm.api.data.BPMCreateOption;
import org.sotower.bpm.api.data.FinishOption;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.sgcc.isc.core.orm.identity.User;
import com.sgcc.uap.bizc.sysbizc.datadictionary.IDataDictionaryBizC;
import com.sgcc.uap.bpm.api.BPMServiceClientFactory;
import com.sgcc.uap.bpm.api.IBPMProcessInstManager;
import com.sgcc.uap.bpm.api.IBPMServiceClient;
import com.sgcc.uap.bpm.api.IBPMWorkItemManager;
import com.sgcc.uap.integrate.isc.wrapper.factory.AdapterWrapperFactory;
import com.sgcc.uap.persistence.IHibernateDao;
import com.sgcc.uap.rest.annotation.ItemResponseBody;
import com.sgcc.uap.rest.support.DicItems;
import com.sgcc.uap.rest.support.QueryResultObject;
import com.sgcc.uap.rest.utils.RestUtils;

public class ExamJavaCode {
	
	
	/*******************************BPM开始**************************************/
	
	/**
	 *流程发起
	 * 
	 * @param businessId
	 *            业务id,如缺陷登记表中新增记录的主键ID
	 * @param processDefName 
	 *            流程定义名称
	 * @param processInstName
	 *            流程实例名称
	 * @param userId
	 *            需要调用者传输的参数变量,当前流程节点的处理人用户id
	 * @param userName
	 *            需要调用者传输的参数变量,当前流程节点的处理人用户姓名,或者用户id
	 */
	public static String startBpm(String businessId, String processDefName,
			String processInstName, String userId, String userName) {
		IBPMServiceClient client;
		try {
			BPMServiceClientFactory.getLoginManager().setCurrentUser(userId,
					userName);
			client = BPMServiceClientFactory.getBPMServiceClient();
			IBPMProcessInstManager processInstManager = client
					.getProcessInstManager();
			Map conditionMap = new HashMap();
			conditionMap.put("BUSINESSID", businessId);
			BPMCreateOption cOption = new BPMCreateOption();
			cOption.setRelativeData(conditionMap);    
			//cOption.setFinishFirstWorkItem(true);
			long processInstId = processInstManager
					.createProcessInstWithOption(processDefName, processInstName,
							processInstName, true, cOption);
			return "1";
		} catch (Exception e) {
			e.printStackTrace();
			return "0";
		}
	}
	
	/**
	 * 流程发送
	 * 
	 * @param workItemId
	 *            流程活动实例号,即工作项id,,需要调用者用Long.valueOf(request.getParameter("workitemid"
	 *            ))获取,
	 * @param userId
	 *            需要调用者传输的参数变量,当前流程节点的处理人用户id
	 * @param userName
	 *            需要调用者传输的参数变量,当前流程节点的处理人用户姓名,或者用户id
	 */
	public static String send(Long workItemId, String userId, String userName) {
		// long workitemid =
		// Integer.valueOf(request.getParameter("workitemid"));//流程活动实例号,即工作项id,
		IBPMServiceClient client = BPMServiceClientFactory
				.getBPMServiceClient();
		BPMServiceClientFactory.getLoginManager().setCurrentUser(userId,
				userName);
		IBPMWorkItemManager iwfwMgr = client.getWorkItemManager();
		try {
			FinishOption option = new FinishOption();
			iwfwMgr.finishWorkItemWithOption(workItemId, option);
			return "1";
		} catch (Exception e) {
			e.printStackTrace();
			return "0";
		}
	}
	
	
	/*******************************缓存数据字典开始**************************************/
	
	@Autowired
	private IDataDictionaryBizC dataDictionaryBizC;
	
	/**
	 * 将字典对象封装为list
	 * "category"是前端MX DropdownEditor绑定的name, PROJECT.TYPE是"config/enum/enum.properies" 文件中定义的名字
	 * @return
	 */
	public List<DicItems> wrapDictList() {
		List<DicItems> dicts = new ArrayList<DicItems>();
        dicts.add(translateFromFile("category", "PROJECT.TYPE"));
        dicts.add(translateFromFile("condition", "PROJECT.STATUS"));
        dicts.add(translateFromFile("condition1", "TASK.STATUS"));
		return dicts;
	}

	/**
	 * get dict item form "config/enum/enum.properies" file
	 * @param fieldName
	 * @param dicId
	 * @return
	 */
	public DicItems translateFromFile(String fieldName, String dicId) {
		List<Map<String, String>> list = dataDictionaryBizC.translateFromFile(
				dicId, "value", "text");
		DicItems dict = new DicItems();
		dict.setName(fieldName);
		dict.setValues(list);
		return dict;
	}
	
	/*******************************获取用户信息开始**************************************/
	
	/**
	 * 获取当前用户ID
	 */
	@SuppressWarnings("unchecked")
	public static String getUserId(HttpServletRequest request){
		if(request.getSession()!=null){
			Map userMap = (Map)request.getSession().getAttribute("user");
			
			if(userMap != null)return (String)userMap.get("id");
		}
		return null;
	}
	
	/**
	 * 获取当前用户名
	 */
	@SuppressWarnings("unchecked")
	public static String getUserName(HttpServletRequest request){
		if(request.getSession()!=null){
			Map userMap = (Map)request.getSession().getAttribute("user");
			
			if(userMap != null)return (String)userMap.get("name");
		}
		return null;
	}
	
	/**
	 * get users from isc by user ids
	 */
	public List<User> getUsersByUserIds(String[] userIds) throws Exception {
		List<User> users = AdapterWrapperFactory.getIdentityService().getUserByIds(userIds);
		return users;
	}
	
	@RequestMapping(value="/viewuser",method=RequestMethod.GET)
	public @ItemResponseBody
    QueryResultObject viewuser(HttpServletRequest request){
		String[] userIds = new String[1];
		Object userMap = request.getSession().getAttribute("user");
		if(userMap instanceof Map)
		{
			String userId = ((Map)userMap).get("id").toString();
			userIds[0] = userId;
		}
		List<User> users = new ArrayList<User>();
		try {
			users = AdapterWrapperFactory.getIdentityService().getUserByIds(userIds);
		} catch (Exception e) {
			e.printStackTrace();
		}
		QueryResultObject result = RestUtils.wrappQueryResult(users);
		return result;
	}
	
	/*******************************多表头SQL语句行转列开始**************************************/
	@Autowired
	private IHibernateDao hibernateDao;
	
	public void setHibernateDao(IHibernateDao hibernateDao) {
		this.hibernateDao = hibernateDao;
	}
	
	/**
	 * select eval_name, eval_base,
		  sum(decode(dep_name,'北京公司',eval_mark,0))bj_sum_mark,
		  sum(decode(dep_name,'天津公司',eval_mark,0))tj_sum_mark,
		  sum(decode(dep_name,'浙江省公司',eval_mark,0))zj_sum_mark,
		  sum(decode(dep_name,'江苏省公司',eval_mark,0))js_sum_mark
		  from sg_dep dep, dep_mark mark, proj_eval eval
		 where dep.dep_id = mark.dep_id
		   and mark.eval_no = eval.eval_no
		 group by eval_name, eval_base
		 order by eval_name
	 */
	public QueryResultObject queryProvinceSum(){
		StringBuilder sqlBuilder = new StringBuilder();
		sqlBuilder.append("select eval_name, eval_base,");
		sqlBuilder.append(" sum(decode(dep_name,'北京公司',eval_mark,0))bj_sum_mark,");
		sqlBuilder.append(" sum(decode(dep_name,'天津公司',eval_mark,0))tj_sum_mark,");
		sqlBuilder.append(" sum(decode(dep_name,'浙江省公司',eval_mark,0))zj_sum_mark,");
		sqlBuilder.append(" sum(decode(dep_name,'江苏省公司',eval_mark,0))js_sum_mark");
		sqlBuilder.append(" from sg_dep dep, dep_mark mark, proj_eval eval");
		sqlBuilder.append(" where dep.dep_id = mark.dep_id");
		sqlBuilder.append(" and mark.eval_no = eval.eval_no");
		sqlBuilder.append(" group by eval_name, eval_base");
		sqlBuilder.append(" order by eval_name");
		String sql = sqlBuilder.toString();
		List groupDataList = hibernateDao.queryForListWithSql(sql);
		return RestUtils.wrappQueryResult(groupDataList);
	};
	
	/*******************************模糊查询开始**************************************/
	/**
	 * 查询主表中的记录
	 * @param params
	 * @return queryResult
	 */
	@RequestMapping(value="/xiangmu/",method=RequestMethod.GET)
	public @ItemResponseBody 
	QueryResultObject query(@QueryRequestParam("params") RequestCondition params){
		if(params.getQueryFilter() != null)
		{
			List<QueryFilter> queryFilters = params.getQueryFilter();
			for(int i = queryFilters.size() - 1; i >= 0; i--)
			{
				QueryFilter qf=queryFilters.get(i);
				if("name1".equals(qf.getFieldName()))
				{
					qf.setFieldName("name1");
					qf.setOperator("^");
					queryFilters.add(qf);
					queryFilters.remove(i);
				}
				if("startdate".equals(qf.getFieldName()))
				{
					qf.setDataType("java.sql.Date");
					queryFilters.add(qf);
					queryFilters.remove(i);
				}
				if("enddate".equals(qf.getFieldName()))
				{
					qf.setDataType("java.sql.Date");
					queryFilters.add(qf);
					queryFilters.remove(i);
				}
			}
			params.setFilter((List<QueryFilter>)queryFilters);
		}
		QueryResultObject queryResult = projectMoreTaskBizc.queryMaster(params);
		List list = queryResult.getItems();
		
		List<XiangmuVO> voList = new ArrayList<XiangmuVO>();
		for(int i = 0;i < list.size();i++){
			Xiangmu po = (Xiangmu)list.get(i);
			XiangmuVO vo = XiangmuTransfer.toVO(po);
			voList.add(vo);
		}
		queryResult.setItems(voList);
		return queryResult;
	}

}


UAP Javascript Code:

/*******************************导入包开始**************************************/
$import("mx.containers.Accordion");
$import("mx.containers.Panel");

$import("mx.containers.HSplit");
$import("mx.containers.VSplit");
$import("mx.containers.Container");

$import("mx.containers.TabControl");
$import("mx.containers.TabPage");

$import("mx.controls.ToolBar");
$import("mx.datacontainers.FormEntityContainer");
$import("mx.datacontrols.DataForm");

$import("mx.datacontainers.GridEntityContainer");
$import("mx.datacontrols.DataGridSearchBox");
$import("mx.datacontrols.DataGrid");
$import("mx.datacontrols.ComplexGrid");

$import("mx.datacontrols.DataTree");
$import("mx.datacontainers.TreeEntityContainer");

/*******************************布局控件上下分割HSplit开始**************************************/

var HSplit1 = null;
var HSplit1Area0 = null;
var HSplit1Area1 = null;

_initHSplit1();
_initHSplit1Area0();
_initHSplit1Area1();

function _initHSplit1(){
	HSplit1 = new mx.containers.HSplit({
		id:"HSplit1",
		rows:"50%,50%"
	});
	
	me.addControl(HSplit1);
}

function _initHSplit1Area0(){
	HSplit1Area0 =  new mx.containers.Container({ 
		id:"HSplit1Area0"
	});
	
	HSplit1.addControl(HSplit1Area0, 0);
}

function _initHSplit1Area1(){
	HSplit1Area1 =  new mx.containers.Container({ 
		id:"HSplit1Area1"
	});
	
	HSplit1.addControl(HSplit1Area1, 1);
}
	
/*******************************布局控件左右分割VSplit开始**************************************/

var VSplit1 = null;
var VSplit1Area0 = null;
var VSplit1Area1 = null;

_initVSplit1();
_initVSplit1Area0();
_initVSplit1Area1();

function _initVSplit1(){
	VSplit1 = new mx.containers.VSplit({
		id:"VSplit1",
		cols:"20%,80%"
	});
	
	me.addControl(VSplit1);
}

function _initVSplit1Area0(){
	VSplit1Area0 =  new mx.containers.Container({ 
		id:"VSplit1Area0"
	});
	
	VSplit1.addControl(VSplit1Area0, 0);
}

function _initVSplit1Area1(){
	VSplit1Area1 =  new mx.containers.Container({ 
		id:"VSplit1Area1"
	});
	
	VSplit1.addControl(VSplit1Area1, 1);
}

/*******************************布局控件手风琴Accordion开始**************************************/

var Accordion1 = null;
var Panel1 = null;
var Panel2 = null;

_initAccordion1();
_initPanel1();
_initPanel2();

function _initAccordion1(){
	Accordion1 = new mx.containers.Accordion({
		id:"Accordion1"
	});
	
	me.addControl(Accordion1);
}

function _initPanel1(){
	Panel1 = new mx.containers.Panel({
		id:"Panel1",
		border:"0",
		title:"Panel"
	});
	
	Accordion1.appendPanel(Panel1);
}

function _initPanel2(){
	Panel2 = new mx.containers.Panel({
		id:"Panel2",
		border:"0",
		title:"Panel"
	});
	
	Accordion1.appendPanel(Panel2);
}

/*******************************布局控件选项卡TabControl开始**************************************/
var TabControl = null;
var TabPage1 = null;

_initTabControl();
_initTabPage1();

function _initTabControl(){
	TabControl = new mx.containers.TabControl({
		id:"TabControl",
		width:"100%"
	});
	
	VSplit1Area1.addControl(TabControl);
}

function _initTabPage1(){
	TabPage1 = new mx.containers.TabPage({
		id:"TabPage1",
		autoInit:true,
		width:"100%",
		text:"欢迎",
		name:"TabPage1"
	});
	
	TabControl.appendPage(TabPage1);
}

 me.getTabControl = function(){
	return TabControl;
}
 

 /*******************************动态添加选项卡TabControl开始**************************************/
 me._tree_οnclick=function(e){
		//create new tab page when note has no children
		if(!e.node.hasChildren){
	    	var nodeId = e.node.id;
	    	var nodeName = e.node.text;
	    	var pages = me.view.getTabControl().pages;
	    	if(!isContainPageById(pages, nodeId)){
		    	var nodePage = mx.containers.TabPage({
		    		id:nodeId,
		    		alias:nodeId,
		    		name:nodeId,
		    		width:"100%",
		    		closable:true,
		    		text:nodeName
		    	});
		    	me.view.getTabControl().appendPage(nodePage);
	    	}
	    	me.view.getTabControl().pages[nodeId].show();
	    	me.view.getTabControl().selectPage(me.view.getTabControl().pages[nodeId]);
	    	//add weblet to tab page
	    	if(me.view.getTabControl().pages[nodeId].controls.length < 1){
	    		var container = new mx.containers.Container();
	    		var webletContainer = new mx.weblets.WebletContainer({ $e:container.$e, webletID: nodeId });
	    		me.view.getTabControl().pages[nodeId].addControl(container);
 		}
		}
 }
	
 function isContainPageById(pages, pageId){
 	var isContain = false;
 	var pages = me.view.getTabControl().pages;
 	if(pages.length > 0){
	    	for(var i = 0; i < pages.length; i++){
	    		if(pages[i].id == pageId){
	    			isContain = true;
	    			break;
	    		}
	    	}
 	}
 	return isContain;
 }
 
/*******************************数据控件DataForm开始**************************************/
var _form = null;

_initDataForm();

function _initDataForm()
{
    var restUrl = "~/rest/deployapp/";
    /* 初始化 EntityContainer */        
    var formEntityContainer = new mx.datacontainers.FormEntityContainer({
        baseUrl : appinfo.mappath(restUrl),
        iscID : "-1", // iscID 是数据元素的统一权限功能编码。默认值为  "-1" ,表示不应用权限设置。
        primaryKey: "appId"
    });
    
    _form = new mx.datacontrols.DataForm({
		
		alias:"appinfoDetailViewDataForm",
		displayPrimaryKey: false,
		fields: [
        {	name: "appId", caption: "应用ID", editorType: "TextEditor", visible:false},
        {	name: "appName", caption: "应用名称", editorType: "TextEditor"},
        {	name: "dispIdx", caption: "部署顺序", editorType: "TextEditor"},
	    {	name: "unitId", caption: "部署单元ID", editorType: "TextEditor"}
	    ],
        entityContainer: formEntityContainer
    });
    
    me.addControl(_form);
}

me.getForm = function(){
	return _form;
}

/*******************************数据控件DataGrid开始**************************************/
var _dataGrid = null;

_initDataGrid();

function _initDataGrid()
{
    var restUrl = "~/rest/deployapp/";
    /* 初始化 EntityContainer */        
    var gridEntityContainer = new mx.datacontainers.GridEntityContainer({
        baseUrl : appinfo.mappath(restUrl),
        iscID : "-1", // iscID 是数据元素的统一权限功能编码。默认值为  "-1" ,表示不应用权限设置。
        primaryKey: "appId"
    });
    
    /* 初始化 DataGrid */
    _dataGrid = new mx.datacontrols.ComplexGrid({   
		// 构造查询属性。
		alias: "appinfoMainViewDataGrid",
		searchBox: new mx.datacontrols.DataGridSearchBox({
		
			fields: [
			]
		}),
		
		columns:[
        {	name: "appId", caption: "应用ID" , editorType: "TextEditor"	},
        {	name: "appName", caption: "应用名称" , editorType: "TextEditor"	},
        {	name: "dispIdx", caption: "部署顺序" , editorType: "TextEditor"	},
        {	name: "unitId", caption: "部署单元ID" , editorType: "TextEditor", visible:false	}
        ],
        // 构造列排序条件,如果有多列,则以逗号分隔。例sorter: "school ASC, class DESC"
        displayCheckBox: true,
        displayPrimaryKey:false,//列表是否显示主键
        allowEditing: false, //列表默认不可编辑
        pageSize : 20,
        entityContainer: gridEntityContainer,
        onl oad: me.controller._dataGrid_onload,
        onitemclick: me.controller._dataGrid_onitemclick,
        create: me.controller._btnNew_onclick,
        remove: me.controller._btnDelete_onclick
    });
    
    //重置toolBar按钮项
    _resetToolBarItems();
    VSplit1Area1.addControl(_dataGrid);
}

/**
 * 重置按钮项
 */
function _resetToolBarItems(){
	_dataGrid.toolBar.removeByName("new");
	//去除保存按钮
	_dataGrid.toolBar.removeByIndex(1);
	_dataGrid.toolBar.removeByName("save");
	/*//插入编辑按钮
	_dataGrid.toolBar.insertItem(2,"-",true);
	_dataGrid.toolBar.insertItem(3,{ name: "edit", text: mx.msg("EDIT"), toolTip: mx.msg("EDIT"), imageKey : "edit", onclick: me.controller._btnEdit_onclick},true);*/
}

me.getDataGrid = function(){
	return _dataGrid;
}

/*******************************多表头GroupHeaderGrid开始**************************************/
//////////////view中的代码
var SumDataGrid = null;

_initSumDataGrid();

function _initSumDataGrid()
{
	//var restUrl = "~/rest/sgdep/";
    /* 初始化 EntityContainer */        
    var gridEntityContainer = new mx.datacontainers.GridEntityContainer({
    	type:"local",
        //baseUrl : provincesum.mappath(restUrl),
        iscID : "-1", // iscID 是数据元素的统一权限功能编码。默认值为  "-1" ,表示不应用权限设置。
        primaryKey: "compId"
    });
    
	SumDataGrid = new mx.datacontrols.GroupHeaderGrid({
	    columns: [
			{
				name:"EVAL_NAME",
			    caption:"评价项目名称",
			},
			{
				name:"EVAL_BASE",
			    caption:"基准分",
			},
	        {
	        	name:"PAR_PARENT",
                caption:"华北地区",
                columns:[
                    {
                        name:"BJ_SUM_MARK",
                        caption:"北京公司"
                    },
                    {
                        name:"TJ_SUM_MARK",
                        caption:"天津公司"
                    }
                ]
	        },
	        {
	        	name:"PAR_PARENT",
                caption:"华东地区",
                columns:[
                    {
                        name:"JS_SUM_MARK",
                        caption:"江苏省公司"
                    },
                    {
                        name:"ZJ_SUM_MARK",
                        caption:"浙江省公司"
                    }
                ]
	        }
	    ],
	    pageSize: 20,
        entityContainer: gridEntityContainer
	});
	
	//SumDataGrid.load();
	me.addControl(SumDataGrid);
}

me.getSumDataGrid = function(){
	return SumDataGrid;
}

//////////////view controller中的代码
me._onactivate = function(e)
{
	me.load_provinceSum();
};

me.load_provinceSum = function()
{
	var restClient = new mx.rpc.RESTClient();
   	var p_context = restClient.get(
   			provincesum.mappath("~/rest/provincesum/"),
   			me.load_provinceSum_complete
    );
};

me.load_provinceSum_complete = function(p_data)
{
	if(p_data && p_data.successful)
	{
		me.view.getSumDataGrid().entityContainer.data = p_data.resultValue.items;
		me.view.getSumDataGrid().load();
	}
}

/*******************************数据控件DataTree开始**************************************/
var _treeView = null;

_initTreeView();

function _initTreeView()
{
    _treeView = new mx.datacontrols.DataTree({
        baseUrl: leave.mappath("~/rest/examdep/tree"),
        displayCheckBox: true, // 是否需要在树中显示选中框
        onnodeclick: me.controller._tree_onclick,
        onselectionchanged: me.controller._tree_selectionchanged
    });
    HSplitLeftArea1.addControl(_treeView);
	_initContextMenu();
}

function _initContextMenu()
{
	_treeView.nodeMenu = new mx.controls.ContextMenu({
		items: [ 
			{ name: "refresh", text: "刷新" } // 菜单项可以嵌套,表示子菜单 
		], // 菜单项集合 

		onitemclick: me.controller._contextMenuItem_click 	
	});
}

me.getTreeView = function(){
	return _treeView;
}

/*******************************弹出表单开始**************************************/
/////////view中代码

var _detailWin = null;

_initDetailWindow();

/**
 * 初始化表单视图窗口对象
 */
function _initDetailWindow(){
	_detailWin = appinfo.context.windowManager.create({
		reusable: true,//是否复用
		width:640,
		height:480,
		title:"表单维护"
	});
}

/**
 * 获取表单视图窗口对象
 */
me.getDetailWindow = function(){
	return _detailWin;
}


/////////view controller中代码
var _detailView = null;

/**
 * 获取表单视图对象
 */
me._getDetailFromView = function(){
	if (_detailView == null)
    {
        var mvc = new appinfo.views.DetailViewController();
        _detailView = mvc.getView();

		_detailView.getForm().entityContainer.off("saved", me._refreshDataGrid);
        _detailView.getForm().entityContainer.on("saved", me._refreshDataGrid);
    }
	return _detailView;
}

/**
 * 新增
 */
me._btnNew_onclick = function()
{
    // TODO: 此处新增的数据需要将服务端返回的 id 值设置到 GridItem 上。
    var _detailView = me._getDetailFromView();
    //设置对象id
    _detailView.objID = null;
    _showDetailFormView(_detailView,"表单填写");
};

/**
 * 显示表单视图
 * @param p_view : 需要显示的视图对象
 * @param p_title : 对话框的标题
 */
function _showDetailFormView(p_view,p_title){
	var win = me.view.getDetailWindow();
	if(typeof p_view != "undefined"){
		p_view.load();
		//设置显示视图、标题信息
		win.setPosition("fixed");
		win.setView(p_view);
		win.setTitle(p_title ? p_title : win.title);
	}
	win.showDialog();
}

/*******************************JS处理BPM开始**************************************/

requires:["bpm/bpmintegrate"],
onload: function(e)
{
	$import("bpmintegrate.utils.BPMClient"); 
},
    
/**
 * 调用js流程发起
 */
me._btnStartJS_onclick = function (){
	var _dataGrid = me.view.getDataGrid()
	if (_dataGrid.getCheckedIDs().length == 0) {
		mx.indicate("info", "请勾选一条待编辑记录。");
		return;
	}
	
	// 多选框勾选记录,判断是否选择多条
	if (_dataGrid.getCheckedIDs().length > 1) {
		mx.indicate("info", "选定的记录条数不能超过一条。");
		return;
	}
	
	// 判断已勾选记录的流程状态,只允许没有发起流程的状态
	var lczt = _dataGrid.getCheckedItems()[0].getValue("lczt");
	if (lczt == "0" || lczt == null|| lczt == "" ||lczt == "null") {
		// 发起流程,参数为勾选记录的ID
		var bpmclient = new bpmintegrate.utils.BPMClient();//创建js代理对象
		var params = "{\"BUSINESSID\" : \"" + _dataGrid.getCheckedIDs()[0] + "\"}";//业务主键
		/**
		 * 创建流程实例,可以选择是否立即启动,可带参数 
		 *    
		 * <p>
		 * 注意事项:
		 * <ul>
		 * <li>如果第一、二个参数为空,则抛出异常
		 * <li>如果第一参数对应的流程定义找不到发布版本,则抛异常
		 * </ul>
		 * 
	     * @param processDefName 流程定义名称
	     * @param processInstName 流程实例名称
	     * @param processInstDesc 流程实例描述
		 * @param isStart 是否启动流程实例
		 * *@param finishFirst 是否完成第一个工作项,取值为true或false
		 * @param relativeData 流程参数,格式为{key1:value1,key2:value2}的JSON串
		 */
		var flag = bpmclient.createProcessInstWithOption("vacation","请假流程管理","",true,false,params);
		
		if(flag){ 
			mx.indicate("info", "流程创建成功");
			//发起成功后处理业务逻辑
			_dataGrid.load();
		}else{
			mx.indicate("info", "流程创建失败");
		}
	} else {
		mx.indicate("info", "选定记录的流程已发送,不能再次发送!");
		return;
	}
}


/**
 * 调用js流程推送
 */
me._btnSendJS_onclick = function(){
	me.view.form.save(function(p_data) {
		if(p_data)
		{
			savedObj = p_data.successful;
			if(!savedObj)
			{
				alert("信息保存【失败】,不能发送流程!");
				return;
			}
			var bpmclient = new bpmintegrate.utils.BPMClient();
			/**
			 * 完成工作项
			 * 
			 * @param workItemId 工作项ID 
			 */
			var flag = bpmclient.finishWorkItem(me.workItemIdD);
			if(flag){
				mx.indicate("info", "流程发送成功");
			}
		}
	});
}

/*******************************form自动填写不渴编辑开始**************************************/
onload: me.controller.setDepId_onload,

me.setDepId_onload = function()
{
    me.view.getForm().entityContainer.data.setValue("depId", me.view.depId);
    me.view.getForm().setFieldReadOnly("depId", true);
};
/*******************************前端调用后台开始**************************************/
var client = new mx.rpc.RESTClient();
var startUrl = "~/../exam/rest/examfeedetail/updateStatus";
var businessData = {
	businessId : checkedID,
	status : status
};
client.get(startUrl, businessData, function(p_flag) {}
// End of callback function
);

/*******************************weblet container使用**************************************/
var WebletContainer = null;

function _initWebletView()
{
	WebletContainer = new mx.weblets.WebletContainer({ $e: HSplitRightArea0.$e, webletID: "emp" });
	//WebletContainer.view.getDataGrid().on("itemclick",me.controller._emp_onitemclick);
}

me.getWebletContainer = function(){
	return WebletContainer;
}

/*******************************导出excel使用开始**************************************/

me._btnExportExcel_onclick = function()
{
	 me.view.getDataGrid().exportExcel(
	{
		tableName:"exam_fee_detail",
		columnNames:"fee_Id,emp_Id,fee,sub_Time,end_Time,fee_Status", 
		columnCaptions:"报销流水ID,员工ID,报销金额,提交时间,结束时间,报销进度", 
		fileName:"报销表单"
	});
};

/*******************************rendCell使用开始**************************************/
{	name: "operate", caption: "操作" , isVirtual: true, editorType: "TextEditor" , renderCell:me.controller._btnOpreateColumn_onclick	}

me._btnOpreateColumn_onclick = function(p_item, $p_cell)
{
	var editLinkEditor = new mx.editors.LinkEditor(
	{
	    "type" : "imgtext",//指定链接的类型。
	    "width" : "30",//指定控件宽度。
	    "imageKey" : "1",//指定图标名称。
	    "text" : "编辑"
	});
	editLinkEditor.on("click", me._btnSubEdit_onclick);
	
	var deleteLinkEditor = new mx.editors.LinkEditor(
	{
	    "type" : "imgtext",//指定链接的类型。
	    "width" : "30",//指定控件宽度。
	    "imageKey" : "1",//指定图标名称。
	    "text" : "删除"
	});
	deleteLinkEditor.on("click", me._btnSubDelete_onclick);
	$p_cell.append(editLinkEditor.$e);
	$p_cell.append(deleteLinkEditor.$e);
};

/**
 * datagrid单元格渲染变色
 */
me._btnMasterItem_oncelledited = function(e)
{
	if(e.column.name == "compName"){
		e.cell.css("background-color","green");
	}
};

/*******************************Form field变色开始**************************************/
{	name: "leader", caption: "法人", editorType: "TextEditor", onchanged:me.controller._btnSubItem_oncelledited},

me._btnSubItem_oncelledited = function()
{
	//me.view.getForm().getEditor("leader").$e.css("background-color","red");
	me.view.getForm().getEditor("leader").$e.find("input").css("background-color","red");
};

/*******************************FilteEditor开始**************************************/
//注意type用form还是grid
{	name: "operFile", caption: "投标文件", editorType: "FileEditor", type: "form" , uploadMode: "blob" , tableName: "proj_unit_detail" , primaryKey: "ID" , colName: "OPER_FILE"	},

/*******************************图表使用开始**************************************/
////图表前端代码
var lineContainer=null;
var chartTitle={};
var chartAxes={};
var dataTable=null;
var createLineChart=null;

_initLineChartContainer();
_initRemoteChart();

//创建div,用于绘制图表
function _initLineChartContainer(){
	lineContainer=new mx.containers.Container({
        id:"divLineChartContainer"
    });
	me.addControl(lineContainer);  
}

/**
 * create pie chart
 */
function _createLineChart(){
    
    createLineChart = new mx.charts.ChartWrapper({
     	//设置图表类型
     	plotType: "CategorizedHorizontal",// 柱状图
         globalSettings : {
         	animation:{
         		enabled:true
         	}
         },
     	title: {text: "部门设备数统计"},//创建标题对象
     	height: "100%",
     	width: "100%",
     	// 设置图表系列显示方式。default_series_type 默认值 Bar,可选值 Bar、RangeBar、Line、RangeArea、RangeSplineArea、
     	// Spline、Marker、Area、Bubble、Candlestick、OHLC等。
     	data_plot_setting: {
     		pie_series:{
    	 	 		label_settings:{
    	 		 		enabled:true,
    	 		 		position:{
    	 		 			anchor:"Center",
    	 		 			padding:20
    	 		 		},
    	 		 		format:"{%Name}-{%YPercentOfSeries}{numDecimals:1}%"
    	 		 	}
    	 	 	},
    	 		tooltip_settings:{
    	 	 		enabled:true,
    	 	 		format:"{%Name}Sales: ${%Value}Percent: {%YPercentOfSeries}{numDecimals: 2}%"
    			}
    	 	},
     	chart_settings: {
     		chart_background:{
     			border: {color: "blue", thickness: 2},
     			corners: {type: "Rounded"}, // type 默认值 Square,可选值 Square、Cut、Rounded、RoundedInner。分别代表方角、切角、圆角。
     			effects: {drop_shaddow: {enabled: true}}
     		},//设置图表背景。
     		axes: { y_axis: {title: {text: "设备数"}}, x_axis:  {title: {text: "部门"}} } //设置图表纵、横坐标标题。
     	},
     	data_plot_background: {
     		fill: {type: "Gradient", opacity: 0.5}, //type 默认值 Solid,可选值 Solid、Gradient、Image,分别代表实线、渐变、图片填充。
     		effects: {enabled: true, inner_shaddow: {enabled: true, distance: 5, angle: 30}}
     	},//设置图表数据区域背景。

     	palettes: {item: {color: "red, blue, yellow"}, gradient: {type: "Radial"}}//type 默认值 Linear,可选值 Linear、Radial,分别代表线性填充和辐射填充。

     });
    createLineChart.setData(dataTable);
    createLineChart.draw("divLineChartContainer");
}

//初始化远程表格属性
function _initRemoteChart(){
	 /*chartTitle.text="部门设备数统计";
  	  chartAxes.y_axis={title:{text:"设备数"}};
  	  chartAxes.x_axis={title:{text:"部门"}};
  	  dataTable = new mx.datas.DataTable({
    	 rows: [
    	     {cells:[{value:"江苏"},{value:1000}]},
    	     {cells:[{value:"南京"},{value:800}]},
    	     {cells:[{value:"苏州"},{value:600}]},
    	     {cells:[{value:"扬州"},{value:650}]}
    	      ]         
     });*/
	 chartTitle.text="设备数统计";
	 chartAxes.y_axis={title:{text:"设备数"}};
	 chartAxes.x_axis={title:{text:"公司"}};
 	 var restClient = new mx.rpc.RESTClient();
	 var p_context=restClient.getSync(
			 case4.mappath("~/rest/uapbm/chart/")
			        );
	 p_context = "{rows:[{cells:[{value:'江苏省电力公司'},{value:'2'}]},{cells:[{value:'南京电力公司'},{value:'1'}]},{cells:[{value:'苏州电力公司'},{value:'1'}]}]}";
	 var jsonObj=eval("("+p_context+")");
     dataTable = new mx.datas.DataTable(jsonObj);
}


////图表后台代码

@RequestMapping(value="/chart",method=RequestMethod.GET)
public @RawResponseBody Object getChartValue() {
	@SuppressWarnings("unchecked")
	
	//根据公司名查询出公司以及公司对应的设备数
	List<Object> chartValueList = departBizc.getChartValue();
	//封装DataTable格式
	
	StringBuffer dataTable=new StringBuffer();
	
	dataTable.append("{rows:[");
	for (int i = 0; i < chartValueList.size(); i++) {
		Object[] obj=(Object[])chartValueList.get(i);
		if(i==chartValueList.size()-1){
			dataTable.append("{cells:[{value:'"+obj[0]+"'},{value:'"+obj[1]+"'}]}");
		}
		else{
			dataTable.append("{cells:[{value:'"+obj[0]+"'},{value:'"+obj[1]+"'}]},");
		}
	}
	dataTable.append("]}");
	System.out.println(dataTable.toString());
	return dataTable; //do not use toString()
}

转载于:https://www.cnblogs.com/yefengmeander/p/3466762.html

标签:me,function,Resource,name,UAP,var,new,mx
来源: https://blog.csdn.net/weixin_30800807/article/details/97889894