main.js 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984
  1. //这里的代码是最早写的,很乱,以后整合优化
  2. var editors = [];
  3. var editors_index = [];
  4. var tables = [];
  5. var select = '';
  6. var submitButton = '';
  7. var editorWidth = 0;
  8. var admingroup = false;
  9. String.prototype.replaceAll = function(reallyDo, replaceWith, ignoreCase) {
  10. if (!RegExp.prototype.isPrototypeOf(reallyDo)) {
  11. return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi": "g")), replaceWith);
  12. } else {
  13. return this.replace(reallyDo, replaceWith);
  14. }
  15. }
  16. Array.prototype.remove = function(val) {
  17. var index = -1;
  18. for(var i = 0; i < this.length; i++)
  19. {
  20. if(this[i] == val)
  21. {
  22. index = i;
  23. }
  24. }
  25. if (index > -1) {
  26. this.splice(index, 1);
  27. }
  28. };
  29. Array.prototype.replaceOne = function(old, val) {
  30. var index = -1;
  31. for(var i = 0; i < this.length; i++)
  32. {
  33. if(this[i] == old)
  34. {
  35. index = i;
  36. }
  37. }
  38. if (index > -1) {
  39. this.splice(index, 1, val);
  40. }
  41. };
  42. $(document).ready(function()
  43. {
  44. //init();
  45. });
  46. function init(ew)
  47. {
  48. if (ew) {
  49. editorWidth = ew;
  50. } else {
  51. editorWidth = 0;
  52. }
  53. editors = [];
  54. editors_index = [];
  55. initEditor();
  56. select = '';
  57. edit();
  58. del();
  59. checkbox();
  60. image();
  61. change();
  62. autocomplete();
  63. template();
  64. submit();
  65. loadShow();
  66. initPic();
  67. initDate();
  68. initLayui();
  69. initColor();
  70. initUpdate();
  71. initClipboard();
  72. initEmoji();
  73. //更新页面一些功能,上边的一些功能等找时间再优化吧
  74. dever_update.init();
  75. hljs.initHighlightingOnLoad();
  76. table();
  77. }
  78. function initEmoji()
  79. {
  80. if ($('.dever-emoji').length) {
  81. $('.dever-emoji').each(function()
  82. {
  83. emoji($(this), $(this).html());
  84. })
  85. }
  86. }
  87. function emoji(e, content)
  88. {
  89. var handle = function()
  90. {
  91. e.html(twemoji.parse(content)).show(200);
  92. };
  93. if (typeof jEmoji != 'object') {
  94. $.getScript('//twemoji.maxcdn.com/2/twemoji.min.js?11.4', function() {
  95. /*
  96. $("head").append("<link>");
  97. var css = $("head").children(":last");
  98. css.attr({
  99. rel: "stylesheet",
  100. type: "text/css",
  101. href: config.script + '/lib/emoji/emoji.css'
  102. });
  103. */
  104. return handle();
  105. });
  106. } else {
  107. return handle();
  108. }
  109. }
  110. function checkClick(e)
  111. {
  112. var objEvt = $._data(e[0], "events");
  113. if (objEvt && !objEvt["click"]) {
  114. return false;
  115. }
  116. return true;
  117. }
  118. function initClipboard()
  119. {
  120. var clipboard = new ClipboardJS('.clipboard');
  121. clipboard.on('success', function(e) {
  122. notify('复制成功', e.trigger);
  123. e.clearSelection();
  124. });
  125. clipboard.on('error', function(e) {
  126. notify('复制失败', e.trigger);
  127. });
  128. }
  129. function initUpdate()
  130. {
  131. if ($('.update_show_editor').length) {
  132. $('.update_show_editor').each(function() {
  133. $(this).bind('click', function()
  134. {
  135. var url = $(this).attr('key');
  136. var value = $(this).attr('editor_id');
  137. var title = $(this).attr('value');
  138. var send = '';
  139. if ($(this).attr('data-value')) {
  140. send = $(this).attr('data-value');
  141. }
  142. $.post(url, {value:send}, function(t)
  143. {
  144. var func = function() {
  145. var url = $('#editor_applet_pic').val();
  146. var appid = $('#editor_applet_id').val();
  147. var path = $('#editor_applet_path').val();
  148. var link = $('#editor_applet_link').val();
  149. if (!appid) {
  150. //alert('请选择小程序');
  151. //return;
  152. }
  153. if (!path) {
  154. alert('请填写路径');
  155. return;
  156. }
  157. if (!url) {
  158. alert('请上传封面');
  159. return;
  160. }
  161. var w = 750/2;
  162. KindEditor.insertHtml('#' + value, '<img src="'+url+'" style="width:'+w+'px;" data-applet="'+url+'||'+appid+'||'+path+'||'+link+'"/>');
  163. layer.closeAll();
  164. };
  165. showAlert(t, func, title);
  166. image();
  167. })
  168. })
  169. });
  170. }
  171. }
  172. function initLayui()
  173. {
  174. layui.use('layer', function() {
  175. var layer = layui.layer;
  176. layer.ready(function() {
  177. $(".dever-img").each(function()
  178. {
  179. layer.photos({
  180. photos: '#' + $(this).attr('id'),
  181. shade : 0.5
  182. });
  183. });
  184. });
  185. });
  186. }
  187. function initColor()
  188. {
  189. if ($('.dever-color').length) {
  190. $('.dever-color').each(function()
  191. {
  192. var self = $(this);
  193. var val = self.val();
  194. if (!val) {
  195. val = '#000000';
  196. }
  197. self.css('border-right', '40px solid '+val);
  198. self.colpick({
  199. layout:'hex',
  200. submit:0,
  201. colorScheme:'dark',
  202. color: val,
  203. onChange : function (hsb,hex,rgb,el,bySetColor) {
  204. $(el).css('border-color','#'+hex);
  205. if(!bySetColor) $(el).val('#' + hex);
  206. }
  207. }).keyup(function(){
  208. $(this).colpickSetColor(this.value);
  209. });
  210. })
  211. }
  212. }
  213. function formData(form)
  214. {
  215. var d = {};
  216. var t = $(form).serializeArray();
  217. var u = '';
  218. $.each(t, function() {
  219. if (this.name.indexOf('search_') != -1) {
  220. d[this.name] = this.value;
  221. u += '&' + this.name + '=' + this.value;
  222. }
  223. });
  224. return [d,u];
  225. }
  226. function initMenu()
  227. {
  228. if(typeof(config.layout) != "undefined")
  229. {
  230. $('.list-unstyled li').each(function(j)
  231. {
  232. $(this).unbind('click').bind('click', function()
  233. {
  234. if ($(this).index() == i) {
  235. //return;
  236. }
  237. $('.list-unstyled .active').each(function()
  238. {
  239. $(this).attr('class', '');
  240. $(this).find('a').attr('class', '');
  241. })
  242. $(this).attr('class', 'active');
  243. var a = $(this).find('a');
  244. a.attr('class', 'subdrop');
  245. //alert($(this).attr('class'));
  246. })
  247. });
  248. /*
  249. $('.project-list').each(function(i)
  250. {
  251. $(this).unbind('click').bind('click', function()
  252. {
  253. if ($(this).index() == i) {
  254. return;
  255. }
  256. $('.project-list').each(function()
  257. {
  258. $(this).find('i').parent().attr('class', '');
  259. $(this).find('ul').attr('class', 'list-unstyled upload-menu');
  260. })
  261. $(this).find('i').parent().attr('class', 'active');
  262. $(this).find('ul').attr('class', 'list-unstyled upload-menu in');
  263. })
  264. });
  265. */
  266. }
  267. }
  268. function setOption(e, id)
  269. {
  270. var s = $("select[name="+id+"]");
  271. var v = s.val();
  272. if (!select) {
  273. select = s.clone();
  274. }
  275. s.find('option[parent]').remove();
  276. //查找出需要显示的option并复制
  277. var options = select.find("option[parent="+e.val()+"]").clone();
  278. //将需要显示的option添加到select中
  279. s.append(options);
  280. //因为option.remove()不会刷新控件,需要将新的option切换上去
  281. //这里排除了options.size() == 0的情况
  282. var state = 2;
  283. s.find('option').each(function()
  284. {
  285. var val = $(this).val();
  286. if (v == val) {
  287. state = 1;
  288. }
  289. });
  290. if (state == 1) {
  291. s.val(v);
  292. } else {
  293. s.val(0);
  294. }
  295. }
  296. function table()
  297. {
  298. if ($('.table-responsive').length) {
  299. $('.table-responsive[data-pattern]').each(function()
  300. {
  301. $(this).responsiveTable('update');
  302. });
  303. }
  304. }
  305. function pjax(param)
  306. {
  307. param.timeout = 8000;
  308. $.pjax(param);
  309. }
  310. function initDate()
  311. {
  312. $.datetimepicker.setLocale('ch');
  313. if($(".manage_date").length)
  314. {
  315. $(".manage_date").each(function()
  316. {
  317. $(this).datetimepicker(
  318. {
  319. //datepicker:false,
  320. format:'Y-m-d H:i:s',
  321. lang:'ch'
  322. });
  323. });
  324. }
  325. if($(".manage_day").length)
  326. {
  327. $(".manage_day").each(function()
  328. {
  329. $(this).datetimepicker(
  330. {
  331. //inline:true,
  332. timepicker:false,
  333. format:'Y-m-d',
  334. lang:'ch'
  335. });
  336. });
  337. }
  338. if($(".manage_sday").length)
  339. {
  340. $(".manage_sday").each(function()
  341. {
  342. $(this).datetimepicker(
  343. {
  344. //inline:true,
  345. timepicker:false,
  346. format:'Y-m-d',
  347. lang:'ch'
  348. });
  349. });
  350. }
  351. if($(".manage_sdate").length)
  352. {
  353. $(".manage_sdate").each(function()
  354. {
  355. $(this).datetimepicker(
  356. {
  357. //datepicker:false,
  358. format:'Y-m-d H:i:s',
  359. lang:'ch'
  360. });
  361. });
  362. }
  363. layui.use('laydate', function() {
  364. var laydate = layui.laydate;
  365. if ($('.manage_year').length) {
  366. laydate.render({
  367. elem: '.manage_year',
  368. type: 'year',
  369. });
  370. }
  371. if ($('.manage_month').length) {
  372. laydate.render({
  373. elem: '.manage_month',
  374. type: 'month',
  375. });
  376. }
  377. });
  378. }
  379. function initPic()
  380. {
  381. $('a[rel]').fancybox();
  382. }
  383. function initEditor(e)
  384. {
  385. if (!e) {
  386. e = $('.editor');
  387. }
  388. if(e.length)
  389. {
  390. var param = false;
  391. var editor = [];
  392. e.each(function()
  393. {
  394. var parent = $(this).parent().parent();
  395. //alert(parent.attr('id'));
  396. if(parent.attr('id') && parent.attr('id').indexOf('-child-0') != -1)
  397. {
  398. return;
  399. }
  400. if (!param) {
  401. param = loadEditorParam($(this));
  402. }
  403. editor.push($(this).attr('id'));
  404. });
  405. if (editor) {
  406. for (var i in editor) {
  407. var id = editor[i];
  408. if (typeof(id) == 'string' && !editors[id]) {
  409. param.index = editors_index.length;
  410. editors[id] = KindEditor.create('#' + id, param);
  411. editors_index.push(id);
  412. }
  413. }
  414. }
  415. }
  416. if ($('.editor_tool').length) {
  417. $('.editor_tool').each(function()
  418. {
  419. $(this).click(function()
  420. {
  421. var tool = $(this).attr('tool');
  422. var id = $(this).attr('editor_id');
  423. editors[id].clickToolbar(tool);
  424. })
  425. });
  426. }
  427. }
  428. function loadEditorParam(e)
  429. {
  430. if(!e.length)
  431. {
  432. return;
  433. }
  434. var key = e.attr('key');
  435. var media = e.attr('media');
  436. var token = e.attr('token');
  437. var host = e.attr('host');
  438. var domain = e.attr('domain');
  439. var path = e.attr('path');
  440. var upload_search = e.attr('upload_search');
  441. var upload_search_value = e.attr('upload_search_value');
  442. var yun = {};
  443. if (token && host) {
  444. yun.token = token;
  445. yun.host = host;
  446. yun.domain = domain;
  447. yun.path = path;
  448. }
  449. if (!media) {
  450. media = key;
  451. }
  452. var view = config.upload.replace('save', 'view');
  453. var param = {
  454. height : "400px",
  455. allowImageUpload: true, //上传图片框本地上传的功能,false为隐藏,默认为true
  456. allowImageRemote : true, //上传图片框网络图片的功能,false为隐藏,默认为true
  457. allowFileManager : true, //浏览图片空间
  458. allowMediaUpload : true,
  459. filterMode : true, //HTML特殊代码过滤
  460. themeType : 'default',
  461. filePostName : 'file',
  462. dialogOffset : 0, //对话框距离页面顶部的位置,默认为0居中,
  463. uploadJson : config.upload + '.kindeditor?key=' + key + '&search=' + upload_search_value,
  464. uploadResJson : config.uploadRes + '.kindeditor?key=' + key + '&search=' + upload_search_value,
  465. uploadMediaJson : config.upload + '.kindeditor?key=' + media + '&search=' + upload_search_value,
  466. uploadYunJson : yun,
  467. fileManagerJson : view + '.files?key=' + media + '&upload_search=' + upload_search,
  468. htmlTags : {
  469. section : ['id', 'class', 'color', 'size', 'face', '.background-color'],
  470. font : ['id', 'class', 'color', 'size', 'face', '.background-color'],
  471. span : [
  472. 'id', 'class', '.color', '.background-color', '.font-size','.letter-spacing', '.background',
  473. '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.line-height'
  474. ],
  475. div : [
  476. 'id', 'class', 'data-applet', 'data-file', 'data-id', 'data-key','.dever-video', 'align', '.border', '.margin', '.padding', '.text-align', '.color',
  477. '.background-color', '.font-size','.letter-spacing', '.font-weight', '.background',
  478. '.font-style', '.text-decoration', '.vertical-align', '.margin-left'
  479. ],
  480. table: [
  481. 'id', 'class', 'border', 'cellspacing', 'cellpadding', 'width', 'height', 'align', 'bordercolor',
  482. '.padding', '.margin', '.border', 'bgcolor', '.text-align', '.color', '.background-color',
  483. '.font-size', '.font-weight', '.font-style', '.text-decoration', '.background',
  484. '.width', '.height', '.border-collapse'
  485. ],
  486. 'td,th': [
  487. 'id', 'class', 'align', 'valign', 'width', 'height', 'colspan', 'rowspan', 'bgcolor',
  488. '.text-align', '.color', '.background-color', '.font-size','.letter-spacing', '.font-weight',
  489. '.font-style', '.text-decoration', '.vertical-align', '.background', '.border'
  490. ],
  491. a : ['id', 'class', 'href', 'target', 'name'],
  492. embed : ['id', 'class', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess', 'wmode'],
  493. img : ['id', 'class', 'data-applet', 'data-file', 'data-id', 'data-key', 'src', 'width', 'height', 'border', 'alt', 'title', 'align', '.width', '.height', '.border'],
  494. 'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [
  495. 'id', 'class', 'align', '.text-align', '.color', '.background-color', '.font-size','.letter-spacing', '.background',
  496. '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.text-indent', '.margin-left'
  497. ],
  498. pre : ['id', 'class'],
  499. hr : ['id', 'class', '.page-break-after'],
  500. 'br,tbody,tr,strong,b,sub,sup,em,i,u,strike,s,del' : ['id', 'class'],
  501. iframe : ['id', 'class', 'src', 'frameborder', 'width', 'height', '.width', '.height']
  502. },
  503. items : [
  504. 'preview', 'undo', 'redo', '|', 'cut', 'copy', 'paste',
  505. 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
  506. 'justifyfull', 'indent', 'outdent', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', 'source', '/',
  507. 'formatblock', 'fontsize', 'fontheight', '|', 'forecolor', 'hilitecolor', 'bold',
  508. 'italic', 'underline', 'lineheight', 'removeformat', 'insertorderedlist','|', 'image','table', 'hr', 'pagebreak','link', 'unlink'
  509. ]
  510. /*
  511. items : [
  512. 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
  513. 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
  514. 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
  515. 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
  516. 'formatblock', 'fontsize', 'fontheight', '|', 'forecolor', 'hilitecolor', 'bold',
  517. 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage','table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
  518. 'anchor', 'link', 'unlink'
  519. ]
  520. */
  521. //media
  522. /*
  523. items : [
  524. 'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
  525. 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
  526. 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
  527. 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
  528. 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
  529. 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
  530. 'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
  531. 'anchor', 'link', 'unlink', '|', 'about'
  532. ]
  533. */
  534. }
  535. if (editorWidth > 0) {
  536. param.width = editorWidth + 'px';
  537. param.minWidth = editorWidth + 'px';
  538. }
  539. return param;
  540. }
  541. //更新页面的提交按钮
  542. function submit()
  543. {
  544. if($(".save-data").length)
  545. {
  546. if (submitButton) {
  547. $(".save-data").each(function()
  548. {
  549. $(this).html(submitButton);
  550. })
  551. }
  552. $(".save-data").unbind('click').bind('click', function()
  553. {
  554. if (editors) {
  555. for (var i in editors) {
  556. if (i.indexOf('update_') != -1) {
  557. editors[i].sync();
  558. }
  559. }
  560. }
  561. //return;
  562. submitButton = $(this).html();
  563. $(this).html('loading...');
  564. $(this).unbind('click');
  565. submit_action();
  566. })
  567. }
  568. }
  569. //直接提交更新页的数据
  570. function submit_action()
  571. {
  572. $(".form1").submit();
  573. }
  574. //设置某一个input的值
  575. function set_update(id, value)
  576. {
  577. if($(id).length)
  578. {
  579. $(id).val(value);
  580. }
  581. }
  582. /**
  583. * 批量复制数据
  584. */
  585. function copy_data(e)
  586. {
  587. var html = '<div>';
  588. html += '<div><span>请输入要复制的数量:</span><input type="text" class="form-control form_margin" id="temp_copy_num" /></div>';
  589. html += '</div>';
  590. $('#dever_modal_body').html(html);
  591. $('#dever_modal_title').html('复制数据');
  592. $("#dever_modal_yes").unbind('click').bind('click', function()
  593. {
  594. set_update('#copy_num', $("#temp_copy_num").val());
  595. set_update('#update_where_id', 0);
  596. submit_action();
  597. });
  598. }
  599. //头部菜单
  600. function topMenu(e)
  601. {
  602. var p = e.parent().parent().parent().find('span');
  603. p.html(e.html());
  604. //更新当前的精细权限
  605. var url = config.host + 'top.update_action?json=1';
  606. var id = e.attr('data-id');
  607. $.post(url, {id:id}, function(t)
  608. {
  609. var href = location.href;
  610. if(location.href.indexOf('where_id') != -1)
  611. {
  612. var temp = location.href.split('where_id');
  613. href = temp[0] + 'where_id=' + t;
  614. }
  615. if(typeof(config.layout) != "undefined" && $(config.layout).length)
  616. {
  617. pjax({url: href, container: config.layout})
  618. }
  619. else
  620. {
  621. location.href = href;
  622. }
  623. })
  624. }
  625. //链接跳转
  626. function go(key, value)
  627. {
  628. var href = location.href;
  629. if(location.href.indexOf(key) != -1)
  630. {
  631. var temp = location.href.split(key + '=');
  632. href = temp[0] + key + '=' + value + '&' + temp[1];
  633. } else {
  634. href = href + '&' + key + '=' + value;
  635. }
  636. location.href = href;
  637. }
  638. //更新页面的批量载入选择
  639. function loadShow()
  640. {
  641. if($(".show_input").length)
  642. {
  643. $(".show_input input").each(function()
  644. {
  645. if($(this).attr('checked'))
  646. {
  647. inputShow($(this), $(this).attr('show_id'), 'input');
  648. }
  649. })
  650. $(".show_input select").each(function()
  651. {
  652. if($(this).find('option:selected').text())
  653. {
  654. inputShow($(this), $(this).attr('show_id'));
  655. }
  656. })
  657. }
  658. }
  659. function menuGroup(id, e)
  660. {
  661. if (typeof(layer) != 'undefined' && admingroup) {
  662. layer.close(admingroup);
  663. }
  664. $('.menu_group').hide();
  665. $('.menu_group_' + id).show();
  666. $('.menu_group_' + id).eq(0).addClass('layui-nav-itemed');
  667. }
  668. function inputShow(e,n,t)
  669. {
  670. $(".show_" + n).hide();
  671. var v = e.val();
  672. console.info(v);
  673. if (t == 'input') {
  674. var item = e.parent().find('input');
  675. item.each(function()
  676. {
  677. if($(this).get(0).checked == true)
  678. {
  679. inputShowOne($(this),n);
  680. }
  681. });
  682. } else {
  683. var item = e.parent().find('select');
  684. item.each(function()
  685. {
  686. if($(this).find('option:selected').text())
  687. {
  688. inputShowOne($(this),n);
  689. }
  690. });
  691. }
  692. var array = ['input', 'textarea'];
  693. for(var a in array)
  694. {
  695. if ($(".show_" + n).find(array[a]).length) {
  696. var s = $(".show_" + n).find(array[a]);
  697. var p = s.parent().parent().parent().css('display');
  698. var c = s.attr('class');
  699. if (c.indexOf('validate[required]') > -1 && p == 'none') {
  700. $(".show_" + n).find(array[a]).removeClass('validate[required]').addClass('validates');
  701. }
  702. if (c.indexOf('validates') > -1) {
  703. $(".show_" + n).find(array[a]).removeClass('validates').addClass('validate[required]');
  704. }
  705. }
  706. }
  707. }
  708. function inputShowOne(e,n)
  709. {
  710. var value = e.val();
  711. var ele = '.show_' + n + '_ajax';
  712. if ($(ele).length) {
  713. $(ele).each(function()
  714. {
  715. var self = $(this);
  716. var url = self.attr('dever-ajax');
  717. $.getJSON(url + value + '&callback=?', function(t) {
  718. self.find('.margin-top').html(t.data);
  719. inputShowOneValiDate(self);
  720. checkbox();
  721. })
  722. })
  723. } else {
  724. ele = '.show_' + n + '_' + value;
  725. inputShowOneValiDate($(ele));
  726. }
  727. }
  728. function inputShowOneValiDate(e)
  729. {
  730. e.show();
  731. var array = ['input', 'textarea'];
  732. for(var a in array)
  733. {
  734. if(e.length && e.attr('class').indexOf('show_no') == -1)
  735. {
  736. e.find(array[a]).each(function()
  737. {
  738. var parent = $(this).parent();
  739. if($(this).attr('class') != 'editor' && $(this).attr('class').indexOf('validates') > -1 && parent.find('label').length && parent.find('label').html().indexOf('选填') == -1)
  740. {
  741. $(this).addClass('validate[required]');
  742. }
  743. })
  744. }
  745. }
  746. }
  747. //批量更新
  748. function list_mul(e)
  749. {
  750. var type = parseInt($("#mul_type").val());
  751. if(type != 1 && type != 2)
  752. {
  753. alert('您还没有选择数据更新方式');
  754. return;
  755. }
  756. var index = layer.confirm('确定进行此项操作吗?', function()
  757. {
  758. $('#method').val('mul');
  759. $('#function').val('msg');
  760. layer.close(index);
  761. $('#form1').attr('target', 'f1').submit();
  762. })
  763. }
  764. //搜索
  765. function list_search(e)
  766. {
  767. $('#method').val('search');
  768. $('#function').val('');
  769. $('#form1').attr('target', '').submit();
  770. }
  771. //更新数据
  772. function update(e, id, project, table, notice, menu_id)
  773. {
  774. var call = function()
  775. {
  776. var col = e.attr('name').replace('up_col_', '');
  777. var value = e.val();
  778. var old = e.attr('data-old');
  779. var url = config.host + 'database.update_action?json=1';
  780. $.post(url, {where_id:id,col:col,value:value,project:project,table:table,menu_id:menu_id}, function(t)
  781. {
  782. var t = eval('('+t+')');
  783. if (t.status == 1) {
  784. e.attr('data-old', value);
  785. notify('操作已成功!您的操作已修改当前选项!', e);
  786. preview();
  787. } else {
  788. msg(t);
  789. e.val(old);
  790. }
  791. })
  792. }
  793. if(notice)
  794. {
  795. var index = layer.confirm(notice, function(i, l)
  796. {
  797. $(l).find('.layui-layer-btn0').css('pointer-events','none');
  798. layer.close(index);
  799. call();
  800. });
  801. }
  802. else
  803. {
  804. call();
  805. }
  806. }
  807. function notify(msg, e)
  808. {
  809. if (!e) {
  810. layer.msg(msg);
  811. return;
  812. }
  813. layer.tips(msg, e, {
  814. tips: [1, '#3595CC']
  815. });
  816. /*
  817. var notice = new PNotify({
  818. title: '提示信息',
  819. text: msg,
  820. buttons: {
  821. closer: false,
  822. sticker: false
  823. }
  824. });
  825. notice.get().click(function() {
  826. notice.remove();
  827. });
  828. */
  829. }
  830. //模板选择
  831. function template()
  832. {
  833. if(config.template)
  834. {
  835. $('body').attr('class', 'theme-' + config.template);
  836. }
  837. if($(".selector").length)
  838. {
  839. $(".selector").each(function()
  840. {
  841. if($(this).data('check') == 'checked')
  842. {
  843. selector($(this));
  844. }
  845. })
  846. }
  847. }
  848. //选择器
  849. function selector(e)
  850. {
  851. var value = e.data('value');
  852. var name = e.data('name');
  853. $('#'+name+'_value').val(value);
  854. $('.'+name+'_selector').children().css({'border':'1px solid #ccc'});
  855. e.children().css({'border':'1px solid black'});
  856. if(name == 'update_template')
  857. {
  858. $('body').attr('class', 'theme-' + value);
  859. }
  860. }
  861. //根据e的值,来载入其他数据
  862. function loading(e, data)
  863. {
  864. var value = e.val();
  865. if(e.attr('id') && e.attr('id').indexOf('_temp') != -1)
  866. {
  867. var id = e.attr('id').replace('_temp', '');
  868. if($('#' + id).length)
  869. {
  870. var value = $('#' + id).val();
  871. }
  872. }
  873. if(data.element)
  874. {
  875. if(data.url)
  876. {
  877. data.value = value;
  878. $.getJSON(data.url, data, function(t)
  879. {
  880. $('#update_'+data.element+'_value').val(t.data);
  881. });
  882. }
  883. else
  884. {
  885. $('#update_'+data.element+'_value').val(value);
  886. }
  887. }
  888. else if(data.url)
  889. {
  890. data.value = value;
  891. data.where_id = $('#update_where_id').val();
  892. data.table = $('#table').val();
  893. data.project = $('#project').val();
  894. $.getJSON(data.url + '&json=1', data, function(s)
  895. {
  896. t = s.data;
  897. if(t.indexOf('onblur') != -1)
  898. {
  899. eval(t);
  900. }
  901. else
  902. {
  903. var parent = e.parent().parent();
  904. if(t.indexOf('status') == -1)
  905. {
  906. if(data.type == 1)
  907. {
  908. $('.checking_1,.checking_2,.checking_3,.checking_4').each(function()
  909. {
  910. $(this).remove();
  911. });
  912. }
  913. else
  914. {
  915. $('.checking_-1,.checking_3,.checking_4').each(function()
  916. {
  917. $(this).remove();
  918. });
  919. }
  920. if (!parent.parent().find('.bind_show').length) {
  921. parent.after('<div class="bind_show">' + t + '</div>');
  922. } else if (parent.parent().find('.bind_show').html() != t) {
  923. parent.parent().find('.bind_show').html(t);
  924. }
  925. checkbox();
  926. }
  927. }
  928. });
  929. }
  930. }
  931. //根据e的值,来载入其他数据,先检测是否选中
  932. function checking(name, e, data)
  933. {
  934. var value = [];
  935. $('.' + name).each(function()
  936. {
  937. if($(this).get(0).checked == true)
  938. {
  939. value.push($(this).val());
  940. }
  941. });
  942. if(data.url)
  943. {
  944. data.value = value.join(',');
  945. data.where_id = $('#update_where_id').val();
  946. data.table = $('#table').val();
  947. data.project = $('#project').val();
  948. if(data.check)
  949. {
  950. data.check_value = false;
  951. $(data.check).each(function()
  952. {
  953. if($(this).get(0).checked == true)
  954. {
  955. data.check_value = $(this).val();
  956. }
  957. });
  958. }
  959. $.getJSON(data.url, data, function(s)
  960. {
  961. t = s.data;
  962. var parent = e.parent().parent().parent();
  963. if(t.indexOf('status') == -1)
  964. {
  965. if(data.type == 1)
  966. {
  967. $('.checking_1,.checking_2,.checking_3,.checking_4').each(function()
  968. {
  969. $(this).remove();
  970. });
  971. }
  972. else
  973. {
  974. $('.checking_-1,.checking_3,.checking_4').each(function()
  975. {
  976. $(this).remove();
  977. });
  978. }
  979. parent.after(t);
  980. checkbox();
  981. }
  982. });
  983. }
  984. }
  985. function autocomplete()
  986. {
  987. if ($("input").length) {
  988. $("input").each(function()
  989. {
  990. $(this).attr('autocomplete', 'off');
  991. });
  992. }
  993. if($("input[complete]").length)
  994. {
  995. $("input[complete]").each(function()
  996. {
  997. var cache = {};
  998. var self = $(this);
  999. self.autocomplete(
  1000. {
  1001. minLength: 2,
  1002. source: function( request, response )
  1003. {
  1004. var term = request.term.split( /,\s*/ );
  1005. request.term = term.pop();
  1006. if ( request.term in cache ) {
  1007. response( cache[ request.term ] );
  1008. return;
  1009. }
  1010. var cate = self.attr('complete_cate');
  1011. if (cate) {
  1012. request[cate] = $('update_' + cate + '_value').val();
  1013. }
  1014. $.getJSON(self.attr('complete') + '&callback=?', request, function( data, status, xhr ) {
  1015. data = data.data
  1016. cache[ term ] = data;
  1017. var state = true;
  1018. for(var i in data)
  1019. {
  1020. if(data[i].id <=0)
  1021. {
  1022. state = false;
  1023. }
  1024. }
  1025. if(state)
  1026. {
  1027. response( data );
  1028. }
  1029. });
  1030. },
  1031. focus: function() {
  1032. // prevent value inserted on focus
  1033. return false;
  1034. },
  1035. select: function( event, ui )
  1036. {
  1037. //log( "Selected: " + ui.item.value + " aka " + ui.item.id );
  1038. var value = self.attr('complete_callback');
  1039. var id = self.attr('id').replace('_temp', '');
  1040. var name = self.attr('name').replace('_temp', '');
  1041. //var e = $("#" + id);
  1042. var e = self;
  1043. var html = '<div style="margin-top: 10px;width: 60%; overflow: auto;max-height: 500px;"><table id="'+id+'_show" class="table table-small-font table-bordered"></table></div>';
  1044. if (!$("#" + id + '_show').length) {
  1045. e.parent().append(html);
  1046. }
  1047. if ($("#" + id + '_show').html().indexOf(ui.item.value) == -1)
  1048. {
  1049. var link = '';
  1050. var attr = '';
  1051. var pic = '';
  1052. if (ui.item['pic']) {
  1053. pic = '<a href="javascript:;"><img src="'+ui.item['pic']+'" width="100"></a>';
  1054. }
  1055. if (ui.item['link']) {
  1056. link = ui.item['link'];
  1057. attr = ' target="_blank"';
  1058. }
  1059. var html = '<tr><td width="90%"><input type="checkbox" checked name="'+name+'[]" value="'+ui.item[value]+'"/>&nbsp;&nbsp;'+pic+'<a href="'+link+'" '+attr+' title="'+ui.item.value+'">'+ui.item.value+'</td><td width="10%"><a href="javascript:;" onclick="autocomplete_del($(this), \''+id+'\', \''+ui.item[value]+'\', \''+name+'\')">[删除]</a></td></tr>';
  1060. $("#" + id + '_show').append(html);
  1061. if (!autocomplete_value[id]) {
  1062. autocomplete_value[id] = [];
  1063. }
  1064. autocomplete_value[id].push(ui.item[value]);
  1065. }
  1066. ui.item.value = '';
  1067. }
  1068. });
  1069. })
  1070. }
  1071. }
  1072. function autocomplete_del(e, id, value, name)
  1073. {
  1074. e.parent().parent().remove();
  1075. autocomplete_value[id].remove(value);
  1076. var len = autocomplete_value[id].length;
  1077. if (len < 1 && !($('#del_' + name).length)) {
  1078. $("#" + id + '_show').append('<input type="hidden" name="'+name+'[]" id="del_'+name+'" value="-1" />');
  1079. }
  1080. }
  1081. function searchbox(id, e)
  1082. {
  1083. var self = e.parent().find("input");
  1084. var v = self.val();
  1085. var key = self.attr('id').replace('_temp', '');
  1086. var request = {};
  1087. request.term = v;
  1088. var cate = self.attr('searchbox_cate');
  1089. if (cate) {
  1090. var c = cate.split(',');
  1091. for (var i in c) {
  1092. if (typeof(c[i]) == 'string' && $('#'+c[i]).length) {
  1093. request[c[i]] = $('#'+c[i]).val();
  1094. }
  1095. }
  1096. }
  1097. var index = layer.msg('加载中...');
  1098. $.getJSON(self.attr('searchbox') + '&callback=?', request, function( data, status, xhr ) {
  1099. layer.close(index);
  1100. var data = data.data;
  1101. if (!data) {
  1102. showAlert('没有搜索到数据');
  1103. return;
  1104. }
  1105. var html = '<div class="layui-tab layui-tab-brief"" overflow><ul class="layui-tab-title" style="height: 60px; overflow: auto;">{cate}</ul><div class="layui-tab-content" style="padding-top: 0px;">{content}</div><div style="margin-left:10px"><input type="checkbox" onclick="searchbox_checkall($(this), \'searchbox_'+id+'\')"/>&nbsp;全选<button type="button" onclick="searchbox_yes(\''+self.attr('id')+'\', \'.searchbox_'+id+'\', true)" class="btn btn-primary layui-btn layuiadmin-btn-list" style="margin-left:10px;margin-top: -2px;"><i class="fa fa-save"></i> 确定</button></div></div>';
  1106. if (data) {
  1107. var j = 0;
  1108. var c = '';
  1109. var s = '';
  1110. var cateHtml = '';
  1111. var content = '';
  1112. for (var i in data) {
  1113. if (j == 0) {
  1114. c = 'class="layui-this"';
  1115. s = 'layui-show';
  1116. } else {
  1117. c = '';
  1118. s = '';
  1119. }
  1120. cateHtml += '<li '+c+'>'+data[i].name+'</li>';
  1121. j++;
  1122. var item = '<div class="layui-tab-item '+s+'"><div style="margin-top: 10px;overflow: auto;max-height: 500px;"><table class="table table-small-font table-bordered">{head}';
  1123. var p = false;
  1124. for (var k in data[i].child) {
  1125. if (data[i].child[k].name) {
  1126. var pic = '';
  1127. if (data[i].child[k].pic) {
  1128. pic = '<td><img src="'+data[i].child[k].pic+'" width="100"></td>';
  1129. p = true;
  1130. }
  1131. var check = '';
  1132. if (searchbox_value[key].indexOf(data[i].child[k].id) != -1) {
  1133. check = 'checked';
  1134. }
  1135. item += '<tr><td width="10%"><input '+check+' type="checkbox" onclick="searchbox_checkone($(this), \''+self.attr('id')+'\', \''+key+'\', '+data[i].child[k].id+', \''+key+'\')" class="searchbox_'+id+' searchbox_'+id+'_'+data[i].id+'" data-class="searchbox_'+id+'_'+data[i].id+'" data-pic="'+data[i].child[k].pic+'" data-name="'+data[i].child[k].name+'" data-value="'+data[i].child[k].id+'" data-link="'+data[i].child[k].link+'" value="'+data[i].child[k].id+'"/></td>'+pic+'<td><a href="" >'+data[i].child[k].name+'</td></tr>';
  1136. }
  1137. }
  1138. item += '</table></div></div>';
  1139. var head = '<tr><td width="10%"><input type="checkbox" class="searchbox_'+id+'" onclick="searchbox_checkall($(this), \'searchbox_'+id+'_'+data[i].id+'\')"/></td><td>标题</td></tr>';
  1140. if (p) {
  1141. head = head.replace('</td><td>', '</td><td>图片</td><td>');
  1142. }
  1143. item = item.replace('{head}', head);
  1144. content += item;
  1145. }
  1146. if (cateHtml) {
  1147. html = html.replace('{cate}', cateHtml);
  1148. }
  1149. if (content) {
  1150. html = html.replace('{content}', content);
  1151. }
  1152. }
  1153. var config = {
  1154. type: 1,
  1155. shade: 0.3,
  1156. title : false,
  1157. shadeClose : true,
  1158. area : ['800px', '600px'],
  1159. content: html
  1160. };
  1161. layer.open(config);
  1162. layui.use('element', function(){
  1163. var element = layui.element;
  1164. });
  1165. });
  1166. }
  1167. function searchbox_checkall(e, id)
  1168. {
  1169. $('.' + id).each(function()
  1170. {
  1171. $(this).get(0).checked = e.get(0).checked;
  1172. //$(this).click();
  1173. })
  1174. }
  1175. function searchbox_checkone(e, id, key, value)
  1176. {
  1177. if (!e.get(0).checked) {
  1178. $('#searchbox_check_' + key + '_' + value).remove();
  1179. searchbox_value.remove(value);
  1180. var len = searchbox_value.length;
  1181. var name = key.replace('_value', '');
  1182. if (len < 1 && !($('#del_' + name).length)) {
  1183. $("#" + key + '_show').append('<input type="hidden" name="'+name+'[]" id="del_'+name+'" value="-1" />');
  1184. }
  1185. } else {
  1186. var c = '.' + e.attr('data-class');
  1187. searchbox_yes(id, c, false);
  1188. }
  1189. }
  1190. function searchbox_yes(e, c, state)
  1191. {
  1192. var self = $("#" +e);
  1193. $(c).each(function()
  1194. {
  1195. if ($(this).get(0).checked && $(this).val() && $(this).attr('data-value')) {
  1196. var value = self.attr('searchbox_callback');
  1197. var id = self.attr('id').replace('_temp', '');
  1198. var name = self.attr('name').replace('_temp', '');
  1199. var html = '<div style="margin-top: 10px;width: 60%; overflow: auto;max-height: 500px;"><table id="'+id+'_show" class="table table-small-font table-bordered"></table></div>';
  1200. if (!$("#" + id + '_show').length) {
  1201. self.parent().append(html);
  1202. }
  1203. if (!$("#" + id + '_show').find('#searchbox_check_'+id+'_'+$(this).attr('data-value')).length)
  1204. {
  1205. var link = '';
  1206. var attr = '';
  1207. var pic = '';
  1208. if ($(this).attr('data-pic') && $(this).attr('data-pic') != 'undefined') {
  1209. pic = '<a href="javascript:;"><img src="'+$(this).attr('data-pic')+'" width="100"></a>';
  1210. }
  1211. if ($(this).attr('data-link')) {
  1212. link = $(this).attr('data-link');
  1213. attr = ' target="_blank"';
  1214. }
  1215. var html = '<tr id="searchbox_check_'+id+'_'+$(this).attr('data-value')+'"><td width="90%"><input type="checkbox" checked name="'+name+'[]" value="'+$(this).attr('data-value')+'"/>&nbsp;&nbsp;'+pic+'<a href="'+link+'" '+attr+' title="'+$(this).attr('data-name')+'">'+$(this).attr('data-name')+'</td><td width="10%"><a href="javascript:;" onclick="searchbox_del($(this), \''+id+'\', \''+$(this).attr('data-value')+'\', \''+name+'\')">[删除]</a></td></tr>';
  1216. $("#" + id + '_show').append(html);
  1217. if (!searchbox_value[id]) {
  1218. searchbox_value[id] = [];
  1219. }
  1220. searchbox_value[id].push($(this).attr('data-value'));
  1221. }
  1222. }
  1223. })
  1224. if (state == true) {
  1225. layer.closeAll();
  1226. }
  1227. }
  1228. function searchbox_del(e, id, value, name)
  1229. {
  1230. e.parent().parent().remove();
  1231. searchbox_value.remove(value);
  1232. var len = searchbox_value.length;
  1233. if (len < 1 && !($('#del_' + name).length)) {
  1234. $("#" + id + '_show').append('<input type="hidden" name="'+name+'[]" id="del_'+name+'" value="-1" />');
  1235. }
  1236. }
  1237. //后台通用的提示
  1238. function msg(value)
  1239. {
  1240. $("#dever_modal_no").click();
  1241. if(!value.data)
  1242. {
  1243. value.data = value.msg;
  1244. }
  1245. if(value == 1)
  1246. {
  1247. location.reload();
  1248. return;
  1249. }
  1250. submit();
  1251. var url = '';
  1252. if(value.data != 'reload' && value.status == 2)
  1253. {
  1254. showAlert(value.msg, false, '错误提示');
  1255. //alert(value.data);
  1256. //location.reload();
  1257. return;
  1258. }
  1259. else if(value.data == 'reload')
  1260. {
  1261. if(typeof(config.layout) != "undefined" && $(config.layout).length)
  1262. {
  1263. pjax({url: location.href, container: config.layout})
  1264. }
  1265. else
  1266. {
  1267. location.reload();
  1268. }
  1269. return;
  1270. }
  1271. else
  1272. {
  1273. if(value.data.indexOf('http') != -1)
  1274. {
  1275. url = value.data;
  1276. }
  1277. else if($("#url").length)
  1278. {
  1279. url = $("#url").val();
  1280. }
  1281. else
  1282. {
  1283. notify(value.data)
  1284. return;
  1285. }
  1286. if(url)
  1287. {
  1288. if(typeof(config.layout) != "undefined" && $(config.layout).length)
  1289. {
  1290. pjax({url: url, container: config.layout});
  1291. }
  1292. else
  1293. {
  1294. location.href = url;
  1295. }
  1296. }
  1297. else
  1298. {
  1299. if(typeof(config.layout) != "undefined" && $(config.layout).length)
  1300. {
  1301. pjax({url: location.href, container: config.layout});
  1302. }
  1303. else
  1304. {
  1305. location.reload();
  1306. }
  1307. }
  1308. }
  1309. return;
  1310. }
  1311. /**
  1312. * 处理多选问题,处理全选按钮
  1313. */
  1314. function checkbox()
  1315. {
  1316. if($(".autoload").length)
  1317. {
  1318. $(".autoload").each(function()
  1319. {
  1320. if($(this).get(0).checked == true)
  1321. {
  1322. $(this).removeClass('autoload');
  1323. $(this).load();
  1324. }
  1325. });
  1326. }
  1327. if($(".autoload_text").length)
  1328. {
  1329. $(".autoload_text").each(function()
  1330. {
  1331. if($(this).val())
  1332. {
  1333. $(this).removeClass('autoload_text');
  1334. $(this).load();
  1335. }
  1336. });
  1337. }
  1338. var name = 'checkbox-checkall';
  1339. var checkbox = $("." + name);
  1340. if(checkbox.length)
  1341. {
  1342. checkbox.unbind('click').bind('click', function()
  1343. {
  1344. var self = $(this);
  1345. $("." + name + "-" + self.val()).each(function()
  1346. {
  1347. $(this).get(0).checked = self.get(0).checked;
  1348. var next = $(this).next();
  1349. if($(this).get(0).checked == true)
  1350. {
  1351. if(next.length && next.attr('type') != 'checkbox' && next.attr('type') != 'hidden')
  1352. {
  1353. next.attr('disabled', false);
  1354. }
  1355. if($("#mul_type").length)
  1356. {
  1357. $("#mul_type").val(1);
  1358. }
  1359. }
  1360. else
  1361. {
  1362. if(next.length && next.attr('type') != 'checkbox' && next.attr('type') != 'hidden')
  1363. {
  1364. next.attr('disabled', true);
  1365. }
  1366. if($("#mul_type").length)
  1367. {
  1368. $("#mul_type").val(0);
  1369. }
  1370. }
  1371. if ($(this).attr('onclick') && $(this).attr('onclick').indexOf('show') > 0) {
  1372. inputShow($(this), 'col');
  1373. }
  1374. })
  1375. });
  1376. checkbox.each(function()
  1377. {
  1378. var self = $(this);
  1379. var len = $("." + name + "-" + self.val()).length;
  1380. $("." + name + "-" + self.val()).each(function()
  1381. {
  1382. $(this).unbind('click').bind('click', function()
  1383. {
  1384. var next = $(this).next();
  1385. var state = $(this).attr('data-state');
  1386. if($(this).get(0).checked == true)
  1387. {
  1388. if (state == 2) {
  1389. self.get(0).checked = true;
  1390. } else {
  1391. if ($("." + name + "-" + self.val()+":checked").length >= len) {
  1392. self.get(0).checked = true;
  1393. }
  1394. }
  1395. if(self.attr('type') == 'radio')
  1396. {
  1397. //如果父选项是radio类型,做下限制
  1398. //alert(1);
  1399. }
  1400. if($("#mul_type").length)
  1401. {
  1402. $("#mul_type").val(1);
  1403. }
  1404. if(next.length && next.attr('type') != 'checkbox' && next.attr('type') != 'hidden')
  1405. {
  1406. next.attr('disabled', false);
  1407. }
  1408. }
  1409. else
  1410. {
  1411. if(next.length && next.attr('type') != 'checkbox' && next.attr('type') != 'hidden')
  1412. {
  1413. next.attr('disabled', true);
  1414. }
  1415. }
  1416. var num = 0;
  1417. $("." + name + "-" + self.val()).each(function()
  1418. {
  1419. if($(this).get(0).checked == true)
  1420. {
  1421. num = 1;
  1422. }
  1423. });
  1424. var id = $(this).attr('name');
  1425. var hidden = id;
  1426. id = id.replace('[]', '');
  1427. if(num == 0)
  1428. {
  1429. self.get(0).checked = false;
  1430. if($("#mul_type").length)
  1431. {
  1432. $("#mul_type").val(0);
  1433. }
  1434. if (state == 2) {
  1435. } else if (!$('#' + id).length) {
  1436. self.parent().append('<input type="hidden" value="0" id="'+id+'" name="'+hidden+'" />');
  1437. }
  1438. } else {
  1439. if ($('#' + id).length) {
  1440. $('#' + id).remove();
  1441. }
  1442. }
  1443. })
  1444. if($(this).get(0).checked == true)
  1445. {
  1446. self.get(0).checked = true;
  1447. if ($(this).attr('onclick') && $(this).attr('onclick').indexOf('show') > 0) {
  1448. inputShow($(this), 'col');
  1449. }
  1450. }
  1451. });
  1452. })
  1453. }
  1454. }
  1455. /**
  1456. * 处理双击编辑
  1457. */
  1458. function edit()
  1459. {
  1460. if($(".edit").length)
  1461. {
  1462. $(".edit").each(function()
  1463. {
  1464. $(this).bind('dblclick', function()
  1465. {
  1466. var col = $(this).attr('data-col');
  1467. var project = $(this).attr('data-project');
  1468. var table = $(this).attr('data-table');
  1469. var url = $(this).attr('data-url');
  1470. var id = $(this).attr('data-id');
  1471. var html = $(this).attr('data-content');
  1472. var type = $(this).attr('data-type');
  1473. if($(this).find(".edit-content").length)
  1474. {
  1475. html = $(this).find(".edit-content").html();
  1476. html = html.replace('<!--', '<');
  1477. html = html.replace('-->', '>');
  1478. }
  1479. if (html == '点此编辑') {
  1480. html = '';
  1481. }
  1482. if(html.indexOf('input') == -1)
  1483. {
  1484. if(type && type == 'textarea')
  1485. {
  1486. $(this).html('<textarea type="text" name="edit" id="edit" rows="10" cols="60" class="layui-input">'+html+'</textarea>');
  1487. }
  1488. else
  1489. {
  1490. $(this).html('<input type="text" name="edit" id="edit" value="'+html+'" class="layui-input">');
  1491. }
  1492. var self = $(this);
  1493. self.find("#edit").focus();
  1494. self.find("#edit").blur(function()
  1495. {
  1496. var value = self.find("#edit").val();
  1497. if(!value)
  1498. {
  1499. alert('不能为空');
  1500. return;
  1501. }
  1502. if($(this).find(".edit-content").length)
  1503. {
  1504. $(this).find(".edit-content").html(value);
  1505. }
  1506. else
  1507. {
  1508. self.attr('data-content', value);
  1509. }
  1510. self.html(value);
  1511. $.post(url, {project:project,table:table,value:value,where_id:id,col:col}, function(t)
  1512. {
  1513. notify('修改成功', self);
  1514. preview();
  1515. /*
  1516. if(type && type == 'textarea')
  1517. {
  1518. self.html(t);
  1519. }
  1520. */
  1521. })
  1522. })
  1523. }
  1524. });
  1525. })
  1526. }
  1527. }
  1528. function preview()
  1529. {
  1530. if($("#preview").length)
  1531. {
  1532. var time = Date.parse(new Date());
  1533. var src = $('#preview').attr('src').split('#');
  1534. $('#preview').attr('src', src[0] + '&' + time + '#' + src[1]);
  1535. }
  1536. }
  1537. function del()
  1538. {
  1539. if($(".oper_delete").length)
  1540. {
  1541. $(".oper_delete").each(function()
  1542. {
  1543. var href = $(this).attr('href');
  1544. $(this).attr('href', '#');
  1545. $(this).unbind('click');
  1546. $(this).bind('click', function()
  1547. {
  1548. del_act(href);
  1549. });
  1550. })
  1551. }
  1552. }
  1553. /**
  1554. * 处理删除
  1555. */
  1556. function del_act(href)
  1557. {
  1558. var index = layer.confirm('确定进行此项操作吗?', function(i, l)
  1559. {
  1560. $(l).find('.layui-layer-btn0').css('pointer-events','none');
  1561. $.getJSON(href + '&json=1&callback=?', {}, function(t)
  1562. {
  1563. msg(t);
  1564. layer.close(index);
  1565. })
  1566. });
  1567. }
  1568. /**
  1569. * 处理特殊加载的按钮
  1570. */
  1571. function load(href, content, title)
  1572. {
  1573. if (!content) {
  1574. content = '确定进行此项操作吗?';
  1575. }
  1576. if (!title) {
  1577. title = '温馨提示';
  1578. }
  1579. var send = {title:title}
  1580. var index = layer.confirm(content, send, function(i, l)
  1581. {
  1582. $(l).find('.layui-layer-btn0').css('pointer-events','none');
  1583. if(href.indexOf('&') == -1)
  1584. {
  1585. href += '?json=1&callback=?';
  1586. }
  1587. else
  1588. {
  1589. href += '&json=1&callback=?';
  1590. }
  1591. $.getJSON(href, {}, function(t)
  1592. {
  1593. msg(t);
  1594. layer.close(index);
  1595. //location.reload();
  1596. })
  1597. })
  1598. /*
  1599. showAlert('确定进行此项操作吗?', function()
  1600. {
  1601. $("#dever_modal_no").click();
  1602. $.getJSON(href + '&json=1', {}, function(t)
  1603. {
  1604. msg(t);
  1605. })
  1606. });
  1607. */
  1608. }
  1609. /**
  1610. * 处理特殊页面
  1611. */
  1612. function loadPage(href, title, submit)
  1613. {
  1614. if(href.indexOf('&') == -1)
  1615. {
  1616. href += '?json=1&callback=?';
  1617. }
  1618. else
  1619. {
  1620. href += '&json=1&callback=?';
  1621. }
  1622. $.getJSON(href, {}, function(t)
  1623. {
  1624. var func = false;
  1625. if (submit) {
  1626. }
  1627. showAlert(t.data, func, title);
  1628. })
  1629. }
  1630. /**
  1631. * 处理特殊加载的按钮
  1632. */
  1633. function jump(href, form)
  1634. {
  1635. if (form) {
  1636. var param = formData(form);
  1637. href += param[1];
  1638. }
  1639. if (href.indexOf('list_excel') != -1) {
  1640. layer.confirm('确认导出数据吗?', function()
  1641. {
  1642. Excel.export(href);
  1643. })
  1644. } else {
  1645. location.href = href;
  1646. }
  1647. }
  1648. /**
  1649. * 处理change
  1650. */
  1651. function change()
  1652. {
  1653. if($(".change").length)
  1654. {
  1655. $(".change").each(function()
  1656. {
  1657. var key = $(this).attr('data-child');
  1658. /*
  1659. $('.' + key).each(function()
  1660. {
  1661. if($(this).find('select option:selected').val())
  1662. {
  1663. $(this).show();
  1664. $('#set_cate_id_child').get(0).value = $(this).attr('parent');
  1665. }
  1666. });
  1667. */
  1668. $(this).change(function()
  1669. {
  1670. $('.' + key).hide();
  1671. var v = $('.' + key + '_' + $(this).val());
  1672. var s = v.find('select');
  1673. s.change(function()
  1674. {
  1675. $('.' + key + '_value').val($(this).val());
  1676. })
  1677. if(v.length)
  1678. {
  1679. $('.' + key + '_value').val(s.val());
  1680. v.show();
  1681. }
  1682. else
  1683. {
  1684. $('.' + key + '_value').val(-1);
  1685. }
  1686. });
  1687. if($(this).val() > 0)
  1688. {
  1689. $(this).change();
  1690. }
  1691. });
  1692. }
  1693. }
  1694. /**
  1695. * 处理图库系统
  1696. */
  1697. function image()
  1698. {
  1699. if($(".dever-note").length)
  1700. {
  1701. $(".dever-note").each(function()
  1702. {
  1703. var key = $(this).attr('key');
  1704. $(this).inlineattachment(
  1705. {
  1706. uploadUrl: config.upload + '.drag?key='+ key
  1707. });
  1708. });
  1709. }
  1710. if($(".image_upload").length)
  1711. {
  1712. $(".image_upload").each(function(i)
  1713. {
  1714. //如果是大文件
  1715. if ($(this).attr('l')) {
  1716. loadUploadL(i,$(this),$(this).attr('key'),config.upload + '.start', config.lib + 'upload/');
  1717. } else {
  1718. var parent = $(this).parent().parent();
  1719. //alert(parent.attr('id'));
  1720. if(parent.attr('id') && parent.attr('id').indexOf('-child-0') != -1)
  1721. {
  1722. return;
  1723. }
  1724. loadUpload(i,$(this),$(this).attr('key'),config.upload + '.start', config.lib + 'upload/');//三个参数说明1:第几个上传框2:文件对象3:图片的基本配置标题
  1725. }
  1726. })
  1727. }
  1728. if($(".upload_show").length)
  1729. {
  1730. $(".upload_show").each(function(i)
  1731. {
  1732. var parent = $(this).parent().parent();
  1733. if(parent.attr('id') && parent.attr('id').indexOf('-child-0') != -1)
  1734. {
  1735. return;
  1736. }
  1737. showUpload(i,$(this),$(this).attr('key'),config.upload + '.files', config.lib + 'upload/', 1);//三个参数说明1:第几个上传框2:文件对象3:图片的基本配置标题
  1738. })
  1739. }
  1740. if($(".upload_cover").length)
  1741. {
  1742. $(".upload_cover").each(function(i)
  1743. {
  1744. var parent = $(this).parent().parent();
  1745. if(parent.attr('id') && parent.attr('id').indexOf('-child-0') != -1)
  1746. {
  1747. return;
  1748. }
  1749. showUploadCover(i,$(this),$(this).attr('key'),config.upload + '.videoCover', config.lib + 'upload/', 1);//三个参数说明1:第几个上传框2:文件对象3:图片的基本配置标题
  1750. })
  1751. }
  1752. if($(".upload_show_editor").length)
  1753. {
  1754. $(".upload_show_editor").each(function(i)
  1755. {
  1756. var parent = $(this).parent().parent();
  1757. if(parent.attr('id') && parent.attr('id').indexOf('-child-0') != -1)
  1758. {
  1759. return;
  1760. }
  1761. showUpload(i,$(this),$(this).attr('key'),config.upload + '.files', config.lib + 'upload/', 3);//三个参数说明1:第几个上传框2:文件对象3:图片的基本配置标题
  1762. })
  1763. }
  1764. }
  1765. /**
  1766. * 修改密码
  1767. */
  1768. function pass(e)
  1769. {
  1770. var html = '<style>.password_edit div{margin:10px;}.password_edit input{width:200px;}</style><div class="password_edit">';
  1771. html += '<div><label class="layui-form-label">旧密码:</label><input type="password" class="form-control form_margin layui-input" id="edit_old_password" /></div>';
  1772. html += '<div><label class="layui-form-label">新密码:</label><input type="password" class="form-control form_margin layui-input" id="edit_new_password" /></div>';
  1773. html += '</div>';
  1774. var edit = function()
  1775. {
  1776. var old_password = $("#edit_old_password").val();
  1777. var new_password = $("#edit_new_password").val();
  1778. if(!old_password || !new_password)
  1779. {
  1780. alert('请输入密码');
  1781. return;
  1782. }
  1783. if(old_password == new_password)
  1784. {
  1785. alert('旧密码和新密码相同');
  1786. return;
  1787. }
  1788. $.post(config.host + 'auth.password', {old:old_password,new:new_password}, function(t)
  1789. {
  1790. alert(t);
  1791. })
  1792. };
  1793. showAlert(html, edit, '修改密码');
  1794. /*
  1795. $('#dever_modal_body').html(html);
  1796. $('#dever_modal_title').html('修改密码');
  1797. */
  1798. }
  1799. var MSG = [];
  1800. /**
  1801. * 打开弹窗
  1802. */
  1803. //function showMsg(title, e, id, func)
  1804. function showMsg(title, e, id, func, param)
  1805. {
  1806. if(id.indexOf('http://') == -1)
  1807. {
  1808. if($(id).length)
  1809. {
  1810. var html = $(id).html();
  1811. if($(id).html())
  1812. {
  1813. var html = $(id).html();
  1814. MSG[id] = html;
  1815. $(id).html('');
  1816. }
  1817. else
  1818. {
  1819. var html = MSG[id];
  1820. }
  1821. }
  1822. else
  1823. {
  1824. var html = id;
  1825. }
  1826. showAlert(html, func, title);
  1827. /*
  1828. $('#dever_modal_body').html(html);
  1829. $('#dever_modal_title').html(title);
  1830. if (func) {
  1831. $("#dever_modal_yes").unbind('click').bind('click', func);
  1832. } else {
  1833. $("#dever_modal_yes").unbind('click').bind('click', function(){$("#dever_modal_no").click()});
  1834. }
  1835. */
  1836. }
  1837. else
  1838. {
  1839. var url = id;
  1840. var send = {};
  1841. if (param) {
  1842. send = param;
  1843. }
  1844. if (e && e.attr('msg-send')) {
  1845. send.data = e.attr('msg-send');
  1846. }
  1847. if (url.indexOf('?') != -1) {
  1848. url = url + '&';
  1849. } else {
  1850. url = url + '?';
  1851. }
  1852. $.getJSON(url+'json=1&callback=?',send,function(t)
  1853. {
  1854. t = t.data;
  1855. showAlert(t, func, t);
  1856. /*
  1857. $('#dever_modal_body').html(t);
  1858. $('#dever_modal_title').html(title);
  1859. if(func)
  1860. {
  1861. $("#dever_modal_yes").unbind('click').bind('click', func);
  1862. }
  1863. */
  1864. });
  1865. }
  1866. }
  1867. function updateMsg(id)
  1868. {
  1869. $("#"+id).submit();
  1870. }
  1871. function showAlert(msg, func, title, index, t)
  1872. {
  1873. if (!title) {
  1874. title = '温馨提示';
  1875. }
  1876. var type = 0;
  1877. if (msg.indexOf('<') != -1) {
  1878. type = 1;
  1879. }
  1880. if (t) {
  1881. type = t;
  1882. }
  1883. var config = {
  1884. type: 0,
  1885. title: title,
  1886. shade: 0.1,
  1887. shadeClose : true,
  1888. content: msg
  1889. };
  1890. if (index) {
  1891. config.zIndex = index;
  1892. }
  1893. config.scrollbar = false;
  1894. if (type == 1) {
  1895. config.type = 1;
  1896. config.btn = ['保存', '关闭'];
  1897. if (func) {
  1898. config.area = ['800px', '500px'];
  1899. config.btn = ['保存', '关闭'];
  1900. } else {
  1901. config.area = ['500px', '550px'];
  1902. config.btn = ['关闭'];
  1903. }
  1904. } else if (type == 2) {
  1905. config.type = 1;
  1906. config.btn = [];
  1907. config.area = ['800px', '550px'];
  1908. }
  1909. config.cancel = config.btn2 = function(index)
  1910. {
  1911. layer.close(index);
  1912. };
  1913. if (func) {
  1914. config.yes = function(index)
  1915. {
  1916. func(index);
  1917. };
  1918. } else {
  1919. config.yes = config.cancel;
  1920. }
  1921. config.success = function() {
  1922. //$('.layui-layer-content').css('padding', '10px');
  1923. }
  1924. config.end = function() {
  1925. $('.layui-layer-content').css('overflow-x', 'auto');
  1926. $('#update_button').show();
  1927. }
  1928. var index = layer.open(config);
  1929. }
  1930. function fastEdit(e, url, title, col, index, type)
  1931. {
  1932. var func = function()
  1933. {
  1934. $(".fast").submit();
  1935. };
  1936. var send = {};
  1937. if (col) {
  1938. send.col = col;
  1939. }
  1940. $.get(url + '&fast=1',send,function(t)
  1941. {
  1942. var html = '';
  1943. var valid = '';
  1944. var action = '';
  1945. if ($(t).find('form').length) {
  1946. if ($(t).find('form').length > 1) {
  1947. var form = $(t).find('form').eq(1);
  1948. form.addClass('layui-card-body');
  1949. } else {
  1950. var form = $(t).find('form').eq(0);
  1951. }
  1952. action = form.attr('action');
  1953. form.addClass('fast');
  1954. form.find('#function').eq(0).val('showYes');
  1955. var html = form.prop("outerHTML");
  1956. if ($(t).find('#valid').length) {
  1957. var valid = $(t).find('#valid').prop("outerHTML");
  1958. html = html + valid;
  1959. }
  1960. if (html.indexOf('left: 740px') != -1) {
  1961. html = html.replace('left: 740px', 'left:583px;')
  1962. }
  1963. } else {
  1964. html = t;
  1965. func = false;
  1966. }
  1967. /*
  1968. if ($(html).find('.layui-card-body').length > 0) {
  1969. html = html.replace('class="layui-card-body"', 'class="layui-card-body" style="display:none"');
  1970. html = html.replaceAll('class="layui-btn layuiadmin-btn-list"', 'class="layui-btn layuiadmin-btn-list" style="display:none"');
  1971. }
  1972. */
  1973. if (!action) {
  1974. type = 2;
  1975. func = false;
  1976. }
  1977. if (index == 1) {
  1978. showAlert(html, func, title, 19850422, type);
  1979. } else {
  1980. showAlert(html, func, title, false, type);
  1981. }
  1982. $('.layui-layer-content').css('overflow-x', 'hidden');
  1983. $('#update_button').hide();
  1984. layui.use(['formSelects', 'form'], function(){
  1985. var form = layui.form;
  1986. form.render();
  1987. $("select").each(function()
  1988. {
  1989. if ($(this).attr('xm-select')) {
  1990. layui.formSelects.render($(this).attr('xm-select'));
  1991. }
  1992. })
  1993. });
  1994. init(560);
  1995. });
  1996. }
  1997. /*
  1998. var test =
  1999. {
  2000. refreshPage: false,
  2001. addAjaxFlag: true,
  2002. //添加收藏
  2003. add: function(cfg)
  2004. {
  2005. }
  2006. }
  2007. */
  2008. function showToggle(e)
  2009. {
  2010. var id = e.attr('toggle');
  2011. var child = e.attr('toggle_child');
  2012. var parent = e.parent();
  2013. parent.parent().find('li').removeClass('active');
  2014. parent.addClass('active');
  2015. $(child).fadeOut(100);
  2016. $(id).fadeIn(500);
  2017. initEditor($(id).find('.editor'));
  2018. }
  2019. var select_api = {};
  2020. var select_api_name = [];
  2021. var select_api_title = '';
  2022. var select_api_open = '';
  2023. function select_linkage(level, id, url, name, value, valid, w, total, search, level_param, col, api, type, title, open)
  2024. {
  2025. var e = '#' + id;
  2026. var parent = value.split(',');
  2027. var cur = parent[0];
  2028. parent.remove(cur);
  2029. value = parent.join(',');
  2030. var html = '';
  2031. var old = level;
  2032. var level_name = '';
  2033. if (!total) {
  2034. level_id = 0;
  2035. } else {
  2036. if (level >= total) {
  2037. //$(e).show();
  2038. return;
  2039. }
  2040. level_id = $(e + '_' + level).val();
  2041. if (level_id.indexOf('|') != -1) {
  2042. var temp = level_id.split('|');
  2043. if (level == 1) {
  2044. select_api_name = [];
  2045. }
  2046. level_id = temp[0];
  2047. level_name = temp[1];
  2048. select_api_name[level-1] = level_name;
  2049. }
  2050. level = parseInt(level) + 1;
  2051. }
  2052. var api_name = '';
  2053. if (col && api) {
  2054. select_api_title = title;
  2055. select_api_open = open;
  2056. if (name.indexOf('_no') == -1) {
  2057. api_name = name;
  2058. } else {
  2059. var t = name.split('_no');
  2060. api_name = t[0];
  2061. }
  2062. name += '_no';
  2063. }
  2064. $.getJSON(url + '&json=1&callback=?', {level_search:search, level_id:level_id, level_num:level,level_param:level_param}, function(t) {
  2065. var check = '';
  2066. if (t.status == 1) {
  2067. var total = t.data.level_total;
  2068. var data = t.data.list;
  2069. if(!$(e + '_' + level).length) {
  2070. html = '<select lay-ignore style="display:inline;margin-top:10px;'+w+'" class="layui-input layui-select update_value form-control '+valid+'" id="'+id+'_'+level+'" name="'+name+'[]" onchange="select_linkage(\''+level+'\', \''+id+'\', \''+url+'\', \''+name+'\', \''+value+'\', \''+valid+'\', \''+w+'\', '+total+', \''+search+'\', \''+level_param+'\', \''+col+'\', \''+api+'\', \''+type+'\', \''+title+'\', \''+open+'\');">';
  2071. }
  2072. for (a in data) {
  2073. if (data[a].value) {
  2074. check = '';
  2075. if (cur == data[a].value) {
  2076. check = ' selected';
  2077. }
  2078. var v = data[a].value;
  2079. if (col && api) {
  2080. v = data[a].value + '|' + data[a].name;
  2081. }
  2082. html += '<option value="'+v+'" '+check+'>'+data[a].name+'</option>';
  2083. }
  2084. }
  2085. if(!$(e + '_' + level).length) {
  2086. html += '</select><span>&nbsp;&nbsp;</span>';
  2087. $(e).append(html);
  2088. $(e + '_' + level).change();
  2089. } else {
  2090. $(e + '_' + level).html(html);
  2091. $(e + '_' + level).change();
  2092. }
  2093. } else {
  2094. $(e + '_' + old).nextAll('select').remove();
  2095. $(e + '_' + old).next('span').nextAll('span').remove();
  2096. }
  2097. if (col && api && level_id > 0) {
  2098. var send = {};
  2099. send[col] = level_id;
  2100. $.getJSON(api + '&json=1&callback=?', send, function(r) {
  2101. var h = '<ul style="list-style:none;margin-top: 20px;display:;" class="">';
  2102. if (type == 'checkbox') {
  2103. h += '<li style="display:inline;margin-left:15px;"><input class="update_value" type="checkbox" onclick="select_linkage_check_all($(this), \'check_level_'+level_id+'\', \''+level_id+'\', \''+select_api_name.join('->')+'\', \''+e+'\', \''+api_name+'\')" value=""/>&nbsp;&nbsp;全选</li>';
  2104. }
  2105. for (var i in r.data) {
  2106. if (r.data[i]['name']) {
  2107. var checked = false;
  2108. if (select_api['level_' + level_id] && select_api['level_' + level_id]['value'] && select_api['level_' + level_id]['value']['id_' + r.data[i]['id']] && select_api['level_' + level_id]['value']['id_' + r.data[i]['id']]['state'] == 1) {
  2109. checked = true;
  2110. }
  2111. h += '<li style="display:inline;margin-left:15px;"><input onclick="select_linkage_check($(this), \''+level_id+'\', \''+select_api_name.join('->')+'\', \''+e+'\', \''+api_name+'\')" '+(checked ? 'checked' : '')+' class="update_value check_level_'+level_id+'" type="' + type + '" id="'+id+'_'+r.data[i]['id']+'" value="'+r.data[i]['id']+'|' + r.data[i]['name'] + '"/>&nbsp;&nbsp;' + r.data[i]['name'] + '</li>';
  2112. }
  2113. }
  2114. h += '</ul>';
  2115. $(e + '_content').html(h);
  2116. });
  2117. }
  2118. /*
  2119. if ($('#' + name + '_level_value').length) {
  2120. var total = $(id).find('select').length;
  2121. $('#' + name + '_level_value').val(total);
  2122. }
  2123. if ($('#' + name + '_up_value').length) {
  2124. $('#' + name + '_up_value').val($(id + '_-2').val());
  2125. }
  2126. */
  2127. });
  2128. if (col && api) {
  2129. select_linkage_check_show(e, api_name);
  2130. }
  2131. }
  2132. function select_linkage_check_all(e, cur, level_id, level_name, id, api_name)
  2133. {
  2134. var checked = e.prop('checked');
  2135. $('.' + cur).each(function() {
  2136. $(this).prop('checked', checked);
  2137. select_linkage_check($(this), level_id, level_name, id, api_name);
  2138. })
  2139. }
  2140. function select_linkage_check(e, level_id, level_name, id, api_name, cid)
  2141. {
  2142. var level_key = 'level_' + level_id;
  2143. if (!select_api[level_key]) {
  2144. select_api[level_key] = {};
  2145. select_api[level_key]['id'] = level_id;
  2146. select_api[level_key]['name'] = level_name;
  2147. select_api[level_key]['value'] = {};
  2148. }
  2149. var value = e.val();
  2150. var temp = value.split('|');
  2151. var key = 'id_' + temp[0];
  2152. if (e.prop('checked')) {
  2153. select_api[level_key]['value'][key] = {};
  2154. select_api[level_key]['value'][key]['id'] = temp[0];
  2155. select_api[level_key]['value'][key]['name'] = temp[1];
  2156. select_api[level_key]['value'][key]['state'] = 1;
  2157. } else {
  2158. if (select_api[level_key] && select_api[level_key]['value'] && select_api[level_key]['value'][key]) {
  2159. select_api[level_key]['value'][key]['state'] = 2;
  2160. }
  2161. if (cid) {
  2162. $(cid).prop('checked', false);
  2163. }
  2164. }
  2165. select_linkage_check_show(id, api_name);
  2166. }
  2167. function select_linkage_check_show(id, api_name)
  2168. {
  2169. if (select_api) {
  2170. var select_api_json = JSON.stringify(select_api);
  2171. var html = '<div style="margin-top: 20px;display:;border: 1px solid #5050b1;padding: 10px;">';
  2172. for (var i in select_api) {
  2173. if (select_api[i]['value']) {
  2174. html += '[' + select_api[i]['name'] + ']:<ul style="list-style:none;" class="">';
  2175. for (var j in select_api[i]['value']) {
  2176. var n = '&nbsp;&nbsp;' + select_api[i]['value'][j]['name'];
  2177. if (select_api_open) {
  2178. var o = select_api_open.replace('{id}', select_api[i]['value'][j]['id']);
  2179. n = '<a href="javascript:;" onclick="fastEdit($(this), \''+o+'\', \''+select_api_title+'\', \'\', 1,1)">'+n+'</a>';
  2180. }
  2181. if (select_api[i]['value'][j]['state'] == 2) {
  2182. n += '[已删除]';
  2183. var checked = false;
  2184. } else {
  2185. var checked = true;
  2186. }
  2187. html += '<li style="display:inline;margin-left:15px;"><input onclick="select_linkage_check($(this), \''+select_api[i]['id']+'\', \''+select_api[i]['name']+'\', \''+id+'\', \''+api_name+'\', \''+id+'_'+select_api[i]['value'][j]['id']+'\')" '+(checked ? 'checked' : '')+' class="update_value" type="checkbox" id="s_'+select_api[i]['value'][j]['id']+'_test" name="s_'+select_api[i]['value'][j]['id']+'_test" value="'+select_api[i]['value'][j]['id']+'|' + select_api[i]['value'][j]['name'] + '"/>'+n+'</li>';
  2188. }
  2189. html += '</ul>';
  2190. }
  2191. }
  2192. html += '</div>';
  2193. html += '<textarea name="'+api_name+'" style="display:none">'+select_api_json+'</textarea>';
  2194. $(id + '_data').html(html);
  2195. }
  2196. }
  2197. /*
  2198. function select_mul(level, id, url, name, value, valid, w, num)
  2199. {
  2200. if(level == 0)
  2201. {
  2202. $(id).find('select').remove();
  2203. $(id).find('span').remove();
  2204. return;
  2205. }
  2206. var parent = value.split(',');
  2207. var cur = parent[0];
  2208. parent.remove(cur);
  2209. value = parent.join(',');
  2210. var html = '';
  2211. var old = level;
  2212. if(level != -1)
  2213. {
  2214. if($(id + '_' + level).length)
  2215. {
  2216. level = $(id + '_' + level).val();
  2217. }
  2218. alert(level);
  2219. if(level == 0)
  2220. {
  2221. $(id + '_' + old).nextAll('select').remove();
  2222. $(id + '_' + old).next('span').nextAll('span').remove();
  2223. if($('#' + name + '_level_value').length)
  2224. {
  2225. var total = $(id).find('select').length;
  2226. $('#' + name + '_level_value').val(total);
  2227. }
  2228. if(old == -2 && $('#' + name + '_value_value').length)
  2229. {
  2230. $('#' + name + '_value_value').val(level);
  2231. }
  2232. return;
  2233. }
  2234. if(old == -2)
  2235. {
  2236. $(id + '_' + old).nextAll('select').remove();
  2237. $(id + '_' + old).next('span').nextAll('span').remove();
  2238. }
  2239. if($('#' + name + '_value_value').length)
  2240. {
  2241. $('#' + name + '_value_value').val(level);
  2242. }
  2243. }
  2244. var total = $(id).find('select').length;
  2245. if(num > 0 && total >= num)
  2246. {
  2247. return;
  2248. }
  2249. var get = url.replace('{level}', level);
  2250. if(level == -1)
  2251. {
  2252. level = -2;
  2253. }
  2254. if(!$(id + '_' + level).length)
  2255. {
  2256. $.getJSON(get + '&json=1', {total:total,level:level}, function(t)
  2257. {
  2258. var check = '';
  2259. if(t.status == 1)
  2260. {
  2261. html = '<select style="'+w+'display:inline;margin-top:10px;" class="update_value form-control '+valid+' dever-mul-'+name+'_'+level+'" name="'+name+'[]" onchange="select_mul(\''+level+'\', \''+id+'\', \''+url+'\', \''+name+'\', \''+value+'\', \''+valid+'\', \''+w+'\', '+num+');">';
  2262. console.log(t.data);
  2263. for(a in t.data)
  2264. {
  2265. if(t.data[a].value)
  2266. {
  2267. check = '';
  2268. if(cur == t.data[a].value)
  2269. {
  2270. check = ' selected';
  2271. }
  2272. html += '<option value="'+t.data[a].value+'" '+check+'>'+t.data[a].name+'</option>';
  2273. }
  2274. }
  2275. html += '</select><span>&nbsp;&nbsp;</span>';
  2276. $(id).append(html);
  2277. $(id + '_' + level).change();
  2278. }
  2279. else
  2280. {
  2281. $(id + '_' + old).nextAll('select').remove();
  2282. $(id + '_' + old).next('span').nextAll('span').remove();
  2283. }
  2284. if($('#' + name + '_level_value').length)
  2285. {
  2286. var total = $(id).find('select').length;
  2287. $('#' + name + '_level_value').val(total);
  2288. }
  2289. if($('#' + name + '_up_value').length)
  2290. {
  2291. $('#' + name + '_up_value').val($(id + '_-2').val());
  2292. }
  2293. });
  2294. }
  2295. }
  2296. */
  2297. //处理更新页面的一些功能,写到一起吧
  2298. var dever_update =
  2299. {
  2300. addIndex : 2,
  2301. index : [],
  2302. auto : false,
  2303. save_key : '',
  2304. init : function()
  2305. {
  2306. var self = this;
  2307. self.index = [];
  2308. // 增加整个更新的表单
  2309. if($(".dever_update_add").length)
  2310. {
  2311. $('.dever_update_add').unbind('click').bind('click', function()
  2312. {
  2313. self.add($(this));
  2314. })
  2315. }
  2316. /* 以后再增加 同时更新另外一个表
  2317. if($(".form-add-content").length)
  2318. {
  2319. var url = config.host + 'auth.password';
  2320. var url = 'http://localhost/dever/manage/?database.update?project=weixin&table=message&menu=weixin&menu_id=39&ajax=1';
  2321. $.get(url, function(t)
  2322. {
  2323. $(".form-add-content").html(t);
  2324. init();
  2325. })
  2326. }
  2327. */
  2328. //增加某一部分表单
  2329. if($(".dever_form_add").length)
  2330. {
  2331. $('.dever_form_add').each(function()
  2332. {
  2333. var key = $.attr('toggle_key');
  2334. if(typeof(self.index[key]) == "undefined")
  2335. {
  2336. self.index[key] = 0;
  2337. }
  2338. $(this).unbind('click').bind('click', function()
  2339. {
  2340. self.append($(this));
  2341. })
  2342. })
  2343. self.del();
  2344. }
  2345. // 开启自动保存
  2346. if($("#struct").length)
  2347. {
  2348. var save = $("#struct").attr('save');
  2349. if(save == 'yes')
  2350. {
  2351. //检测
  2352. self.save_key = location.href + 'test';
  2353. self.check();
  2354. }
  2355. }
  2356. if($('.dever-note').length)
  2357. {
  2358. $('.dever-note').each(function()
  2359. {
  2360. var mditor = new Mditor($(this),{
  2361. fixedHeight:true
  2362. });
  2363. mditor.openPreview();
  2364. })
  2365. }
  2366. },
  2367. save : function()
  2368. {
  2369. //var data = $("#data-1").html();
  2370. var data = [];
  2371. $(".update_value").each(function(i)
  2372. {
  2373. if($(this).attr("update_type") == 'checked')
  2374. {
  2375. data[i] = $(this).get(0).checked;
  2376. }
  2377. else if($(this).attr("update_type") == 'html')
  2378. {
  2379. data[i] = $(this).html();
  2380. }
  2381. else if($(this).attr("update_type") == 'src')
  2382. {
  2383. data[i] = $(this).attr('src');
  2384. }
  2385. else
  2386. {
  2387. data[i] = $(this).val();
  2388. }
  2389. });
  2390. store.set(this.save_key, data.join('|||'));
  2391. //console.info(data);
  2392. },
  2393. recover : function()
  2394. {
  2395. var index = layer.confirm('确定恢复上次保存的数据吗?', function(i, l)
  2396. {
  2397. $(l).find('.layui-layer-btn0').css('pointer-events','none');
  2398. var data = store.get(this.save_key).split('|||');
  2399. if(data)
  2400. {
  2401. var value = $(".update_value");
  2402. for(var k in data)
  2403. {
  2404. var e = value.eq(k);
  2405. if(e.attr('update_type') == 'checked')
  2406. {
  2407. if(data[k] == 'true')
  2408. {
  2409. e.get(0).checked = true;
  2410. }
  2411. else
  2412. {
  2413. e.get(0).checked = false;
  2414. }
  2415. }
  2416. else if(e.attr('update_type') == 'html')
  2417. {
  2418. e.html(data[k]);
  2419. }
  2420. else if(e.attr('update_type') == 'src')
  2421. {
  2422. e.attr('src', data[k]);
  2423. }
  2424. else
  2425. {
  2426. if(e.attr('id'))
  2427. {
  2428. var id = e.attr('id');
  2429. if(typeof(editors[id]) != "undefined")
  2430. {
  2431. editors[id].html(data[k]);
  2432. }
  2433. }
  2434. e.val(data[k]);
  2435. }
  2436. }
  2437. store.set(this.save_key, '');
  2438. this.check();
  2439. }
  2440. })
  2441. },
  2442. check : function()
  2443. {
  2444. var data = store.get(this.save_key);
  2445. var self = this;
  2446. if(data)
  2447. {
  2448. $(".dever_save").unbind('click').bind('click', function()
  2449. {
  2450. self.recover();
  2451. }).show();
  2452. }
  2453. else
  2454. {
  2455. $(".dever_save").hide();
  2456. self.auto = setInterval(function(){self.save()}, 3000);
  2457. }
  2458. },
  2459. del : function()
  2460. {
  2461. var self = this;
  2462. if($(".dever_form_delete").length)
  2463. {
  2464. $('.dever_form_delete').each(function()
  2465. {
  2466. $(this).unbind('click').bind('click', function()
  2467. {
  2468. var parent = $(this).parent();
  2469. var id = parent.attr('id');
  2470. var index = parseInt($('#tab-' + id).attr('toggle_id'));
  2471. var key = $('#tab-' + id).attr('toggle_key');
  2472. if(index <= 1 && self.index[key] <= index)
  2473. {
  2474. }
  2475. else if(index <= 1 && self.index[key] > index)
  2476. {
  2477. index = index+1;
  2478. $("#tab-"+key+"-child-" + index).click();
  2479. }
  2480. else
  2481. {
  2482. index = index-1;
  2483. $("#tab-"+key+"-child-" + index).click();
  2484. };
  2485. $('#tab-' + id).parent().remove();
  2486. parent.remove();
  2487. self.index[key]--;
  2488. })
  2489. })
  2490. }
  2491. },
  2492. append : function(e)
  2493. {
  2494. var self = this;
  2495. var key = e.attr('toggle_key');
  2496. var child = '.dever_'+key+'_child';
  2497. if(typeof(self.index[key]) == "undefined")
  2498. {
  2499. self.index[key] = 0;
  2500. }
  2501. if (isNaN(self.index[key])) {
  2502. self.index[key] = 0;
  2503. }
  2504. if(self.index[key] <= 0)
  2505. {
  2506. self.index[key] = $(child).length;
  2507. }
  2508. if(self.index[key] > 30)
  2509. {
  2510. layer.showAlert('最多只能增加30条');
  2511. return;
  2512. }
  2513. var p = e.parent();
  2514. var id = key + '-child-' + self.index[key];
  2515. var name = '第' + (self.index[key]) + '条';
  2516. p.before('<li><a href="javascript:;" id="tab-'+id+'" toggle_key="'+key+'" toggle_id="'+self.index[key]+'" toggle_child="'+child+'" toggle="#'+id+'" onclick="showToggle($(this))">'+name+'</a></li>');
  2517. var e = e.parent().parent();
  2518. var n = e.next();
  2519. var p = e.parent();
  2520. var content = n.html();
  2521. content = content.replaceAll('_c_', '_c_' + (self.index[key]-1) + '_i_');
  2522. content = '<div id="'+id+'" style="display:none;margin:10px" class="'+n.attr('class')+' dever_form_add_child">' + content + '</div>';
  2523. p.append(content);
  2524. if ($("#" + id).find('.ke-container').length >= 1) {
  2525. $("#" + id).find('.ke-container').eq(0).remove();
  2526. }
  2527. $('#update_' + key +'_c_' + (self.index[key]-1) + '_i_' + 'order_value').val(parseInt($('#update_' + key +'_c_' + (self.index[key]-2) + '_i_' + 'order_value').val())+1);
  2528. self.del();
  2529. //$("html,body").animate({scrollTop:$('.dever_form_add_child').eq(this.appendIndex).offset().top},500);
  2530. self.index[key]++;
  2531. image();
  2532. loadShow();
  2533. autocomplete();
  2534. change();
  2535. layui.use(['formSelects'], function(){
  2536. $('#' + id + " select").each(function()
  2537. {
  2538. if ($(this).attr('xm-select')) {
  2539. layui.formSelects.render($(this).attr('xm-select'));
  2540. }
  2541. })
  2542. });
  2543. },
  2544. add : function(e)
  2545. {
  2546. var self = this;
  2547. var p = e.parent();
  2548. var id = 'data-' + this.addIndex;
  2549. var name = '新增数据-' + (this.addIndex-1);
  2550. p.before('<li><a href="#'+id+'" data-toggle="tab">'+name+'</a></li>');
  2551. var content = $("#content").find('.tab-pane').eq(0).html();
  2552. content = content.replaceAll('update_', 'update_' + this.addIndex + '__');
  2553. content = '<div class="tab-pane fade" id="'+id+'">' + content + '</div>';
  2554. $("#content").append(content);
  2555. $('#update_' + this.addIndex + '__where_id').val('-1');
  2556. this.addIndex++;
  2557. }
  2558. }
  2559. $.fn.pasteEvents = function( delay ) {
  2560. if (delay == undefined) delay = 20;
  2561. return $(this).each(function() {
  2562. var $el = $(this);
  2563. $el.on("paste", function() {
  2564. $el.trigger("prepaste");
  2565. setTimeout(function() { $el.trigger("postpaste"); }, delay);
  2566. });
  2567. });
  2568. };
  2569. $("textarea").on("postpaste", function()
  2570. {
  2571. if($(this).val().indexOf('<') != -1)
  2572. {
  2573. $(this).val(toMarkdown($(this).val()));
  2574. }
  2575. }).pasteEvents();
  2576. function showYes(msg)
  2577. {
  2578. if (msg.status == 2) {
  2579. layer.alert(msg.msg);
  2580. } else {
  2581. showAlert('保存成功', function() {
  2582. if (select_api_open) {
  2583. $('.layui-layer-content').css('overflow-x', 'auto');
  2584. $('#update_button').show();
  2585. layer.closeAll();
  2586. } else {
  2587. if(msg.data.indexOf('http') != -1) {
  2588. location.href = msg.data;
  2589. } else {
  2590. location.reload()
  2591. }
  2592. }
  2593. });
  2594. }
  2595. }
  2596. function setDay(e, d)
  2597. {
  2598. $('#search_option_sday').val(d);
  2599. $('.sday_button').removeClass('sday_button_border');
  2600. e.addClass('sday_button_border');
  2601. var date = new Date();
  2602. var year = date.getFullYear();
  2603. var month = date.getMonth()+1;
  2604. var day = date.getDate();
  2605. var nowDate = year + "-" + (month < 10 ? "0" + month : month) + "-" + (day < 10 ? "0" + day : day);
  2606. //获取30天前得日期
  2607. var lastDate = new Date(date - 1000 * 60 * 60 * 24 * d);
  2608. var lastY = lastDate.getFullYear();
  2609. var lastM = lastDate.getMonth()+1;
  2610. var lastD = lastDate.getDate();
  2611. var LDate = lastY + "-" + (lastM < 10 ? "0" + lastM : lastM) + "-" + (lastD < 10 ? "0" + lastD : lastD);
  2612. $('.manage_sday').eq(0).val(LDate);
  2613. $('.manage_sday').eq(1).val(nowDate);
  2614. }
  2615. function setDate(e, d)
  2616. {
  2617. $('#search_option_sdate').val(d);
  2618. $('.sdate_button').removeClass('sdate_button_border');
  2619. e.addClass('sdate_button_border');
  2620. var date = new Date();
  2621. var year = date.getFullYear();
  2622. var month = date.getMonth()+1;
  2623. var day = date.getDate();
  2624. var nowDate = year + "-" + (month < 10 ? "0" + month : month) + "-" + (day < 10 ? "0" + day : day);
  2625. //获取30天前得日期
  2626. var lastDate = new Date(date - 1000 * 60 * 60 * 24 * d);
  2627. var lastY = lastDate.getFullYear();
  2628. var lastM = lastDate.getMonth()+1;
  2629. var lastD = lastDate.getDate();
  2630. var LDate = lastY + "-" + (lastM < 10 ? "0" + lastM : lastM) + "-" + (lastD < 10 ? "0" + lastD : lastD);
  2631. $('.manage_sdate').eq(0).val(LDate + ' 00:00:00');
  2632. $('.manage_sdate').eq(1).val(nowDate + ' 23:59:59');
  2633. }
  2634. function showVideo(video)
  2635. {
  2636. var html = '<meta name="referrer" content="no-referrer"><video width="400" height="300" controls autoplay="autoplay"><source src="'+video+'" type="video/mp4">您的浏览器不支持Video标签。</video>';
  2637. showAlert(html);
  2638. }