mode_demoAction.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /**
  3. * 此文件是流程模块【demo.演示测试】对应控制器接口文件。
  4. */
  5. class mode_demoClassAction extends inputAction{
  6. /**
  7. * 重写函数:保存前处理,主要用于判断是否可以保存
  8. * $table String 对应表名
  9. * $arr Array 表单参数
  10. * $id Int 对应表上记录Id 0添加时,大于0修改时
  11. * $addbo Boolean 是否添加时
  12. * return array('msg'=>'错误提示内容','rows'=> array()) 可返回空字符串,或者数组 rows 是可同时保存到数据库上数组
  13. */
  14. protected function savebefore($table, $arr, $id, $addbo){
  15. }
  16. /**
  17. * 重写函数:保存后处理,主要保存其他表数据
  18. * $table String 对应表名
  19. * $arr Array 表单参数
  20. * $id Int 对应表上记录Id
  21. * $addbo Boolean 是否添加时
  22. */
  23. protected function saveafter($table, $arr, $id, $addbo){
  24. }
  25. //读取客户的数据源
  26. public function getmycust()
  27. {
  28. //webmain\model\crmModel.php
  29. $rows = m('crm')->getmycust($this->adminid); //这个是写的否方法了
  30. return $rows;//返回,在去试试
  31. }
  32. public function getcustinfoAjax()
  33. {
  34. $custid = (int)$this->get('custid');//客户Id
  35. $rs = m('customer')->getone('`id`='.$custid.'');//读取客户,这个是操作数据库方法,官网有帮助
  36. return $rs;//返回
  37. }
  38. //弹出下拉选择单选
  39. public function tanxuan()
  40. {
  41. for($i=1;$i<=1520;$i++)
  42. $rows[] = array(
  43. 'name' => '第'.$i.'个数据',
  44. 'value'=> ''.$i.''
  45. );
  46. return $rows;
  47. }
  48. //弹出下拉选择多选
  49. public function tanxuancheck()
  50. {
  51. $rows = array();
  52. $tanxuanid = $this->get('tanxuanid'); //根据id过滤数据
  53. //咱们就根据这个id来读取数据源吧
  54. if($tanxuanid==0){
  55. $rows[] = array(
  56. 'name' => '数据0'
  57. );
  58. $rows[] = array(
  59. 'name' => '数据1'
  60. );
  61. }
  62. if($tanxuanid==1){
  63. $rows[] = array(
  64. 'name' => '选择数据0'
  65. );
  66. $rows[] = array(
  67. 'name' => '选择数据1'
  68. );
  69. }
  70. //这个数据源只是简单处理,更复杂就需要自己的业务逻辑了,如读取操作数据库等。
  71. return $rows;
  72. $rows[] = array(
  73. 'name' => '数据1:'.$tanxuan.''
  74. );
  75. $rows[] = array(
  76. 'name' => '数据2'
  77. );
  78. for($i=3;$i<=500;$i++)$rows[] = array(
  79. 'name' => '数据'.$i.''
  80. );
  81. return $rows;
  82. }
  83. //联动获取城市数据数据库表city,根据pid读取
  84. public function getcityAjax()
  85. {
  86. $sheng = $this->post('sheng');//省名称
  87. if(isempt($sheng))return array();//为空
  88. $dbs = m('city');
  89. //获取省ID
  90. $pid = $dbs->getmou('id',"`type`=1 and `name`='$sheng'");//type=1
  91. $rows = $dbs->getall("`pid`='$pid'",'name','`sort`'); //查找数据
  92. return $rows;//返回数据
  93. }
  94. //联动获取城市数据数据库表city,根据pid读取
  95. public function getxianAjax()
  96. {
  97. $city = $this->post('city');//省名称
  98. if(isempt($city))return array();//为空
  99. $dbs = m('city');
  100. //获取城市ID
  101. $pid = $dbs->getmou('id',"`type`=2 and `name`='$city'");//type=2
  102. $rows = $dbs->getall("`pid`='$pid'",'name','`sort`'); //查找数据
  103. return $rows;//返回数据
  104. }
  105. //下拉框市的数据源
  106. public function citydata()
  107. {
  108. return $this->getshegnxiandat(arrvalue($this->rs,'sheng'), 1);
  109. }
  110. //下拉框县的数据源
  111. public function xiandata()
  112. {
  113. return $this->getshegnxiandat(arrvalue($this->rs,'shi'), 2);
  114. }
  115. //获取下级
  116. private function getshegnxiandat($name, $type)
  117. {
  118. if(isempt($name))return array();
  119. $dbs = m('city');
  120. //获取城市ID
  121. $pid = $dbs->getmou('id',"`type`='$type' and `name`='$name'");
  122. $rows = $dbs->getall("`pid`='$pid'",'name','`sort`'); //查找数据
  123. return $rows;//返回数据
  124. }
  125. }
粤ICP备19079148号