1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654 |
- <?php
- namespace Manage\Src\Lib;
- use Dever;
- class Input
- {
- public static function __callStatic($name, $param = array())
- {
- $method = '_' . $name;
- $result = call_user_func_array(array(__CLASS__, $method), $param);
- if ($result && is_string($result) && $name != 'pageLeft') {
- if (layadmin()) {
- if (strstr($result, '<select')) {
- $result = str_replace('form-control', 'form-control layui-input layui-select', $result);
- $result = str_replace('<select', '<select lay-ignore ', $result);
- } elseif (strstr($result, 'radio')) {
- $result = str_replace('form-control', 'form-control layui-radio', $result);
- } elseif (strstr($result, 'checkbox')) {
- $result = str_replace('form-control', 'form-control layui-checkbox', $result);
- } else {
- $result = str_replace('form-control', 'form-control layui-input', $result);
- }
-
- if ((isset($param[0]['type']) && $param[0]['type'] == 'hidden')) {
- $result = '<div class="layui-inline" style="display:none;">'.$result.'</div>';
- } elseif (isset($param[1]) && !$param[1] && ((isset($param[0]['update']) && $param[0]['update'] != 'hidden') || !isset($param[0]['update']))) {
- $result = '<div class="layui-inline"><div class="layui-input-inline">'.$result.'</div></div>';
- } else {
- $result = '<div>'.$result.'</div>';
- }
- } else {
- if (isset($param[0]['update']) && $param[0]['update'] == 'hidden') {
-
- } elseif (isset($param[1]) && !$param[1]) {
- $result = '<div style="display:inline;margin-right: 10px;">'.$result.'</div>';
- }
- }
-
- }
- return $result;
- }
- /**
- * 地图
- *
- * @return string
- */
- public static function _map($param)
- {
- $url = Dever::url('map', 'manage');
- $html = self::text($param);
- $id = $param['name'] . '_value';
- $iframe_id = $id . '_map';
- $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>';
- $html .= '<script>$(function()
- {
- $("#'.$id.'").blur(function()
- {
- layui.layer.msg("搜索中...");
- $("#'.$iframe_id.'")[0].contentWindow.search($(this).val());
- });
- });
- function mapLoad(){
- if ($("#'.$id.'").val()) {
- $("#'.$iframe_id.'")[0].contentWindow.showMaker($("#'.$id.'").val());
- }
- }
- function closeMsg() {
- layui.layer.closeAll();
- }
- function setMap(x, y, z) {
- var val = $("#'.$id.'").val();
- if (val) {
- var temp = val.split(",");
- val = temp[0];
- }
- $("#'.$id.'").val(val + "," + x + "," + y + "," + z);
- }</script>';
- return $html;
- }
- /**
- * desc
- *
- * @return string
- */
- public static function _modal($modal, $desc)
- {
- return '<a href="javascript:;" onclick="showAlert($(this).next().html());initLayui();">' . $modal . '</a><div style="display:none;">' . $desc . '</div>';
- }
- /**
- * desc
- *
- * @return string
- */
- public static function _desc($desc)
- {
- return '';
- return $desc;
- }
- /**
- * hr 分割线
- *
- * @return string
- */
- public static function _hr($param)
- {
- if (layadmin()) {
-
- $col = '';
- if (isset($param['right'])) {
- $col = '</div><div class="layui-col-md6">';
- }
- $html = '</div></div></div>'.$col.'<div class="layui-card"><div class="layui-card-header">[' . $param['name'] . ']</div><div class="layui-card-body"><div>';
- return $html;
- }
- return '<div class="dever_form_hr ' . (isset($param['class']) ? $param['class'] : '') . '" ' . (isset($param['attr']) ? $param['attr'] : '') . '>' . $param['name'] . '</div>';
- }
- /**
- * cue
- *
- * @return string
- */
- public static function _cue($param)
- {
- $param['cue'] = isset($param['cue']) ? $param['cue'] : '';
- if (strpos($param['name'], '-') !== false) {
- $temp = explode('-', $param['name']);
- $param['name'] = $temp[0];
- $param['cue'] = $temp[1];
- } elseif (strpos($param['name'], '(') !== false) {
- $temp = explode('(', $param['name']);
- $param['name'] = $temp[0];
- $param['cue'] = str_replace(')', '', $temp[1]);
- } elseif (strpos($param['name'], '(') !== false) {
- $temp = explode('(', $param['name']);
- $param['name'] = $temp[0];
- $param['cue'] = str_replace(')', '', $temp[1]);
- }
- return $param;
- }
- /**
- * pageLeft
- *
- * @return string
- */
- public static function _pageLeft($param)
- {
- $param = self::cue($param);
- if ($param['cue']) {
- $param['cue'] = '<span style="font-size:12px;font-weight:normal;font-color:#bababa;margin-left:5px;">[' . $param['cue'] . ']</span>';
- }
- $param['button'] = '';
- if (isset($param['update_type']) && $param['update_type'] == 2) {
- $param['button'] = '<a href="javascript:;" onclick="append($(this), \''.$param['ext'].'\')" style="margin-left:5px;" class="layui-btn layui-btn-xs layui-btn-normal">新增</a>';
- }
- $class = '';
- $style = '';
- if (layadmin()) {
- //$class = 'layui-form-label';
- if (isset($param['update']) && is_array($param['update'])) {
- $style = ' style="margin:10px;"';
- }
- }
-
- $html = '<div '.$style.'><label style="font-size:14px;font-weight:bold;" class="'.$class.'">' . $param['name'] . $param['cue'] . $param['button'] . '</label></div>';
- return $html;
- }
- /**
- * textarea
- *
- * @return string
- */
- public static function _textarea($param)
- {
- 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>';
- 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>';
- }
- private static function uploadHandle($param)
- {
- $html = $style = '';
- $div = array('', '');
- $type = 'button';
- $yun = false;
- if (isset($param['upload']) && ($param['upload'] == 'yun' || $param['upload'] == 'qiniu')) {
- $upload = Dever::project('upload');
- if ($upload && !strstr($upload['path'], 'http')) {
- $upload = Dever::load('upload/yun.token?return=1&key=' . $param['key']);
- } else {
- $upload = Dever::load('upload/yun.token?key=' . $param['key']);
- }
-
- if (isset($upload['domain'])) {
- $bucket = $upload['bucket'];
- $domain = $upload['domain'];
- $token = $upload['uptoken'];
- $host = $upload['host'];
- $cover = 1;
- $yun = true;
- if (isset($param['cover']) && $param['cover']) {
- $cover = $param['cover'];
- } elseif (isset($upload['cover']) && $upload['cover']) {
- $cover = $upload['cover'];
- }
- $date = explode('-', date("Y-m-d"));
- $path = $param['key'] . '/' . $date[0] . '/' . $date[1] . '/' . $date[2] . '/';
- $html = ' m="'.$upload['type'].'" cover="'.$cover.'" domain="'.$domain.'" bucket="'.$bucket.'" path="'.$path.'" host="'.$host.'" token="'.$token.'" ';
- }
- }
- if (isset($param['large']) && $param['large'] && isset($upload['domain'])) {
- $html .= ' l="1" ';
- $type = 'file';
- $div = array('<div class="layui-input" style=" position: relative;
- display: inline-block;
- border-radius: 2px;
- color: black;
- text-decoration: none;
- text-indent: 0;
- line-height: 37px;
- height: 37px;
- width: 97px;
- padding-left: 19px;">', '本地上传</div>');
- $style = 'position: absolute;
- font-size: 21px;
- right: 0;
- top: 0;
- opacity: 0;';
- }
- return array($html, $type, $div, $style, $yun);
- }
- private static function uploadParam($param)
- {
- if (isset($param['upload_key'])) {
- $param['key'] = $param['upload_key'];
- }
- if (isset($param['upload_place'])) {
- $param['place'] = $param['upload_place'];
- }
- if (!isset($param['upload_search'])) {
- $param['upload_search_value'] = $param['project'] . '-' . $param['table'] . '.' . $param['col'];
- $param['upload_search'] = $param['upload_search_value'];
-
- } else {
- if (!isset($param['upload_search_value'])) {
- $param['upload_search_value'] = $param['upload_search'];
- }
- }
- $param['upload_search_show'] = $param['upload_search'];
- if (strstr($param['upload_search'], '#')) {
- $temp = explode('#', $param['upload_search']);
- $param['upload_search_show'] = $temp[0];
- if ($temp[1] > 0) {
- $param['upload_search_show'] .= '_<script>document.write($("#upload_'.$temp[1].'_value").val());</script>';
- }
-
- }
- if (isset($param['place']) && $param['place']) {
- //$pic = 'src="http://placehold.it/' . $param['place'] . '"';
- //$param['placeimg'] = '<img src="http://temp.im/' . $param['place'] . '" class="place" width="150" />';
- $place = $param['place'];
- $default = '';
- if (strstr($param['place'], '?')) {
- $temp = explode('?', $param['place']);
- $param['place'] = $temp[0];
- $default .= '&';
- } else {
- $default .= '?';
- }
- if (strstr($place, '*')) {
- $place = str_replace('*', 'x', $place);
- } elseif (strstr($place, 'X')) {
- $place = str_replace('X', 'x', $place);
- } else {
- $place = $param['place'] . 'x' . $param['place'];
- }
- $text = '';
- //$text = "" . $place . "px \n 大小不能超过2M";
- //$text = "图片尺寸".$place."px \n 也可以上传等比尺寸 \n 上传大小不能超过2M \n 支持JPG、PNG、 GIF格式";
-
- //$default .= 'auto=yes&theme=social&text=' . $text;
- $default .= 'auto=yes&text=' . $text;
- $place .= $default;
- $param['placeimg'] = '<img src="holder.js/' . $place . '" class="place" style="width:150px" onclick="$(this).parent().parent().find(\'.image_upload\').click()"/>';
- } else {
- $param['place'] = '';
- $param['placeimg'] = '';
- }
- if (isset($param['upload_call'])) {
- $param['call'] = $param['upload_call'];
- }
- if (!isset($param['call'])) {
- $param['call'] = '';
- }
- return $param;
- }
- /**
- * image
- *
- * @return string
- */
- public static function _image($param)
- {
- $param = self::uploadParam($param);
- if (isset($param['value']) && $param['value']) {
- $pic = 'src="' . $param['value'] . '"';
- if (strstr($param['value'], '.cr')) {
- $temp = explode('.cr', $param['value']);
- $pic .= ' data-src="' . $temp[0] . '"';
- }
- } else {
- $pic = 'src="" style=display:none;';
- }
- $class = 'width:100px;display:inline;';
- if (layadmin()) {
- $class .= 'padding-left:0px;';
- }
- $upload = self::uploadHandle($param);
- $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];
- return $button .'
- <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>
- <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">
- <div class="layui-progress-bar" lay-percent="0%"></div>
- </div>
- <div style="margin-top: 10px;margin-bottom: 10px;">
-
- '.$param['placeimg'].'
- <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>
- <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'] : '')) . '">';
- }
- /**
- * images
- *
- * @return string
- */
- public static function _images($param)
- {
- $param = self::uploadParam($param);
- $pic = $param['placeimg'];
- if (isset($param['value']) && $param['value']) {
- $temp = explode(',', $param['value']);
- foreach ($temp as $k => $v) {
- $data_src = '';
- if (strstr($v, '.cr')) {
- $temp = explode('.cr', $v);
- $data_src = $temp[0];
- }
- $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>';
- }
- }
- $class = 'width:100px;display:inline;';
- if (layadmin()) {
- $class .= 'padding-left:0px;';
- }
- $upload = self::uploadHandle($param);
- $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];
- return $button . '
- <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>
- <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">
- <div class="layui-progress-bar" lay-percent="0%"></div>
- </div>
- <div style="margin-top: 10px;margin-bottom: 10px;" update_type="html" class="update_value ' . $param['name'] . '_' . $param['index'] . '_mul">' . $pic . '</div>
- <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'] : '')) . '">';
- }
- /**
- * upload
- *
- * @return string
- */
- public static function _upload($param)
- {
- $param = self::uploadParam($param);
- $class = 'width:100px;display:inline;';
- if (layadmin()) {
- $class .= 'padding-left:0px;';
- }
- $upload = self::uploadHandle($param);
- $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];
- return $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="文件库"/><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">
- <div class="layui-progress-bar" lay-percent="0%"></div>
- </div>
- <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'] : '')) . '">
- </div>';
- //return '<input type="file" class="form-control" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '" name="' . $param['name'] . '"/>';
- }
- /**
- * upload
- *
- * @return string
- */
- public static function _uploads($param)
- {
- $param = self::uploadParam($param);
- $file = '';
- if (isset($param['value']) && $param['value']) {
- $temp = explode(',', $param['value']);
- foreach ($temp as $k => $v) {
- $upload = Dever::load('upload/file-check', array('option_key' => md5($v)));
- $file .= '<li><a href="' . $v . '" rel="box" title="点此下载" >' . $upload['source_name'] . '</a> <a href="javascript:;" style="color:red;" title="点此删除" onclick="fileDel($(this), \'' . $param['name'] . '_' . $param['index'] . '\')">[删除]</a></li>';
- }
- }
- $class = 'width:100px;display:inline;';
- if (layadmin()) {
- $class .= 'padding-left:0px;';
- }
- $upload = self::uploadHandle($param);
- $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];
- return $button .'
- <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>
- <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">
- <div class="layui-progress-bar" lay-percent="0%"></div>
- </div>
- <ul style="margin-top: 10px;margin-bottom: 10px;" update_type="html" class="update_value ' . $param['name'] . '_' . $param['index'] . '_mul">' . $file . '</ul>
- <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'] : '')) . '">';
- //return '<input type="file" class="form-control" value="' . (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '')) . '" name="' . $param['name'] . '"/>';
- }
- /**
- * video
- *
- * @return string
- */
- public static function _video($param)
- {
- $param = self::uploadParam($param);
- $class = 'width:100px;display:inline;';
- if (layadmin()) {
- $class .= 'padding-left:0px;';
- }
- $upload = self::uploadHandle($param);
- $value = (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : ''));
- $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];
- $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="视频库"/>';
- if (isset($upload[4]) && $upload[4]) {
- $cover = isset($param['cover']) ? $param['cover'] : 'pic';
- $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="生成封面图"/>';
- }
- $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">
- <div class="layui-progress-bar" lay-percent="0%"></div>
- </div>
- <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 . '">
- </div>';
- return $button;
- }
- /**
- * editor
- *
- * @return string
- */
- public static function _editor($param)
- {
- $param = self::uploadParam($param);
- $width = '100%';
- $html = '';
- if (isset($param['editor'])) {
- $width = '70%';
- if (layadmin()) {
- $left = '740px';
- } else {
- $left = '766px';
- }
- $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>';
- foreach ($param['editor']['button'] as $k => $v) {
- if (isset($v['type'])) {
- if ($v['type'] == 'image') {
- $param['key'] = $v['key'];
- } elseif ($v['type'] == 'media') {
- $param['media'] = $v['key'];
- }
- $v['attr'] = 'editor_tool" tool="' . $v['type'];
-
- } else {
- $v['attr'] = 'upload_show_editor';
- }
- if (isset($v['type']) && $v['type'] == 'update') {
- $v['attr'] = 'update_show_editor';
- $v['key'] = Dever::url($v['key']);
- $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'].'">';
- } else {
- $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'].'">';
- }
-
- }
- $html .= '</div></div>';
- }
- $upload = self::uploadHandle($param);
- 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>';
- }
- /**
- * markdown
- *
- * @return string
- */
- public static function _markdown($param)
- {
- 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>';
- }
- /**
- * selector
- *
- * @return string
- */
- public static function _selector($param, $type = '')
- {
- $html = '';
- if (isset($param['key']) && strpos($param['key'], '.css') !== false) {
- $param['key'] = '<link rel="stylesheet" href="' . $param['key'] . '"/>';
- }
- if (isset($param['option'])) {
- foreach ($param['option'] as $k => $v) {
- $check = '';
- if ((isset($param['value']) && $param['value'] == $k) || (empty($param['value']) && isset($param['default']) && $param['default'] == $k)) {
- $check = 'checked';
- }
- if (is_array($v)) {
- $value = $v['name'];
- } else {
- $value = $v;
- }
- $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> ';
- }
- $html .= self::hidden($param);
- }
- return '<div class="am-btn-group" >' . $html . '</div>';
- }
- /**
- * radio
- *
- * @return string
- */
- public static function _radio($param, $type = '')
- {
- $html = '';
- if (isset($param['option'])) {
- if (isset($param['option']['state']) && $param['option']['state'] >= 1) {
- # 处理比较复杂的多维数组
- $state = $param['option']['state'];
- unset($param['option']['state']);
- if (isset($param['value']) && $param['value']) {
- if ($state == 2) {
- $param['value'] = Dever::json_decode($param['value']);
- } else {
- $param['value'] = explode(',', $param['value']);
- }
-
- } else {
- $param['value'] = array();
- }
-
- $j = -1;
- $name = $param['name'];
- foreach ($param['option'] as $k => $v) {
- $check = '';
- if (isset($param['update_parent'])) {
- $input_type = $param['update_parent'];
- } else {
- $input_type = $param['update'];
- }
- if ($state == 2) {
- $parent_check = '';
-
- if (isset($param['value']) && isset($param['value'][$v['id']])) {
- $vt = implode(',', $param['value'][$v['id']]);
- if ($vt != -1) {
- $parent_check = 'checked';
- }
- }
- $name = $name . '['.$v['id'].']';
- $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 />';
- } else {
- $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 />';
- }
- $span = array('', '');
- if (isset($v['child']) && $v['child']) {
- //$i = 1;
-
- $html .= '<ul style="list-style:none;margin:0px;display:;margin-left: 26px;" class="">';
- foreach ($v['child'] as $ki => $vi) {
- if (!is_array($vi)) {
- $temp = $vi;
- $vi = array();
- $vi['name'] = $temp;
- $vi['id'] = $ki;
- }
- if (isset($v['url'])) {
- $span = array('<span class="edit" data-url="' . Dever::url($v['url'] . '?id=' . $vi['id']) . '">', '</span>');
- }
- $check = '';
- $disabled = 'disabled="true"';
- if ($state == 2) {
- if (isset($param['value']) && isset($param['value'][$v['id']]) && in_array($vi['id'], $param['value'][$v['id']])) {
- $check = 'checked';
- $disabled = '';
- $j++;
- }
- } elseif (isset($param['value']) && in_array($vi['id'], $param['value'])) {
- $check = 'checked';
- $disabled = '';
- $j++;
- } elseif (isset($param['default']) && is_array($param['default']) && (in_array($k . '_' . $vi['id'], $param['default']))) {
- $check = 'checked';
- $disabled = '';
- $j++;
- }
- $input = $input_value = '';
- if (isset($vi['func']) && $vi['func']) {
- $input .= '<ul style="margin-left: 26px;">';
- foreach ($vi['func'] as $vf) {
- $fcheck = '';
- if (isset($param['value']) && in_array('f_' . $vf['id'], $param['value'])) {
- $fcheck = 'checked';
- }
- $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>';
- // ' . $span[0] . $vf['name'] . $span[1] . '
- }
- $input .= '</ul>';
- $vi['name'] .= '('.count($vi['func']).')';
- } elseif (isset($param['update_input']) && $param['update_input']) {
- if (isset($param['update_input_data']) && isset($param['update_input_data'][$j])) {
- $input_value = $param['update_input_data'][$j];
- if ($disabled) {
- $input_value = '';
- }
- } else {
- $input_value = isset($param['update_input_default']) ? $param['update_input_default'] : '';
- }
- if ($param['update_input']) {
- $input = '[' . $param['update_input'] . ']';
- }
- $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 . '/>';
- }
- //$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] . ' ' . $input . '</li>';
- if (!$input) {
- $s = 'style="display:inline"';
- } else {
- $s = '';
- }
- $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>';
- //++$i;
- }
- $html .= '</ul>';
- }
- $html .= '<br />';
- }
- } else {
- $js = '';
- if (isset($param['control']) && is_string($param['control'])) {
- //print_r($param);die;
- $js = ' show_id="' . $param['control'] . '" onclick="inputShow($(this), \'' . $param['control'] . '\', \'input\')"';
- } elseif (isset($param['load'])) {
- $js = ' onchange="loadChange($(this), \'' . $param['load'] . '\')" ';
- $js .= ' onload="loadChange($(this), \'' . $param['load'] . '\')" ';
- } elseif (isset($param['bind'])) {
- $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
- $js = $param['bind'][0] . '="' . $param['bind'][1] . '(\'' . $param['name'] . '\', $(this), ' . $param['bind'][2] . ')" ';
- $js .= ' onload="' . $param['bind'][1] . '(\'' . $param['name'] . '\', $(this), ' . $param['bind'][2] . ')" ';
- }
- $param['parent'] = isset($param['parent']) ? $param['parent'] : '0';
- $param['parent'] .= '_' . $param['name'];
- if ($param['update'] == 'checkbox' && empty($param['checkall'])) {
- $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"/>';
- }
- $i = 0;
- foreach ($param['option'] as $k => $v) {
- $check = '';
- if (is_array($v)) {
- $value = $v['name'];
- isset($v['id']) && $k = $v['id'];
- } else {
- $value = $v;
- }
- if (isset($param['bit'][$k])) {
- if (isset($param['value']) && ($param['value'] & $k) > 0) {
- $check = 'checked';
- }
- } elseif (isset($param['value'])) {
- if (is_string($param['value']) && strpos(',' . $param['value'] . ',', ',' . $k . ',') !== false) {
- $check = 'checked';
- } elseif (is_array($param['value']) && in_array($k, $param['value'])) {
- $check = 'checked';
- }
- } elseif (isset($param['default']) && $param['default']) {
- if (is_string($param['default']) && strpos(',' . $param['default'], ',' . $k) !== false) {
- $check = 'checked';
- } elseif (is_array($param['default']) && in_array($k, $param['default'])) {
- $check = 'checked';
- }
- } elseif ($param['update'] == 'radio' && $i == 0) {
- $check = 'checked';
- }
- $cjs = $js;
- if (isset($param['control']) && is_string($param['control']) && $param['control'] != $param['name']) {
- $cjs = str_replace('update_', '', str_replace($param['control'], $param['name'], $js));
- }
- $disabled = '';
- if (isset($param['disabled'])) {
- $disabled = 'disabled="true"';
- }
- $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.'"/>';
- if (isset($param['bind'])) {
- //$html .= '<script>$(document).ready(function(){$(".checkbox-checkall-'.$param['parent'].'").click();})</script>';
- }
- $i++;
- }
- }
- }
- return '<div class="am-btn-group" >' . $html . '</div>';
- }
- /**
- * group
- *
- * @return string
- */
- public static function _group($param, $class = '', $hidden = '', $change = '')
- {
- $html = $class ? '<div class="' . $class . '">' : '';
- $html .= $hidden . '<select class="update_value form-control ' . (isset($param['valid']) ? $param['valid'] : '') . '" name="' . $param['name'] . '" ' . $change . '>';
- if (isset($param['option'])) {
- foreach ($param['option'] as $k => $v) {
- if ($v['id'] <= 0) {
- $html .= '<option value="0" selected>' . $v['name'] . '</option>';
- } else {
- $html .= '<optgroup label="' . $v['name'] . '">';
- if (isset($v['child'])) {
- foreach ($v['child'] as $k1 => $v1) {
- $selected = '';
- if ((isset($param['value']) && $param['value'] == $v1['id']) || (empty($param['value']) && isset($param['default']) && $param['default'] == $v1['id'])) {
- $selected = 'selected';
- }
- $html .= '<option value="' . $v1['id'] . '" ' . $selected . '>' . $v1['name'] . '</option>';
- }
- }
- $html .= '</optgroup>';
- }
- }
- }
- $html .= '</select>';
- $html .= $class ? '</div>' : '';
- return $html;
- }
- /**
- * linkage select 多级联动
- *
- * @return string
- */
- public static function _linkage($param, $class = '', $hidden = '', $change = '')
- {
- $div = 'div';
- $fast = Dever::input('fast');
- $w = 'width:20%;';
-
- if ($class == 'span') {
- $div = 'span';
- $w = '';
- }
- if (layadmin()) {
- $w = 'margin-top:0px;width:20%;margin-left:-3px;';
- if ($fast == 1) {
- $w = 'margin-top:0px;width:35%;margin-left:-3px;';
- } else {
- $w = 'margin-top:0px;width:20%;margin-left:-3px;';
- }
- }
- if (!isset($param['search_state'])) {
- $param['search_state'] = false;
- }
- # 当前级别
- $level = 1;
- # 传入的参数
- $level_param = '';
- if (isset($param['linkage'])) {
- $level_param = $param['linkage'];
- }
-
- $id = 'dever-linkage-' . $param['name'];
- $html = '<' . $div . ' class="' . $class . '" id="' . $id . '" >';
- # 默认值
- if (isset($param['value']) && is_array($param['value'])) {
- $param['value'] = implode(',', $param['value']);
- }
- $col = $api = $type = $script = '';
- $title = '';
- $open = '';
- if (is_array($param['option'])) {
- $option = $param['option'];
- $param['option'] = $option[0];
- $col = $option[1];
- $api = $option[2];
- $type = 'checkbox';
-
- if (isset($option[3])) {
- $title = $option[3];
- }
- if (isset($option[4])) {
- $open = str_replace('{where_id}', Dever::input('where_id'), $option[4]);
- }
- if (isset($param['value']) && $param['value']) {
- $script = 'select_api = JSON.parse(\''.$param['value'].'\');';
- $param['value'] = '';
- }
-
- }
- $load = '';
- if (isset($param['load'])) {
- $load = $param['load'];
- }
- $method = $param['name'];
- if (strstr($method, '-')) {
- $method = str_replace('-', '', $method);
- }
- $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.'")};';
- $html .= '$(document).ready(function(){linkage_' . $method . '(' . $level . ');'.$script.'});</script>';
- $html .= '</' . $div . '><div id="'.$id.'_content"></div><div id="'.$id.'_data"></div>';
- return $html;
- }
- /**
- * select
- *
- * @return string
- */
- public static function _selects($param, $class = '', $hidden = '', $change = '')
- {
- return self::_select($param, $class, $hidden, $change);
- }
- /**
- * select
- *
- * @return string
- */
- public static function _select($param, $class = '', $hidden = '', $change = '')
- {
- $html = $class ? '<div class="' . $class . '">' : '';
- $html .= $hidden;
- $xm = true;
- if (strstr($param['name'], 'up_col_')) {
- $xm = false;
- } elseif (isset($param['option']) && isset($param['update']) && $param['update'] == 'select') {
- $total = count($param['option']);
- if ($total <= 30) {
- $xm = false;
- }
- }
- if ($xm && isset($param['update'])) {
- $url = '';
- //https://maplemei.gitee.io/xm-select/?select=#/basic/paging
- if (isset($param['update_search'])) {
- $search_value = '';
- if (isset($param['value'])) {
- $search_value = $param['value'];
- } elseif (isset($param['default'])) {
- $search_value = $param['default'];
- }
- if (strstr($param['update_search'], '{id}')) {
- $param['update_search'] = str_replace('{id}', 'where_id=' . $param['where_id'], $param['update_search']);
- }
- $url = Dever::url($param['update_search'] . '&yes='.$search_value.'&json=1');
- }
- $xm_data = array();
- if (!$url && isset($param['option']) && $param['option']) {
- foreach ($param['option'] as $k => $v) {
- if (is_array($v)) {
- if (isset($v['id'])) {
- $xm_data[] = array('name' => $v['name'], 'value' => $v['id']);
- }
- } else {
- $xm_data[] = array('name' => $v, 'value' => $k);
- }
- }
- }
- $xm_value = isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : '');
- $xm_tips = '请选择';
- $xm_data = Dever::json_encode($xm_data);
- $xm_id = $param['name'];
- $xm_radio = ($param['update'] == 'selects' ? false : true);
- $xm_on = '';
- if (isset($param['control']) && is_string($param['control'])) {
- $xm_on = 'inputShow(e, \'' . $param['control'] . '\');';
- $change = ' show_id="' . $param['control'] . '"';
- } elseif (isset($param['load'])) {
- $xm_on = 'loadChange(e, \'' . $param['load'] . '\');';
- } elseif (isset($param['bind'])) {
- $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
- $xm_on = '' . $param['bind'][1] . '(e, ' . $param['bind'][2] . ', 1);';
- }
- if ($xm_on) {
- $xm_on = 'function(data){
- var arr = data.arr;
- if (arr && arr.length > 0) {
- var xm_radio = '.$xm_radio.';
- if (xm_radio) {
- var e = $("#'.$xm_id.'");
- e.attr("v", arr[0].value);
- '.$xm_on.'
- }
- }
- }';
- } else {
- $xm_on = 'function(){}';
- }
- $html .= '<div id="' . $param['name'] . '" '.$change.' class="xm-select-demo" style="min-width:150px"></div>';
- $html .= '<script>
- $(document).ready(function() {
- layui.use(["table"], function() {
- console.info(11);
- init_xm("'.$xm_id.'", "'.$xm_radio.'", "'.$xm_tips.'", "'.$url.'", '.$xm_data.', ['.$xm_value.'], '.$xm_on.');
- });
- });
-
- </script>';
- } else {
- $child_class = '';
- $style = '';
- if (isset($param['child'])) {
- $child_param['name'] = 'update_' . $param['child_name'];
- isset($param['value']) && $param['value'] = $param['value'];
- isset($param['child_value']) && $child_param['value'] = $param['child_value'];
- $change = 'style="width:45%" id="' . $param['name'] . '" data-child="' . $child_param['name'] . '_child" ';
- $child_class = ' change';
- }
- if (isset($param['control']) && is_string($param['control'])) {
- $change = ' show_id="' . $param['control'] . '" onchange="inputShow($(this), \'' . $param['control'] . '\')"';
- } elseif (isset($param['option_add'])) {
- $change = ' onchange="addChange($(this))" ';
- $style = 'width:25%';
- $child_class .= ' change';
- } elseif (isset($param['load'])) {
- $change = ' onchange="loadChange($(this), \'' . $param['load'] . '\')" ';
- $child_class .= ' change';
- } elseif (isset($param['bind'])) {
- $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
- $change = $param['bind'][0] . '="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
- $child_class .= ' change';
- }
- $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">';
- if (isset($param['option'])) {
- if (!isset($param['option'][-100]) && isset($param['lang']) && $param['lang']) {
- $html .= '<option value="0" selected>' . $param['lang'] . '</option>';
- }
- if (isset($param['option_add'])) {
- $html .= '<option value="0" data-type="add" data-url="'.Dever::url($param['option_add'][1]).'">' . $param['option_add'][0] . '</option>';
- }
- foreach ($param['option'] as $k => $v) {
- if (is_array($v)) {
- if (isset($v['lang']) && $v['lang']) {
- $value = $v['lang'];
- } else {
- $value = $v['name'];
- }
-
- isset($v['id']) && $k = $v['id'];
- } else {
- $value = $v;
- }
- $check = '';
- 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 . ','))) {
- $check = 'selected';
- }
- $parent = '';
- if (isset($param['parent']) && $param['parent'] && isset($v[$param['parent']])) {
- $parent = $v[$param['parent']];
- }
- if (is_array($v)) {
- $value = isset($v['name']) ? $v['name'] : $v['lang'];
- } else {
- $value = $v;
- }
- $html .= '<option parent="'.$parent.'" value="' . $k . '" ' . $check . '>' . $value . '</option>';
- }
- }
- $html .= '</select>';
- if (isset($param['child'])) {
- $child = $child_param['name'];
- $hidden = self::hidden(array('name' => $child, 'class' => $child . '_child_value'));
- foreach ($param['child'] as $k => $v) {
- $child_param['name'] = 'child-' . $k;
- $child_param['option'] = $v;
- $html .= self::select($child_param, $child . '_child ' . $child . '_child_' . $k . '" parent="' . $k . '" style="display:none;margin-top: -38px;margin-left: 47%;"', $hidden);
- }
- }
- }
- $html .= $class ? '</div>' : '';
- return $html;
- }
- /**
- * select
- *
- * @return string
- *
- public static function _select($param, $class = '', $hidden = '', $change = '')
- {
- $html = $class ? '<div class="' . $class . '">' : '';
- $child_class = '';
- $style = '';
- if (isset($param['child'])) {
- $child_param['name'] = 'update_' . $param['child_name'];
- isset($param['value']) && $param['value'] = $param['value'];
- isset($param['child_value']) && $child_param['value'] = $param['child_value'];
- $change = 'style="width:45%" id="' . $param['name'] . '" data-child="' . $child_param['name'] . '_child" ';
- $child_class = ' change';
- //$param['name'] .= '_parent';
- }
- if (isset($param['control']) && is_string($param['control'])) {
- //print_r($param);die;
- $change = ' show_id="' . $param['control'] . '" onchange="inputShow($(this), \'' . $param['control'] . '\')"';
- } elseif (isset($param['option_add'])) {
- $change = ' onchange="addChange($(this))" ';
- $style = 'width:25%';
- $child_class .= ' change';
- } elseif (isset($param['load'])) {
- $change = ' onchange="loadChange($(this), \'' . $param['load'] . '\')" ';
- $child_class .= ' change';
- } elseif (isset($param['bind']) && !isset($param['update_search'])) {
- $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
- $change = $param['bind'][0] . '="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
- $child_class .= ' change';
- }
- $xm = '';
- if ($change) {
- $xm = '';
- } else {
-
- }
-
- if (!$change && isset($param['update'])) {
- $xm = 'xm-select="' . $param['name'] . '" xm-select-skin="normal" xm-select-search="" xm-select-search-type="dl"';
- if ($param['update'] != 'selects') {
- $xm .= ' xm-select-radio=""';
- }
- $search_value = '';
- if (isset($param['value'])) {
- $search_value = $param['value'];
- } elseif (isset($param['default'])) {
- $search_value = $param['default'];
- }
- if (isset($param['update_search'])) {
- if (strstr($param['update_search'], '{id}')) {
- $param['update_search'] = str_replace('{id}', 'where_id=' . $param['where_id'], $param['update_search']);
- }
- $xm = str_replace('xm-select-search=""', 'xm-select-search="'.Dever::url($param['update_search'] . '&yes='.$search_value.'&json=1').'"', $xm);
- if (isset($param['bind'])) {
- $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
- $xm .= ' xm-select-callback="'.$param['bind'][1].'" xm-select-callback-param="'.$param['bind'][2].'"';
- }
- }
- if (isset($param['update_create'])) {
- $xm .= ' xm-select-create=""';
- }
- if ($param['match'] != 'option') {
- $xm .= ' lay-verify="' . $param['name'] . '"';
- }
- if ($param['update'] == 'selects' && isset($param['lang']) && $param['lang']) {
- $xm .= ' xm-select-placeholder="'.$param['lang'].'"';
- unset($param['lang']);
- }
- } else {
- $xm .= ' xm-select-radio=""';
- }
- if (isset($param['option']) && isset($param['update']) && $param['update'] == 'select') {
- $total = count($param['option']);
- if ($total <= 30) {
- $xm = '';
- }
- }
-
- $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">';
- if (isset($param['option'])) {
- if (!isset($param['option'][-100]) && isset($param['lang']) && $param['lang']) {
- $html .= '<option value="0" selected>' . $param['lang'] . '</option>';
- }
- if (isset($param['option_add'])) {
- $html .= '<option value="0" data-type="add" data-url="'.Dever::url($param['option_add'][1]).'">' . $param['option_add'][0] . '</option>';
- }
- foreach ($param['option'] as $k => $v) {
- if (is_array($v)) {
- if (isset($v['lang']) && $v['lang']) {
- $value = $v['lang'];
- } else {
- $value = $v['name'];
- }
-
- isset($v['id']) && $k = $v['id'];
- } else {
- $value = $v;
- }
- $check = '';
- 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 . ','))) {
- $check = 'selected';
- }
- $parent = '';
- if (isset($param['parent']) && $param['parent'] && isset($v[$param['parent']])) {
- $parent = $v[$param['parent']];
- }
- if (is_array($v)) {
- $value = isset($v['name']) ? $v['name'] : $v['lang'];
- } else {
- $value = $v;
- }
- $html .= '<option parent="'.$parent.'" value="' . $k . '" ' . $check . '>' . $value . '</option>';
- }
- }
- $html .= '</select>';
- if (isset($param['child'])) {
- $child = $child_param['name'];
- $hidden = self::hidden(array('name' => $child, 'class' => $child . '_child_value'));
- foreach ($param['child'] as $k => $v) {
- $child_param['name'] = 'child-' . $k;
- $child_param['option'] = $v;
- $html .= self::select($child_param, $child . '_child ' . $child . '_child_' . $k . '" parent="' . $k . '" style="display:none;margin-top: -38px;margin-left: 47%;"', $hidden);
- }
- }
- $html .= $class ? '</div>' : '';
- return $html;
- }
- /**
- * radio
- *
- * @return string
- */
- public static function _checkbox($param)
- {
- return self::radio($param);
- }
- /**
- * text
- *
- * @return string
- */
- public static function _text($param, $class = '')
- {
- if ($class) {
- return '<div class="">' . self::text($param, false) . '</div>';
- } else {
- $auto = $input = '';
- if (isset($param['const'])) {
- $value = $param['const'];
- } else {
- $value = (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : ''));
- }
-
- if (isset($param['autocomplete']) && $param['update'] == 'text') {
- if (empty($param['autocomplete'][1])) {
- $param['autocomplete'][1] = 'value';
- }
- if ($param['autocomplete'][1] == 'id') {
- $input = self::hidden(array('name' => $param['name'], 'value' => $value));
- $input = '<script>var autocomplete_value = {};autocomplete_value[\''.$param['name'].'_value\'] = [];</script>';
- if (isset($param['autocomplete'][2]) && $value) {
- # 重新定义value
- $value = Dever::load($param['autocomplete'][2], $value);
-
- if (is_array($value)) {
-
- $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">';
- foreach ($value as $k => $v) {
- $link = '';
- $attr = '';
- $pic = '';
- if (!isset($v['value'])) {
- $v['value'] = $v['name'];
- }
- if (isset($v['pic']) && $v['pic']) {
- $pic = '<a href="javascript:;"><img src="'.$v['pic'].'" width="100"></a> ';
- }
- if (isset($v['link']) && $v['link']) {
- $link = $v['link'];
- $attr = ' target="_blank"';
- }
- if (isset($v['click']) && $v['click']) {
- $link = 'javascript:;';
- $attr = ' onclick="'.$v['click'].'"';
- }
- $html .= '<tr id="autocomplate_check_'.$param['name'].'_value"><td width="90%"><input type="checkbox" checked name="'.$param['name'].'[]" value="'.$v['id'].'"/> '.$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>';
- }
- $html .= '</table></div>';
- $input .= $html;
- $value = '';
- }
- }
- $param['name'] = $param['name'] . '_temp';
- }
- $auto = 'complete="' . Dever::url($param['autocomplete'][0]) . '" complete_callback="' . $param['autocomplete'][1] . '" ';
- if (isset($param['autocomplete'][3])) {
- $auto .= ' complete_cate="' . $param['autocomplete'][3] . '" ';
- }
- } elseif (isset($param['searchbox'])) {
- if (empty($param['searchbox'][1])) {
- $param['searchbox'][1] = 'value';
- }
- if ($param['searchbox'][1] == 'id') {
- $input = self::hidden(array('name' => $param['name'], 'value' => $value));
- $input = '<script>var searchbox_value = [];searchbox_value[\''.$param['name'].'_value\'] = [];</script>';
- if (isset($param['searchbox'][2]) && $value) {
- # 重新定义value
- $value = Dever::load($param['searchbox'][2], $value);
- if (is_array($value)) {
-
- $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">';
- foreach ($value as $k => $v) {
- $link = '';
- $attr = '';
- $pic = '';
- if (!isset($v['value'])) {
- $v['value'] = $v['name'];
- }
- if (isset($v['pic']) && $v['pic']) {
- $pic = '<a href="javascript:;"><img src="'.$v['pic'].'" width="100"></a> ';
- }
- if (isset($v['link']) && $v['link']) {
- $link = $v['link'];
- $attr = ' target="_blank"';
- }
- $html .= '<tr id="searchbox_check_'.$param['name'].'_value_'.$v['id'].'"><td width="90%"><input type="checkbox" checked name="'.$param['name'].'[]" value="'.$v['id'].'"/> '.$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>';
- }
- $html .= '</table></div>';
- $input .= $html;
- $value = '';
- }
- }
- $param['name'] = $param['name'] . '_temp';
- }
- $auto = 'searchbox="' . Dever::url($param['searchbox'][0]) . '" searchbox_callback="' . $param['searchbox'][1] . '" ';
- if (isset($param['searchbox'][3])) {
- $auto .= ' searchbox_cate="' . $param['searchbox'][3] . '" ';
- }
- $search = '';
- if (isset($param['searchbox'][4])) {
- $temp = explode(',', $param['searchbox'][3]);
- $link = explode(',', $param['searchbox'][4]);
- $p = array();
- $p['option'] = array();
- foreach ($temp as $k => $v) {
- $p['name'] = $v;
- $p['option'] = Dever::load($link[$k]);
- $search .= self::_select($p, '', '', ' style="width: 15%;display: inline;margin-left:5px;"');
- }
- }
- $auto .= ' style="display: inline;"';
- $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;
- }
- if (isset($param['bind'])) {
- $param['bind'][2] = isset($param['bind'][2]) ? str_replace('"', '\'', json_encode($param['bind'][2], true)) : false;
- $auto .= $param['bind'][0] . '="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
- $auto .= ' onload="' . $param['bind'][1] . '($(this), ' . $param['bind'][2] . ')" ';
- }
- //id _value
- 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;
- }
- }
- /**
- * color
- *
- * @return string
- */
- public static function _color($param)
- {
- $param['class'] = 'dever-color form-control';
- $param['update'] = 'text';
- $param['default'] = isset($param['default']) ? $param['default'] : '#000000';
- return self::_text($param, '');
- }
- /**
- * password
- *
- * @return string
- */
- public static function _password($param)
- {
- $param['value'] = '';
- return self::_text($param);
- }
- /**
- * hidden
- *
- * @return string
- */
- public static function _hidden($param)
- {
- $param['type'] = 'hidden';
- $param['update'] = 'hidden';
- return self::_text($param, '');
- }
- /**
- * 选择详细的时间
- *
- * @return string
- */
- public static function _date($param, $type = true, $key = 'date', $parse = 'Y-m-d H:i:s')
- {
- $time = $value = '';
- if ((isset($param['value']) && $param['value'] > 0)) {
- $time = $param['value'];
- } elseif ((isset($param['default']) && $param['default'] > 0)) {
- $time = $param['default'];
- } elseif($type) {
- $time = time();
- }
- if ($time) {
- if (strlen($time) >= 10) {
- $value = date($parse, $time);
- } else {
- $value = $time;
- }
- }
-
- 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"/>';
- }
- /**
- * time已废弃,用day替换,兼容不删除
- *
- * @return string
- */
- public static function _time($param, $type = false)
- {
- return self::_day($param, $type);
- }
- /**
- * day 选择天
- *
- * @return string
- */
- public static function _day($param, $type = false)
- {
- return self::_date($param, $type, 'day', 'Y-m-d');
- }
- /**
- * 选择年
- *
- * @return string
- */
- public static function _year($param, $type = false)
- {
- return self::_date($param, $type, 'year', 'Y');
- }
- /**
- * 选择月
- *
- * @return string
- */
- public static function _month($param, $type = false)
- {
- return self::_date($param, $type, 'month', 'Y-m');
- }
- /**
- * 选择几天内
- *
- * @return string
- */
- public static function _sday($param, $type = false)
- {
- $date = self::_date($param, $type, 'sday', 'Y-m-d');
- return $date;
- }
- /**
- * 选择几天内
- *
- * @return string
- */
- public static function _sdate($param, $type = false)
- {
- $date = self::_date($param, $type, 'sdate');
- return $date;
- }
- /**
- * div
- *
- * @return string
- */
- public static function _node($param, $type = 'div')
- {
- $result = array('', '');
- foreach ($param as $k => $v) {
- $result[0] .= '<' . $type . ' ' . $v . '>';
- $result[1] .= '</' . $type . '>';
- }
- return $result;
- }
- /**
- * _load
- *
- * @return string
- */
- public static function _load($param)
- {
- $cate = '';
- $load = $param['update_load'];
- if (is_array($load)) {
- $cate = $load[1];
- $load = $load[0];
- }
- $html = '<div class="update_load" id="'.$param['name'].'" data-load="'.Dever::url($load).'" data-cate="'.$cate.'" data-id="'.$param['where_id'].'"></div>';
- return $html;
- }
- /**
- * 规格设置
- *
- * @return string
- */
- public static function _sku($param)
- {
- $col = Dever::json_encode($param['sku']['col']);
- $param['sku']['api']['spec'] = Dever::url($param['sku']['api']['spec'] . '?json=1&id=' . $param['where_id']);
- $param['sku']['api']['sku'] = Dever::url($param['sku']['api']['sku'] . '?json=1&id=' . $param['where_id']);
- $param['sku']['api']['upload'] = Dever::url($param['sku']['api']['upload']);
- if (isset($param['data']) && isset($param['data']['spec_type']) && $param['data']['spec_type']) {
- $type = $param['data']['spec_type'];
- } else {
- $type = 1;
- }
- $html = '<!-- 规格类型 -->
- <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>
- <!--商品规格表-->
- <div id="sku_spec_table"></div>
- <!--商品库存表-->
- <div id="sku_table"></div><div id="sku_table_col" style="display:none">'.$col.'</div>';
- return $html;
- }
- /**
- * show
- *
- * @return string
- */
- public static function _show($param, $class = '')
- {
- $value = (isset($param['value']) ? $param['value'] : (isset($param['default']) ? $param['default'] : ''));
- return '<div id="' . $param['name'] . '">' . $value . '</div>';
- }
- }
|