php的对一张表(表里面主键ID被引用)三重迭代去提
如有不懂或者需要更详细资料的朋友请在联系我
如有不懂或者需要更详细资料的朋友请在联系我
<script language="javascript" type="text/javascript"> function submitForm() { var node = $.trim($("#node").val()); alert(node); var name = $.trim($('#name').val()); alert(name); var url = $.trim($('#url').val()); alert(url); var position = $.trim($('#position').val()); var config = $.trim($('#config').val()); var oper = $.trim($('#oper').val()); alert("oper:"+oper); $.post("/Module/addModele1", { 'node':node, 'name':name, 'url':url, 'position':position, 'config':config, 'operId':oper }, function(data) { alert("添加成功"); data = eval('(' + data + ')'); if (data.code == 1) { redirectNav('/Module/index', 'contentDiv', 'resultMsg=操作成功'); } else { redirectNav('/Module/index', 'contentDiv', 'resultMsg=操作失败'); } }); } function submitForm1() { var node = $.trim($("#node1").val()); alert(node); var name = $.trim($('#name1').val()); alert(name); var url = $.trim($('#url1').val()); alert(url); var position = $.trim($('#position1').val()); var config = $.trim($('#config1').val()); var oper = $.trim($('#oper1').val()); alert("oper:"+oper); $.post("/Module/addModele1", { 'node':node, 'name':name, 'url':url, 'position':position, 'config':config, 'operId':oper }, function(data) { alert("添加成功"); data = eval('(' + data + ')'); if (data.code == 1) { redirectNav('/Module/index', 'contentDiv', 'resultMsg=操作成功'); } else { redirectNav('/Module/index', 'contentDiv', 'resultMsg=操作失败'); } }); } function submitForm2() { var node = $.trim($("#smname").val()); alert(node); var name = $.trim($('#name2').val()); alert(name); var url = $.trim($('#url2').val()); alert(url); var position = $.trim($('#position2').val()); var config = $.trim($('#config2').val()); var oper = $.trim($('#oper2').val()); alert("oper:"+oper); $.post("/Module/addModele1", { 'node':node, 'name':name, 'url':url, 'position':position, 'config':config, 'operId':oper }, function(data) { alert("添加成功"); data = eval('(' + data + ')'); if (data.code == 1) { redirectNav('/Module/index', 'contentDiv', 'resultMsg=操作成功'); } else { redirectNav('/Module/index', 'contentDiv', 'resultMsg=操作失败'); } }); } function getmoname(){ var Moname_id = $("#Moname").val(); //获得下拉框中大区域的值 alert(data); if(Moname_id != '') { $.ajax({ dataType:'json', type: "post", url: "/Module/selectModule", data:"Moname_id="+Moname_id, cache:false, beforeSend: function(XMLHttpRequest){ }, success: function(data, textStatus){ $("#smname").empty(); //清空module下拉框 for(var i=0;i<data.length;i++){ $("#smname").append("<option value="+data[i]['id']+"\">"+data[i]['name']+"</option>"); } //给module下拉框添加option 请求出错处理 }, complete: function(XMLHttpRequest, textStatus){ }, error: function(){ } }); } } </script> <div class="chat"> <div class="publish"> <div class="publish_top"> <ul class="clearfix"> <li style="display: none;"><a href="#" class="vote">发起投票</a></li> </ul> 模块名称:<input type='text' id="name" name="name" value="" /> url:<input type='text' id="url" name="url" value="" /><br> position:<input type='text' id="position" name="position" value="" /> 角色ID:<input type='text' id="config" name="config" value="" /> <br> 模块权限:<select name="oper" id="oper"> <volist name="oper" id="o"> <option value="{$o.id}">{$o.name}</option> </volist> </select> <input style="display: none;" type='text' id="node" name="node" value="-1" /> <br> <br> <a href="javascript:submitForm();"> 一级模块添加 </a> <br> <br> 请选择模块:<select name="node1" id="node1"> <volist name="module" id="m"> <option value="{$m.id}">{$m.name}</option> </volist> </select> 模块名称:<input type='text' id="name1" name="name1" /> <br> <br> url:<input type='text' id="url1" name="url1" /> position:<input type='text' id="position1" name="position1" /> <br> 角色ID:<input type='text' id="config1" name="config1" /> 模块权限:<select name="oper1" id="oper1"> <volist name="oper" id="o"> <option value="{$o.id}">{$o.name}</option> </volist> </select> <br> <br> <a href="javascript:submitForm1();"> 二级模块添加 </a> <br> <br> <select name="Moname" id="Moname" onchange="getmoname();"> <volist name="module" id="m"> <neq name="m.subModules" value=""> <option value="{$m.id}">{$m.name}</option> </neq> </volist> </select> <select name="smname" id="smname"> <option id="smname" selected="selected">二级模块</option> </select> 模块名称:<input type='text' id="name2" name="name2" value="" /></div> url:<input type='text' id="url" name="url" value="" /> position:<input type='text' id="position" name="position" value="" /> <br> 角色ID:<input type='text' id="config2" name="config2" value="" /> 模块权限:<select name="oper2" id="oper2"> <volist name="oper" id="o"> <option value="{$o.id}">{$o.name}</option> </volist> </select> <br> <br> <a href="javascript:submitForm2();"> 三级模块添加 </a> <br> <br> <div class="feed"> <div class="feed_type"> <div class="menu"> <div class="menu_top"><span></span></div> </div> <h4>所有的模块</h4> </div> <div class="feed_list"> <div class="afeed"> <div class="afeed_face"><img src="/Res/Platform/img/work/feed_face.jpg" width="50" height="50"> </div> <div class="afeed_detail"> <div class="info"> <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCC"> <tr align="center" style="color: #555;"> <td>模块编号</td> <td>模块名称</td> <td>父类名称</td> <td>操作</td> </tr> <volist name="module" id="m"> <tr> <td>{$m.id}</td> <td>{$m.name}</td> <td>{$m.node}</td> <td><a href="javascript:redirectNav('/Module/onemodule?','contentDiv','id={$m.id}');">修改</a></td> </tr> <volist name="m.subModules" id="sm"> <tr> <td bgcolor="blue">---->{$sm.id}</td> <td>{$sm.name}</td> <td>{$m.id}</td> <td><a href="javascript:redirectNav('/Module/onemodule?','contentDiv','id={$sm.id}');">修改</a></td> </tr> <volist name="sm.subModules" id="sms"> <tr> <td bgcolor="red">-------->{$sms.id}</td> <td>{$sms.name}</td> <td>{$sm.id}</td> <td><a href="javascript:redirectNav('/Module/onemodule?','contentDiv','id={$sms.id}');">修改</a></td> </tr> </volist> </volist> </volist> <!-- <volist name="module" id="module"> <tr align="center" style="color: #555;"> <td type=hidde>{$module.id}</td> <td>{$module.name}</td> <td>{$module.node}</td> <td><a href="#">删除</a></td> </tr> </volist> <volist name="module" id="module"> <volist name="module" id="module"> <tr align="center" style="color: #555;"> <td type=hidde>{$parModules.id}</td> <td>{$parModules.name}</td> <td>{$parModules.node}</td> <td><a href="#">删除</a></td> </tr> </volist> </volist>--> </table> </div> <div class="repeat"> <div class="repeat_arrow"></div> <div class="repeat_put"></div> </div> </div> </div> </div> </div> </div> <div class="rightbar"> <div class="notice"> <h3>公告</h3> <ul> <li><a href="#">平台新功能上线,欢迎使用。</a></li> <li><a href="#">2013年度工商年检已经开始了,请未参加年检的用户马上参加。</a></li> <li><a href="#">2013年度精英学院已经开始了,请未参加的用户马上参加。</a></li> </ul> </div> </div>
2. [文件] onemodule.html ~ 3KB 下载(5) 跳至 [1] [2] [3] [4] [全屏预览]
<script language="javascript" type="text/javascript"> function submitForm3() { alert("ssssss"); var id =$("#id").val(); var node = $("#node").val(); alert(node) var name = $.trim($("#name").val()); alert(name); var url = $.trim($("#url").val()); alert(url); var position = $.trim($("#position").val()); alert(position); var createtime = $.trim($("#createtime").val()); alert(createtime); var config = $.trim($("#config").val()); alert(config); var operId = $("#oper").val(); alert(operId); $.post("/Module/updateModule1", { 'id' : id, 'node' : node, 'name' : name, 'url' : url, 'position' : position, 'config' : config, 'operId' : operId }, function(data) { data = eval('(' + data + ')'); if (data.code == 1) { alert("修改成功!"); redirectNav('/Module/index', 'contentDiv', 'resultMsg=操作成功'); } else { alert("修改失败!"); redirectNav('/Module/index', 'contentDiv', 'resultMsg=操作失败'); } }); } </script> <div class="chat"> <div class="publish"> <div class="publish_top"> <ul class="clearfix"> <li style="display: none;"><a href="#" class="vote">发起投票</a></li> </ul> <h4>请修改您的模块信息</h4> <br> <input style="display: none;" tyep='text' id="id" value="{$id}" /><br> <br> <br> node:<select name="node" id="node"> <option value="-1" selected="selected">-1</option> <volist name="node" id="node"> <eq name="node.id" value="$node1"> <option value="{$node.id}" selected="selected">{$node.id}</option> </eq> <neq name="node.id" value="$node1"> <option value="{$node.id}">{$node.id}</option> </neq> </volist> </select><br> <br> 模板名称: <br> <input tyep='text' id="name" value="{$name}" /><br> <br> url:<br> <input tyep='text' id="url" value="{$url}" /><br> <br></div> position:<br> <input tyep='text' id="position" value="{$position}" /><br> <br> 创建时间:<br> <input tyep='text' id="createtime" value="{$createtime}" /><br> <br> 角色id:<br> <input tyep='text' id="config" value="{$config}" /><br> <br> 模块权限:<select name="oper" id="oper"> <volist name="oper" id="o"> <eq name="o.id" value="$operId"> <option value="{$o.id}" selected="selected">{$o.name}</option> </eq> <neq name="o.id" value="$operId"> <option value="{$o.id}">{$o.name}</option> </neq> </volist> </select> <br> <br> <br> <br> <input style="display: none" id="pid" value="{$pid}" readonly /><br> <h2><a href="javascript:submitForm3();"> 提交 </a></h2> <br> <br> <br> <br> <br> <br> <br> </div> <div class="repeat"> <div class="repeat_arrow"></div> <div class="repeat_put"></div> </div> <div class="rightbar"> <div class="notice"> <h3>公告</h3> <ul> <li><a href="#">平台新功能上线,欢迎使用。</a></li> <li><a href="#">2013年度工商年检已经开始了,请未参加年检的用户马上参加。</a></li> <li><a href="#">2013年度精英学院已经开始了,请未参加的用户马上参加。</a></li> </ul> </div> </div>
3. [文件] ModuleModel.class.php ~ 4KB 下载(5) 跳至 [1] [2] [3] [4] [全屏预览]
<?php /** * 平台模块管理 * @author jiajing * */ import ( '@.Model.Platform.CommonModel' ); class ModuleModel extends CommonModel { const CACHE_PLATFORM_MODULE = 'pmodule'; public function findHomeModule($pid, $proleId) { $results = parent::cacheGet ( self::CACHE_PLATFORM_MODULE . 'HOME' . $pid . $proleId ); if (empty ( $results )) { $results = $this->findModule ( $pid, $proleId ); parent::cacheSet ( self::CACHE_PLATFORM_MODULE . 'HOME' . $pid . $proleId, $results ); } return $results; } /** * 获取登录企业的平台模块 * * @param String $pid * @param String $proleId */ public function findModule($pid, $proleId) { $table = 'tbl_p_r_module prm,tbl_module m'; $where = 'prm.moduleId=m.id'; $where .= ' and prm.pid=' . $pid; $where .= ' and prm.roleId=' . $proleId; $where .= ' and prm.status=1'; $where .= ' and m.status=1'; $field = 'm.id,m.name,m.url,m.position'; $order = 'sequence'; $responder = $this->table ( $table )->where ( $where )->field ( $field )->order ( $order )->select (); if ($responder === false) throw new DBException ( $this->getModelName (), $this->getDbError (), $this->getLastSql () ); return $responder; } public function configModule($config) { $where = array ('status' => 1, 'config' => $config ); $responder = $this->where ( $where )->field ( 'id' )->select (); if ($responder === false) throw new DBException ( $this->getModelName (), $this->getDbError (), $this->getLastSql () ); return $responder; } /** * 查看节点是否为父节点 是:true 否:false */ public function isParent($mid) { $map ['node'] = $mid; $res = $this->where ( $map )->select (); if (count ( $res ) > 0) { return true; } return false; } /** * 获取平台或者企业模块 * @param $node * @param $config * @return array */ public function getmoudel($node, $config) { $map ['node'] = $node; $map ['config'] = $config; $map ['status'] = 1; $result = $this->where ( $map )->select (); if ($result === false) throw new DBException ( $this->getModelName (), $this->getDbError (), $this->getLastSql () ); return $result; } /** * 获取所有平台 * @param $node * @param $config * @return array */ public function findAllModule($node) { $map ['node'] = $node; $result = $this->where ( $map )->select (); if ($result === false) throw new DBException ( $this->getModelName (), $this->getDbError (), $this->getLastSql () ); return $result; } public function findAllModule1($id) { $map ['node'] = $id; $result = $this->where ( $map )->select (); if ($result === false) throw new DBException ( $this->getModelName (), $this->getDbError (), $this->getLastSql () ); return $result; } public function addNodeModule($module) { $responder = $this->add ( $module ); if ($responder === false) throw new DBException ( $this->getModelName (), $this->getDbError (), $this->getLastSql () ); return true; } public function findOneModule($id){ $map['id']=$id; $result = $this->where ($map)->find(); if ($result === false) throw new DBException ( $this->getModelName (), $this->getDbError (), $this->getLastSql () ); return $result; } public function findAllNode(){ $result = $this->select(); if ($result === false) throw new DBException ( $this->getModelName (), $this->getDbError (), $this->getLastSql () ); return $result; } public function updataModule($id,$data){ $map['id']=$id; $result = $this->where($map)->save($data); if ($result === false) throw new DBException ( $this->getModelName (), $this->getDbError (), $this->getLastSql () ); return $result; } } ?>
4. [文件] ModuleAction.class.php ~ 4KB 下载(4) 跳至 [1] [2] [3] [4] [全屏预览]
<?php /** *帮助中心 * @author shendoudou * */ import ( '@.Model.Platform.QuestionModel' ); class ModuleAction extends ContextAction { public function index() { $mModel = D ( 'Module' ); $parModules = $mModel->findAllModule ( - 1 ); // for($i = 0; $i < count ( $result ); $i ++) { // $module [$i] ['id'] = $result [$i] ['id']; // $module [$i]['name']=$result [$i]['name']; // $module [$i]['node']=$result [$i]['node']; // } // for($i = 0; $i < count ( $result ); $i ++) { // $module [$i] ['id'] = $result [$i] ['id']; // $module [$i]['name']=$result [$i]['name']; // $module [$i]['node']=$result [$i]['node']; // } // $result = $mModel->findAllMoudle($module [$i] ['id']); foreach ( $parModules as &$pm ) { $subModules = $mModel->findAllModule ( $pm ['id'] ); $pm ['subModules'] = $subModules; foreach ( $subModules as &$sm ) { $sms = $mModel->findAllModule ( $sm ['id'] ); $sm ['subModules'] = $sms; } $pm ['subModules'] = $subModules; } $oper = array (); $mOper = D ( 'Oper' ); $result = $mOper->findAllOper ( 1 ); for($i = 0; $i < count ( $result ); $i ++) { $oper [$i] ['id'] = $result [$i] ['id']; $oper [$i] ['name'] = $result [$i] ['name']; } $this->assign ( 'oper', $oper ); $this->assign ( 'module', $parModules ); $this->display (); } public function selectModule($Moname_id) { $seModule = array (); $sModel = D ( 'Module' ); $id = $Moname_id; $xModules = $sModel->findAllModule1 ( $id ); for($i = 0; $i < count ( $xModules ); $i ++) { $seModule [$i] ['id'] = $xModules [$i] ['id']; $seModule [$i] ['name'] = $xModules [$i] ['name']; } echo json_encode ( $seModule ); // dump($seModule); // $this->assign('seModule',$seModule); // $this->display(); // } } public function addModele1($node, $name, $url, $position, $config, $operId) { $module = array ('node' => ($node), 'name' => ($name), 'url' => ($url), 'position' => ($position), 'config' => ($config), 'operId' => ($operId) ); $addmoduleModel = D ( "Module" ); $result = $addmoduleModel->addNodeModule ( $module ); if ($result) { $this->outjson ( 1, '成功' ); } else { $this->outjson ( - 1, '失败' ); } } public function updateModule1($id,$node, $name, $url, $position, $config, $operId){ $data = array( 'node' => ($node), 'name' => ($name), 'url' => ($url), 'position' => ($position), 'config' => ($config), 'operId' => ($operId) ); $updateModuleModel = D("Module"); $result=$updateModuleModel->updataModule($id,$data); if ($result) { $this->outjson ( 1, '成功' ); } else { $this->outjson ( - 1, '失败' ); } } public function onemodule() { $id = $_REQUEST ['id']; try { $moModel = D ( 'Module' ); $result = $moModel->findOneModule ( $id ); $id = $result ['id']; $node1 = $result ['node']; $name = $result ['name']; $url = $result ['url']; $position = $result ['position']; $config = $result ['config']; $flag = $result ['flag']; $operId = $result ['operId']; $createtime = $result ['createtime']; $status = $result ['status']; } catch ( Exception $e ) { Logger::error ( $e ); } $oper = array (); $mOper = D ( 'Oper' ); $result = $mOper->findAllOper ( 1 ); for($i = 0; $i < count ( $result ); $i ++) { $oper [$i] ['id'] = $result [$i] ['id']; $oper [$i] ['name'] = $result [$i] ['name']; } $node = array (); $result = $moModel->findAllNode (); for($i = 0; $i < count ( $result ); $i ++) { $node [$i] ['id'] = $result [$i] ['id']; } $this->assign('id',$id); $this->assign ( 'node', $node ); $this->assign ( 'oper', $oper ); $this->assign ( 'node1', $node1 ); $this->assign ( 'name', $name ); $this->assign ( 'url', $url ); $this->assign ( 'position', $position ); $this->assign ( 'config', $config ); $this->assign ( 'flag', $flag ); $this->assign ( 'operId', $operId ); $this->assign ( 'createtime', $createtime ); $this->assign ( 'status', $status ); $this->display (); } } ?>
- 上一篇:HTML上做表单页面上的开启和冻结切换以及功能实
- 下一篇:检测页面是否被百度收录
精彩图集
精彩文章