配置实现-增删改查的配置实例

以部门为例:

1、部门的列表配置(含增删改查的按钮及删除的实现)

<?xml version="1.0" encoding="utf-8"?>
<root>
<myquery title="{0}部门信息列表" islogicdeal="false" isfirstload="true" allowsorting="true" allowpaging="true" pagervisible="true" >
<title parameters="parentid">
select name from S_Dep where id='{0}'
</title>
<select keycolumnnames="id" ismultiselect="false" issingleselect="true" isshowrownum="false" sortdirection="ascending">
<column name="id" title="编号" width="40px">
s_dep.id
</column>
<column name="name" title="名称">
s_dep.name
</column>
<column name="manager" title="负责人" width="180px">
s_user.name
</column>
<column name="sn" title="排序" width="40px">
s_dep.sn
</column>
<column name="iflag" title="状态" width="40px" sort="s_dep.iflag">
case when s_dep.iflag=1 then '' else '停用' end
</column>
</select>
<from type="table">
<table title="部门表">s_dep</table>
<table title="人员表">left join s_user on s_dep.manager=s_user.id</table>
</from>
<where isparameter="true" isshowappend="true" issession="false">
<append type="default">
and s_dep.parentid is not null
</append>
<append type="sql" name="sql" title="角色数据权限:">
<sql>
<![CDATA[select max(S_Role.DataScope)
from S_Role
inner join S_RoleUser on S_RoleUser.roleid=S_Role.id
where S_RoleUser.uid='#USERID#']]>
</sql>
<value when="" title="所在部门的" where="#USERDEPID#%"><![CDATA[and s_dep.id like {0}]]></value>
<value when="0" title="所在部门的" where="#USERDEPID#%"><![CDATA[and s_dep.id like {0}]]></value>
<value when="1" title="所在部门的" where="#USERDEPID#%"><![CDATA[and s_dep.id like {0}]]></value>
</append>
<append type="querystring" name="parentid" title="上级为所选部门">
and s_dep.parentid={0}
</append>
<colgroup>
<col width="80px">
</col>
<col width="100px">
</col>
<col width="80px">
</col>
<col>
</col>
</colgroup>
<column name="name" title="部门名称" width="100px" target="all" cssclass="input_text">
and s_dep.name like {0}
</column>
<column name="iflag" title="状态" type="selectint" dataformat=",全部" urlformatstring="1,启用;0,停用">
and s_dep.iflag={0}
</column>
</where>
<order>
s_dep.id
</order>
<buttons>
<button name="btnAdd" title="新 增" type="dialog" cssclass="input_button" windowwidth="350" windowheight="350" parameters="parentid">
tmp/MyEdit.aspx?n=editdep
</button>
<button name="btnEdit" title="编 辑" type="dialog" cssclass="input_button" isselectedrow="true" windowwidth="350" windowheight="350">
tmp/MyEdit.aspx?n=editdep&amp;id={0}
</button>
<button name="toexcel" title="导出Excel" type="toexcel" cssclass="input_button">
</button>
<button name="delnot" title="删 除" type="runsql" isselectedrow="true" cssclass="input_button" confirminfo="确认删除选中的记录吗?">
<sql>select case when count(*)>0 then 1 else 0 end from s_user where depid='{0}'</sql>
<sql value="1" title="选择记录停用成功">update s_dep set iflag=0 where id='{0}'</sql>
<sql value="0">delete from s_dep where parentid='{0}'</sql>
<sql value="0" title="选择记录删除成功">delete from s_dep where id='{0}'</sql>
</button>
<button name="btnUser" title="人员管理" type="redirect" cssclass="input_button" isselectedrow="true">
tmp/MyQuery.aspx?n=listuser&amp;depid={0}
</button>
<button name="btnSun" title="下级部门管理" type="redirect" cssclass="input_button" isselectedrow="true">
tmp/MyQuery.aspx?n=listdep&amp;parentid={0}
</button>
<button name="btnReturn" title="返 回" type="redirect" cssclass="input_button">
tmp/myQuery.aspx?n=listdep&amp;parentid=
</button>
</buttons>
</myquery>

2、部门编辑的配置

<?xml version="1.0" encoding="utf-8"?>
<root>
<myquery title="部门信息" pagesize="0">
<select>
<colgroup>
<col width="100px">
</col>
<col>
</col>
</colgroup>
<column name="id" title="部门编号" width="200px" maxlength="20" visible="false" cssclass="input_text">
<validates>
<validate type="js" scope="add">checkid()</validate>
<validate type="isexit" title="编号已经存在不能重复" scope="add">
</validate>
</validates>
</column>
<column name="name" title="名称" width="200px" maxlength="25" cssclass="input_text">
<validates>
<validate type="isnotnull">
</validate>
</validates>
</column>
<column name="manager" title="负责人" width="200px" type="textajax" urlformatstring="/WebService.asmx" usefields="GetUserNameList" dataformat="{0:ID}" maxlength="1" cssclass="text_ajax">
<validates>
<validate type="isnotnull" scope="edit">
</validate>
<validate type="servervalidate" title="人员必须存在" scope="edit">
LTKJ.BAL.QueryValidate
</validate>
</validates>
</column>
<column name="parentid" title="上级部门" width="205px" type="select" dataformat=",保定市" urlformatstring="sql:select id,case when parentid='' then '' else ' ' end+name from s_dep where iflag=1 and ParentID is not null order by id,sn" cssclass="select">
</column>
<column name="sn" title="排序" type="textint" width="100px" maxlength="6" value="0" cssclass="input_num">
<validates>
<validate type="isnotnull">
</validate>
</validates>
</column>
<column name="iflag" title="状态" width="205px" type="selectint" urlformatstring="1,启用;0,停用">
</column>
<javascript>
<![CDATA[function checkid()
{
var objid = document.getElementById('id');
if (objid)
{
if (objid.value.search(/^[0-9a-zA-Z]+$/)==-1)
{
alert('不是有效的部门编号,不能为空且必须为字母和数字');
objid.select();
objid.focus();
return false;
}
}
var objparentid = document.getElementById('parentid');
if (objid && objparentid && objparentid.value!='0')
{
if (objid.value.indexOf(objparentid.value)!=0 || objid.value.length<=objparentid.value.length)
{
alert("编号必须以上级部门的编号作为开始,如"+objparentid.value+"01");
objid.select();
objid.focus();
return false;
}
}
return true;
}]]>
</javascript>
</select>
<from type="table">
<table title="部门表">s_dep</table>
</from>
<where isparameter="true">
<append type="querystring" name="id">
id={0}
</append>
</where>
<buttons>
<button name="save" title="提 交" type="save" cssclass="input_button">
</button>
<button name="btnReturn" title="取 消" type="doscript" cssclass="input_button">
window.opener=null;window.open('','_self');window.close();
</button>
</buttons>
</myquery>

欢迎访问:http://121.18.78.216 适易查询分析、工作流、内容管理及项目管理演示平台

你可能感兴趣的:(增删改查)