Input.php 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654
  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. $param['button'] = '';
  147. if (isset($param['update_type']) && $param['update_type'] == 2) {
  148. $param['button'] = '<a href="javascript:;" onclick="append($(this), \''.$param['ext'].'\')" style="margin-left:5px;" class="layui-btn layui-btn-xs layui-btn-normal">新增</a>';
  149. }
  150. $class = '';
  151. $style = '';
  152. if (layadmin()) {
  153. //$class = 'layui-form-label';
  154. if (isset($param['update']) && is_array($param['update'])) {
  155. $style = ' style="margin:10px;"';
  156. }
  157. }
  158. $html = '<div '.$style.'><label style="font-size:14px;font-weight:bold;" class="'.$class.'">' . $param['name'] . $param['cue'] . $param['button'] . '</label></div>';
  159. return $html;
  160. }
  161. /**
  162. * textarea
  163. *
  164. * @return string
  165. */
  166. public static function _textarea($param)
  167. {
  168. 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>';
  169. 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>';
  170. }
  171. private static function uploadHandle($param)
  172. {
  173. $html = $style = '';
  174. $div = array('', '');
  175. $type = 'button';
  176. $yun = false;
  177. if (isset($param['upload']) && ($param['upload'] == 'yun' || $param['upload'] == 'qiniu')) {
  178. $upload = Dever::project('upload');
  179. if ($upload && !strstr($upload['path'], 'http')) {
  180. $upload = Dever::load('upload/yun.token?return=1&key=' . $param['key']);
  181. } else {
  182. $upload = Dever::load('upload/yun.token?key=' . $param['key']);
  183. }
  184. if (isset($upload['domain'])) {
  185. $bucket = $upload['bucket'];
  186. $domain = $upload['domain'];
  187. $token = $upload['uptoken'];
  188. $host = $upload['host'];
  189. $cover = 1;
  190. $yun = true;
  191. if (isset($param['cover']) && $param['cover']) {
  192. $cover = $param['cover'];
  193. } elseif (isset($upload['cover']) && $upload['cover']) {
  194. $cover = $upload['cover'];
  195. }
  196. $date = explode('-', date("Y-m-d"));
  197. $path = $param['key'] . '/' . $date[0] . '/' . $date[1] . '/' . $date[2] . '/';
  198. $html = ' m="'.$upload['type'].'" cover="'.$cover.'" domain="'.$domain.'" bucket="'.$bucket.'" path="'.$path.'" host="'.$host.'" token="'.$token.'" ';
  199. }
  200. }
  201. if (isset($param['large']) && $param['large'] && isset($upload['domain'])) {
  202. $html .= ' l="1" ';
  203. $type = 'file';
  204. $div = array('<div class="layui-input" style=" position: relative;
  205. display: inline-block;
  206. border-radius: 2px;
  207. color: black;
  208. text-decoration: none;
  209. text-indent: 0;
  210. line-height: 37px;
  211. height: 37px;
  212. width: 97px;
  213. padding-left: 19px;">', '本地上传</div>');
  214. $style = 'position: absolute;
  215. font-size: 21px;
  216. right: 0;
  217. top: 0;
  218. opacity: 0;';
  219. }
  220. return array($html, $type, $div, $style, $yun);
  221. }
  222. private static function uploadParam($param)
  223. {
  224. if (isset($param['upload_key'])) {
  225. $param['key'] = $param['upload_key'];
  226. }
  227. if (isset($param['upload_place'])) {
  228. $param['place'] = $param['upload_place'];
  229. }
  230. if (!isset($param['upload_search'])) {
  231. $param['upload_search_value'] = $param['project'] . '-' . $param['table'] . '.' . $param['col'];
  232. $param['upload_search'] = $param['upload_search_value'];
  233. } else {
  234. if (!isset($param['upload_search_value'])) {
  235. $param['upload_search_value'] = $param['upload_search'];
  236. }
  237. }
  238. $param['upload_search_show'] = $param['upload_search'];
  239. if (strstr($param['upload_search'], '#')) {
  240. $temp = explode('#', $param['upload_search']);
  241. $param['upload_search_show'] = $temp[0];
  242. if ($temp[1] > 0) {
  243. $param['upload_search_show'] .= '_<script>document.write($("#upload_'.$temp[1].'_value").val());</script>';
  244. }
  245. }
  246. if (isset($param['place']) && $param['place']) {
  247. //$pic = 'src="http://placehold.it/' . $param['place'] . '"';
  248. //$param['placeimg'] = '<img src="http://temp.im/' . $param['place'] . '" class="place" width="150" />';
  249. $place = $param['place'];
  250. $default = '';
  251. if (strstr($param['place'], '?')) {
  252. $temp = explode('?', $param['place']);
  253. $param['place'] = $temp[0];
  254. $default .= '&';
  255. } else {
  256. $default .= '?';
  257. }
  258. if (strstr($place, '*')) {
  259. $place = str_replace('*', 'x', $place);
  260. } elseif (strstr($place, 'X')) {
  261. $place = str_replace('X', 'x', $place);
  262. } else {
  263. $place = $param['place'] . 'x' . $param['place'];
  264. }
  265. $text = '';
  266. //$text = "" . $place . "px \n 大小不能超过2M";
  267. //$text = "图片尺寸".$place."px \n 也可以上传等比尺寸 \n 上传大小不能超过2M \n 支持JPG、PNG、 GIF格式";
  268. //$default .= 'auto=yes&theme=social&text=' . $text;
  269. $default .= 'auto=yes&text=' . $text;
  270. $place .= $default;
  271. $param['placeimg'] = '<img src="holder.js/' . $place . '" class="place" style="width:150px" onclick="$(this).parent().parent().find(\'.image_upload\').click()"/>';
  272. } else {
  273. $param['place'] = '';
  274. $param['placeimg'] = '';
  275. }
  276. if (isset($param['upload_call'])) {
  277. $param['call'] = $param['upload_call'];
  278. }
  279. if (!isset($param['call'])) {
  280. $param['call'] = '';
  281. }
  282. return $param;
  283. }
  284. /**
  285. * image
  286. *
  287. * @return string
  288. */
  289. public static function _image($param)
  290. {
  291. $param = self::uploadParam($param);
  292. if (isset($param['value']) && $param['value']) {
  293. $pic = 'src="' . $param['value'] . '"';
  294. if (strstr($param['value'], '.cr')) {
  295. $temp = explode('.cr', $param['value']);
  296. $pic .= ' data-src="' . $temp[0] . '"';
  297. }
  298. } else {
  299. $pic = 'src="" style=display:none;';
  300. }
  301. $class = 'width:100px;display:inline;';
  302. if (layadmin()) {
  303. $class .= 'padding-left:0px;';
  304. }
  305. $upload = self::uploadHandle($param);
  306. $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];
  307. return $button .'
  308. <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>
  309. <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">
  310. <div class="layui-progress-bar" lay-percent="0%"></div>
  311. </div>
  312. <div style="margin-top: 10px;margin-bottom: 10px;">
  313. '.$param['placeimg'].'
  314. <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>
  315. <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'] : '')) . '">';
  316. }
  317. /**
  318. * images
  319. *
  320. * @return string
  321. */
  322. public static function _images($param)
  323. {
  324. $param = self::uploadParam($param);
  325. $pic = $param['placeimg'];
  326. if (isset($param['value']) && $param['value']) {
  327. $temp = explode(',', $param['value']);
  328. foreach ($temp as $k => $v) {
  329. $data_src = '';
  330. if (strstr($v, '.cr')) {
  331. $temp = explode('.cr', $v);
  332. $data_src = $temp[0];
  333. }
  334. $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>';
  335. }
  336. }
  337. $class = 'width:100px;display:inline;';
  338. if (layadmin()) {
  339. $class .= 'padding-left:0px;';
  340. }
  341. $upload = self::uploadHandle($param);
  342. $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];
  343. return $button . '
  344. <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>
  345. <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">
  346. <div class="layui-progress-bar" lay-percent="0%"></div>
  347. </div>
  348. <div style="margin-top: 10px;margin-bottom: 10px;" update_type="html" class="update_value ' . $param['name'] . '_' . $param['index'] . '_mul">' . $pic . '</div>
  349. <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'] : '')) . '">';
  350. }
  351. /**
  352. * upload
  353. *
  354. * @return string
  355. */
  356. public static function _upload($param)
  357. {
  358. $param = self::uploadParam($param);
  359. $class = 'width:100px;display:inline;';
  360. if (layadmin()) {
  361. $class .= 'padding-left:0px;';
  362. }
  363. $upload = self::uploadHandle($param);
  364. $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];
  365. return $button .'
  366. <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>
  367. <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">
  368. <div class="layui-progress-bar" lay-percent="0%"></div>
  369. </div>
  370. <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'] : '')) . '">
  371. </div>';
  372. //return '<input type="file" class="form-control" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '" name="' . $param['name'] . '"/>';
  373. }
  374. /**
  375. * upload
  376. *
  377. * @return string
  378. */
  379. public static function _uploads($param)
  380. {
  381. $param = self::uploadParam($param);
  382. $file = '';
  383. if (isset($param['value']) && $param['value']) {
  384. $temp = explode(',', $param['value']);
  385. foreach ($temp as $k => $v) {
  386. $upload = Dever::load('upload/file-check', array('option_key' => md5($v)));
  387. $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>';
  388. }
  389. }
  390. $class = 'width:100px;display:inline;';
  391. if (layadmin()) {
  392. $class .= 'padding-left:0px;';
  393. }
  394. $upload = self::uploadHandle($param);
  395. $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];
  396. return $button .'
  397. <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>
  398. <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">
  399. <div class="layui-progress-bar" lay-percent="0%"></div>
  400. </div>
  401. <ul style="margin-top: 10px;margin-bottom: 10px;" update_type="html" class="update_value ' . $param['name'] . '_' . $param['index'] . '_mul">' . $file . '</ul>
  402. <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'] : '')) . '">';
  403. //return '<input type="file" class="form-control" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '" name="' . $param['name'] . '"/>';
  404. }
  405. /**
  406. * video
  407. *
  408. * @return string
  409. */
  410. public static function _video($param)
  411. {
  412. $param = self::uploadParam($param);
  413. $class = 'width:100px;display:inline;';
  414. if (layadmin()) {
  415. $class .= 'padding-left:0px;';
  416. }
  417. $upload = self::uploadHandle($param);
  418. $value = (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : ''));
  419. $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];
  420. $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="视频库"/>';
  421. if (isset($upload[4]) && $upload[4]) {
  422. $cover = isset($param['cover']) ? $param['cover'] : 'pic';
  423. $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="生成封面图"/>';
  424. }
  425. $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">
  426. <div class="layui-progress-bar" lay-percent="0%"></div>
  427. </div>
  428. <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 . '">
  429. </div>';
  430. return $button;
  431. }
  432. /**
  433. * editor
  434. *
  435. * @return string
  436. */
  437. public static function _editor($param)
  438. {
  439. $param = self::uploadParam($param);
  440. $width = '100%';
  441. $html = '';
  442. if (isset($param['editor'])) {
  443. $width = '70%';
  444. if (layadmin()) {
  445. $left = '740px';
  446. } else {
  447. $left = '766px';
  448. }
  449. $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>';
  450. foreach ($param['editor']['button'] as $k => $v) {
  451. if (isset($v['type'])) {
  452. if ($v['type'] == 'image') {
  453. $param['key'] = $v['key'];
  454. } elseif ($v['type'] == 'media') {
  455. $param['media'] = $v['key'];
  456. }
  457. $v['attr'] = 'editor_tool" tool="' . $v['type'];
  458. } else {
  459. $v['attr'] = 'upload_show_editor';
  460. }
  461. if (isset($v['type']) && $v['type'] == 'update') {
  462. $v['attr'] = 'update_show_editor';
  463. $v['key'] = Dever::url($v['key']);
  464. $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'].'">';
  465. } else {
  466. $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'].'">';
  467. }
  468. }
  469. $html .= '</div></div>';
  470. }
  471. $upload = self::uploadHandle($param);
  472. 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>';
  473. }
  474. /**
  475. * markdown
  476. *
  477. * @return string
  478. */
  479. public static function _markdown($param)
  480. {
  481. 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>';
  482. }
  483. /**
  484. * selector
  485. *
  486. * @return string
  487. */
  488. public static function _selector($param, $type = '')
  489. {
  490. $html = '';
  491. if (isset($param['key']) && strpos($param['key'], '.css') !== false) {
  492. $param['key'] = '<link rel="stylesheet" href="' . $param['key'] . '"/>';
  493. }
  494. if (isset($param['option'])) {
  495. foreach ($param['option'] as $k => $v) {
  496. $check = '';
  497. if ((isset($param['value']) && $param['value'] == $k) || (empty($param['value']) && isset($param['default']) && $param['default'] == $k)) {
  498. $check = 'checked';
  499. }
  500. if (is_array($v)) {
  501. $value = $v['name'];
  502. } else {
  503. $value = $v;
  504. }
  505. $html .= '<a style="padding-top:10px;" href="javascript:;" onclick="selector($(this))" class="' . $param['name'] . '_selector selector" data-check="' . $check . '" data-name="' . $param['name'] . '" data-value="' . $k . '">' . $value . '</a>&nbsp;&nbsp;';
  506. }
  507. $html .= self::hidden($param);
  508. }
  509. return '<div class="am-btn-group" >' . $html . '</div>';
  510. }
  511. /**
  512. * radio
  513. *
  514. * @return string
  515. */
  516. public static function _radio($param, $type = '')
  517. {
  518. $html = '';
  519. if (isset($param['option'])) {
  520. if (isset($param['option']['state']) && $param['option']['state'] >= 1) {
  521. # 处理比较复杂的多维数组
  522. $state = $param['option']['state'];
  523. unset($param['option']['state']);
  524. if (isset($param['value']) && $param['value']) {
  525. if ($state == 2) {
  526. $param['value'] = Dever::json_decode($param['value']);
  527. } else {
  528. $param['value'] = explode(',', $param['value']);
  529. }
  530. } else {
  531. $param['value'] = array();
  532. }
  533. $j = -1;
  534. $name = $param['name'];
  535. foreach ($param['option'] as $k => $v) {
  536. $check = '';
  537. if (isset($param['update_parent'])) {
  538. $input_type = $param['update_parent'];
  539. } else {
  540. $input_type = $param['update'];
  541. }
  542. if ($state == 2) {
  543. $parent_check = '';
  544. if (isset($param['value']) && isset($param['value'][$v['id']])) {
  545. $vt = implode(',', $param['value'][$v['id']]);
  546. if ($vt != -1) {
  547. $parent_check = 'checked';
  548. }
  549. }
  550. $name = $name . '['.$v['id'].']';
  551. $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 . ' title="【' . $v['name'] . '】" lay-skin="primary"/><br />';
  552. } else {
  553. $html .= '<input update_type="checked" class="update_value checkbox-checkall ' . (isset($param['valid']) ? $param['valid'] : '') . '" type="' . $input_type . '" name="temp[]" value="'.$param['name'] . '-' . $k . '" title="【' . $v['name'] . '】" lay-skin="primary"/><br />';
  554. }
  555. $span = array('', '');
  556. if (isset($v['child']) && $v['child']) {
  557. //$i = 1;
  558. $html .= '<ul style="list-style:none;margin:0px;display:;margin-left: 26px;" class="">';
  559. foreach ($v['child'] as $ki => $vi) {
  560. if (!is_array($vi)) {
  561. $temp = $vi;
  562. $vi = array();
  563. $vi['name'] = $temp;
  564. $vi['id'] = $ki;
  565. }
  566. if (isset($v['url'])) {
  567. $span = array('<span class="edit" data-url="' . Dever::url($v['url'] . '?id=' . $vi['id']) . '">', '</span>');
  568. }
  569. $check = '';
  570. $disabled = 'disabled="true"';
  571. if ($state == 2) {
  572. if (isset($param['value']) && isset($param['value'][$v['id']]) && in_array($vi['id'], $param['value'][$v['id']])) {
  573. $check = 'checked';
  574. $disabled = '';
  575. $j++;
  576. }
  577. } elseif (isset($param['value']) && in_array($vi['id'], $param['value'])) {
  578. $check = 'checked';
  579. $disabled = '';
  580. $j++;
  581. } elseif (isset($param['default']) && is_array($param['default']) && (in_array($k . '_' . $vi['id'], $param['default']))) {
  582. $check = 'checked';
  583. $disabled = '';
  584. $j++;
  585. }
  586. $input = $input_value = '';
  587. if (isset($vi['func']) && $vi['func']) {
  588. $input .= '<ul style="margin-left: 26px;">';
  589. foreach ($vi['func'] as $vf) {
  590. $fcheck = '';
  591. if (isset($param['value']) && in_array('f_' . $vf['id'], $param['value'])) {
  592. $fcheck = 'checked';
  593. }
  594. $input .= '<li style="display:inline"><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 . ' lay-skin="primary" title="'.$vf['name'].'" lay-filter="'.$param['name'].'_'.$k.'_'.$vf['id'].'"/></li>';
  595. // ' . $span[0] . $vf['name'] . $span[1] . '&nbsp;&nbsp;
  596. }
  597. $input .= '</ul>';
  598. $vi['name'] .= '('.count($vi['func']).')';
  599. } elseif (isset($param['update_input']) && $param['update_input']) {
  600. if (isset($param['update_input_data']) && isset($param['update_input_data'][$j])) {
  601. $input_value = $param['update_input_data'][$j];
  602. if ($disabled) {
  603. $input_value = '';
  604. }
  605. } else {
  606. $input_value = isset($param['update_input_default']) ? $param['update_input_default'] : '';
  607. }
  608. if ($param['update_input']) {
  609. $input = '[' . $param['update_input'] . ']';
  610. }
  611. $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 . '/>';
  612. }
  613. //$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 . ' lay-skin="primary"/> ' . $span[0] . $vi['name'] . $span[1] . '&nbsp;&nbsp;' . $input . '</li>';
  614. if (!$input) {
  615. $s = 'style="display:inline"';
  616. } else {
  617. $s = '';
  618. }
  619. $html .= '<li '.$s.'><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 . ' lay-skin="primary" title="'.$vi['name'].'" lay-filter="'.$param['name'].'_'.$k.'"/>' . $input . '</li>';
  620. //++$i;
  621. }
  622. $html .= '</ul>';
  623. }
  624. $html .= '<br />';
  625. }
  626. } else {
  627. $js = '';
  628. if (isset($param['control']) && is_string($param['control'])) {
  629. //print_r($param);die;
  630. $js = ' show_id="' . $param['control'] . '" onclick="inputShow($(this), \'' . $param['control'] . '\', \'input\')"';
  631. } elseif (isset($param['load'])) {
  632. $js = ' onchange="loadChange($(this), \'' . $param['load'] . '\')" ';
  633. $js .= ' onload="loadChange($(this), \'' . $param['load'] . '\')" ';
  634. } elseif (isset($param['bind'])) {
  635. $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
  636. $js = $param['bind'][0] . '="' . $param['bind'][1] . '(\'' . $param['name'] . '\', $(this), ' . $param['bind'][2] . ')" ';
  637. $js .= ' onload="' . $param['bind'][1] . '(\'' . $param['name'] . '\', $(this), ' . $param['bind'][2] . ')" ';
  638. }
  639. $param['parent'] = isset($param['parent']) ? $param['parent'] : '0';
  640. $param['parent'] .= '_' . $param['name'];
  641. if ($param['update'] == 'checkbox' && empty($param['checkall'])) {
  642. $html .= '<input update_type="checked" class="checkbox-checkall ' . $param['name'] . ' update_value" type="' . $param['update'] . '" name="temp_' . $param['name'] . '[]" value="' . $param['parent'] . '" lay-skin="primary" title="全选" lay-filter="'.$param['name'].'_all"/>';
  643. }
  644. $i = 0;
  645. foreach ($param['option'] as $k => $v) {
  646. $check = '';
  647. if (is_array($v)) {
  648. $value = $v['name'];
  649. isset($v['id']) && $k = $v['id'];
  650. } else {
  651. $value = $v;
  652. }
  653. if (isset($param['bit'][$k])) {
  654. if (isset($param['value']) && ($param['value'] & $k) > 0) {
  655. $check = 'checked';
  656. }
  657. } elseif (isset($param['value'])) {
  658. if (is_string($param['value']) && strpos(',' . $param['value'] . ',', ',' . $k . ',') !== false) {
  659. $check = 'checked';
  660. } elseif (is_array($param['value']) && in_array($k, $param['value'])) {
  661. $check = 'checked';
  662. }
  663. } elseif (isset($param['default']) && $param['default']) {
  664. if (is_string($param['default']) && strpos(',' . $param['default'], ',' . $k) !== false) {
  665. $check = 'checked';
  666. } elseif (is_array($param['default']) && in_array($k, $param['default'])) {
  667. $check = 'checked';
  668. }
  669. } elseif ($param['update'] == 'radio' && $i == 0) {
  670. $check = 'checked';
  671. }
  672. $cjs = $js;
  673. if (isset($param['control']) && is_string($param['control']) && $param['control'] != $param['name']) {
  674. $cjs = str_replace('update_', '', str_replace($param['control'], $param['name'], $js));
  675. }
  676. $disabled = '';
  677. if (isset($param['disabled'])) {
  678. $disabled = 'disabled="true"';
  679. }
  680. $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 . ' title="'.$value.'" lay-skin="primary" lay-filter="'.$param['name'].'_'.$k.'"/>';
  681. if (isset($param['bind'])) {
  682. //$html .= '<script>$(document).ready(function(){$(".checkbox-checkall-'.$param['parent'].'").click();})</script>';
  683. }
  684. $i++;
  685. }
  686. }
  687. }
  688. return '<div class="am-btn-group" >' . $html . '</div>';
  689. }
  690. /**
  691. * group
  692. *
  693. * @return string
  694. */
  695. public static function _group($param, $class = '', $hidden = '', $change = '')
  696. {
  697. $html = $class ? '<div class="' . $class . '">' : '';
  698. $html .= $hidden . '<select class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" ' . $change . '>';
  699. if (isset($param['option'])) {
  700. foreach ($param['option'] as $k => $v) {
  701. if ($v['id'] <= 0) {
  702. $html .= '<option value="0" selected>' . $v['name'] . '</option>';
  703. } else {
  704. $html .= '<optgroup label="' . $v['name'] . '">';
  705. if (isset($v['child'])) {
  706. foreach ($v['child'] as $k1 => $v1) {
  707. $selected = '';
  708. if ((isset($param['value']) && $param['value'] == $v1['id']) || (empty($param['value']) && isset($param['default']) && $param['default'] == $v1['id'])) {
  709. $selected = 'selected';
  710. }
  711. $html .= '<option value="' . $v1['id'] . '" ' . $selected . '>' . $v1['name'] . '</option>';
  712. }
  713. }
  714. $html .= '</optgroup>';
  715. }
  716. }
  717. }
  718. $html .= '</select>';
  719. $html .= $class ? '</div>' : '';
  720. return $html;
  721. }
  722. /**
  723. * linkage select 多级联动
  724. *
  725. * @return string
  726. */
  727. public static function _linkage($param, $class = '', $hidden = '', $change = '')
  728. {
  729. $div = 'div';
  730. $fast = Dever::input('fast');
  731. $w = 'width:20%;';
  732. if ($class == 'span') {
  733. $div = 'span';
  734. $w = '';
  735. }
  736. if (layadmin()) {
  737. $w = 'margin-top:0px;width:20%;margin-left:-3px;';
  738. if ($fast == 1) {
  739. $w = 'margin-top:0px;width:35%;margin-left:-3px;';
  740. } else {
  741. $w = 'margin-top:0px;width:20%;margin-left:-3px;';
  742. }
  743. }
  744. if (!isset($param['search_state'])) {
  745. $param['search_state'] = false;
  746. }
  747. # 当前级别
  748. $level = 1;
  749. # 传入的参数
  750. $level_param = '';
  751. if (isset($param['linkage'])) {
  752. $level_param = $param['linkage'];
  753. }
  754. $id = 'dever-linkage-' . $param['name'];
  755. $html = '<' . $div . ' class="' . $class . '" id="' . $id . '" >';
  756. # 默认值
  757. if (isset($param['value']) && is_array($param['value'])) {
  758. $param['value'] = implode(',', $param['value']);
  759. }
  760. $col = $api = $type = $script = '';
  761. $title = '';
  762. $open = '';
  763. if (is_array($param['option'])) {
  764. $option = $param['option'];
  765. $param['option'] = $option[0];
  766. $col = $option[1];
  767. $api = $option[2];
  768. $type = 'checkbox';
  769. if (isset($option[3])) {
  770. $title = $option[3];
  771. }
  772. if (isset($option[4])) {
  773. $open = str_replace('{where_id}', Dever::input('where_id'), $option[4]);
  774. }
  775. if (isset($param['value']) && $param['value']) {
  776. $script = 'select_api = JSON.parse(\''.$param['value'].'\');';
  777. $param['value'] = '';
  778. }
  779. }
  780. $load = '';
  781. if (isset($param['load'])) {
  782. $load = $param['load'];
  783. }
  784. $method = $param['name'];
  785. if (strstr($method, '-')) {
  786. $method = str_replace('-', '', $method);
  787. }
  788. $html .= '<script>function linkage_' . $method . '(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.'", "'.$load.'")};';
  789. $html .= '$(document).ready(function(){linkage_' . $method . '(' . $level . ');'.$script.'});</script>';
  790. $html .= '</' . $div . '><div id="'.$id.'_content"></div><div id="'.$id.'_data"></div>';
  791. return $html;
  792. }
  793. /**
  794. * select
  795. *
  796. * @return string
  797. */
  798. public static function _selects($param, $class = '', $hidden = '', $change = '')
  799. {
  800. return self::_select($param, $class, $hidden, $change);
  801. }
  802. /**
  803. * select
  804. *
  805. * @return string
  806. */
  807. public static function _select($param, $class = '', $hidden = '', $change = '')
  808. {
  809. $html = $class ? '<div class="' . $class . '">' : '';
  810. $html .= $hidden;
  811. $xm = true;
  812. if (strstr($param['name'], 'up_col_')) {
  813. $xm = false;
  814. } elseif (isset($param['option']) && isset($param['update']) && $param['update'] == 'select') {
  815. $total = count($param['option']);
  816. if ($total <= 30) {
  817. $xm = false;
  818. }
  819. }
  820. if ($xm && isset($param['update'])) {
  821. $url = '';
  822. //https://maplemei.gitee.io/xm-select/?select=#/basic/paging
  823. if (isset($param['update_search'])) {
  824. $search_value = '';
  825. if (isset($param['value'])) {
  826. $search_value = $param['value'];
  827. } elseif (isset($param['default'])) {
  828. $search_value = $param['default'];
  829. }
  830. if (strstr($param['update_search'], '{id}')) {
  831. $param['update_search'] = str_replace('{id}', 'where_id=' . $param['where_id'], $param['update_search']);
  832. }
  833. $url = Dever::url($param['update_search'] . '&yes='.$search_value.'&json=1');
  834. }
  835. $xm_data = array();
  836. if (!$url && isset($param['option']) && $param['option']) {
  837. foreach ($param['option'] as $k => $v) {
  838. if (is_array($v)) {
  839. if (isset($v['id'])) {
  840. $xm_data[] = array('name' => $v['name'], 'value' => $v['id']);
  841. }
  842. } else {
  843. $xm_data[] = array('name' => $v, 'value' => $k);
  844. }
  845. }
  846. }
  847. $xm_value = isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '');
  848. $xm_tips = '请选择';
  849. $xm_data = Dever::json_encode($xm_data);
  850. $xm_id = $param['name'];
  851. $xm_radio = ($param['update'] == 'selects' ? false : true);
  852. $xm_on = '';
  853. if (isset($param['control']) && is_string($param['control'])) {
  854. $xm_on = 'inputShow(e, \'' . $param['control'] . '\');';
  855. $change = ' show_id="' . $param['control'] . '"';
  856. } elseif (isset($param['load'])) {
  857. $xm_on = 'loadChange(e, \'' . $param['load'] . '\');';
  858. } elseif (isset($param['bind'])) {
  859. $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
  860. $xm_on = '' . $param['bind'][1] . '(e, ' . $param['bind'][2] . ', 1);';
  861. }
  862. if ($xm_on) {
  863. $xm_on = 'function(data){
  864. var arr = data.arr;
  865. if (arr && arr.length > 0) {
  866. var xm_radio = '.$xm_radio.';
  867. if (xm_radio) {
  868. var e = $("#'.$xm_id.'");
  869. e.attr("v", arr[0].value);
  870. '.$xm_on.'
  871. }
  872. }
  873. }';
  874. } else {
  875. $xm_on = 'function(){}';
  876. }
  877. $html .= '<div id="' . $param['name'] . '" '.$change.' class="xm-select-demo" style="min-width:150px"></div>';
  878. $html .= '<script>
  879. $(document).ready(function() {
  880. layui.use(["table"], function() {
  881. console.info(11);
  882. init_xm("'.$xm_id.'", "'.$xm_radio.'", "'.$xm_tips.'", "'.$url.'", '.$xm_data.', ['.$xm_value.'], '.$xm_on.');
  883. });
  884. });
  885. </script>';
  886. } else {
  887. $child_class = '';
  888. $style = '';
  889. if (isset($param['child'])) {
  890. $child_param['name'] = 'update_' . $param['child_name'];
  891. isset($param['value']) && $param['value'] = $param['value'];
  892. isset($param['child_value']) && $child_param['value'] = $param['child_value'];
  893. $change = 'style="width:45%" id="' . $param['name'] . '" data-child="' . $child_param['name'] . '_child" ';
  894. $child_class = ' change';
  895. }
  896. if (isset($param['control']) && is_string($param['control'])) {
  897. $change = ' show_id="' . $param['control'] . '" onchange="inputShow($(this), \'' . $param['control'] . '\')"';
  898. } elseif (isset($param['option_add'])) {
  899. $change = ' onchange="addChange($(this))" ';
  900. $style = 'width:25%';
  901. $child_class .= ' change';
  902. } elseif (isset($param['load'])) {
  903. $change = ' onchange="loadChange($(this), \'' . $param['load'] . '\')" ';
  904. $child_class .= ' change';
  905. } elseif (isset($param['bind'])) {
  906. $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
  907. $change = $param['bind'][0] . '="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
  908. $child_class .= ' change';
  909. }
  910. $html .= '<select class="update_value form-control ' . $child_class . ' ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" id="' . $param['name'] . '" ' . $change . ' style="' . $style . '" data-validation-placeholder="0">';
  911. if (isset($param['option'])) {
  912. if (!isset($param['option'][-100]) && isset($param['lang']) && $param['lang']) {
  913. $html .= '<option value="0" selected>' . $param['lang'] . '</option>';
  914. }
  915. if (isset($param['option_add'])) {
  916. $html .= '<option value="0" data-type="add" data-url="'.Dever::url($param['option_add'][1]).'">' . $param['option_add'][0] . '</option>';
  917. }
  918. foreach ($param['option'] as $k => $v) {
  919. if (is_array($v)) {
  920. if (isset($v['lang']) && $v['lang']) {
  921. $value = $v['lang'];
  922. } else {
  923. $value = $v['name'];
  924. }
  925. isset($v['id']) && $k = $v['id'];
  926. } else {
  927. $value = $v;
  928. }
  929. $check = '';
  930. 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 . ','))) {
  931. $check = 'selected';
  932. }
  933. $parent = '';
  934. if (isset($param['parent']) && $param['parent'] && isset($v[$param['parent']])) {
  935. $parent = $v[$param['parent']];
  936. }
  937. if (is_array($v)) {
  938. $value = isset($v['name']) ? $v['name'] : $v['lang'];
  939. } else {
  940. $value = $v;
  941. }
  942. $html .= '<option parent="'.$parent.'" value="' . $k . '" ' . $check . '>' . $value . '</option>';
  943. }
  944. }
  945. $html .= '</select>';
  946. if (isset($param['child'])) {
  947. $child = $child_param['name'];
  948. $hidden = self::hidden(array('name' => $child, 'class' => $child . '_child_value'));
  949. foreach ($param['child'] as $k => $v) {
  950. $child_param['name'] = 'child-' . $k;
  951. $child_param['option'] = $v;
  952. $html .= self::select($child_param, $child . '_child ' . $child . '_child_' . $k . '" parent="' . $k . '" style="display:none;margin-top: -38px;margin-left: 47%;"', $hidden);
  953. }
  954. }
  955. }
  956. $html .= $class ? '</div>' : '';
  957. return $html;
  958. }
  959. /**
  960. * select
  961. *
  962. * @return string
  963. *
  964. public static function _select($param, $class = '', $hidden = '', $change = '')
  965. {
  966. $html = $class ? '<div class="' . $class . '">' : '';
  967. $child_class = '';
  968. $style = '';
  969. if (isset($param['child'])) {
  970. $child_param['name'] = 'update_' . $param['child_name'];
  971. isset($param['value']) && $param['value'] = $param['value'];
  972. isset($param['child_value']) && $child_param['value'] = $param['child_value'];
  973. $change = 'style="width:45%" id="' . $param['name'] . '" data-child="' . $child_param['name'] . '_child" ';
  974. $child_class = ' change';
  975. //$param['name'] .= '_parent';
  976. }
  977. if (isset($param['control']) && is_string($param['control'])) {
  978. //print_r($param);die;
  979. $change = ' show_id="' . $param['control'] . '" onchange="inputShow($(this), \'' . $param['control'] . '\')"';
  980. } elseif (isset($param['option_add'])) {
  981. $change = ' onchange="addChange($(this))" ';
  982. $style = 'width:25%';
  983. $child_class .= ' change';
  984. } elseif (isset($param['load'])) {
  985. $change = ' onchange="loadChange($(this), \'' . $param['load'] . '\')" ';
  986. $child_class .= ' change';
  987. } elseif (isset($param['bind']) && !isset($param['update_search'])) {
  988. $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
  989. $change = $param['bind'][0] . '="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
  990. $child_class .= ' change';
  991. }
  992. $xm = '';
  993. if ($change) {
  994. $xm = '';
  995. } else {
  996. }
  997. if (!$change && isset($param['update'])) {
  998. $xm = 'xm-select="' . $param['name'] . '" xm-select-skin="normal" xm-select-search="" xm-select-search-type="dl"';
  999. if ($param['update'] != 'selects') {
  1000. $xm .= ' xm-select-radio=""';
  1001. }
  1002. $search_value = '';
  1003. if (isset($param['value'])) {
  1004. $search_value = $param['value'];
  1005. } elseif (isset($param['default'])) {
  1006. $search_value = $param['default'];
  1007. }
  1008. if (isset($param['update_search'])) {
  1009. if (strstr($param['update_search'], '{id}')) {
  1010. $param['update_search'] = str_replace('{id}', 'where_id=' . $param['where_id'], $param['update_search']);
  1011. }
  1012. $xm = str_replace('xm-select-search=""', 'xm-select-search="'.Dever::url($param['update_search'] . '&yes='.$search_value.'&json=1').'"', $xm);
  1013. if (isset($param['bind'])) {
  1014. $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
  1015. $xm .= ' xm-select-callback="'.$param['bind'][1].'" xm-select-callback-param="'.$param['bind'][2].'"';
  1016. }
  1017. }
  1018. if (isset($param['update_create'])) {
  1019. $xm .= ' xm-select-create=""';
  1020. }
  1021. if ($param['match'] != 'option') {
  1022. $xm .= ' lay-verify="' . $param['name'] . '"';
  1023. }
  1024. if ($param['update'] == 'selects' && isset($param['lang']) && $param['lang']) {
  1025. $xm .= ' xm-select-placeholder="'.$param['lang'].'"';
  1026. unset($param['lang']);
  1027. }
  1028. } else {
  1029. $xm .= ' xm-select-radio=""';
  1030. }
  1031. if (isset($param['option']) && isset($param['update']) && $param['update'] == 'select') {
  1032. $total = count($param['option']);
  1033. if ($total <= 30) {
  1034. $xm = '';
  1035. }
  1036. }
  1037. $html .= $hidden . '<select '.$xm.' class="update_value form-control ' . $child_class . ' ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" id="' . $param['name'] . '" ' . $change . ' style="' . $style . '" data-validation-placeholder="0">';
  1038. if (isset($param['option'])) {
  1039. if (!isset($param['option'][-100]) && isset($param['lang']) && $param['lang']) {
  1040. $html .= '<option value="0" selected>' . $param['lang'] . '</option>';
  1041. }
  1042. if (isset($param['option_add'])) {
  1043. $html .= '<option value="0" data-type="add" data-url="'.Dever::url($param['option_add'][1]).'">' . $param['option_add'][0] . '</option>';
  1044. }
  1045. foreach ($param['option'] as $k => $v) {
  1046. if (is_array($v)) {
  1047. if (isset($v['lang']) && $v['lang']) {
  1048. $value = $v['lang'];
  1049. } else {
  1050. $value = $v['name'];
  1051. }
  1052. isset($v['id']) && $k = $v['id'];
  1053. } else {
  1054. $value = $v;
  1055. }
  1056. $check = '';
  1057. 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 . ','))) {
  1058. $check = 'selected';
  1059. }
  1060. $parent = '';
  1061. if (isset($param['parent']) && $param['parent'] && isset($v[$param['parent']])) {
  1062. $parent = $v[$param['parent']];
  1063. }
  1064. if (is_array($v)) {
  1065. $value = isset($v['name']) ? $v['name'] : $v['lang'];
  1066. } else {
  1067. $value = $v;
  1068. }
  1069. $html .= '<option parent="'.$parent.'" value="' . $k . '" ' . $check . '>' . $value . '</option>';
  1070. }
  1071. }
  1072. $html .= '</select>';
  1073. if (isset($param['child'])) {
  1074. $child = $child_param['name'];
  1075. $hidden = self::hidden(array('name' => $child, 'class' => $child . '_child_value'));
  1076. foreach ($param['child'] as $k => $v) {
  1077. $child_param['name'] = 'child-' . $k;
  1078. $child_param['option'] = $v;
  1079. $html .= self::select($child_param, $child . '_child ' . $child . '_child_' . $k . '" parent="' . $k . '" style="display:none;margin-top: -38px;margin-left: 47%;"', $hidden);
  1080. }
  1081. }
  1082. $html .= $class ? '</div>' : '';
  1083. return $html;
  1084. }
  1085. /**
  1086. * radio
  1087. *
  1088. * @return string
  1089. */
  1090. public static function _checkbox($param)
  1091. {
  1092. return self::radio($param);
  1093. }
  1094. /**
  1095. * text
  1096. *
  1097. * @return string
  1098. */
  1099. public static function _text($param, $class = '')
  1100. {
  1101. if ($class) {
  1102. return '<div class="">' . self::text($param, false) . '</div>';
  1103. } else {
  1104. $auto = $input = '';
  1105. if (isset($param['const'])) {
  1106. $value = $param['const'];
  1107. } else {
  1108. $value = (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : ''));
  1109. }
  1110. if (isset($param['autocomplete']) && $param['update'] == 'text') {
  1111. if (empty($param['autocomplete'][1])) {
  1112. $param['autocomplete'][1] = 'value';
  1113. }
  1114. if ($param['autocomplete'][1] == 'id') {
  1115. $input = self::hidden(array('name' => $param['name'], 'value' => $value));
  1116. $input = '<script>var autocomplete_value = {};autocomplete_value[\''.$param['name'].'_value\'] = [];</script>';
  1117. if (isset($param['autocomplete'][2]) && $value) {
  1118. # 重新定义value
  1119. $value = Dever::load($param['autocomplete'][2], $value);
  1120. if (is_array($value)) {
  1121. $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">';
  1122. foreach ($value as $k => $v) {
  1123. $link = '';
  1124. $attr = '';
  1125. $pic = '';
  1126. if (!isset($v['value'])) {
  1127. $v['value'] = $v['name'];
  1128. }
  1129. if (isset($v['pic']) && $v['pic']) {
  1130. $pic = '<a href="javascript:;"><img src="'.$v['pic'].'" width="100"></a>&nbsp;&nbsp;';
  1131. }
  1132. if (isset($v['link']) && $v['link']) {
  1133. $link = $v['link'];
  1134. $attr = ' target="_blank"';
  1135. }
  1136. if (isset($v['click']) && $v['click']) {
  1137. $link = 'javascript:;';
  1138. $attr = ' onclick="'.$v['click'].'"';
  1139. }
  1140. $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>';
  1141. }
  1142. $html .= '</table></div>';
  1143. $input .= $html;
  1144. $value = '';
  1145. }
  1146. }
  1147. $param['name'] = $param['name'] . '_temp';
  1148. }
  1149. $auto = 'complete="' . Dever::url($param['autocomplete'][0]) . '" complete_callback="' . $param['autocomplete'][1] . '" ';
  1150. if (isset($param['autocomplete'][3])) {
  1151. $auto .= ' complete_cate="' . $param['autocomplete'][3] . '" ';
  1152. }
  1153. } elseif (isset($param['searchbox'])) {
  1154. if (empty($param['searchbox'][1])) {
  1155. $param['searchbox'][1] = 'value';
  1156. }
  1157. if ($param['searchbox'][1] == 'id') {
  1158. $input = self::hidden(array('name' => $param['name'], 'value' => $value));
  1159. $input = '<script>var searchbox_value = [];searchbox_value[\''.$param['name'].'_value\'] = [];</script>';
  1160. if (isset($param['searchbox'][2]) && $value) {
  1161. # 重新定义value
  1162. $value = Dever::load($param['searchbox'][2], $value);
  1163. if (is_array($value)) {
  1164. $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">';
  1165. foreach ($value as $k => $v) {
  1166. $link = '';
  1167. $attr = '';
  1168. $pic = '';
  1169. if (!isset($v['value'])) {
  1170. $v['value'] = $v['name'];
  1171. }
  1172. if (isset($v['pic']) && $v['pic']) {
  1173. $pic = '<a href="javascript:;"><img src="'.$v['pic'].'" width="100"></a>&nbsp;&nbsp;';
  1174. }
  1175. if (isset($v['link']) && $v['link']) {
  1176. $link = $v['link'];
  1177. $attr = ' target="_blank"';
  1178. }
  1179. $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>';
  1180. }
  1181. $html .= '</table></div>';
  1182. $input .= $html;
  1183. $value = '';
  1184. }
  1185. }
  1186. $param['name'] = $param['name'] . '_temp';
  1187. }
  1188. $auto = 'searchbox="' . Dever::url($param['searchbox'][0]) . '" searchbox_callback="' . $param['searchbox'][1] . '" ';
  1189. if (isset($param['searchbox'][3])) {
  1190. $auto .= ' searchbox_cate="' . $param['searchbox'][3] . '" ';
  1191. }
  1192. $search = '';
  1193. if (isset($param['searchbox'][4])) {
  1194. $temp = explode(',', $param['searchbox'][3]);
  1195. $link = explode(',', $param['searchbox'][4]);
  1196. $p = array();
  1197. $p['option'] = array();
  1198. foreach ($temp as $k => $v) {
  1199. $p['name'] = $v;
  1200. $p['option'] = Dever::load($link[$k]);
  1201. $search .= self::_select($p, '', '', ' style="width: 15%;display: inline;margin-left:5px;"');
  1202. }
  1203. }
  1204. $auto .= ' style="display: inline;"';
  1205. $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;
  1206. }
  1207. if (isset($param['bind'])) {
  1208. $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
  1209. $auto .= $param['bind'][0] . '="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
  1210. $auto .= ' onload="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
  1211. }
  1212. //id _value
  1213. 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'] . '" autocomplete="new'.time().'" placeholder="' . (isset($param['placeholder']) ? $param['placeholder'] : '') . '"/>' . $input;
  1214. }
  1215. }
  1216. /**
  1217. * color
  1218. *
  1219. * @return string
  1220. */
  1221. public static function _color($param)
  1222. {
  1223. $param['class'] = 'dever-color form-control';
  1224. $param['update'] = 'text';
  1225. $param['default'] = isset($param['default']) ? $param['default'] : '#000000';
  1226. return self::_text($param, '');
  1227. }
  1228. /**
  1229. * password
  1230. *
  1231. * @return string
  1232. */
  1233. public static function _password($param)
  1234. {
  1235. $param['value'] = '';
  1236. return self::_text($param);
  1237. }
  1238. /**
  1239. * hidden
  1240. *
  1241. * @return string
  1242. */
  1243. public static function _hidden($param)
  1244. {
  1245. $param['type'] = 'hidden';
  1246. $param['update'] = 'hidden';
  1247. return self::_text($param, '');
  1248. }
  1249. /**
  1250. * 选择详细的时间
  1251. *
  1252. * @return string
  1253. */
  1254. public static function _date($param, $type = true, $key = 'date', $parse = 'Y-m-d H:i:s')
  1255. {
  1256. $time = $value = '';
  1257. if ((isset($param['value']) && $param['value'] > 0)) {
  1258. $time = $param['value'];
  1259. } elseif ((isset($param['default']) && $param['default'] > 0)) {
  1260. $time = $param['default'];
  1261. } elseif($type) {
  1262. $time = time();
  1263. }
  1264. if ($time) {
  1265. if (strlen($time) >= 10) {
  1266. $value = date($parse, $time);
  1267. } else {
  1268. $value = $time;
  1269. }
  1270. }
  1271. 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"/>';
  1272. }
  1273. /**
  1274. * time已废弃,用day替换,兼容不删除
  1275. *
  1276. * @return string
  1277. */
  1278. public static function _time($param, $type = false)
  1279. {
  1280. return self::_day($param, $type);
  1281. }
  1282. /**
  1283. * day 选择天
  1284. *
  1285. * @return string
  1286. */
  1287. public static function _day($param, $type = false)
  1288. {
  1289. return self::_date($param, $type, 'day', 'Y-m-d');
  1290. }
  1291. /**
  1292. * 选择年
  1293. *
  1294. * @return string
  1295. */
  1296. public static function _year($param, $type = false)
  1297. {
  1298. return self::_date($param, $type, 'year', 'Y');
  1299. }
  1300. /**
  1301. * 选择月
  1302. *
  1303. * @return string
  1304. */
  1305. public static function _month($param, $type = false)
  1306. {
  1307. return self::_date($param, $type, 'month', 'Y-m');
  1308. }
  1309. /**
  1310. * 选择几天内
  1311. *
  1312. * @return string
  1313. */
  1314. public static function _sday($param, $type = false)
  1315. {
  1316. $date = self::_date($param, $type, 'sday', 'Y-m-d');
  1317. return $date;
  1318. }
  1319. /**
  1320. * 选择几天内
  1321. *
  1322. * @return string
  1323. */
  1324. public static function _sdate($param, $type = false)
  1325. {
  1326. $date = self::_date($param, $type, 'sdate');
  1327. return $date;
  1328. }
  1329. /**
  1330. * div
  1331. *
  1332. * @return string
  1333. */
  1334. public static function _node($param, $type = 'div')
  1335. {
  1336. $result = array('', '');
  1337. foreach ($param as $k => $v) {
  1338. $result[0] .= '<' . $type . ' ' . $v . '>';
  1339. $result[1] .= '</' . $type . '>';
  1340. }
  1341. return $result;
  1342. }
  1343. /**
  1344. * _load
  1345. *
  1346. * @return string
  1347. */
  1348. public static function _load($param)
  1349. {
  1350. $cate = '';
  1351. $load = $param['update_load'];
  1352. if (is_array($load)) {
  1353. $cate = $load[1];
  1354. $load = $load[0];
  1355. }
  1356. $html = '<div class="update_load" id="'.$param['name'].'" data-load="'.Dever::url($load).'" data-cate="'.$cate.'" data-id="'.$param['where_id'].'"></div>';
  1357. return $html;
  1358. }
  1359. /**
  1360. * 规格设置
  1361. *
  1362. * @return string
  1363. */
  1364. public static function _sku($param)
  1365. {
  1366. $col = Dever::json_encode($param['sku']['col']);
  1367. $param['sku']['api']['spec'] = Dever::url($param['sku']['api']['spec'] . '?json=1&id=' . $param['where_id']);
  1368. $param['sku']['api']['sku'] = Dever::url($param['sku']['api']['sku'] . '?json=1&id=' . $param['where_id']);
  1369. $param['sku']['api']['upload'] = Dever::url($param['sku']['api']['upload']);
  1370. if (isset($param['data']) && isset($param['data']['spec_type']) && $param['data']['spec_type']) {
  1371. $type = $param['data']['spec_type'];
  1372. } else {
  1373. $type = 1;
  1374. }
  1375. $html = '<!-- 规格类型 -->
  1376. <div id="sku_spec_type" data-id="'.$param['where_id'].'" data-type="'.$type.'" data-spec="'.$param['sku']['api']['spec'].'" data-sku="'.$param['sku']['api']['sku'].'" data-upload="'.$param['sku']['api']['upload'].'"></div>
  1377. <!--商品规格表-->
  1378. <div id="sku_spec_table"></div>
  1379. <!--商品库存表-->
  1380. <div id="sku_table"></div><div id="sku_table_col" style="display:none">'.$col.'</div>';
  1381. return $html;
  1382. }
  1383. /**
  1384. * show
  1385. *
  1386. * @return string
  1387. */
  1388. public static function _show($param, $class = '')
  1389. {
  1390. $value = (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : ''));
  1391. return '<div id="' . $param['name'] . '">' . $value . '</div>';
  1392. }
  1393. }