Input.php 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360
  1. <?php
  2. namespace Manage\Src\Lib;
  3. use Dever;
  4. class Input
  5. {
  6. public static function __callStatic($name, $param = array())
  7. {
  8. $method = '_' . $name;
  9. $result = call_user_func_array(array(__CLASS__, $method), $param);
  10. if ($result && is_string($result) && $name != 'pageLeft') {
  11. if (layadmin()) {
  12. if (strstr($result, '<select')) {
  13. $result = str_replace('form-control', 'form-control layui-input layui-select', $result);
  14. $result = str_replace('<select', '<select lay-ignore ', $result);
  15. } elseif (strstr($result, 'radio')) {
  16. $result = str_replace('form-control', 'form-control layui-radio', $result);
  17. } elseif (strstr($result, 'checkbox')) {
  18. $result = str_replace('form-control', 'form-control layui-checkbox', $result);
  19. } else {
  20. $result = str_replace('form-control', 'form-control layui-input', $result);
  21. }
  22. if ((isset($param[0]['type']) && $param[0]['type'] == 'hidden')) {
  23. $result = '<div class="layui-inline" style="display:none;">'.$result.'</div>';
  24. } elseif (isset($param[1]) && !$param[1] && ((isset($param[0]['update']) && $param[0]['update'] != 'hidden') || !isset($param[0]['update']))) {
  25. $result = '<div class="layui-inline"><div class="layui-input-inline">'.$result.'</div></div>';
  26. } else {
  27. $result = '<div>'.$result.'</div>';
  28. }
  29. } else {
  30. if (isset($param[0]['update']) && $param[0]['update'] == 'hidden') {
  31. } elseif (isset($param[1]) && !$param[1]) {
  32. $result = '<div style="display:inline;margin-right: 10px;">'.$result.'</div>';
  33. }
  34. }
  35. }
  36. return $result;
  37. }
  38. /**
  39. * 地图
  40. *
  41. * @return string
  42. */
  43. public static function _map($param)
  44. {
  45. $url = Dever::url('map', 'manage');
  46. $html = self::text($param);
  47. $id = $param['name'] . '_value';
  48. $iframe_id = $id . '_map';
  49. $html .= '<iframe id="'.$iframe_id.'" src="'.$url.'" style="margin-top:10px;display: block;" width="800" height="500" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes" onload="mapLoad()"></iframe>';
  50. $html .= '<script>$(function()
  51. {
  52. $("#'.$id.'").blur(function()
  53. {
  54. layui.layer.msg("搜索中...");
  55. $("#'.$iframe_id.'")[0].contentWindow.search($(this).val());
  56. });
  57. });
  58. function mapLoad(){
  59. if ($("#'.$id.'").val()) {
  60. $("#'.$iframe_id.'")[0].contentWindow.showMaker($("#'.$id.'").val());
  61. }
  62. }
  63. function closeMsg() {
  64. layui.layer.closeAll();
  65. }
  66. function setMap(x, y, z) {
  67. var val = $("#'.$id.'").val();
  68. if (val) {
  69. var temp = val.split(",");
  70. val = temp[0];
  71. }
  72. $("#'.$id.'").val(val + "," + x + "," + y + "," + z);
  73. }</script>';
  74. return $html;
  75. }
  76. /**
  77. * desc
  78. *
  79. * @return string
  80. */
  81. public static function _modal($modal, $desc)
  82. {
  83. return '<a href="javascript:;" onclick="showAlert($(this).next().html());initLayui();">' . $modal . '</a><div style="display:none;">' . $desc . '</div>';
  84. }
  85. /**
  86. * desc
  87. *
  88. * @return string
  89. */
  90. public static function _desc($desc)
  91. {
  92. return '';
  93. return $desc;
  94. }
  95. /**
  96. * hr 分割线
  97. *
  98. * @return string
  99. */
  100. public static function _hr($param)
  101. {
  102. if (layadmin()) {
  103. $col = '';
  104. if (isset($param['right'])) {
  105. $col = '</div><div class="layui-col-md6">';
  106. }
  107. $html = '</div></div></div>'.$col.'<div class="layui-card"><div class="layui-card-header">[' . $param['name'] . ']</div><div class="layui-card-body"><div>';
  108. return $html;
  109. }
  110. return '<div class="dever_form_hr ' . (isset($param['class']) ? $param['class'] : '') . '" ' . (isset($param['attr']) ? $param['attr'] : '') . '>' . $param['name'] . '</div>';
  111. }
  112. /**
  113. * cue
  114. *
  115. * @return string
  116. */
  117. public static function _cue($param)
  118. {
  119. $param['cue'] = isset($param['cue']) ? $param['cue'] : '';
  120. if (strpos($param['name'], '-') !== false) {
  121. $temp = explode('-', $param['name']);
  122. $param['name'] = $temp[0];
  123. $param['cue'] = $temp[1];
  124. } elseif (strpos($param['name'], '(') !== false) {
  125. $temp = explode('(', $param['name']);
  126. $param['name'] = $temp[0];
  127. $param['cue'] = str_replace(')', '', $temp[1]);
  128. } elseif (strpos($param['name'], '(') !== false) {
  129. $temp = explode('(', $param['name']);
  130. $param['name'] = $temp[0];
  131. $param['cue'] = str_replace(')', '', $temp[1]);
  132. }
  133. return $param;
  134. }
  135. /**
  136. * pageLeft
  137. *
  138. * @return string
  139. */
  140. public static function _pageLeft($param)
  141. {
  142. $param = self::cue($param);
  143. if ($param['cue']) {
  144. $param['cue'] = '<span style="font-size:12px;font-weight:normal;font-color:#bababa;margin-left:5px;">[' . $param['cue'] . ']</span>';
  145. }
  146. $class = '';
  147. $style = '';
  148. if (layadmin()) {
  149. //$class = 'layui-form-label';
  150. if (isset($param['update']) && is_array($param['update'])) {
  151. $style = ' style="margin:10px;"';
  152. }
  153. }
  154. $html = '<div '.$style.'><label style="font-size:14px;font-weight:bold;" class="'.$class.'">' . $param['name'] . $param['cue'] . '</label></div>';
  155. return $html;
  156. }
  157. /**
  158. * textarea
  159. *
  160. * @return string
  161. */
  162. public static function _textarea($param)
  163. {
  164. return '<textarea style="height:100px;" update_type="value" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" >' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '</textarea>';
  165. return '<textarea style="height:100px;" update_type="value" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '">' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '</textarea>';
  166. }
  167. private static function uploadHandle($param)
  168. {
  169. $html = $style = '';
  170. $div = array('', '');
  171. $type = 'button';
  172. $yun = false;
  173. if (isset($param['upload']) && ($param['upload'] == 'yun' || $param['upload'] == 'qiniu')) {
  174. $upload = Dever::project('upload');
  175. if ($upload && !strstr($upload['path'], 'http')) {
  176. $upload = Dever::load('upload/yun.token?return=1&key=' . $param['key']);
  177. } else {
  178. $upload = Dever::load('upload/yun.token?key=' . $param['key']);
  179. }
  180. if (isset($upload['domain'])) {
  181. $bucket = $upload['bucket'];
  182. $domain = $upload['domain'];
  183. $token = $upload['uptoken'];
  184. $host = $upload['host'];
  185. $cover = 1;
  186. $yun = true;
  187. if (isset($param['cover']) && $param['cover']) {
  188. $cover = $param['cover'];
  189. } elseif (isset($upload['cover']) && $upload['cover']) {
  190. $cover = $upload['cover'];
  191. }
  192. $date = explode('-', date("Y-m-d"));
  193. $path = $param['key'] . '/' . $date[0] . '/' . $date[1] . '/' . $date[2] . '/';
  194. $html = ' m="'.$upload['type'].'" cover="'.$cover.'" domain="'.$domain.'" bucket="'.$bucket.'" path="'.$path.'" host="'.$host.'" token="'.$token.'" ';
  195. }
  196. }
  197. if (isset($param['large']) && $param['large'] && isset($upload['domain'])) {
  198. $html .= ' l="1" ';
  199. $type = 'file';
  200. $div = array('<div class="layui-input" style=" position: relative;
  201. display: inline-block;
  202. border-radius: 2px;
  203. color: black;
  204. text-decoration: none;
  205. text-indent: 0;
  206. line-height: 37px;
  207. height: 37px;
  208. width: 97px;
  209. padding-left: 19px;">', '本地上传</div>');
  210. $style = 'position: absolute;
  211. font-size: 21px;
  212. right: 0;
  213. top: 0;
  214. opacity: 0;';
  215. }
  216. return array($html, $type, $div, $style, $yun);
  217. }
  218. private static function uploadParam($param)
  219. {
  220. if (isset($param['upload_key'])) {
  221. $param['key'] = $param['upload_key'];
  222. }
  223. if (isset($param['upload_place'])) {
  224. $param['place'] = $param['upload_place'];
  225. }
  226. if (!isset($param['upload_search'])) {
  227. $param['upload_search_value'] = $param['project'] . '-' . $param['table'] . '.' . $param['col'];
  228. $param['upload_search'] = $param['upload_search_value'];
  229. } else {
  230. if (!isset($param['upload_search_value'])) {
  231. $param['upload_search_value'] = $param['upload_search'];
  232. }
  233. }
  234. $param['upload_search_show'] = $param['upload_search'];
  235. if (strstr($param['upload_search'], '#')) {
  236. $temp = explode('#', $param['upload_search']);
  237. $param['upload_search_show'] = $temp[0];
  238. if ($temp[1] > 0) {
  239. $param['upload_search_show'] .= '_<script>document.write($("#upload_'.$temp[1].'_value").val());</script>';
  240. }
  241. }
  242. if (isset($param['place']) && $param['place']) {
  243. //$pic = 'src="http://placehold.it/' . $param['place'] . '"';
  244. //$param['placeimg'] = '<img src="http://temp.im/' . $param['place'] . '" class="place" width="150" />';
  245. $place = $param['place'];
  246. $default = '';
  247. if (strstr($param['place'], '?')) {
  248. $temp = explode('?', $param['place']);
  249. $param['place'] = $temp[0];
  250. $default .= '&';
  251. } else {
  252. $default .= '?';
  253. }
  254. if (strstr($place, '*')) {
  255. $place = str_replace('*', 'x', $place);
  256. } elseif (strstr($place, 'X')) {
  257. $place = str_replace('X', 'x', $place);
  258. } else {
  259. $place = $param['place'] . 'x' . $param['place'];
  260. }
  261. $text = '';
  262. //$text = "" . $place . "px \n 大小不能超过2M";
  263. //$text = "图片尺寸".$place."px \n 也可以上传等比尺寸 \n 上传大小不能超过2M \n 支持JPG、PNG、 GIF格式";
  264. //$default .= 'auto=yes&theme=social&text=' . $text;
  265. $default .= 'auto=yes&text=' . $text;
  266. $place .= $default;
  267. $param['placeimg'] = '<img src="holder.js/' . $place . '" class="place" style="width:150px" onclick="$(this).parent().parent().find(\'.image_upload\').click()"/>';
  268. } else {
  269. $param['place'] = '';
  270. $param['placeimg'] = '';
  271. }
  272. if (isset($param['upload_call'])) {
  273. $param['call'] = $param['upload_call'];
  274. }
  275. if (!isset($param['call'])) {
  276. $param['call'] = '';
  277. }
  278. return $param;
  279. }
  280. /**
  281. * image
  282. *
  283. * @return string
  284. */
  285. public static function _image($param)
  286. {
  287. $param = self::uploadParam($param);
  288. if (isset($param['value']) && $param['value']) {
  289. $pic = 'src="' . $param['value'] . '"';
  290. if (strstr($param['value'], '.cr')) {
  291. $temp = explode('.cr', $param['value']);
  292. $pic .= ' data-src="' . $temp[0] . '"';
  293. }
  294. } else {
  295. $pic = 'src="" style=display:none;';
  296. }
  297. $class = 'width:100px;display:inline;';
  298. if (layadmin()) {
  299. $class .= 'padding-left:0px;';
  300. }
  301. $upload = self::uploadHandle($param);
  302. $button = $upload[2][0] . '<input type="'.$upload[1].'" style="'.$class.$upload[3].'" class="form-control image_upload" '.$upload[0].' v="' . $param['name'] . '_' . $param['index'] . '" i="' . $param['name'] . '_info_value' . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" call="' . $param['call'] . '" upload_search_value="'.$param['upload_search_value'].'" place="'.$param['place'].'" value="本地上传"/>' . $upload[2][1];
  303. return $button .'
  304. <input type="button" style="'.$class.'" class="form-control upload_show" v="' . $param['name'] . '_' . $param['index'] . '" i="' . $param['name'] . '_info_value' . '" id="file_show_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" call="' . $param['call'] . '" upload_search="'.$param['upload_search'].'" value="图库"/><span style="margin-left:10px;font-size:8px;">标识:'.$param['upload_search_show'].'</span>
  305. <div style="margin-top:10px;display:none;" class="layui-progress layui-progress-big" id="file_' . $param['name'] . '_' . $param['index'] . '_progress" lay-filter="file_' . $param['name'] . '_' . $param['index'] . '_progress" lay-showPercent="true">
  306. <div class="layui-progress-bar" lay-percent="0%"></div>
  307. </div>
  308. <div style="margin-top: 10px;margin-bottom: 10px;">
  309. '.$param['placeimg'].'
  310. <a href="javascript:;" title="打开图片管理工具" onclick="picManage($(this), \'' . $param['name'] . '_' . $param['index'] . '\', \''.$param['key'].'\', 1, \''.$param['name'] . '_info_value\', \''.$param['place'].'\')"><img ' . $pic . ' class="update_value cropper_img" update_type="src" id="show_' . $param['name'] . '_' . $param['index'] . '" width="150" /></a></div>
  311. <input type="text" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" id="' . $param['name'] . '_' . $param['index'] . '" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '">';
  312. }
  313. /**
  314. * images
  315. *
  316. * @return string
  317. */
  318. public static function _images($param)
  319. {
  320. $param = self::uploadParam($param);
  321. $pic = $param['placeimg'];
  322. if (isset($param['value']) && $param['value']) {
  323. $temp = explode(',', $param['value']);
  324. foreach ($temp as $k => $v) {
  325. $data_src = '';
  326. if (strstr($v, '.cr')) {
  327. $temp = explode('.cr', $v);
  328. $data_src = $temp[0];
  329. }
  330. $pic .= '<a href="javascript:;" title="打开图片管理工具" onclick="picManage($(this), \'' . $param['name'] . '_' . $param['index'] . '\', \''.$param['key'].'\', 2, \''.$param['name'] . '_info_value\', \''.$param['place'].'\')"><img class="cropper_img" data-src="'.$data_src.'" src="' . $v . '" id="show_' . $param['name'] . '_' . $param['index'] . '_' . $k . '" width="150" style="margin-left:5px;" alt="打开图片管理工具"/></a>';
  331. }
  332. }
  333. $class = 'width:100px;display:inline;';
  334. if (layadmin()) {
  335. $class .= 'padding-left:0px;';
  336. }
  337. $upload = self::uploadHandle($param);
  338. $button = $upload[2][0] . '<input type="'.$upload[1].'" style="'.$class.$upload[3].'" class="form-control image_upload" '.$upload[0].' mul="yes" v="' . $param['name'] . '_' . $param['index'] . '" i="' . $param['name'] . '_info_value' . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" call="' . $param['call'] . '" upload_search_value="'.$param['upload_search_value'].'" place="'.$param['place'].'" value="本地上传"/>' . $upload[2][1];
  339. return $button . '
  340. <input type="button" style="'.$class.'" class="form-control upload_show" mul="yes" v="' . $param['name'] . '_' . $param['index'] . '" i="' . $param['name'] . '_info_value' . '" id="file_show_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" call="' . $param['call'] . '" upload_search="'.$param['upload_search'].'" value="图库"/><span style="margin-left:10px;font-size:8px;">标识:'.$param['upload_search_show'].'</span>
  341. <div style="margin-top:10px;display:none;" class="layui-progress layui-progress-big" id="file_' . $param['name'] . '_' . $param['index'] . '_progress" lay-filter="file_' . $param['name'] . '_' . $param['index'] . '_progress" lay-showPercent="true">
  342. <div class="layui-progress-bar" lay-percent="0%"></div>
  343. </div>
  344. <div style="margin-top: 10px;margin-bottom: 10px;" update_type="html" class="update_value ' . $param['name'] . '_' . $param['index'] . '_mul">' . $pic . '</div>
  345. <input type="text" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" id="' . $param['name'] . '_' . $param['index'] . '" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '">';
  346. }
  347. /**
  348. * upload
  349. *
  350. * @return string
  351. */
  352. public static function _upload($param)
  353. {
  354. $param = self::uploadParam($param);
  355. $class = 'width:100px;display:inline;';
  356. if (layadmin()) {
  357. $class .= 'padding-left:0px;';
  358. }
  359. $upload = self::uploadHandle($param);
  360. $button = $upload[2][0] . '<input type="'.$upload[1].'" style="'.$class.$upload[3].'" class="form-control image_upload" '.$upload[0].' t="file" v="' . $param['name'] . '_' . $param['index'] . '" i="' . $param['name'] . '_info_value' . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" call="' . $param['call'] . '" upload_search_value="'.$param['upload_search_value'].'" value="本地上传"/>' . $upload[2][1];
  361. return $button .'
  362. <input type="button" style="'.$class.'" class="form-control upload_show" t="file" v="' . $param['name'] . '_' . $param['index'] . '" i="' . $param['name'] . '_info_value' . '" id="file_show_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" call="' . $param['call'] . '" upload_search="'.$param['upload_search'].'" value="文件库"/><span style="margin-left:10px;font-size:8px;">标识:'.$param['upload_search_show'].'</span>
  363. <div style="margin-top:10px;display:none;" class="layui-progress layui-progress-big" id="file_' . $param['name'] . '_' . $param['index'] . '_progress" lay-filter="file_' . $param['name'] . '_' . $param['index'] . '_progress" lay-showPercent="true">
  364. <div class="layui-progress-bar" lay-percent="0%"></div>
  365. </div>
  366. <div style="margin-top:10px;"><input type="text" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" id="' . $param['name'] . '_' . $param['index'] . '" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '">
  367. </div>';
  368. //return '<input type="file" class="form-control" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '" name="' . $param['name'] . '"/>';
  369. }
  370. /**
  371. * upload
  372. *
  373. * @return string
  374. */
  375. public static function _uploads($param)
  376. {
  377. $param = self::uploadParam($param);
  378. $file = '';
  379. if (isset($param['value']) && $param['value']) {
  380. $temp = explode(',', $param['value']);
  381. foreach ($temp as $k => $v) {
  382. $upload = Dever::load('upload/file-check', array('option_key' => md5($v)));
  383. $file .= '<li><a href="' . $v . '" rel="box" title="点此下载" >' . $upload['source_name'] . '</a>&nbsp;&nbsp;<a href="javascript:;" style="color:red;" title="点此删除" onclick="fileDel($(this), \'' . $param['name'] . '_' . $param['index'] . '\')">[删除]</a></li>';
  384. }
  385. }
  386. $class = 'width:100px;display:inline;';
  387. if (layadmin()) {
  388. $class .= 'padding-left:0px;';
  389. }
  390. $upload = self::uploadHandle($param);
  391. $button = $upload[2][0] . '<input type="'.$upload[1].'" style="'.$class.$upload[3].'" class="form-control image_upload" '.$upload[0].' t="file" mul="yes" v="' . $param['name'] . '_' . $param['index'] . '" i="' . $param['name'] . '_info_value' . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" call="' . $param['call'] . '" upload_search_value="'.$param['upload_search_value'].'" value="本地上传"/>' . $upload[2][1];
  392. return $button .'
  393. <input type="button" style="'.$class.'" class="form-control upload_show" t="file" mul="yes" v="' . $param['name'] . '_' . $param['index'] . '" i="' . $param['name'] . '_info_value' . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" call="' . $param['call'] . '" upload_search="'.$param['upload_search'].'" value="文件库"/><span style="margin-left:10px;font-size:8px;">标识:'.$param['upload_search_show'].'</span>
  394. <div style="margin-top:10px;display:none;" class="layui-progress layui-progress-big" id="file_' . $param['name'] . '_' . $param['index'] . '_progress" lay-filter="file_' . $param['name'] . '_' . $param['index'] . '_progress" lay-showPercent="true">
  395. <div class="layui-progress-bar" lay-percent="0%"></div>
  396. </div>
  397. <ul style="margin-top: 10px;margin-bottom: 10px;" update_type="html" class="update_value ' . $param['name'] . '_' . $param['index'] . '_mul">' . $file . '</ul>
  398. <input type="hidden" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" id="' . $param['name'] . '_' . $param['index'] . '" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '">';
  399. //return '<input type="file" class="form-control" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '" name="' . $param['name'] . '"/>';
  400. }
  401. /**
  402. * video
  403. *
  404. * @return string
  405. */
  406. public static function _video($param)
  407. {
  408. $param = self::uploadParam($param);
  409. $class = 'width:100px;display:inline;';
  410. if (layadmin()) {
  411. $class .= 'padding-left:0px;';
  412. }
  413. $upload = self::uploadHandle($param);
  414. $value = (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : ''));
  415. $button = $upload[2][0] . '<input type="'.$upload[1].'" style="'.$class.$upload[3].'" class="form-control image_upload" '.$upload[0].' t="file" v="' . $param['name'] . '_' . $param['index'] . '" i="' . $param['name'] . '_info_value' . '" id="file_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" call="' . $param['call'] . '" upload_search_value="'.$param['upload_search_value'].'" value="本地上传"/>' . $upload[2][1];
  416. $button .= ' <input type="button" style="'.$class.'" class="form-control upload_show" t="file" v="' . $param['name'] . '_' . $param['index'] . '" i="' . $param['name'] . '_info_value' . '" id="file_show_' . $param['name'] . '_' . $param['index'] . '" key="' . $param['key'] . '" call="' . $param['call'] . '" upload_search="'.$param['upload_search'].'" value="视频库"/>';
  417. if (isset($upload[4]) && $upload[4]) {
  418. $cover = isset($param['cover']) ? $param['cover'] : 'pic';
  419. $button .= ' <input type="button" style="'.$class.'" class="form-control upload_cover" t="file" v="' . $param['name'] . '_' . $param['index'] . '" i="' . $param['name'] . '_info_value' . '" id="file_show_' . $param['name'] . '_' . $param['index'] . '" data-cover="'.$cover.'" key="' . $param['key'] . '" call="' . $param['call'] . '" value="生成封面图"/>';
  420. }
  421. $button .= ' <span style="margin-left:10px;font-size:8px;">标识:'.$param['upload_search_show'].'</span> <div style="margin-top:10px;display:none;" class="layui-progress layui-progress-big" id="file_' . $param['name'] . '_' . $param['index'] . '_progress" lay-filter="file_' . $param['name'] . '_' . $param['index'] . '_progress" lay-showPercent="true">
  422. <div class="layui-progress-bar" lay-percent="0%"></div>
  423. </div>
  424. <div style="margin-top:10px;"><input type="text" class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" id="' . $param['name'] . '_' . $param['index'] . '" value="' . $value . '">
  425. </div>';
  426. return $button;
  427. }
  428. /**
  429. * editor
  430. *
  431. * @return string
  432. */
  433. public static function _editor($param)
  434. {
  435. $param = self::uploadParam($param);
  436. $width = '100%';
  437. $html = '';
  438. if (isset($param['editor'])) {
  439. $width = '70%';
  440. if (layadmin()) {
  441. $left = '740px';
  442. } else {
  443. $left = '766px';
  444. }
  445. $html .= '<div class="layui-col-lg6" style="display:inline;position: absolute;left: '.$left.';"><div><label style="font-size:14px;font-weight:bold;" class="">'.$param['editor']['name'].'</label></div><div>';
  446. foreach ($param['editor']['button'] as $k => $v) {
  447. if (isset($v['type'])) {
  448. if ($v['type'] == 'image') {
  449. $param['key'] = $v['key'];
  450. } elseif ($v['type'] == 'media') {
  451. $param['media'] = $v['key'];
  452. }
  453. $v['attr'] = 'editor_tool" tool="' . $v['type'];
  454. } else {
  455. $v['attr'] = 'upload_show_editor';
  456. }
  457. if (isset($v['type']) && $v['type'] == 'update') {
  458. $v['attr'] = 'update_show_editor';
  459. $v['key'] = Dever::url($v['key']);
  460. $html .= '<input type="button" style="width:100px;padding-left:0px;margin:5px;" class="form-control layui-input '.$v['attr'].'" editor_id="' . $param['name'] . '_editor" key="'.$v['key'].'" upload_search="'.$param['upload_search'].'" upload_search_value="'.$param['upload_search_value'].'" value="'.$v['name'].'">';
  461. } else {
  462. $html .= '<input type="button" style="width:100px;display:inline;padding-left:0px;margin:5px;" class="form-control layui-input '.$v['attr'].'" editor_id="' . $param['name'] . '_editor" key="'.$v['key'].'" upload_search="'.$param['upload_search'].'" upload_search_value="'.$param['upload_search_value'].'" value="'.$v['name'].'">';
  463. }
  464. }
  465. $html .= '</div></div>';
  466. }
  467. $upload = self::uploadHandle($param);
  468. return $html . '<textarea '.$upload[0].' style="'.$width.';display: inline" update_type="value" class=" update_value editor" id="' . $param['name'] . '_editor" upload_search="'.$param['upload_search'].'" upload_search_value="'.$param['upload_search_value'].'" key="' . (isset($param['key']) ? $param['key'] : 1) . '" media="' . (isset($param['media']) ? $param['media'] : "") . '" name="' . $param['name'] . '" rows="18" cols="100" >' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '</textarea>';
  469. }
  470. /**
  471. * markdown
  472. *
  473. * @return string
  474. */
  475. public static function _markdown($param)
  476. {
  477. return '<textarea style="height:300px;" update_type="value" key="' . (isset($param['key']) ? $param['key'] : 1) . '" class="maze-note update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" >' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '</textarea>';
  478. }
  479. /**
  480. * selector
  481. *
  482. * @return string
  483. */
  484. public static function _selector($param, $type = '')
  485. {
  486. $html = '';
  487. if (isset($param['key']) && strpos($param['key'], '.css') !== false) {
  488. $param['key'] = '<link rel="stylesheet" href="' . $param['key'] . '"/>';
  489. }
  490. if (isset($param['option'])) {
  491. foreach ($param['option'] as $k => $v) {
  492. $check = '';
  493. if ((isset($param['value']) && $param['value'] == $k) || (empty($param['value']) && isset($param['default']) && $param['default'] == $k)) {
  494. $check = 'checked';
  495. }
  496. if (is_array($v)) {
  497. $value = $v['name'];
  498. } else {
  499. $value = $v;
  500. }
  501. $html .= '<a href="javascript:;" onclick="selector($(this))" class="' . $param['name'] . '_selector selector" data-check="' . $check . '" data-name="' . $param['name'] . '" data-value="' . $k . '">' . $value . '</a>&nbsp;&nbsp;';
  502. }
  503. $html .= self::hidden($param);
  504. }
  505. return '<div class="am-btn-group" >' . $html . '</div>';
  506. }
  507. /**
  508. * radio
  509. *
  510. * @return string
  511. */
  512. public static function _radio($param, $type = '')
  513. {
  514. $html = '';
  515. if (isset($param['option'])) {
  516. if (isset($param['option']['state']) && $param['option']['state'] >= 1) {
  517. # 处理比较复杂的多维数组
  518. $state = $param['option']['state'];
  519. unset($param['option']['state']);
  520. if (isset($param['value']) && $param['value']) {
  521. if ($state == 2) {
  522. $param['value'] = Dever::json_decode($param['value']);
  523. } else {
  524. $param['value'] = explode(',', $param['value']);
  525. }
  526. } else {
  527. $param['value'] = array();
  528. }
  529. $j = -1;
  530. $name = $param['name'];
  531. foreach ($param['option'] as $k => $v) {
  532. $check = '';
  533. if (isset($param['update_parent'])) {
  534. $input_type = $param['update_parent'];
  535. } else {
  536. $input_type = $param['update'];
  537. }
  538. if ($state == 2) {
  539. $parent_check = '';
  540. if (isset($param['value']) && isset($param['value'][$v['id']])) {
  541. $vt = implode(',', $param['value'][$v['id']]);
  542. if ($vt != -1) {
  543. $parent_check = 'checked';
  544. }
  545. }
  546. $name = $name . '['.$v['id'].']';
  547. $html .= '<input type="hidden" name="'.$name.'[]" value="-1" /><input update_type="checked" class="update_value checkbox-checkall ' . (isset($param['valid']) ? $param['valid'] : '') . '" type="' . $input_type . '" name="temp[]" value="'.$param['name'] . '-' . $k . '" ' . $parent_check . '/> -----【' . $v['name'] . '】-----&nbsp;&nbsp;<br />';
  548. } else {
  549. $html .= '<input update_type="checked" class="update_value checkbox-checkall ' . (isset($param['valid']) ? $param['valid'] : '') . '" type="' . $input_type . '" name="temp[]" value="'.$param['name'] . '-' . $k . '"/> -----【' . $v['name'] . '】-----&nbsp;&nbsp;<br />';
  550. }
  551. $span = array('', '');
  552. if (isset($v['child']) && $v['child']) {
  553. //$i = 1;
  554. $html .= '<ul style="list-style:none;margin:0px;display:;" class="">';
  555. foreach ($v['child'] as $ki => $vi) {
  556. if (!is_array($vi)) {
  557. $temp = $vi;
  558. $vi = array();
  559. $vi['name'] = $temp;
  560. $vi['id'] = $ki;
  561. }
  562. if (isset($v['url'])) {
  563. $span = array('<span class="edit" data-url="' . Dever::url($v['url'] . '?id=' . $vi['id']) . '">', '</span>');
  564. }
  565. $check = '';
  566. $disabled = 'disabled="true"';
  567. if ($state == 2) {
  568. if (isset($param['value']) && isset($param['value'][$v['id']]) && in_array($vi['id'], $param['value'][$v['id']])) {
  569. $check = 'checked';
  570. $disabled = '';
  571. $j++;
  572. }
  573. } elseif (isset($param['value']) && in_array($vi['id'], $param['value'])) {
  574. $check = 'checked';
  575. $disabled = '';
  576. $j++;
  577. } elseif (isset($param['default']) && is_array($param['default']) && (in_array($k . '_' . $vi['id'], $param['default']))) {
  578. $check = 'checked';
  579. $disabled = '';
  580. $j++;
  581. }
  582. $input = $input_value = '';
  583. if (isset($vi['func']) && $vi['func']) {
  584. $input .= '[';
  585. foreach ($vi['func'] as $vf) {
  586. $fcheck = '';
  587. if (isset($param['value']) && in_array('f_' . $vf['id'], $param['value'])) {
  588. $fcheck = 'checked';
  589. }
  590. $input .= '&nbsp;&nbsp;<input update_type="checked" class="update_value checkbox-checkall-' . $param['name'] . '-'. $k . ' ' . (isset($param['valid']) ? $param['valid'] : '') . '" data-state="'.$state.'" type="' . $param['update'] . '" name="' . $name . '[]" value="f_' . $vf['id'] . '" ' . $fcheck . '/> ' . $span[0] . $vf['name'] . $span[1] . '&nbsp;&nbsp;';
  591. }
  592. $input .= ']';
  593. } elseif (isset($param['update_input'])) {
  594. if (isset($param['update_input_data']) && isset($param['update_input_data'][$j])) {
  595. $input_value = $param['update_input_data'][$j];
  596. if ($disabled) {
  597. $input_value = '';
  598. }
  599. } else {
  600. $input_value = isset($param['update_input_default']) ? $param['update_input_default'] : '';
  601. }
  602. if ($param['update_input']) {
  603. $input = '[' . $param['update_input'] . ']';
  604. }
  605. $input = $input . ': <input class="form-control" name="' . $param['name'] . '_input[]" type="text" value="' . $input_value . '" style="width:20%;margin:5px;display:inline" placeholder="' . $param['update_input'] . '" ' . $disabled . '/>';
  606. }
  607. $html .= '<li><input update_type="checked" class="update_value checkbox-checkall-' . $param['name'] . '-'. $k . ' ' . (isset($param['valid']) ? $param['valid'] : '') . '" data-state="'.$state.'" type="' . $param['update'] . '" name="' . $name . '[]" value="' . $vi['id'] . '" ' . $check . '/> ' . $span[0] . $vi['name'] . $span[1] . '&nbsp;&nbsp;' . $input . '</li>';
  608. //++$i;
  609. }
  610. $html .= '</ul>';
  611. }
  612. $html .= '<br />';
  613. }
  614. } else {
  615. $js = '';
  616. if (isset($param['control']) && is_string($param['control'])) {
  617. //print_r($param);die;
  618. $js = ' show_id="' . $param['control'] . '" onclick="inputShow($(this), \'' . $param['control'] . '\', \'input\')"';
  619. } elseif (isset($param['bind'])) {
  620. $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
  621. $js = $param['bind'][0] . '="' . $param['bind'][1] . '(\'' . $param['name'] . '\', $(this), ' . $param['bind'][2] . ')" ';
  622. $js .= ' onload="' . $param['bind'][1] . '(\'' . $param['name'] . '\', $(this), ' . $param['bind'][2] . ')" ';
  623. }
  624. $param['parent'] = isset($param['parent']) ? $param['parent'] : '0';
  625. $param['parent'] .= '_' . $param['name'];
  626. if ($param['update'] == 'checkbox' && empty($param['checkall'])) {
  627. $html .= '<input update_type="checked" class="checkbox-checkall ' . $param['name'] . ' update_value" type="' . $param['update'] . '" name="temp_' . $param['name'] . '[]" value="' . $param['parent'] . '"/> 全选 &nbsp;&nbsp;';
  628. }
  629. foreach ($param['option'] as $k => $v) {
  630. $check = '';
  631. if (is_array($v)) {
  632. $value = $v['name'];
  633. isset($v['id']) && $k = $v['id'];
  634. } else {
  635. $value = $v;
  636. }
  637. if (isset($param['bit'][$k])) {
  638. if (isset($param['value']) && ($param['value'] & $k) > 0) {
  639. $check = 'checked';
  640. }
  641. } elseif (isset($param['value'])) {
  642. if (is_string($param['value']) && strpos(',' . $param['value'] . ',', ',' . $k . ',') !== false) {
  643. $check = 'checked';
  644. } elseif (is_array($param['value']) && in_array($k, $param['value'])) {
  645. $check = 'checked';
  646. }
  647. } elseif (isset($param['default'])) {
  648. if (is_string($param['default']) && strpos(',' . $param['default'], ',' . $k) !== false) {
  649. $check = 'checked';
  650. } elseif (is_array($param['default']) && in_array($k, $param['default'])) {
  651. $check = 'checked';
  652. }
  653. }
  654. $cjs = $js;
  655. if (isset($param['control']) && is_string($param['control']) && $param['control'] != $param['name']) {
  656. $cjs = str_replace('update_', '', str_replace($param['control'], $param['name'], $js));
  657. }
  658. $disabled = '';
  659. if (isset($param['disabled'])) {
  660. $disabled = 'disabled="true"';
  661. }
  662. $html .= '<input update_type="checked" class="autoload checkbox-checkall-' . $param['parent'] . ' ' . $param['name'] . ' update_value ' . (isset($param['valid']) ? $param['valid'] : '') . '" type="' . $param['update'] . '" name="' . $param['name'] . '[]" value="' . $k . '" ' . $check . ' ' . $cjs . ' ' . $disabled . '/> ' . $value . ' &nbsp;&nbsp;';
  663. if (isset($param['bind'])) {
  664. //$html .= '<script>$(document).ready(function(){$(".checkbox-checkall-'.$param['parent'].'").click();})</script>';
  665. }
  666. }
  667. }
  668. }
  669. return '<div class="am-btn-group" >' . $html . '</div>';
  670. }
  671. /**
  672. * group
  673. *
  674. * @return string
  675. */
  676. public static function _group($param, $class = '', $hidden = '', $change = '')
  677. {
  678. $html = $class ? '<div class="' . $class . '">' : '';
  679. $html .= $hidden . '<select class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" ' . $change . '>';
  680. if (isset($param['option'])) {
  681. foreach ($param['option'] as $k => $v) {
  682. if ($v['id'] <= 0) {
  683. $html .= '<option value="0" selected>' . $v['name'] . '</option>';
  684. } else {
  685. $html .= '<optgroup label="' . $v['name'] . '">';
  686. if (isset($v['child'])) {
  687. foreach ($v['child'] as $k1 => $v1) {
  688. $selected = '';
  689. if ((isset($param['value']) && $param['value'] == $v1['id']) || (empty($param['value']) && isset($param['default']) && $param['default'] == $v1['id'])) {
  690. $selected = 'selected';
  691. }
  692. $html .= '<option value="' . $v1['id'] . '" ' . $selected . '>' . $v1['name'] . '</option>';
  693. }
  694. }
  695. $html .= '</optgroup>';
  696. }
  697. }
  698. }
  699. $html .= '</select>';
  700. $html .= $class ? '</div>' : '';
  701. return $html;
  702. }
  703. /**
  704. * linkage select 多级联动
  705. *
  706. * @return string
  707. */
  708. public static function _linkage($param, $class = '', $hidden = '', $change = '')
  709. {
  710. $div = 'div';
  711. $w = 'width:20%;';
  712. if ($class == 'span') {
  713. $div = 'span';
  714. $w = '';
  715. }
  716. if (layadmin()) {
  717. $w = 'margin-top:0px;width:20%;margin-left:-3px;';
  718. }
  719. if (!isset($param['search_state'])) {
  720. $param['search_state'] = false;
  721. }
  722. # 当前级别
  723. $level = 1;
  724. # 传入的参数
  725. $level_param = '';
  726. if (isset($param['linkage'])) {
  727. $level_param = $param['linkage'];
  728. }
  729. $id = 'dever-linkage-' . $param['name'];
  730. $html = '<' . $div . ' class="' . $class . '" id="' . $id . '" >';
  731. # 默认值
  732. if (isset($param['value']) && is_array($param['value'])) {
  733. $param['value'] = implode(',', $param['value']);
  734. }
  735. $col = $api = $type = $script = '';
  736. $title = '';
  737. $open = '';
  738. if (is_array($param['option'])) {
  739. $option = $param['option'];
  740. $param['option'] = $option[0];
  741. $col = $option[1];
  742. $api = $option[2];
  743. $type = 'checkbox';
  744. if (isset($option[3])) {
  745. $title = $option[3];
  746. }
  747. if (isset($option[4])) {
  748. $open = str_replace('{where_id}', Dever::input('where_id'), $option[4]);
  749. }
  750. if (isset($param['value']) && $param['value']) {
  751. $script = 'select_api = JSON.parse(\''.$param['value'].'\');';
  752. $param['value'] = '';
  753. }
  754. }
  755. $html .= '<script>function linkage_' . $param['name'] . '(level){select_linkage(level, "' . $id . '","' . $param['option'] . '", "' . $param['name'] . '", \'' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '\', "' . (isset($param['valid']) ? $param['valid'] : '') . '", "' . $w . '", false, "'.$param['search_state'].'", "'.$level_param.'", "'.$col.'", "'.$api.'", "'.$type.'", "'.$title.'", "'.$open.'")};';
  756. $html .= '$(document).ready(function(){linkage_' . $param['name'] . '(' . $level . ');'.$script.'});</script>';
  757. $html .= '</' . $div . '><div id="'.$id.'_content"></div><div id="'.$id.'_data"></div>';
  758. return $html;
  759. }
  760. /**
  761. * select
  762. *
  763. * @return string
  764. */
  765. public static function _selects($param, $class = '', $hidden = '', $change = '')
  766. {
  767. return self::_select($param, $class, $hidden, $change);
  768. }
  769. /**
  770. * select
  771. *
  772. * @return string
  773. */
  774. public static function _select($param, $class = '', $hidden = '', $change = '')
  775. {
  776. $html = $class ? '<div class="' . $class . '">' : '';
  777. $child_class = '';
  778. if (isset($param['child'])) {
  779. $child_param['name'] = 'update_' . $param['child_name'];
  780. isset($param['value']) && $param['value'] = $param['value'];
  781. isset($param['child_value']) && $child_param['value'] = $param['child_value'];
  782. $change = 'style="width:45%" id="' . $param['name'] . '" data-child="' . $child_param['name'] . '_child" ';
  783. $child_class = ' change';
  784. //$param['name'] .= '_parent';
  785. }
  786. if (isset($param['control']) && is_string($param['control'])) {
  787. //print_r($param);die;
  788. $change = ' show_id="' . $param['control'] . '" onchange="inputShow($(this), \'' . $param['control'] . '\')"';
  789. } elseif (isset($param['bind'])) {
  790. $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
  791. $change = $param['bind'][0] . '="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
  792. $child_class .= ' change';
  793. }
  794. $xm = '';
  795. if ($change) {
  796. $xm = '';
  797. } else {
  798. }
  799. if (!$change && isset($param['update'])) {
  800. $xm = 'xm-select="' . $param['name'] . '" xm-select-skin="normal" xm-select-search="" xm-select-search-type="dl"';
  801. if ($param['update'] != 'selects') {
  802. $xm .= ' xm-select-radio=""';
  803. }
  804. $search_value = '';
  805. if (isset($param['value'])) {
  806. $search_value = $param['value'];
  807. } elseif (isset($param['default'])) {
  808. $search_value = $param['default'];
  809. }
  810. if (isset($param['update_search'])) {
  811. $xm = str_replace('xm-select-search=""', 'xm-select-search="'.Dever::url($param['update_search'] . '&yes='.$search_value.'&json=1').'"', $xm);
  812. }
  813. if (isset($param['update_create'])) {
  814. $xm .= ' xm-select-create=""';
  815. }
  816. if ($param['match'] != 'option') {
  817. $xm .= ' lay-verify="' . $param['name'] . '"';
  818. }
  819. if ($param['update'] == 'selects' && isset($param['lang']) && $param['lang']) {
  820. $xm .= ' xm-select-placeholder="'.$param['lang'].'"';
  821. unset($param['lang']);
  822. }
  823. } else {
  824. $xm .= ' xm-select-radio=""';
  825. }
  826. if (isset($param['option']) && isset($param['update']) && $param['update'] == 'select') {
  827. $total = count($param['option']);
  828. if ($total <= 5) {
  829. $xm = '';
  830. }
  831. }
  832. $html .= $hidden . '<select '.$xm.' class="update_value form-control ' . $child_class . ' ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" id="' . $param['name'] . '" ' . $change . '>';
  833. if (isset($param['option'])) {
  834. if (!isset($param['option'][-100]) && isset($param['lang']) && $param['lang']) {
  835. $html .= '<option value="0" selected>' . $param['lang'] . '</option>';
  836. }
  837. foreach ($param['option'] as $k => $v) {
  838. if (is_array($v)) {
  839. if (isset($v['lang']) && $v['lang']) {
  840. $value = $v['lang'];
  841. } else {
  842. $value = $v['name'];
  843. }
  844. isset($v['id']) && $k = $v['id'];
  845. } else {
  846. $value = $v;
  847. }
  848. $check = '';
  849. if ((isset($param['value']) && strstr(','. $param['value'] . ',', ',' . $k . ',')) || (isset($param['bit'][$k]) && isset($param['value']) && ($param['value'] & $k) > 0) || (empty($param['value']) && isset($param['default']) && strstr(',' . $param['default'] . ',', ',' . $k . ','))) {
  850. $check = 'selected';
  851. }
  852. $parent = '';
  853. if (isset($param['parent']) && $param['parent'] && isset($v[$param['parent']])) {
  854. $parent = $v[$param['parent']];
  855. }
  856. if (is_array($v)) {
  857. $value = isset($v['name']) ? $v['name'] : $v['lang'];
  858. } else {
  859. $value = $v;
  860. }
  861. $html .= '<option parent="'.$parent.'" value="' . $k . '" ' . $check . '>' . $value . '</option>';
  862. }
  863. }
  864. $html .= '</select>';
  865. if (isset($param['child'])) {
  866. $child = $child_param['name'];
  867. $hidden = self::hidden(array('name' => $child, 'class' => $child . '_child_value'));
  868. foreach ($param['child'] as $k => $v) {
  869. $child_param['name'] = 'child-' . $k;
  870. $child_param['option'] = $v;
  871. $html .= self::select($child_param, $child . '_child ' . $child . '_child_' . $k . '" parent="' . $k . '" style="display:none;margin-top: -38px;margin-left: 47%;"', $hidden);
  872. }
  873. }
  874. $html .= $class ? '</div>' : '';
  875. return $html;
  876. }
  877. /**
  878. * radio
  879. *
  880. * @return string
  881. */
  882. public static function _checkbox($param)
  883. {
  884. return self::radio($param);
  885. }
  886. /**
  887. * text
  888. *
  889. * @return string
  890. */
  891. public static function _text($param, $class = '')
  892. {
  893. if ($class) {
  894. return '<div class="">' . self::text($param, false) . '</div>';
  895. } else {
  896. $auto = $input = '';
  897. if (isset($param['const'])) {
  898. $value = $param['const'];
  899. } else {
  900. $value = (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : ''));
  901. }
  902. if (isset($param['autocomplete']) && $param['update'] == 'text') {
  903. if (empty($param['autocomplete'][1])) {
  904. $param['autocomplete'][1] = 'value';
  905. }
  906. if ($param['autocomplete'][1] == 'id') {
  907. $input = self::hidden(array('name' => $param['name'], 'value' => $value));
  908. $input = '<script>var autocomplete_value = {};autocomplete_value[\''.$param['name'].'_value\'] = [];</script>';
  909. if (isset($param['autocomplete'][2]) && $value) {
  910. # 重新定义value
  911. $value = Dever::load($param['autocomplete'][2], $value);
  912. if (is_array($value)) {
  913. $html = '<div style="margin-top: 10px;width: 60%;overflow: auto;max-height: 500px;"><table id="'.$param['name'].'_value_show" class="table table-small-font table-bordered">';
  914. foreach ($value as $k => $v) {
  915. $link = '';
  916. $attr = '';
  917. $pic = '';
  918. if (!isset($v['value'])) {
  919. $v['value'] = $v['name'];
  920. }
  921. if (isset($v['pic']) && $v['pic']) {
  922. $pic = '<a href="javascript:;"><img src="'.$v['pic'].'" width="100"></a>&nbsp;&nbsp;';
  923. }
  924. if (isset($v['link']) && $v['link']) {
  925. $link = $v['link'];
  926. $attr = ' target="_blank"';
  927. }
  928. if (isset($v['click']) && $v['click']) {
  929. $link = 'javascript:;';
  930. $attr = ' onclick="'.$v['click'].'"';
  931. }
  932. $html .= '<tr id="autocomplate_check_'.$param['name'].'_value"><td width="90%"><input type="checkbox" checked name="'.$param['name'].'[]" value="'.$v['id'].'"/>&nbsp;&nbsp;'.$pic.'<a href="'.$link.'" '.$attr.' title="'.$v['value'].'">'.$v['value'].'</td><td width="10%"><a href="javascript:;" onclick="autocomplete_del($(this), \''.$param['name'].'_value\', \''.$v['id'].'\', \''.$param['name'].'\')">[删除]</a></td></tr><script>autocomplete_value[\''.$param['name'].'_value\'].push('.$v['id'].');</script>';
  933. }
  934. $html .= '</table></div>';
  935. $input .= $html;
  936. $value = '';
  937. }
  938. }
  939. $param['name'] = $param['name'] . '_temp';
  940. }
  941. $auto = 'complete="' . Dever::url($param['autocomplete'][0]) . '" complete_callback="' . $param['autocomplete'][1] . '" ';
  942. if (isset($param['autocomplete'][3])) {
  943. $auto .= ' complete_cate="' . $param['autocomplete'][3] . '" ';
  944. }
  945. } elseif (isset($param['searchbox'])) {
  946. if (empty($param['searchbox'][1])) {
  947. $param['searchbox'][1] = 'value';
  948. }
  949. if ($param['searchbox'][1] == 'id') {
  950. $input = self::hidden(array('name' => $param['name'], 'value' => $value));
  951. $input = '<script>var searchbox_value = [];searchbox_value[\''.$param['name'].'_value\'] = [];</script>';
  952. if (isset($param['searchbox'][2]) && $value) {
  953. # 重新定义value
  954. $value = Dever::load($param['searchbox'][2], $value);
  955. if (is_array($value)) {
  956. $html = '<div style="margin-top: 10px;width: 60%;overflow: auto;max-height: 500px;"><table id="'.$param['name'].'_value_show" class="table table-small-font table-bordered">';
  957. foreach ($value as $k => $v) {
  958. $link = '';
  959. $attr = '';
  960. $pic = '';
  961. if (!isset($v['value'])) {
  962. $v['value'] = $v['name'];
  963. }
  964. if (isset($v['pic']) && $v['pic']) {
  965. $pic = '<a href="javascript:;"><img src="'.$v['pic'].'" width="100"></a>&nbsp;&nbsp;';
  966. }
  967. if (isset($v['link']) && $v['link']) {
  968. $link = $v['link'];
  969. $attr = ' target="_blank"';
  970. }
  971. $html .= '<tr id="searchbox_check_'.$param['name'].'_value_'.$v['id'].'"><td width="90%"><input type="checkbox" checked name="'.$param['name'].'[]" value="'.$v['id'].'"/>&nbsp;&nbsp;'.$pic.'<a href="'.$link.'" '.$attr.' title="'.$v['value'].'">'.$v['value'].'</td><td width="10%"><a href="javascript:;" onclick="searchbox_del($(this), \''.$param['name'].'_value\', \''.$v['id'].'\', \''.$param['name'].'\')">[删除]</a></td></tr><script>searchbox_value[\''.$param['name'].'_value\'].push('.$v['id'].');</script>';
  972. }
  973. $html .= '</table></div>';
  974. $input .= $html;
  975. $value = '';
  976. }
  977. }
  978. $param['name'] = $param['name'] . '_temp';
  979. }
  980. $auto = 'searchbox="' . Dever::url($param['searchbox'][0]) . '" searchbox_callback="' . $param['searchbox'][1] . '" ';
  981. if (isset($param['searchbox'][3])) {
  982. $auto .= ' searchbox_cate="' . $param['searchbox'][3] . '" ';
  983. }
  984. $search = '';
  985. if (isset($param['searchbox'][4])) {
  986. $temp = explode(',', $param['searchbox'][3]);
  987. $link = explode(',', $param['searchbox'][4]);
  988. $p = array();
  989. $p['option'] = array();
  990. foreach ($temp as $k => $v) {
  991. $p['name'] = $v;
  992. $p['option'] = Dever::load($link[$k]);
  993. $search .= self::_select($p, '', '', ' style="width: 15%;display: inline;margin-left:5px;"');
  994. }
  995. }
  996. $auto .= ' style="display: inline;"';
  997. $input = $search . '<button type="button" onclick="searchbox(\''.$param['name'].'\', $(this))" class="btn btn-primary layui-btn layuiadmin-btn-list" style="margin-left:10px;margin-top: -2px;"><i class="fa fa-save"></i> 搜索</button>' . $input;
  998. }
  999. if (isset($param['bind'])) {
  1000. $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
  1001. $auto .= $param['bind'][0] . '="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
  1002. $auto .= ' onload="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
  1003. }
  1004. return '<input ' . $auto . ' type="' . (isset($param['update']) ? $param['update'] : 'text') . '" class="autoload_text layui-input update_value ' . (isset($param['class']) ? $param['class'] : 'form-control') . ' ' . (isset($param['valid']) ? $param['valid'] : '') . '" value="' . $value . '" name="' . $param['name'] . '" id="' . $param['name'] . '_value" autocomplete="new'.time().'" placeholder="' . (isset($param['placeholder']) ? $param['placeholder'] : '') . '"/>' . $input;
  1005. }
  1006. }
  1007. /**
  1008. * color
  1009. *
  1010. * @return string
  1011. */
  1012. public static function _color($param)
  1013. {
  1014. $param['class'] = 'dever-color form-control';
  1015. $param['update'] = 'text';
  1016. $param['default'] = isset($param['default']) ? $param['default'] : '#000000';
  1017. return self::_text($param, '');
  1018. }
  1019. /**
  1020. * password
  1021. *
  1022. * @return string
  1023. */
  1024. public static function _password($param)
  1025. {
  1026. $param['value'] = '';
  1027. return self::_text($param);
  1028. }
  1029. /**
  1030. * hidden
  1031. *
  1032. * @return string
  1033. */
  1034. public static function _hidden($param)
  1035. {
  1036. $param['type'] = 'hidden';
  1037. $param['update'] = 'hidden';
  1038. return self::_text($param, '');
  1039. }
  1040. /**
  1041. * 选择详细的时间
  1042. *
  1043. * @return string
  1044. */
  1045. public static function _date($param, $type = true, $key = 'date', $parse = 'Y-m-d H:i:s')
  1046. {
  1047. $time = $value = '';
  1048. if ((isset($param['value']) && $param['value'] > 0)) {
  1049. $time = $param['value'];
  1050. } elseif ((isset($param['default']) && $param['default'] > 0)) {
  1051. $time = $param['default'];
  1052. } elseif($type) {
  1053. $time = time();
  1054. }
  1055. if ($time) {
  1056. if (strlen($time) >= 10) {
  1057. $value = date($parse, $time);
  1058. } else {
  1059. $value = $time;
  1060. }
  1061. }
  1062. return '<input type="text" value="' . $value . '" placeholder="' . (isset($param['lang']) ? $param['lang'] : '') . '" name="' . $param['name'] . '" class="manage_'.$key.' update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" autocomplete="off"/>';
  1063. }
  1064. /**
  1065. * time已废弃,用day替换,兼容不删除
  1066. *
  1067. * @return string
  1068. */
  1069. public static function _time($param, $type = false)
  1070. {
  1071. return self::_day($param, $type);
  1072. }
  1073. /**
  1074. * day 选择天
  1075. *
  1076. * @return string
  1077. */
  1078. public static function _day($param, $type = false)
  1079. {
  1080. return self::_date($param, $type, 'day', 'Y-m-d');
  1081. }
  1082. /**
  1083. * 选择年
  1084. *
  1085. * @return string
  1086. */
  1087. public static function _year($param, $type = false)
  1088. {
  1089. return self::_date($param, $type, 'year', 'Y');
  1090. }
  1091. /**
  1092. * 选择月
  1093. *
  1094. * @return string
  1095. */
  1096. public static function _month($param, $type = false)
  1097. {
  1098. return self::_date($param, $type, 'month', 'Y-m');
  1099. }
  1100. /**
  1101. * 选择几天内
  1102. *
  1103. * @return string
  1104. */
  1105. public static function _sday($param, $type = false)
  1106. {
  1107. $date = self::_date($param, $type, 'sday', 'Y-m-d');
  1108. return $date;
  1109. }
  1110. /**
  1111. * 选择几天内
  1112. *
  1113. * @return string
  1114. */
  1115. public static function _sdate($param, $type = false)
  1116. {
  1117. $date = self::_date($param, $type, 'sdate');
  1118. return $date;
  1119. }
  1120. /**
  1121. * div
  1122. *
  1123. * @return string
  1124. */
  1125. public static function _node($param, $type = 'div')
  1126. {
  1127. $result = array('', '');
  1128. foreach ($param as $k => $v) {
  1129. $result[0] .= '<' . $type . ' ' . $v . '>';
  1130. $result[1] .= '</' . $type . '>';
  1131. }
  1132. return $result;
  1133. }
  1134. }