1.企业员工添加删除、部门添加编辑删除
实际:
完成70%
收获:
1.如何将企业信息表里面的id和name合并到部门表里面来?
用 union
select ep.id as id, ep.enterpriseName as name from enterprise ep union select d.id as id, d.departmentName as name from department d
2.input type=radio 实现赋值取值,利用jQuery绑定单击事件
$("input[type='radio']").bind("click", function(e){ var theEvent = window.event || e; var theObj = theEvent.target || theEvent.srcElement; var selectedValue = $(this).val(); if (selectedValue == "0") { $('input[name="' + theObj.name + '"][value="1"]').removeAttr("checked"); $('input[name="' + theObj.name + '"][value="0"]').attr("checked", true); } else { $('input[name="' + theObj.name + '"][value="0"]').removeAttr("checked"); $('input[name="' + theObj.name + '"][value="1"]').attr("checked", true); } }); // 打开Dialog时让后台传递过来的值处于选中状态 $('input[name=Sex][value="' + rowData.Sex + '"]').attr("checked", true); // 提交时获取选中的值 Sex : $("input[name='Sex'][checked]").val();
3.mysql函数,先开启函数支持:
set Global log_bin_trust_function_creators=1;
然后写函数
cast(rootId as CHAR); concat(sTemp,',',sTempChd); SELECT group_concat(id) INTO sTempChd FROM treeNodes where FIND_IN_SET(pid,sTempChd)>0;
eg:查询所有子节点,包括自己
Drop Function if exists getChildList CREATE FUNCTION getChildList (rootId INT) RETURNS varchar(1000) BEGIN DECLARE sTemp VARCHAR(1000); DECLARE sTempChd VARCHAR(1000); SET sTemp = '$'; SET sTempChd =cast(rootId as CHAR); WHILE sTempChd is not null DO SET sTemp = concat(sTemp,',',sTempChd); SELECT group_concat(id) INTO sTempChd FROM treeNodes where FIND_IN_SET(pid,sTempChd)>0; END WHILE; RETURN sTemp; END //调用 select getChildList(10081); // 输出 '$,10081,10086'