device.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <?php
  2. # 定义几个常用的选项
  3. $option = array
  4. (
  5. 1 => '显示',
  6. 2 => '不显示',
  7. );
  8. $type = array
  9. (
  10. 1 => '非通讯设备',
  11. 2 => '通讯设备',
  12. );
  13. /*
  14. $system = function()
  15. {
  16. $data = Dever::load('device/system-all');
  17. return $data;
  18. };
  19. */
  20. $system = Dever::url('data.system?id={level}', 'device');
  21. $park = Dever::input('option_park_id');
  22. $server = function() use($park)
  23. {
  24. $param['option_park_id'] = $park;
  25. $data = Dever::load('company/park_server-all', $param);
  26. return $data;
  27. };
  28. $list = function()
  29. {
  30. $data = Dever::load('company/park-all');
  31. return $data;
  32. };
  33. return array
  34. (
  35. # 表名
  36. 'name' => 'device',
  37. # 显示给用户看的名称
  38. 'lang' => '设备列表',
  39. 'menu' => false,
  40. # 数据结构
  41. 'struct' => array
  42. (
  43. 'id' => array
  44. (
  45. 'type' => 'int-11',
  46. 'name' => '设备ID',
  47. 'default' => '',
  48. 'desc' => '',
  49. 'match' => 'is_numeric',
  50. 'search' => 'order',
  51. 'order' => 'desc',
  52. 'list' => true,
  53. ),
  54. 'park_id' => array
  55. (
  56. 'type' => 'int-11',
  57. 'name' => '所属园区',
  58. 'default' => Dever::input('option_park_id', '-1'),
  59. 'desc' => '所属园区ID',
  60. 'match' => 'is_numeric',
  61. 'update' => 'hidden',
  62. 'option' => $list,
  63. 'search' => 'select',
  64. 'list' => 'Dever::load("company/park-one#name", {park_id})',
  65. ),
  66. /*
  67. 'device' => array
  68. (
  69. 'type' => 'varchar-80',
  70. 'name' => '设备ID',
  71. 'default' => '',
  72. 'desc' => '设备ID',
  73. 'match' => 'is_string',
  74. 'update' => 'text',
  75. 'list' => true,
  76. ),
  77. */
  78. 'name' => array
  79. (
  80. 'type' => 'varchar-32',
  81. 'name' => '设备名',
  82. 'default' => '',
  83. 'desc' => '设备名',
  84. 'match' => 'is_string',
  85. 'update' => 'text',
  86. 'list' => true,
  87. ),
  88. 'type' => array
  89. (
  90. 'type' => 'tinyint-1',
  91. 'name' => '设备类型',
  92. 'default' => '1',
  93. 'desc' => '请选择类型',
  94. 'match' => 'is_numeric',
  95. 'option' => $type,
  96. 'update' => 'radio',
  97. 'show' => 'type',
  98. //'list' => true,
  99. ),
  100. 'element_id' => array
  101. (
  102. 'type' => 'varchar-200',
  103. 'name' => '通讯码设备',
  104. 'default' => '1',
  105. 'desc' => '选择通讯码设备',
  106. 'match' => 'is_numeric',
  107. //'list' => true,
  108. 'update' => 'mul',
  109. //'search' => 'mul',
  110. 'option' => $system,
  111. 'order' => 'desc',
  112. 'show' => array('type_2'),
  113. ),
  114. 'element_id_value' => array
  115. (
  116. 'type' => 'int-11',
  117. 'name' => '通讯码设备-最终的值',
  118. 'default' => '1',
  119. 'desc' => '请选择通讯码设备',
  120. 'match' => 'is_numeric',
  121. 'update' => 'hidden',
  122. //'list' => true,
  123. ),
  124. 'server_id' => array
  125. (
  126. 'type' => 'int-11',
  127. 'name' => '通讯服务器',
  128. 'default' => '1',
  129. 'desc' => '选择通讯服务器',
  130. 'match' => 'is_numeric',
  131. 'list' => '{type} == 2 ? {server_id} > 0 ? Dever::load("company/park_server-one#name", {server_id}) : "未选择服务器" : "非通讯设备"',
  132. 'update' => 'radio',
  133. 'option' => $server,
  134. 'show' => array('type_2'),
  135. ),
  136. 'sdate' => array
  137. (
  138. 'type' => 'int-11',
  139. 'name' => '应用日期',
  140. 'match' => 'is_numeric',
  141. 'desc' => '',
  142. 'list' => 'date("Y-m-d", {sdate})',
  143. 'update' => 'time',
  144. 'callback' => 'maketime',
  145. ),
  146. 'info' => array
  147. (
  148. 'type' => 'varchar-100',
  149. 'name' => '备注',
  150. 'default' => '',
  151. 'desc' => '备注',
  152. 'match' => 'option',
  153. 'update' => 'text',
  154. 'list' => true,
  155. 'edit' => true,
  156. ),
  157. 'reorder' => array
  158. (
  159. 'type' => 'int-11',
  160. 'name' => '排序-数值越大越靠前',
  161. 'default' => '1',
  162. 'desc' => '请输入排序',
  163. 'match' => 'option',
  164. 'update' => 'text',
  165. 'search' => 'order',
  166. 'list' => true,
  167. 'order' => 'desc',
  168. 'edit' => true,
  169. ),
  170. 'state' => array
  171. (
  172. 'type' => 'tinyint-1',
  173. 'name' => '状态',
  174. 'default' => '1',
  175. 'desc' => '请选择状态',
  176. 'match' => 'is_numeric',
  177. 'option' => $option,
  178. 'update' => 'radio',
  179. 'list' => true,
  180. ),
  181. 'cdate' => array
  182. (
  183. 'type' => 'int-11',
  184. 'name' => '录入时间',
  185. 'match' => array('is_numeric', time()),
  186. 'desc' => '',
  187. # 只有insert时才生效
  188. 'insert' => true,
  189. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  190. ),
  191. ),
  192. //'auth' => 'company',
  193. 'manage' => array
  194. (
  195. //'insert' => false,
  196. //'edit' => false,
  197. 'excel' => true,
  198. ),
  199. # request 请求接口定义
  200. 'request' => array
  201. (
  202. 'allKey' => array
  203. (
  204. 'type' => 'all',
  205. 'where' => array
  206. (
  207. 'park_id' => 'yes',
  208. 'state' => 1,
  209. 'type' => 2,
  210. ),
  211. 'order' => array('reorder` desc,`element_id_value` desc,`id', 'desc'),
  212. 'col' => '*|element_id_value|',
  213. ),
  214. 'getOrderBySdate' => array
  215. (
  216. 'type' => 'all',
  217. 'where' => array
  218. (
  219. 'park_id' => 'yes',
  220. 'state' => 1,
  221. ),
  222. 'order' => array('sdate` desc, `reorder` desc,`element_id_value` desc,`id', 'desc'),
  223. 'col' => '*',
  224. )
  225. ),
  226. );