用友一些小知识(获取当前登录人的部门和名字赋值)

用友前端获取登录人的部门还有名字

用友体系下的前后端交互

用友框架下的架构,nccloud实现前后端分离是主要有前端的ajax访问的xml文件映射到相应的动作类实现前后端的交互的数据问题

前端

注意前端代码要根据你的具体业务看需要加在哪?

//获取当前登录人的部门和名字
	let dates = {};
	debugger;
	ajax({
		url: BUYINGREQ_CARD.defaultValueURL,
		async: false,
		success: (res) => {
			debugger;
			let { success, data } = res;
			if (success) {
				dates = res;
			}
		}	
	});
	this.props.form.setFormItemsValue(BUYINGREQ_CARD.formId, {
		//填报部门
		pk_plandept:{ value: dates.data.pk_dept, display: dates.data.deptName },
		//填报人员
		pk_planpsn:{ value: dates.data.pk_psndoc, display: dates.data.psndocName }
	});

xml文件(俗称健全文件)
文件路径:
/cmet/nccloud/src/client/yyconfig/modules/cmet/common/communal/config/authorize/common_authorize.xml


	
		*
		
			cmet.common.defaultValue
		
		

/cmet/nccloud/src/client/yyconfig/modules/cmet/common/communal/config/action/common.xml



	
		cmet.common.defaultValue
		
		nccloud.web.cmet.common.communal.action.DefaultValueAction
		
	

动作类文件

package nccloud.web.cmet.common.communal.action;

import java.util.HashMap;
import java.util.Map;

import nc.bs.framework.common.NCLocator;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.BeanProcessor;
import nc.vo.bd.defdoc.DefdocVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDate;
import nccloud.base.exception.ExceptionUtils;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.container.SessionContext;
import nccloud.pubitf.cmet.purchaseplan.yearpurchaseplan.IYearPurchasePlan4Cloud;
import nccloud.web.tbb.pub.action.CommonAction;

public class DefaultValueAction extends CommonAction{

	@Override
	public Object doAction(IRequest request) {
		Map map = new HashMap();
		try {
			// 执行查询
			IYearPurchasePlan4Cloud service = ServiceLocator.find(IYearPurchasePlan4Cloud.class);
			service.queryInformation(SessionContext.getInstance().getClientInfo().getUserid(),map);
			
			long busiTime = SessionContext.getInstance().getClientInfo()
					.getBizDateTime();
			// 获取到当前业务年份
			int busiYear = new UFDate(busiTime).getYear();
			if (busiYear < 1)
				throw new BusinessException("未获取到当年业务日期");
			String pk_group = SessionContext.getInstance().getClientInfo().getPk_group();
			if (pk_group == null || "".equals(pk_group))
				throw new BusinessException("未获取到当前集团");
			String sql = "select pk_defdoc, code, name, shortname, mnecode, enablestate from bd_defdoc where 1 = 1 and enablestate=2 ";
			// 自定义档案(结算年度)1001A3100000000011CL这个要根据自己系统的值
			sql += " and pk_defdoclist = '1001A3100000000011CL'";
			sql += " and pk_group = '" + pk_group + "'";
			sql += " and name = '" + busiYear + "'";
			// 查询
			IUAPQueryBS query2 = NCLocator.getInstance().lookup(IUAPQueryBS.class);
			DefdocVO docvo = (DefdocVO) query2.executeQuery(sql, new BeanProcessor(DefdocVO.class));
			if (docvo != null) {
				if (docvo.getPk_defdoc() != null && !"".equals(docvo.getPk_defdoc())) {
					map.put("pk_defdoc", docvo.getPk_defdoc());
					map.put("code", docvo.getCode());
					map.put("name", docvo.getName());
				}
			}
		} catch (Exception e) {
			ExceptionUtils.wrapException(e);
		}
		return map;
	}

}

实现效果

用友一些小知识(获取当前登录人的部门和名字赋值)_第1张图片
以上仅仅是小弟的看法,有什么见解有待商榷…

你可能感兴趣的:(用友一些小知识(获取当前登录人的部门和名字赋值))