Manager.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?php
  2. /**
  3. * FecShop file.
  4. *
  5. * @link http://www.fecshop.com/
  6. * @copyright Copyright (c) 2016 FecShop Software LLC
  7. * @license http://www.fecshop.com/license/
  8. */
  9. namespace fecadmin\block\account;
  10. use fecadmin\FecadminbaseBlock;
  11. use fecadmin\models\AdminUser;
  12. use fecadmin\models\AdminRole;
  13. use fec\helpers\CUrl;
  14. /**
  15. * @author Terry Zhao <2358269014@qq.com>
  16. * @since 1.0
  17. */
  18. class Manager extends FecadminbaseBlock{
  19. public $_obj ;
  20. public $_paramKey = 'id';
  21. public $_defaultDirection = 'asc';
  22. # 初始化参数
  23. public function initParam(){
  24. # 定义编辑和删除的URL
  25. $this->_editUrl = CUrl::getUrl("fecadmin/account/manageredit");
  26. $this->_deleteUrl = CUrl::getUrl("fecadmin/account/managerdelete");
  27. $this->_obj = new AdminUser;
  28. $this->_paramKey = 'id';
  29. /*
  30. # 自定义参数如下:
  31. #排序默认为主键倒序
  32. $this->_orderField = 'created_at';
  33. $this->_sortDirection = 'asc';
  34. # 主键默认为id
  35. $this->_paramKey = 'id';
  36. #第一次打开默认为第一页,一页显示50个
  37. $this->_pageNum = 1;
  38. $this->_numPerPage;
  39. */
  40. parent::initParam();
  41. }
  42. public function getLastData(){
  43. # 返回数据的函数
  44. # 隐藏部分
  45. $pagerForm = $this->getPagerForm();
  46. # 搜索部分
  47. $searchBar = $this->getSearchBar();
  48. # 编辑 删除 按钮部分
  49. $editBar = $this->getEditBar();
  50. # 表头部分
  51. $thead = $this->getTableThead();
  52. # 表内容部分
  53. $tbody = $this->getTableTbody();
  54. # 分页部分
  55. $toolBar = $this->getToolBar($this->_param['numCount'],$this->_param['pageNum'],$this->_param['numPerPage']);
  56. return [
  57. 'pagerForm' => $pagerForm,
  58. 'searchBar' => $searchBar,
  59. 'editBar' => $editBar,
  60. 'thead' => $thead,
  61. 'tbody' => $tbody,
  62. 'toolBar' => $toolBar,
  63. ];
  64. }
  65. # 定义搜索部分字段格式
  66. public function getSearchArr(){
  67. $data = [
  68. [ # selecit的Int 类型
  69. 'type'=>'select',
  70. 'title'=>'状态',
  71. 'name'=>'status',
  72. 'columns_type' =>'int', # int使用标准匹配, string使用模糊查询
  73. 'value'=> [ # select 类型的值
  74. AdminUser::STATUS_ACTIVE=>'激活',
  75. AdminUser::STATUS_DELETED=>'关闭',
  76. ],
  77. ],
  78. [ # 字符串类型
  79. 'type'=>'inputtext',
  80. 'title'=>'用户名',
  81. 'name'=>'username' ,
  82. 'columns_type' =>'string'
  83. ],
  84. [ # 字符串类型
  85. 'type'=>'inputtext',
  86. 'title'=>'员工编号',
  87. 'name'=>'code' ,
  88. 'columns_type' =>'string'
  89. ],
  90. [ # 字符串类型
  91. 'type'=>'inputtext',
  92. 'title'=>'邮箱',
  93. 'name'=>'email' ,
  94. 'columns_type' =>'string'
  95. ],
  96. [ # 时间区间类型搜索
  97. 'type'=>'inputdatefilter',
  98. 'name'=> 'created_at_datetime',
  99. 'columns_type' =>'datetime',
  100. 'value'=>[
  101. 'gte'=>'用户创建时间开始',
  102. 'lt' =>'用户创建时间结束',
  103. ]
  104. ],
  105. ];
  106. return $data;
  107. }
  108. # 定义表格显示部分的配置
  109. public function getTableFieldArr(){
  110. $table_th_bar = [
  111. [
  112. 'orderField' => 'id',
  113. 'label' => 'ID',
  114. 'width' => '110',
  115. 'align' => 'center',
  116. ],
  117. [
  118. 'orderField' => 'username',
  119. 'label' => '用户名称',
  120. 'width' => '110',
  121. 'align' => 'center',
  122. ],
  123. [
  124. 'orderField' => 'person',
  125. 'label' => '姓名',
  126. 'width' => '110',
  127. 'align' => 'center',
  128. ],
  129. [
  130. 'orderField' => 'code',
  131. 'label' => '员工编号',
  132. 'width' => '110',
  133. 'align' => 'center',
  134. ],
  135. /*
  136. [
  137. 'orderField' => 'role',
  138. 'width' => '110',
  139. 'align' => 'left',
  140. 'display' => AdminRole::getAdminRoleArr(),
  141. ],
  142. */
  143. [
  144. 'orderField' => 'email',
  145. 'width' => '110',
  146. 'align' => 'center',
  147. ],
  148. [
  149. 'orderField' => 'created_at_datetime',
  150. //'label' => '用户名称',
  151. 'width' => '190',
  152. 'align' => 'center',
  153. //'convert' => ['datetime' =>'date'],
  154. ],
  155. [
  156. 'orderField' => 'updated_at_datetime',
  157. //'label' => '用户名称',
  158. 'width' => '190',
  159. 'align' => 'center',
  160. //'convert' => ['datetime' =>'date'], # int date datetime 显示的转换
  161. ],
  162. [
  163. 'orderField' => 'status',
  164. //'label' => '用户名称',
  165. 'width' => '60',
  166. 'align' => 'center',
  167. 'display' => [ # 显示转换 ,譬如 值为1显示为激活,值为10显示为关闭
  168. '1' => '激活',
  169. '10' => '关闭',
  170. ],
  171. ],
  172. /*
  173. [
  174. 'orderField' => 'allowance',
  175. //'label' => '用户名称',
  176. //'width' => '190',
  177. 'align' => 'center',
  178. ],
  179. [
  180. 'orderField' => 'allowance_updated_at',
  181. //'label' => '用户名称',
  182. //'width' => '190',
  183. 'align' => 'center',
  184. ],
  185. */
  186. ];
  187. return $table_th_bar ;
  188. }
  189. }