Input.php 77 KB

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