mode_demoAction.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. $limit = (int)$this->get('limit', '10');
  42. $page = (int)$this->get('page', '1');
  43. $totalCount = 1520;
  44. $start = ($page-1)*$limit;
  45. for($i=$start;$i<$start + $limit && $i<=$totalCount;$i++){
  46. $rows[] = array(
  47. 'name' => '第'.$i.'个数据',
  48. 'value'=> ''.$i.''
  49. );
  50. }
  51. return array(
  52. 'rows' => $rows,
  53. 'totalCount'=> $totalCount,
  54. 'limit' => $limit,
  55. 'page' => $page,
  56. );
  57. }
  58. //弹出下拉选择多选
  59. public function tanxuancheck()
  60. {
  61. $rows = array();
  62. $tanxuanid = $this->get('tanxuanid'); //根据id过滤数据
  63. //咱们就根据这个id来读取数据源吧
  64. if($tanxuanid==0){
  65. $rows[] = array(
  66. 'name' => '数据0'
  67. );
  68. $rows[] = array(
  69. 'name' => '数据1'
  70. );
  71. }
  72. if($tanxuanid==1){
  73. $rows[] = array(
  74. 'name' => '选择数据0'
  75. );
  76. $rows[] = array(
  77. 'name' => '选择数据1'
  78. );
  79. }
  80. //这个数据源只是简单处理,更复杂就需要自己的业务逻辑了,如读取操作数据库等。
  81. return $rows;
  82. $rows[] = array(
  83. 'name' => '数据1:'.$tanxuan.''
  84. );
  85. $rows[] = array(
  86. 'name' => '数据2'
  87. );
  88. for($i=3;$i<=500;$i++)$rows[] = array(
  89. 'name' => '数据'.$i.''
  90. );
  91. return $rows;
  92. }
  93. //联动获取城市数据数据库表city,根据pid读取
  94. public function getcityAjax()
  95. {
  96. $sheng = $this->post('sheng');//省名称
  97. if(isempt($sheng))return array();//为空
  98. $dbs = m('city');
  99. //获取省ID
  100. $pid = $dbs->getmou('id',"`type`=1 and `name`='$sheng'");//type=1
  101. $rows = $dbs->getall("`pid`='$pid'",'name','`sort`'); //查找数据
  102. return $rows;//返回数据
  103. }
  104. //联动获取城市数据数据库表city,根据pid读取
  105. public function getxianAjax()
  106. {
  107. $city = $this->post('city');//省名称
  108. if(isempt($city))return array();//为空
  109. $dbs = m('city');
  110. //获取城市ID
  111. $pid = $dbs->getmou('id',"`type`=2 and `name`='$city'");//type=2
  112. $rows = $dbs->getall("`pid`='$pid'",'name','`sort`'); //查找数据
  113. return $rows;//返回数据
  114. }
  115. //下拉框市的数据源
  116. public function citydata()
  117. {
  118. return $this->getshegnxiandat(arrvalue($this->rs,'sheng'), 1);
  119. }
  120. //下拉框县的数据源
  121. public function xiandata()
  122. {
  123. return $this->getshegnxiandat(arrvalue($this->rs,'shi'), 2);
  124. }
  125. //获取下级
  126. private function getshegnxiandat($name, $type)
  127. {
  128. if(isempt($name))return array();
  129. $dbs = m('city');
  130. //获取城市ID
  131. $pid = $dbs->getmou('id',"`type`='$type' and `name`='$name'");
  132. $rows = $dbs->getall("`pid`='$pid'",'name','`sort`'); //查找数据
  133. return $rows;//返回数据
  134. }
  135. }
粤ICP备19079148号