main.js 67 KB

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