projectinfoadd
<div role="control" label="所属地区" starred="true">
<input class="mini-treeselect" action="getBelongzoneModel" id="belongzone" bind="dataBean.belongzone" textField="text" valueField="id" emptyText="请选择...required="true"
onbeforenodeselect="onBeforeTreeNodeSelect" requiredErrorText="所属地区不能为空!" /> </div>
function onBeforeTreeNodeSelect(e) {
if (!e.isLeaf) {
e.cancel = "true";
}
}
<div role="control" label="项目类别" starred="true">
<input class="minicombobox"action="projecttypeModel"id="projecttype"bind="dataBean.projecttype" textField="text" valueField="id" emptyText="请选择..." required="true"onvalueChanged = "onProjectTypeChanged" requiredErrorText="项目类别不能为空!" /></div>
<div role="control" label="资金金额" starred="true">
<input id="projectmoney" class="mini-textbox" readOnly="true" bind="dataBean.projectmoney" required="true" requiredErrorText="资金金额不能为空!" vType="int" /></div>
//设置类别和金额联动
function onProjectTypeChanged(e){
// console.log(e);
var val = e.value;
switch(val){
case "1" :
mini.get("projectmoney").setValue(1000000)
break;
case "2" :
mini.get("projectmoney").setValue(500000)
break;
case "3" :
mini.get("projectmoney").setValue(300000)
break;
case "4" :
mini.get("projectmoney").setValue(150000)
break;
}
mini.get("projectmoney").setIsValid(true);
}
<div role="control" label="项目经理" starred="true">
<input id="projectmanager" class="mini-buttonedit" onButtonclick = "onProjectManagerClick"
bind="dataBean.projectmanager" required="true" allowInput="false" requiredErrorText="项目经理不能为空!" /></div>
<div role="control" label="项目人员" starred="true">
<input id="projectuser" class="mini-buttonedit" onButtοnclick="onProjectUserClick" allowInput="false" bind="dataBean.projectuser" required="true" requiredErrorText="项目人员不能为空!" /> </div>
//弹出项目经理选择框
function onProjectManagerClick(){
epoint.openDialog('选择项目经理',"framemanager/orga/orga/ou/selectouuser",onProjectManagerCallBack,{
'width' : 970,
'height' : 550
});
}
//关闭项目经理选择页面的回调
function onProjectManagerCallBack(data){
console.log(data);
var userSplit = data.split(";");
if(data!="close"){
mini.get("projectmanager").setValue(userSplit[1])
mini.get("projectmanager").setText(userSplit[0])
}
mini.get("projectmanager").setIsValid(true);
}
//选择项目人员
function onProjectUserClick(data) {
//获取当前控件里的人员guid,以便于去除所选人员,弹出页显示数据 userGuid: 固有数据
var userGuid = mini.get("projectuser").getValue();
epoint.openDialog('选择项目人员', "framemanager/orga/orga/user/selectuser", onProjectUserCallBack, {
'width' : 970,
'height' : 550,
param:{
userGuid:userGuid
}
});
}
//关闭项目人员选择页面的回调
function onProjectUserCallBack(data) {
console.log(data);
var userSplit = data.split("_SPLIT_");
if (data != "close") {
mini.get("projectuser").setValue(userSplit[0])
mini.get("projectuser").setText(userSplit[1])
}
//设置非空验证
mini.get("projectuser").setIsValid(true);
}
projectAddAction
public void add() {
dataBean.setRowguid(UUID.randomUUID().toString());
dataBean.setOperatedate(new Date());
dataBean.setOperateusername(userSession.getDisplayName());
// 保存时的重名验证
String projectName = dataBean.getProjectname();
// 查询数据库是否已存在
Projectinfo projectinfo = service.findProjectinfoByProjectname(projectName);
if (projectinfo != null) {
addCallbackParam("msg", projectName + " 已经存在,请勿重新添加");
addCallbackParam("info", "exist");
}
else {
service.insert(dataBean);
addCallbackParam("msg", "保存成功!!");
}
dataBean = null;
}
projectinfoedit
public void save() {
dataBean.setOperatedate(new Date());
// 修改页的重名验证
sql=select * from projectmanagerinfo where projectname!=? and projectname=?
String projectNameOld = service.find(dataBean.getRowguid()).getProjectname();
String projectNameNew = dataBean.getProjectname();
// 查询数据库是否已存在
Projectinfo projectinfo = service.findProjectinfoByProjectname(projectNameOld, projectNameNew);
if (projectinfo != null) {
addCallbackParam("msg", projectNameNew + " 已经存在,请勿重新添加");
}
else {
service.update(dataBean);
addCallbackParam("msg", "修改成功!!");
}
}
修改页面初始化
public void pageLoad() {
String guid = getRequestParameter("guid");
dataBean = service.find(guid);
if (dataBean == null) {
dataBean = new Projectinfo();
}
// 将所属地区的value转成文本
String belogZoneName = codeItemsService.getItemTextByCodeName("所属地区", dataBean.getBelongzone());
addCallbackParam("belogZoneName", belogZoneName);
// 获取项目经理的姓名
String projectManagerName = userService.getUserNameByUserGuid(dataBean.getProjectmanager());
addCallbackParam("projectManagerName", projectManagerName);
// 获取项目人员姓名
String projectUserGuid = dataBean.getProjectuser();
String projectUserName = service.getUserAllNameByUserGuid(projectUserGuid);
addCallbackParam("projectUserName", projectUserName);
}
Service:
public String getUserAllNameByUserGuid(String projectUserGuid) {
String[] projectUserGuidSplit = projectUserGuid.split(";");
List<String> userList = new ArrayList<>();
// 在当前serrvice中实例化其他service的时候,使用容器工厂的方式实现实例化
IUserService userService = ContainerFactory.getContainInfo().getComponent(IUserService.class);
for (String str : projectUserGuidSplit) {
userList.add(userService.getUserNameByUserGuid(str));
}
return StringUtil.join(userList, ";");
}
// 初始化页面
epoint.initPage('projectinfoeditaction',null,function(data){
console.log(data.belogZoneName);
//判断是否有数据所属地区
if(data.belogZoneName){
mini.get("belongzone").setText(data.belogZoneName);
}
//项目经理
if(data.projectManagerName){
mini.get("projectmanager").setText(data.projectManagerName);
}
//人员名称 projectUserName
if(data.projectUserName){
mini.get("projectuser").setText(data.projectUserName);
}
});
AssentinfoWorkFlowAction
pageload里
String userName;
Date applytimeouput = new Date();
if (StringUtil.isNotBlank(rowguid)) {
dataBean = service.find(rowguid);
if (null != dataBean.getBudgetguid()) {
Projectbudgetinfo info = projectbudgetinfoService.find(dataBean.getBudgetguid());
if (null != info) {
addCallbackParam("budgetname", info.getBudgetname());
}
}
// 不管还是第一次加载还是第二次加载都是有值的
userName = userService.getUserNameByUserGuid(dataBean.getApplyuserguid());
applytimeouput = dataBean.getApplytime();
}
else {
dataBean = new Assetinfo();
// rowguid = UUID.randomUUID().toString();
// getViewData从通用隐藏域里面获取rowguid,如果有就是这个值,如果没有就加一个值
rowguid = getViewData("rowguid");
if (StringUtil.isBlank(rowguid)) {
rowguid = UUID.randomUUID().toString();
addViewData("rowguid", rowguid);
}
// userSession 来自BaseController类是这个类继承的框架类WorkflowBaseController
dataBean.setApplyuserguid(userSession.getUserGuid());
userName = userSession.getDisplayName();
dataBean.setApplytime(applytimeouput);
}
addCallbackParam("applyusername", userName);
addCallbackParam("applytimeoutput",
EpointDateUtil.convertDate2String(applytimeouput, EpointDateUtil.DATE_TIME_FORMAT));
save里
wfInstanceAPI9.singlematerialSubmit(pvi, SQLTableName, rowguid, userSession.getUserGuid(), false);
AssentInfoListAction
// 发消息内容
if ("申请".equals(item.getActivityName())) {
String displayName = userSession.getDisplayName();
item.setWorkItemName("待提交的采购申请");
wfInstanceAPI9.updateWorkFlowWorkItem(Arrays.asList(item));
// 统一消息的提示 messagesCenterService 更新标题并且展示 消息id 新标题 发给谁 是否发送统一消息
messagesCenterService.updateMessageTitleAndShow(item.getWaitHandleGuid(), "待提交的采购申请",
userSession.getUserGuid(), true);
}
public DataGridModel<Assetinfo> getDataGridData() {
// 获得表格对象
if (model == null) {
model = new DataGridModel<Assetinfo>()
{
@Override
public List<Assetinfo> fetchData(int first, int pageSize, String sortField, String sortOrder) {
// 获取where条件Map集合
// System.out.println(nodeInfo);
Map<String, Object> conditionMap = ListGenerator.getSearchMap(getRequestContext().getComponents(),
sortField, sortOrder);
if (StringUtil.isNotBlank(nodeInfo)) {
String nodeId = nodeInfo.split(";")[0];
String nodeTypr = nodeInfo.split(";")[1];
// 当点击子节点时 sNode
if ("sNode".equals(nodeTypr)) {
SqlConditionUtil util = new SqlConditionUtil();
// select * from assetinfo 1=1 and budgetguid=nodeId
util.eq("budgetguid", nodeId);
conditionMap.putAll(util.getMap());
}
// 当点击的时父节点时
if ("pNode".equals(nodeTypr)) {
// 拿到的nodeId是projectguid
// selete rowguid from projectbudgetinfo where 1=1
// and projectguid = '';
// selete * from assetinfo where 1=1 and budgetinfo
// in ( );
// 首先获取当前项目下的所有预算guid
SqlConditionUtil util = new SqlConditionUtil();
util.eq("projectguid", nodeId);
List<Projectbudgetinfo> projectBudgetinfoList = projectbudgetinfoService
.findList(util.getMap());
List<String> budgetGuidList = new ArrayList<>();
for (Projectbudgetinfo projectbudgetinfo : projectBudgetinfoList) {
budgetGuidList.add(projectbudgetinfo.getRowguid());
}
String budgetGuidStr = StringUtil.join(budgetGuidList, "','");
SqlConditionUtil util2 = new SqlConditionUtil();
util2.in("budgetguid", "'" + budgetGuidStr + "'");
conditionMap.putAll(util2.getMap());
}
}
// 当点击的是根节点时,不需要筛选,显示所有的assetinfo
PageData<Assetinfo> pageData = service.paginatorList(conditionMap, first, pageSize);
this.setRowCount(pageData.getRowCount());
List<Assetinfo> list = pageData.getList();
String title = "采购详情", urlString = "";
for (Assetinfo assetinfo : list) {
assetinfo.put("applyUserName", userService.getUserNameByUserGuid(assetinfo.getApplyuserguid()));
Projectbudgetinfo projectbudgetinfo1 = projectbudgetinfoService.find(assetinfo.getBudgetguid());
if (projectbudgetinfo1 != null) {
assetinfo.put("budgetName", projectbudgetinfo1.getBudgetname());
}
// 数据重置
title = "采购详情";
urlString = "";
if (null != assetinfo.getPviguid()) {
ProcessVersionInstance pvi = wfInstanceAPI9
.getProcessVersionInstance(assetinfo.getPviguid());
// 当前人员的所有的工作项
List<WorkflowWorkItem> wItems = wfInstanceAPI9.getWorkItemListByUserGuid(pvi,
userSession.getUserGuid());
// 获取
if (!wItems.isEmpty() && wItems.size() > 0) {
title = wItems.get(0).getWorkItemName();
urlString = wItems.get(0).getHandleUrl();
}
}
assetinfo.put("title", title);
assetinfo.put("url", urlString);
}
return list;
}
};
}
return model;
}
/**
*
* 构建项目预算树
*
* @return
* @exception/throws [违例类型] [违例说明]
* @see [类、类#方法、类#成员]
*/
public TreeModel getTreeModel() {
if (treeModel == null) {
treeModel = new TreeModel()
{
@Override
public List<TreeNode> fetch(TreeNode node) {
// TODO Auto-generated method stub
List<TreeNode> list = new ArrayList<>();
if (node == null) {
// 初次加载 构建根节点和父节点两个层级
// 创建根节点
TreeNode rNode = new TreeNode();
rNode.setId("");// 根节点id设置为空
rNode.setPid("-1");// 根节点的父节点设置为-1
rNode.setText("所有项目预算");
rNode.setExpanded(true);
// 给当前节点设置一个自定义属性
rNode.getColumns().put("nodeType", "rNode");
list.add(rNode);
// 构建父节点
List<Projectinfo> projectinfoList = projectinfoService.findList(new HashMap<>());
TreeNode pNode = null;
for (Projectinfo projectinfo : projectinfoList) {
pNode = new TreeNode();
pNode.setId(projectinfo.getRowguid());
pNode.setPid(rNode.getId());
pNode.setText(projectinfo.getProjectname());
// 当前父节点是否为叶子节点,判断依据是查询当前项目下是否有预算信息
SqlConditionUtil util = new SqlConditionUtil();
util.eq("projectguid", projectinfo.getRowguid());
List<Projectbudgetinfo> projectbudgetinfolist = projectbudgetinfoService
.findList(util.getMap());
// if(EpointCollectionUtils.isEmpty(projectbudgetinfolist))
// {
// pNode.setLeaf(true);
// }else {
// pNode.setLeaf(false);
// }
// EpointCollectionUtils 框架封装方法判断集合是否为空
pNode.setLeaf(EpointCollectionUtils.isEmpty(projectbudgetinfolist));
pNode.getColumns().put("nodeType", "pNode");
list.add(pNode);
}
}
else {
// 再次加载
SqlConditionUtil util = new SqlConditionUtil();
// ..where project = ?
util.eq("projectguid", node.getId());
List<Projectbudgetinfo> projectBudgetinfoList = projectbudgetinfoService
.findList(util.getMap());
TreeNode sNode = null;
for (Projectbudgetinfo projectbudgetinfo : projectBudgetinfoList) {
sNode = new TreeNode();
sNode.setId(projectbudgetinfo.getRowguid());
sNode.setPid(node.getId());
sNode.setText(projectbudgetinfo.getBudgetname());
sNode.setLeaf(true);
sNode.getColumns().put("nodeType", "sNode");
list.add(sNode);
}
}
return list;
}
};
}
return treeModel;
}
assentInfoListhtml
<body>
<!-- 必须有,加载时的loading效果 -->
<div class="page-loading"></div>
<div class="fui-left">
<div role="head" title="所有项目预算"></div>
<div role="body">
<ul id="tree" name="tree" class="mini-tree" style="width: 100%; height: 100%" autoLoad="false" showTreeIcon="true" textField="text" idField="id" parentField="pid"
action="getTreeModel" onNodeClick="onTreeNodeClick" resultAsTree="false"></ul>
</div>
</div>
<div class="fui-right" id="fui-right">
<!-- toolbar区域 -->
<div class="fui-toolbar">
<a class="mini-button" state="primary" οnclick="openAdd" id="btnAddRecord"> 采购申请 </a> <a id="btnDel" state="danger" class="mini-button" οnclick="deleteData"> 删除选定 </a>
<!-- <a class="mini-dataexport" id="dataexport" gridId="datagrid" fileName="查询列表" action="getExportModel" extraId="fui-form"></a> -->
</div>
<!-- 内容区域 -->
<input id="nodeInfo" class ="mini-hidden" bind="nodeInfo" />
<div id="fuiContent" class="fui-content">
<div id="datagrid" class="mini-datagrid" idField="rowguid" action="getDataGridData" sortOrder="desc" showPager="true" style="height: 100%;" allowResize="true" multiSelect="true"
allowCellEdit="true" allowCellSelect="true" editNextOnEnterKey="true" editNextRowCell="true">
<div property="columns">
<div type="checkcolumn" width="40"></div>
<div type="indexcolumn" width="40" align="left" headerAlign="left">序</div>
<div field="title" renderer="onTitleRenderer">标题</div>
<div field="url" name = "urlColumn">url</div>
<div field="applyUserName">申请人员</div>
<!-- <div field="budgetName">预算标识</div> -->
<div field="applytime" data-options="{'format':'yyyy-MM-dd HH:mm:ss'}" dateFormat="yyyy-MM-dd HH:mm:ss">申请时间</div>
<div field="arrivaltime" data-options="{'format':'yyyy-MM-dd HH:mm:ss'}" dateFormat="yyyy-MM-dd HH:mm:ss">到货时间</div>
<div field="assettype" data-options="{code:'采购类型'}">采购类型</div>
<div field="totalmoney">物品总价</div>
<!-- <div field="description">申请说明</div> -->
<div field="status" data-options="{code:'申请状态'}">申请状态</div>
<!-- <div width="50" align="left" headerAlign="left" renderer="onEditRenderer">修改</div> -->
<!-- <div width="50" align="left" headerAlign="left" renderer="onDetailRenderer">查看</div> -->
</div>
</div>
</div>
</div>
<!-- 请修改相对路径 -->
<script src="../../../../rest/resource/jsboot"></script>
<script>
// 初始化页面
epoint.initPage('assetinfolistaction',null,function(data){
var grid = mini.get('datagrid');
grid.hideColumn('urlColumn');
});
function openAdd() {
epoint.openDialog('采购申请', "frame/pages/epointworkflow/client/processcreateinstance?ProcessGuid=fe0cad81-2de7-4990-a86e-da7be07e2c42", searchData, {
'width' : 970,
'height' : 550
});
}
// 删除数据
function deleteSelect() {
epoint.execute("deleteSelect", '', callback);
}
//
function onTitleRenderer(e){
//console.log(e.row.rowguid);
var guid = e.row.rowguid;
var url = e.row.url;
if(""==(url)){
url = "frame/pages/xmcg/assetinfo/assetinfodetail?guid=" + guid;
}
var str = "<a onClick=\"onTitleClick('" + url + "')\">" + e.row.title +"</a>";
//console.log(str);
return str;
}
//
function onTitleClick(url){
//console.log( '123'+ projectGuid);
epoint.openDialog('采购信息', url);
}
function callback(data) {
if(data.msg) {
epoint.alert(data.msg, '', searchData, 'info');
}
}
// 表格的搜索
function searchData() {
epoint.refresh(['datagrid','nodeInfo'], '', true);
}
function deleteData(){
if(mini.get('datagrid').getSelecteds().length == 0){
epoint.alert('请选择要删除的记录!', '', null, 'warning');
}else{
epoint.confirm('确认要删除吗?','',deleteSelect);
}
}
function onTreeNodeClick(e){
console.log(e);
var nodeId = e.node.id;
var nodeType = e.node.nodeType;
var nodeInfo = nodeId + ";"+ nodeType;
mini.get("nodeInfo").setValue(nodeInfo);
epoint.refresh(['nodeInfo','datagrid']);
}
</script>
</body>