概述
前台基本标签
1 按钮
<a id="btn" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'">easyui</a>
Add eidt no ok cancel print help back cut redo reload search undo
2 下拉列表
--------jsp-----------
<input name="pgvo.jobgfcontent" id='gongfenid' style="width: 325px;" />
---------js---------------
$('#gongfenid').combobox({
editable:false,
url:'<c:url value="/nnmis/view/system/findBasedicByClassNameBASEDIC.tg?dicClassName=临时任务工分"/>',
valueField:'DICNAME',
textField:'DICNAME'
});
-----------action-----------------
public void findBasedicByClassName() {
try {
String classname = request.getParameter("dicClassName");
List<Map> list = basedicservice.findBasedicByClassName(classname);
JSONArray jsonArray = JSONArray.fromObject(list);
returnJson(jsonArray.toString(), response);
} catch (Exception e) {
e.printStackTrace();
logger.info(e.getMessage());
outJsonPlainString(response, "[]");
}
}
3 下拉树
-------------jsp-------------------------
<input id="zzy" align="center" data-options="width:180" />
-------------js-------------------------
$('#zzy').combotree({
url:'<c:url value="/nnmis/wxunn/pGrycxByOrgidAndPgDate_ZZYTreePG.tg"/>?zrgqid='+zrgqid+'&plantype='+plantype,
editable:false,
required:true,
multiple:true,
onlyLeafCheck:true,
onBeforeSelect: function(node) {
//只可以选中子节点
if (!$(this).tree('isLeaf', node.target)) {
return false;
}
},
onClick: function(node) {
if (!$(this).tree('isLeaf', node.target)) {
$(this).combo('showPanel');
}
},
onLoadSuccess:function(){
if(data[0].ZZYPERSONID == null){
$('#zzy').combotree('setValues',[]);
}else{
var duan = data[0].ZZYPERSONID.split(",");
$('#zzy').combotree('setValues',duan);
}
//只有选中的节点 才会展开
var duanper_tree = $('#zzy').combotree('tree');
duanper_tree.tree('collapseAll');
var root = duanper_tree.tree('getRoot');
duanper_tree.tree('expand', root.target);
}
});
---------------action--------------------------
public void pGrycxByOrgidAndPgDate_ZZYTree() {
String zrgqid = request.getParameter("zrgqid");
String plantype = request.getParameter("plantype");
String orgnum = request.getSession().getAttribute("session_orgnum").toString();
String jtgqnum = (String) jtgqOrgnum.get("SY");
List<TreeNode> list = cqPersonService.pGrycxByOrgidAndPgDate_SYTree(zrgqid, plantype, orgnum, jtgqnum);
JSONArray json = JSONArray.fromObject(list);
returnJson(json.toString(), response);
}
--------------service----------------------------
public List<TreeNode> pGrycxByOrgidAndPgDate_SYTree(String zrgqid, String plantype, String orgnum, String jtgqnum) {
List list = wxuNnTPgPersonDao.pGrycxByOrgidAndPgDate_SYTree(zrgqid, plantype, orgnum, jtgqnum);
List<TreeNode> rlist = new ArrayList<TreeNode>();
rlist = getPersonTree(list);
return rlist;
}
----------------------封装数据--------------------------------------
private List<TreeNode> getPersonTree(List<Map> list2) {
List<TreeNode> list = new ArrayList<TreeNode>();
List<TreeNode> tempList = new ArrayList<TreeNode>();
try {
// 拉出数据库的数据,放入list2中
// 将list2中的数据,转换成TreeNode类型,放入Map中备用
for (Map map : list2) {
TreeNode node = new TreeNode();
node.setId((String) map.get("ID"));
node.setText((String) map.get("TEXT"));
String parent = (String) map.get("PARENT_ID");
node.setParentId("");
if (parent != null && !parent.isEmpty()) {
node.setParentId(parent);
}
tempList.add(node);
}
for (Map map : list2) {
String parent = (String) map.get("PARENT_ID");
// 如果父节点不为空
if (parent != null && !parent.isEmpty()) {
String pidString = parent;
TreeNode pnode = null;// list2里面的父节点信息
TreeNode cnode = null;// list2里面的当前节点信息
for (int i = 0; i < tempList.size(); i++) {
if (tempList.get(i).getId().equals(pidString)) {
// 如果这个组织号是跟parentId一样的,存到pnode
pnode = tempList.get(i);
}
if (tempList.get(i).getId().equals(map.get("ID"))
&& tempList.get(i).getParentId().equals(parent)) {
// 找到相同的组织机构存到cnode
cnode = tempList.get(i);
}
}
if (pnode == null) {
// 如果没有找到父节点,则直接加为根节点
list.add(cnode);
} else {
// 找到父节点,则加为父节点的子节点
// 可能一站多线,若pnode已存在相同车站,则不添加
if (pnode.getChildren() == null || pnode.getChildren().size() == 0) {
pnode.addChild(cnode);
} else {
// 判断节点里面是否已经添加了改子节点,默认未添加
boolean flag = false;
for (int k = 0; k < pnode.getChildren().size(); k++) {
if (pnode.getChildren().get(k).getId().equals(cnode.getId())) {
flag = true;
}
}
if (!flag) {
pnode.addChild(cnode);
}
}
}
// 父节点为空
} else {
for (int i = 0; i < tempList.size(); i++) {
if (tempList.get(i).getId().equals(map.get("ID"))
&& tempList.get(i).getParentId().equals(parent == null ? "" : parent)) {
list.add(tempList.get(i));
break;
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return list;
}
---------------------------DAO层中必须有父节点---------------
sb.append(" select ID, text , PARENT_ID");
sb.append(" from ( ");
sb.append(" select p.personid ID, p.personname text ,p.orgid PARENT_ID from SYS_MV_PERSON_NODEP p,sys_t_person tp where");
sb.append(" p.orgnum like (select substr(o.orgnum,0,6) from sys_mv_org_nodep o where o.id='" + zrgqid
+ "')||'%' and length(p.orgnum)=8 ");
sb.append(" and p.orgnum in('" + jtgqnum.replaceAll(",", "','") + "')");
sb.append(" and tp.id=p.personid");
sb.append(" and tp.isfhzz='1'");
// g机构名
sb.append(" union all ");
sb.append(" select distinct p.orgid ID, p.orgname text ,'' PARENT_ID from SYS_MV_PERSON_NODEP p,sys_t_person tp where");
sb.append(" p.orgnum like (select substr(o.orgnum,0,6) from sys_mv_org_nodep o where o.id='" + zrgqid
+ "')||'%' and length(p.orgnum)=8 ");
sb.append(" and p.orgnum in('" + jtgqnum.replaceAll(",", "','") + "')");
sb.append(" and tp.id=p.personid");
sb.append(" and tp.isfhzz='1'");
4 日期下拉列表
A 年月日
<input id="dd" type="text" class="easyui-datebox" required="required"></input>
有时候想要赋默认值
-----------------js--------------------------
服务器时间
<%!public String getStrTime() {
SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
return fm.format(date);
}
public String getEndTime() {
SimpleDateFormat fm = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
date.setDate(date.getDate() + 1);
return fm.format(date);
}%>
赋值
$('#strTime').datebox('setValue','<%=getStrTime()%>');
添加事件
$('#tcDaystr').datebox({
onSelect: knowDate,
onChange:changeDate
});
function knowDate(date){
//alert(date.getFullYear()+":"+(date.getMonth()+1)+":"+date.getDate());
var datestr = formatDate(date);
var max='<%=getImportDateMax()%>';
var next="<%=getImportDateMin()%>";
if (datestr<next||datestr>max){
}
}
function changeDate(newv,oldv){
var date = new Date();
if(formatDate(date)==newv){
}
}
日期的转化方法
/**
* 格式化日期格式yyyy-MM-dd
*/
function formatDate(date) {
var strYear = date.getFullYear() + "-";
var strBeginMonth = date.getMonth() + 1;
var strDate = date.getDate();
if (strBeginMonth < 10)
strBeginMonth = "0" + strBeginMonth;
if (strDate < 10)
strDate = "0" + strDate;
return strYear + strBeginMonth + "-" + strDate;
}
/**
* 日期格式yyyy-MM-dd转化为Date对象
*/
function StringToDate(dateString){
var array=dateString.split("-");
if (array.length==3)
{
var strYear=array[0];
var strMonth=array[1]-1;
var strDate=array[2];
var date = new Date(strYear,strMonth,strDate);
return date;
}
else
return null;
}
/**
* 格式化日期格式yyyy-MM-dd hh:mm:ss
*/
function formatDatetime(date) {
var strYear = date.getFullYear() + "-";
var strBeginMonth = date.getMonth() + 1;
var strDate = date.getDate();
var strHour = date.getHours();
var strMinutes = date.getMinutes();
var strSeconds = date.getSeconds();
if (strBeginMonth < 10)
strBeginMonth = "0" + strBeginMonth;
if (strDate < 10)
strDate = "0" + strDate;
if (strHour < 10)
strHour = "0" + strHour;
if (strMinutes < 10)
strMinutes = "0" + strMinutes;
if (strSeconds < 10)
strSeconds = "0" + strSeconds;
return strYear + strBeginMonth + "-" + strDate + " " + strHour + ":"
+ strMinutes+":"+strSeconds;
}
B年月日时分 以上方法 此标签
<input class="easyui-datetimebox" name="birthday"
data-options="required:true,showSeconds:false" style="width:150px">
5 form 表单提交
$('#fm').form(
'submit',
{
url : '<c:url value='/nnmis/view/scgl/saveXunShiWaiZuoYeTCIM.tg'/>',
onSubmit : function(param) {
//传参数
param.workdate = workdate;
param.line = line;
//验证必填项
var isValid = $(this).form('validate');
if (!isValid) {
//无效时执行的事件
$.messager.progress('close');
}
return isValid;//返回false则终止表单提交
},
success : function(data) {
$.messager.progress('close');
var result = eval('(' + data + ')');
if (result.success) {
$('#dlg').dialog("close");
$.messager.show({
title : '信息',
msg : '保存成功!'
});
$("#tcjhzx_dg").datagrid("reload");
} else {
$.messager.show({
title : "错误",
msg : '保存失败'
});
$("#tcjhzx_dg").datagrid("reload");
}
}
});
6 datalog
查询条件 加一个列表 最通常的用法
$('#finshbigdgid').dialog('open');
$('#finshbigdgid').dialog('close');
<div id="finshbigdgid" class="easyui-dialog" title="设备信息" style="width:590px;height:360px;"
data-options="iconCls:'icon-save',resizable:true,modal:true,closed:true">
<table border="0" style="padding:5px">
<tr>
<td>完成情况:</td><td>
<select id="addwcid" class="easyui-combobox" data-options="panelHeight:100">
<option value=""></option>
<option value="0">未完成</option>
<option value="1">已完成</option>
</select>
</td>
<td style="padding-left:8px;"><a href="javascript:void(0);"
class="easyui-linkbutton" iconCls="icon-search"
οnclick="searchEquList()">查询 </a></td>
<td style="padding-left:8px;"> <a
id="btn" href="#" class="easyui-linkbutton" οnclick="equConfim()">批量确认</a></td></tr>
</table>
<table class="easyui-datagrid" id="addequlistid"
data-options="fitColumns:true,singleSelect:false">
<thead>
<tr>
<th data-options="field:'NAME',width:80">站/区间</th>
<th data-options="field:'EQUTYPENAME',width:80">设备类型</th>
<th data-options="field:'EQUNAME',width:60">设备名</th>
<th data-options="field:'STATUS',width:100" formatter="retrunStatus">完成情况</th> </tr>
</thead>
</table>
</div>
在对话框关闭 打开时都可以添加触发事件
<div id="dialog_lsrw" class="easyui-dialog" title="新增重点工作"style="width:750px;height:500px;"data-options="iconCls:'icon-save',resizable:true,modal:true,closed:true,onClose:hidebutton">
7 datagrid列表
-----------------jsp---------------------------------------------
<table id="tcjhzx_dg" border="false" nowrap="false"
singleSelect="true" pagination="true" rownumbers="true"
pageSize="50" pageList="[50,100,150]" fit="true"
rowStyler="returnRowStyler">
<thead>
<tr>
<th field="tcstate" width="65px" align="center" sortable="false"
data-options="formatter:tcstateformatter" align="center">天窗状态</th>
data-options="formatter:zuoYeKaKong,styler:zuoYeKaKongStyle">作业卡控状态 </th>
</tr>
</thead>
</table>
--------------------js--------------------------------------------
var url = '<c:url value='/nnmis/wxunn/findTcjhzxPLAN.tg'/>';
$('#tcjhzx_dg').datagrid({
url : url,
queryParams : {
strTime : strTime,
endTime : endTime,
orgnum : orgnum,
wctype:wctype,
workconter:workconter
},
onLoadSuccess:function(){
tcjhzxdgSelect();
},
onDblClickRow : function(rowIndex, rowData) {
toPginfoIframe(rowData);
}
});
A 列的返回值
function tcstateformatter(value, row, index) {
var str = "未开始作业"; //默认状态
var worktime=row.WORKTIME;
var workdate=row.WORKDATE;
if(worktime.indexOf("-")>-1){
}else{
worktime = "00:00-00:00"
}
var startTime=worktime.split('-')[0];
var startTimearr=startTime.split(':');
startTime=returnRightNum(startTimearr[0])+":"+returnRightNum(startTimearr[1]);
var endTime=worktime.split('-')[1];
// alert(endTime);
if(endTime.indexOf("日") >-1 ){
//如果结束日期中带有“日”字,需要进行处理
endTime=endTime.split('日')[1];
}
var endTimearr=endTime.split(':');
endTime=returnRightNum(endTimearr[0])+":"+returnRightNum(endTimearr[1]);
//24:00 处理
var ksdate=workdate;
var jsdate=workdate;
if(startTime.substring(0,2)=='24'){
ksdate=initaddDate(workdate,1);
startTime='00:'+startTime.substring(3,5);
}
if(endTime.substring(0,2)=='24'){
jsdate=initaddDate(workdate,1);
endTime='00:'+endTime.substring(3,5);
}
var repairStartDate=ksdate+" "+startTime;
var repairEndDate=jsdate+" "+endTime;
repairStartDate = repairStartDate.replace(/-/g,"/");
repairEndDate = repairEndDate.replace(/-/g,"/");
var startDate = new Date(repairStartDate);
var endDate = new Date(repairEndDate);
if( startDate-endDate >= 0 ){
//如果为正数,则跨天,天数+1
endDate=new Date((new Date(repairEndDate)/1000+86400)*1000);
}
var sjstarttime=row.USETIME_BEGIN;//空,未开始,否则,开始
var sjsendtime=row.USETIME_END;//非空 完成
if(sjstarttime==""){
var time=Math.floor((startDate - new Date())/1000/60);
var endtime=Math.floor((endDate - new Date())/1000/60);
if(time > 40 ){
//距离开始还有40分钟,改变颜色警告
str = "未开始作业";
return str;
}
if((time <= 40 && time >= 0)||( /* endtime>=10 && */endtime>=0)){
//距离开始前40分钟,结束前10
str = "未开始作业";
return str;
}
}
if(sjstarttime!=""&&sjsendtime==""){
/* if(new Date(sjstarttime)<new Date()){
return 'background-color:#de34846;';
} */
//作业中
str = "作业中";
return str;
}
if(sjstarttime!=""&&sjsendtime!=""){
//完成
str = "作业完成";
return str;
}
if(sjsendtime==""){
if(new Date()>endDate){
str = "作业超期";
return str;
}
}
return str;
}
B 修饰列
function zuoYeKaKongStyle(val,row,index){
if(parseInt(row.BHLYNUM)>0&&parseInt(row.BQLYNUM)>0&&parseInt(row.PICNUM)>0){
if(parseInt(row.BHLYDATE)>0&&parseInt(row.BQLYDATE)>0&&parseInt(row.PICDATE)>0){
return 'background-color:#dace3e;';
}else{
return 'background-color:#00DD00;';
}
}
}
C 分组显示
$('#pg_jxitem_dg').datagrid({
url : "<c:url value='/nnmis/wxunn/findSyPGDayPlanYEARITEM.tg'/>",
view : groupview,
groupField : 'ITEMJWXTYPENAME',
groupFormatter : function(ITEMJWXTYPENAME, rows) {
return ITEMJWXTYPENAME + '共' + rows.length
+ '条 ';
},
singleSelect:false,
border:true,
pagination:false,
rownumbers:true,
fit:true,
autoRowHeight:true,
nowrap:false,
columns:[[
{field:'ck',checkbox:true},
{field:'JXID',hidden:true},
{field:'BEGINDAYWORK',hidden:true},
{field:'ENDDAYWORK',hidden:true},
{field:'ITEMNAME_SIMPLE',title:'作业内容',width:200,sortable:true,formatter:wxRowformater,align:'left'},
{field:'ITEMWXUZQ_MS',title:'周期',width:60,sortable:true,align:'center'},
{field:'ITEMVTYPE',title:'作业类型',width:60,sortable:true,align:'center',formatter:zyType},
{field:'ITEMID',title:'任务子项',width:100,sortable:true,align:'center',formatter:returnWcQk}
]]
});
D 行合并
$('#yearitem_dg')
.datagrid(
{
pageList : [ 30, 50, 100 ],
fitColumns : false,
url : "<c:url value='/nnmis/wxunn/findMonthItemMONTH.tg'/>?year="
+ year + '&gqid=' + gqid,
collapsible : true,
onLoadSuccess : function(data) {
//----------合并行
var mergesStation = mergeRows(data['rows'],
'SBLB', 0, data['rows'].length);
for (var i = 0; i < mergesStation.length; i++) {
$('#yearitem_dg').datagrid('mergeCells', {
index : mergesStation[i].index,
field : 'SBLB',
rowspan : mergesStation[i].rowspan
});
}
//合并设备分类
var mergesTypeName = new Array();
for (var i = 0; i < mergesStation.length; i++) {
var obj = mergesStation[i];
var temp = mergeRows(data['rows'], 'SBCS',
obj.index,
(obj.index + obj.rowspan));
for ( var key in temp)
mergesTypeName.push(temp[key]);
}
for (var i = 0; i < mergesTypeName.length; i++) {
$('#yearitem_dg').datagrid('mergeCells', {
index : mergesTypeName[i].index,
field : 'SBCS',
rowspan : mergesTypeName[i].rowspan
});
}
}
});
//定义对象用户合并行
function objClass(){
this.index=0;
this.rowspan=0;
}
//totalData为后台返回的内容的数组对象,rowName是合并列的名字,first-last是表示data中的一段数据数组
//合并相同名称的行
function mergeRows(totalData,rowName,first,last)
{
if(last<first||last>totalData.length)
return [];
var data=new Array();
for(var i=first;i<last;i++)
{
data.push(totalData[i]);
}
var merges=new Array();
if(data.length==0)
{
merges=[];
}
else if(data.length==1)
{
var obj=new objClass();
obj.index=first;
obj.rowspan=1;
merges.push(obj);
}
else
{
var head=0;
var tail=1;
for(var i=0;i<data.length-1;i++)
{
var value=data[i][rowName];
var nextValue=data[i+1][rowName];
if(value==nextValue)
{
tail++;
}
else
{
var obj=new objClass();
obj.index=head+first;
obj.rowspan=tail;
merges.push(obj);
head=head+tail;
tail=1;
}
if(i==data.length-2)
{
var obj=new objClass();
obj.index=head+first;
obj.rowspan=tail;
merges.push(obj);
}
}
}
return merges;
}
E 冻结列
$('#yearitem_dg').datagrid({
pageList : [30,50,100],
frozenColumns:[[
{
field:'auto_index',
rowspan:'2',
formatter:function(value, row, index){
var opts=$('#yearitem_dg').datagrid('options');
return opts.pageSize*(opts.pageNumber-1)+index+1;
},
title:'序号',
align:'center'
},
{
field:'checked',
rowspan:'2',
checkbox:true
},
{field:'itemnamesimple',
title:'工作内容',
width:'250',
sortable:true,
align:'left',
rowspan:'2'
},
{
field:'itemunit',
title:'单位',
width:'50',
sortable:true,
align:'center',
rowspan:'2'
},
{
field:'plannum',
title:'总数',
width:'50',
sortable:true,
align:'center',
rowspan:'2'
},
{
field:'itemwxzqms',
title:'周期',
width:'100',
sortable:true,
align:'center',
rowspan:'2'
}
],[]],
fitColumns:false,
url : "<c:url value='/nnmis/wxunn/findYearItemYEARITEM.tg'/>?year="+year + '&gqid=' + gqid,
collapsible:true,
view:groupview,
groupField:'equtypeXctypeGroupname',
groupFormatter:function(equtypeXctypeGroupname,rows){
return equtypeXctypeGroupname + ' 共' + rows.length + '条 ';
}
});
F 表头合并,序号列不对齐
<table id="yearitem_dg" singleSelect="true"
pagination="true" pageSize="30" fit="true" border="true"
nowrap="false" toolbar="#yearitemtb" autoRowHeight="false"
data-options="onClickCell: onClickCell">
<thead>
<tr>
<th field="auto_index"
data-options="formatter:function(value, row, index){
var opts=$('#yearitem_dg').datagrid('options');
return opts.pageSize*(opts.pageNumber-1)+index+1;
},align:'center'" rowspan="2">序号</th>
<th colspan="2">工时(分钟)</th>
<th colspan="12">工作月份</th>
</tr>
<tr>
<th field="ITEM_NUM" width="50" sortable="true" align="center">单位</th>
<th field="countyear" width="50" sortable="true" align="center" formatter="countyearnum">年计</th>
</tr>
</thead>
</table>
G 行编辑
---------------jsp--------------------------------
带触发事件
<table id="pg_persongroup_dg" singleSelect="true" fit="true"
toolbar="#persongrouptb" autoRowHeight="false"
data-options="onClickRow: onPersonGroupClickRow" pagination="false"
nowrap="false" rownumbers="true" border="true">
<thead>
<tr>
<th align="center"
data-options="field:'num',width:45,editor:'text'">
编号
</th>
<th align="center"
data-options="field:'zzId',width:70,
formatter:function(value,row){
return row.zzName;
},
editor:{
type:'combotree',
options:{
url:'<c:url value="/nnmis/wxunn/pGrycxFhByOrgidAndPgDatePG.tg?type=0&dcjorgnum="/>'+'<%=request.getParameter("duancjorgnum")%>',
required:false,
editable:false,
panelWidth:250,
panelHeight:150,
onBeforeSelect: function(node) {
if (!$(this).tree('isLeaf', node.target)) {
return false;
}
},
onClick: function(node) {
if (!$(this).tree('isLeaf', node.target)) {
$(this).combo('showPanel');
}
},
onLoadSuccess:zzCombotreeOnLoadSuccess
}
}">
组长
</th>
<th align="center"
data-options="field:'zzPhone',width:120,editor:'text'">
手机号
</th>
<th align="center"
data-options="field:'fhId',width:75,
formatter:function(value,row){
return row.fhName;
},
editor:{
type:'combotree',
options:{
url:'<c:url value="/nnmis/wxunn/pGrycxFhByOrgidAndPgDatePG.tg?fhzz=1&dcjorgnum="/>'+'<%=request.getParameter("duancjorgnum")%>',
required:false,
editable:false,
panelWidth:250,
panelHeight:150,
multiple:true,
onlyLeafCheck:true,
onBeforeSelect: function(node) {
if (!$(this).tree('isLeaf', node.target)) {
return false;
}
},
onClick: function(node) {
if (!$(this).tree('isLeaf', node.target)) {
$(this).combo('showPanel');
}
},
onLoadSuccess:fhyCombotreeOnLoadSuccess
}
}">
防护员
</th>
<th align="center"
data-options="field:'fhyPhone',width:120,editor:'text'">
手机号
</th>
<th align="center"
data-options="field:'zyIds',width:275,
formatter:function(value,row){
return row.zyNames;
},
editor:{
type:'combotree',
options:{
url:'<c:url value="/nnmis/wxunn/pGrycxFhByOrgidAndPgDatePG.tg?type=0&dcjorgnum="/>'+'<%=request.getParameter("duancjorgnum")%>',
required:false,
editable:false,
panelWidth:250,
panelHeight:150,
onlyLeafCheck:true,
multiple:true,
onLoadSuccess:zyCombotreeOnLoadSuccess
}
}">
组员
</th>
<th align="center" hidden="hidden" data-options="field:'jgwryIds',width:120,
formatter:function(value,row){
return row.jgwryNames;
},
editor:{
type:'combotree',
options:{
url:'<c:url value="/nnmis/wxunn/pGrycxFhByOrgidAndPgDatePG.tg?type=1&dcjorgnum="/>'+'<%=request.getParameter("duancjorgnum")%>',
required:false,
multiple:true,
editable:false,
panelWidth:250,
panelHeight:150
}
}">机构外人员</th>
<th align="center" hidden="hidden"
data-options="field:'jgwfhId',width:75,
formatter:function(value,row){
return row.jgwfhName;
},
editor:{
type:'combotree',
options:{
url:'<c:url value="/nnmis/wxunn/pGrycxFhByOrgidAndPgDatePG.tg?fhzz=1&type=1&dcjorgnum="/>'+'<%=request.getParameter("duancjorgnum")%>',
required:false,
editable:false,
panelWidth:250,
panelHeight:150
}
}">
机构外防护员
</th>
<th field="id" width="10" hidden="true"></th>
</tr>
</thead>
</table>
<div id="persongrouptb" style="height: auto">
<table>
<tr height="20px">
<td width="60px" height="15px">
<a href="javascript:void(0)" class="easyui-linkbutton"
data-options="iconCls:'icon-add',plain:true"
οnclick="addGroup()">新增</a>
</td>
<td width="60px" height="15px">
<a href="javascript:void(0)" class="easyui-linkbutton"
data-options="iconCls:'icon-remove',plain:true"
οnclick="removeGroup()">删除</a>
</td>
<td width="60px" height="15px">
<a href="javascript:void(0)" class="easyui-linkbutton"
data-options="iconCls:'icon-save',plain:true"
οnclick="saveGroup()">保存</a>
</td>
</tr>
</table>
</div>
------------------------js------------------------------------------------------------
单击处于可编辑状态
var editIndex = undefined;
function onPersonGroupClickRow(index) {
if (editIndex != index) {
if (endEditing()) {
$('#pg_persongroup_dg').datagrid('selectRow', index).datagrid(
'beginEdit', index);
editIndex = index;
var jgwryIds=$('#pg_persongroup_dg').datagrid('getRows')[index]['jgwryIds'];
var jgwzys = $('#pg_persongroup_dg').datagrid('getEditor', {
index : editIndex,
field : 'jgwryIds'
});
$(jgwzys.target).combotree({
url:'<c:url value="/nnmis/wxunn/pGrycxFhByOrgidAndPgDatePG.tg?fhzz=1&type=1&dcjorgnum="/>'+dcjorgnum,
onLoadSuccess:function(){
$(jgwzys.target).combotree('setValues',stringToJsonArray(jgwryIds));
}
});
var zyIds=$('#pg_persongroup_dg').datagrid('getRows')[index]['zyIds'];
var zys = $('#pg_persongroup_dg').datagrid('getEditor', {
index : editIndex,
field : 'zyIds'
});
var tree = $(zys.target).combotree('tree');
$(zys.target).combotree({
width:275,
url:'<c:url value="/nnmis/wxunn/pGrycxFhByOrgidAndPgDatePG.tg?type=0&dcjorgnum="/>'+dcjorgnum,
onLoadSuccess:function(){
tree.tree('collapseAll');
$(zys.target).combotree('setValues',stringToJsonArray(zyIds));
var ids=stringToJsonArray(zyIds);
for (var i = 0; i < zyIds.length; i++) {
var node = tree.tree('find', ids[i] == null || ids[i] == "" ? orgid: ids[i]);
if (node != null) {
tree.tree('expandTo', node.target);
tree.tree('expand', node.target);
}
}
var gqnode=tree.tree('find',zrgqid);
tree.tree('expandTo', gqnode.target);
tree.tree('expand', gqnode.target);
}
});
//防护员 多选修改
var fhIds=$('#pg_persongroup_dg').datagrid('getRows')[index]['fhId'];
var fhs = $('#pg_persongroup_dg').datagrid('getEditor', {
index : editIndex,
field : 'fhId'
});
var ftree = $(fhs.target).combotree('tree');
$(fhs.target).combotree({
width:275,
url:'<c:url value="/nnmis/wxunn/pGrycxFhByOrgidAndPgDatePG.tg?fhzz=1&dcjorgnum="/>'+dcjorgnum,
onLoadSuccess:function(){
ftree.tree('collapseAll');
$(fhs.target).combotree('setValues',stringToJsonArray(fhIds));
var ids=stringToJsonArray(fhIds);
for (var i = 0; i < fhIds.length; i++) {
var node = tree.tree('find', ids[i] == null || ids[i] == "" ? orgid: ids[i]);
if (node != null) {
ftree.tree('expandTo', node.target);
ftree.tree('expand', node.target);
}
}
var gqnode=ftree.tree('find',zrgqid);
ftree.tree('expandTo', gqnode.target);
ftree.tree('expand', gqnode.target);
}
});
} else {
$('#pg_persongroup_dg').datagrid('selectRow', editIndex);
}
}
}
function endEditing() {
if (editIndex == undefined) {
return true
}
if ($('#pg_persongroup_dg').datagrid('validateRow', editIndex)) {
var zz = $('#pg_persongroup_dg').datagrid('getEditor', {
index : editIndex,
field : 'zzId'
});
var fhy = $('#pg_persongroup_dg').datagrid('getEditor', {
index : editIndex,
field : 'fhId'
});
var zys = $('#pg_persongroup_dg').datagrid('getEditor', {
index : editIndex,
field : 'zyIds'
});
var jgwfhy = $('#pg_persongroup_dg').datagrid('getEditor', {
index : editIndex,
field : 'jgwfhId'
});
var jgwzys = $('#pg_persongroup_dg').datagrid('getEditor', {
index : editIndex,
field : 'jgwryIds'
});
if (zz != null) {
var zid = $(zz.target).combotree('getValue');
var ztree = $(zz.target).combotree('tree');
var znode = ztree.tree('find', zid);
var zztext = $(zz.target).combotree('getText');
$('#pg_persongroup_dg').datagrid('getRows')[editIndex]['zzName'] = zztext;
var fhyid = $(jgwfhy.target).combotree('getValue');
var tree = $(jgwfhy.target).combotree('tree');
var node = tree.tree('find', fhyid);
var jgwfhytext;
if(node!=null){
var type = node.otherInfo;
if (type == 1) {
$.messager.alert('提示', '机构外防护员,请选择人员!!!', 'info');
return false;
}
jgwfhytext= $(jgwfhy.target).combotree('getText');
}else
{
jgwfhytext="";
}
$('#pg_persongroup_dg').datagrid('getRows')[editIndex]['jgwfhName'] = jgwfhytext;
var zysid = $(zys.target).combotree('getValues');
var zytree = $(zys.target).combotree('tree');
var zynode;
var zytext;
for (var i = 0; i < zysid.length; i++) {
zynode=zytree.tree('find', zysid[i]);
if(zynode!=null){
zytext= $(zys.target).combotree('getText');
}else{
zytext="";
}
}
//防护员修改 可选多人
var fhsid = $(fhy.target).combotree('getValues');
var fhtree = $(fhy.target).combotree('tree');
var fhnode;
var fhtext;
for (var i = 0; i < fhsid.length; i++) {
fhnode=fhtree.tree('find', fhsid[i]);
if(fhnode!=null){
fhtext= $(fhy.target).combotree('getText');
}else{
fhtext="";
}
}
var jgwzysid = $(jgwzys.target).combotree('getValues');
var tree = $(jgwzys.target).combotree('tree');
var node;
var jgwzytext;
var type;
for (var i = 0; i < jgwzysid.length; i++) {
node=tree.tree('find', jgwzysid[i]);
if(node!=null){
type=node.otherInfo;
if (type == 1) {
$.messager.alert('提示', '机构外作业人员,请选择人员!!!', 'info');
return false;
}
jgwzytext= $(jgwzys.target).combotree('getText');
}else{
jgwzytext="";
}
}
$('#pg_persongroup_dg').datagrid('getRows')[editIndex]['jgwryNames'] = jgwzytext;
$('#pg_persongroup_dg').datagrid('getRows')[editIndex]['zyNames'] = zytext;
$('#pg_persongroup_dg').datagrid('getRows')[editIndex]['fhName'] = fhtext;
$('#pg_persongroup_dg').datagrid('endEdit', editIndex);
$('#pg_persongroup_dg').datagrid('getRows')[editIndex]['zyIds'] = arrayToString(zysid);
$('#pg_persongroup_dg').datagrid('getRows')[editIndex]['fhId'] = arrayToString(fhsid);
$('#pg_persongroup_dg').datagrid('getRows')[editIndex]['jgwryIds'] = arrayToString(jgwzysid);
}
editIndex = undefined;
return true;
} else {
return false;
}
}
//增加一行,处于可编辑状态
function addGroup() {
var staTcSelectRow =$('#isexistzzyid').val();
if (staTcSelectRow) {
var selectId = staTcSelectRow;
if (endEditing()) {
$('#pg_persongroup_dg').datagrid('appendRow', {});
editIndex = $('#pg_persongroup_dg').datagrid('getRows').length - 1;
$('#pg_persongroup_dg').datagrid('selectRow', editIndex)
.datagrid('beginEdit', editIndex);
}
} else {
$.messager.alert('提示', '请先保存驻站员及负责人!', 'info');
}
}
//删除一行
function removeGroup() {
if (editIndex == undefined) {
$.messager.show({
title : '提示',
msg : '请先选择一条记录,再进行删除。'
});
return;
} else {
$.messager
.confirm(
'确认',
'确定要删除该记录?',
function(result) {
if (result) {
var row = $('#pg_persongroup_dg').datagrid(
'getSelected');
var deleterowstr = JSON.stringify(row);
url = '<c:url value="/nnmis/wxunn/deleteGroupPG.tg"/>?deleterowstr='
+ deleterowstr
+ '&pgnumhh='
+ pgnumhh;
$
.post(
url,
deleterowstr,
function(data) {
data = eval('(' + data
+ ')');
if (data.success) {
$.messager.alert(
'提示',
'删除成功!',
'info');
//重新载入组datagrid
$('#pg_persongroup_dg').datagrid('reload',{'stationcode' : stationcode })
$('#groupcomb').combobox('reload','<c:url value="/nnmis/wxunn/makeGroupCombPG.tg"/>')
}
if (data.error) {$.messager.alert( '提示',data.message,'error');
}});
}});
}
}
保存设置的设置的行
function saveGroup() {
if (endEditing()) {
var changerows = $('#pg_persongroup_dg').datagrid('getRows');
var arr = new Array();
for (var i = 0; i < changerows.length; i++) {
if (arr[changerows[i].num] == null) {
arr[changerows[i].num] = '1';
} else {
$.messager.alert('提示', '组编号不能相同!', 'info');
$('#pg_persongroup_dg').datagrid('reload')
return;
}
if (changerows[i].zzId == null || changerows[i].zzId == "") {
$.messager.alert('提示', '组长不能为空', 'info');
$('#pg_persongroup_dg').datagrid('reload')
return;
}
if (changerows[i].fhId != null && changerows[i].fhId != "") {
if(changerows[i].jgwfhId != null && changerows[i].jgwfhId != ""){
$.messager.alert('提示', '不能同时选择防护员和机构外防护员', 'info');
$('#pg_persongroup_dg').datagrid('reload')
return;
}
}
}
var rowstr = JSON.stringify(changerows);
var url = '<c:url value="/nnmis/wxunn/saveGroupPG.tg"/>';
$.post(url, {
groupStr : rowstr
}, function(data) {
data = eval('(' + data + ')');
if (data.success) {
$.messager.alert('提示', '组设置成功!', 'info');
//重新载入出勤人员datagrid
$('#pg_persongroup_dg').datagrid('reload', {})
} else {
$.messager.alert('提示', data.message, 'error');
}
});
}
}
H多行提交解析
var rows = $('#addequlistid').datagrid('getSelections');
var effectRow = new Object();
effectRow["allRows"] = JSON.stringify(rows);
effectRow["status"] = status;
effectRow["pgdate"] = pgdate;
effectRow["wcdate"] = wcdate;
effectRow["srcid"] = qaddid;
var url='<c:url value="/nnmis/view/lsrw/addEqulistLSRWJD.tg"/>';
$.post(url, effectRow, function() {
searchEquList();
$.messager.show({
title : '提示',
msg : '保存成功!'
});
});
JSONArray array = JSONArray.fromObject(rows);
for (int i = 0; i < array.size(); i++) {
Map map = new HashMap<String, String>();
JSONObject obj = (JSONObject) array.get(i);
map.put("id", UUIDGenerator.getUUID());
map.put("pgdate", pgdate);
map.put("code", obj.getString("CODE"));
map.put("srcid", srcid);
map.put("equtypeid", obj.getString("EQUTYPEID"));
map.put("equid", obj.getString("EQUID"));
map.put("equname", obj.getString("EQUNAME"));
map.put("status", status);
map.put("wcdate", wcdate);
flag = lsrwZrorgDAO.insertEqu(map);
if ("nok".equals(flag)) {
break;
}
}
最后
以上就是淡淡海燕为你收集整理的easyUI基本标签 前台基本标签的全部内容,希望文章能够帮你解决easyUI基本标签 前台基本标签所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复