tpl.blade.php 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124
  1. @extends('admin/layout')
  2. @section('header')
  3. <link href="{{asset('css/plugins/chosen/chosen.css')}}" rel="stylesheet">
  4. <link href="{{asset('css/plugins/switchery/switchery.css')}}" rel="stylesheet">
  5. <link rel="stylesheet"
  6. href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/css/bootstrap-select.min.css">
  7. <link rel="stylesheet" href="{{asset('js/plugins/zTree_v3-master/css/zTreeStyle/zTreeStyle.css')}}">
  8. <style>
  9. .ace_editor {
  10. height: 600px;
  11. }
  12. .my-table {
  13. width: 100%;
  14. }
  15. .my-table td {
  16. border: 1px solid #E5E6E7;
  17. padding: 8px;
  18. }
  19. .my-table tr td:last-child {
  20. cursor: pointer;
  21. text-align: center;
  22. }
  23. .ztree li span.button.add {
  24. margin-left: 2px;
  25. margin-right: -1px;
  26. background-position: -144px 0;
  27. vertical-align: top;
  28. *vertical-align: middle
  29. }
  30. .li_ys {
  31. margin: -10px;
  32. clear: both;
  33. padding-left: 10px;
  34. }
  35. .li_ys li {
  36. display: inline-block;
  37. float: left;
  38. text-align: center;
  39. font-size: 1em;
  40. color: #333;
  41. width: 100px;
  42. overflow: hidden;
  43. margin-right: 5px;
  44. padding: 8px;
  45. border-radius: 4px;
  46. cursor: pointer;
  47. }
  48. .li_ys .selected {
  49. background: #333;
  50. color: #fff;
  51. }
  52. .tab_box div {
  53. border: 1px solid red;
  54. height: 150px;
  55. width: 500px;
  56. }
  57. .form-horizontal .form-boxs {
  58. display: none;
  59. }
  60. .form-horizontal .form-boxs2 {
  61. /* display: none; */
  62. padding: 0 15px;
  63. }
  64. .form-horizontal .form-boxs:first-child {
  65. display: block;
  66. }
  67. .form-horizontal .form-boxs2 {
  68. display: none;
  69. }
  70. .form-horizontal .form-boxs2:first-child {
  71. display: block;
  72. }
  73. .ibox-content {
  74. padding: 5px 0;
  75. border: none;
  76. }
  77. .ibox {
  78. overflow: hidden;
  79. }
  80. .ibox-title {
  81. /* border: dotted 1px #ddd; */
  82. border: none;
  83. }
  84. #left_Box_1, #left_Box_2, #left_Box_3, #left_Box_4 {
  85. display: none;
  86. }
  87. #left_Box_1 {
  88. display: block;
  89. }
  90. .form-control-select {
  91. vertical-align: middle;
  92. padding: 6px 8px;
  93. height: 32;
  94. font-size: 13px;
  95. font-weight: normal;
  96. border-radius: 3px;
  97. background: #fbfbfb;
  98. -webkit-appearance: none;
  99. appearance: none;
  100. background-color: #f8f8f8;
  101. background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='28' viewBox='0 0 16 28' fill='%23777'%3E%3Cpath d='M16 17q0 .406-.297.703l-7 7Q8.406 25 8 25t-.703-.297l-7-7Q0 17.406 0 17t.297-.703T1 16h14q.406 0 .703.297T16 17zm0-6q0 .406-.297.703T15 12H1q-.406 0-.703-.297T0 11t.297-.703l7-7Q7.594 3 8 3t.703.297l7 7Q16 10.594 16 11z'/%3E%3C/svg%3E");
  102. background-position: right 8px center;
  103. background-repeat: no-repeat;
  104. -webkit-background-size: 8px 16px;
  105. background-size: 8px 16px;
  106. padding-right: 25px;
  107. }
  108. input[type="checkbox"]:before, input[type="radio"]:before {
  109. visibility: visible;
  110. content: "\f096";
  111. float: left;
  112. font-family: FontAwesome;
  113. width: 13px;
  114. height: 13px;
  115. line-height: 13px;
  116. font-size: 16px;
  117. border-radius: 5px;
  118. margin-right: 8px;
  119. text-align: left;
  120. font-weight: normal;
  121. color: #888;
  122. }
  123. input[type="checkbox"]:checked:before, input[type="radio"]:checked:before {
  124. content: "\f046";
  125. color: #666;
  126. }
  127. input[type="checkbox"], input[type="radio"] {
  128. visibility: hidden;
  129. cursor: pointer;
  130. position: relative;
  131. top: 3px;
  132. }
  133. .table.table-datalist tbody tr td label {
  134. font-weight: normal;
  135. }
  136. .table.table-datalist thead td label, .table.table-datalist thead td {
  137. font-weight: bold;
  138. }
  139. </style>
  140. <style>
  141. .wrapper-content {
  142. width: 100%;
  143. height: 100%;
  144. position: relative;
  145. }
  146. .sep-wrap {
  147. position: absolute;
  148. width: 100%;
  149. height: 100%;
  150. left: 0;
  151. top: 0;
  152. display: flex;
  153. display: -webkit-flex;
  154. display: -moz-flex;
  155. display: -ms-flex;
  156. display: -o-flex;
  157. /* padding: 15px; */
  158. }
  159. .sep-sidebar {
  160. width: 400px;
  161. flex-shrink: 0;
  162. /* margin-right: 16px; */
  163. overflow-x: auto;
  164. overflow-y: auto;
  165. background: #f2f4f6;
  166. border-right: solid 1px #d5dbe0;
  167. box-shadow: 0 2px 2px #ddd;
  168. z-index: 10;
  169. padding-top: 15px;
  170. }
  171. .sep-sidebar::-webkit-scrollbar {
  172. width: 6px;
  173. }
  174. .sep-sidebar::-webkit-scrollbar:horizontal {
  175. height: 6px;
  176. }
  177. .sep-sidebar::-webkit-scrollbar-track:horizontal {
  178. border-left: none;
  179. border-top: solid 1px #ddd;
  180. }
  181. .sep-sidebar::-webkit-scrollbar-track {
  182. background: rgba(255, 255, 255, 0.4);
  183. -webkit-border-radius: 0;
  184. border-radius: 0;
  185. border-left: solid 1px #ddd;
  186. }
  187. .sep-sidebar::-webkit-scrollbar-thumb {
  188. -webkit-border-radius: 10px;
  189. border-radius: 10px;
  190. background: rgba(0, 0, 0, 0.5);
  191. }
  192. .sep-sidebar .ibox-content {
  193. background: transparent;
  194. }
  195. .sep-sidebar .ibox {
  196. overflow: unset;
  197. }
  198. .sep-primary {
  199. flex: auto;
  200. overflow-y: auto;
  201. padding: 15px;
  202. }
  203. .control-sidebar {
  204. position: absolute;
  205. top: 0;
  206. bottom: 0;
  207. left: 0;
  208. width: 250px;
  209. z-index: 8;
  210. }
  211. .ui-resizable-handle {
  212. width: 5px;
  213. background: #ddd;
  214. position: absolute;
  215. top: 0;
  216. bottom: 0;
  217. right: -5px;
  218. cursor: col-resize;
  219. opacity: 0;
  220. }
  221. .ui-resizable-handle:hover {
  222. opacity: 1;
  223. }
  224. .ui-resizable-handle:before {
  225. position: absolute;
  226. top: 50%;
  227. right: -10px;
  228. width: 20px;
  229. height: 60px;
  230. line-height: 60px;
  231. font-family: FontAwesome;
  232. content: "\f039";
  233. color: #888;
  234. background: #ddd;
  235. margin-top: -30px;
  236. margin-left: -1px;
  237. border-radius: 0 3px 3px 0;
  238. display: block;
  239. font-size: 12px;
  240. -webkit-transform: scale(.6);
  241. text-transform: rotate(-90deg);
  242. text-align: center;
  243. }
  244. .edui-default .edui-editor {
  245. max-width: 100% !important;
  246. width: 100% !important;
  247. }
  248. .form-action-fixed {
  249. position: fixed;
  250. right: 40px;
  251. top: 16px;
  252. margin: 0;
  253. padding: 12px;
  254. text-indent: 0;
  255. border-radius: 0 0 4px 4px;
  256. background: rgba(200, 200, 200, 0.5);
  257. }
  258. </style>
  259. <style type="text/css">
  260. div#rMenu {
  261. position: absolute;
  262. visibility: hidden;
  263. top: 0;
  264. background-color: #555;
  265. text-align: left;
  266. padding: 2px 4px;
  267. z-index: 999;
  268. }
  269. div#rMenu ul li {
  270. margin: 1px 0;
  271. cursor: pointer;
  272. list-style: none outside none;
  273. background-color: #DFDFDF;
  274. padding: 4px;
  275. }
  276. div#rMenu ul {
  277. padding-left: 0;
  278. margin: 0;
  279. width: 100%;
  280. }
  281. .image-li img {
  282. width: 100%;
  283. max-height: 100%;
  284. }
  285. .imageDiv {
  286. border: 2px solid #F0F0F0;
  287. border-radius: 5px;
  288. }
  289. .image-li {
  290. list-style-type: none;
  291. cursor: pointer;
  292. float: left;
  293. width: 200px;
  294. padding: 5px 5px;
  295. text-align: center;
  296. }
  297. </style>
  298. @endsection
  299. @section('content')
  300. <body class="gray-bg">
  301. <div class="wrapper wrapper-content animated fadeInRight">
  302. <div class="sep-wrap">
  303. <div class="sep-sidebar">
  304. <div class="ibox float-e-margins">
  305. <div class="ibox float-e-margins">
  306. <div class="ibox-title hide">
  307. 基本设置
  308. </div>
  309. <div class="ibox-content">
  310. <ul id="treeDemo" class="ztree"></ul>
  311. </div>
  312. </div>
  313. </div>
  314. </div>
  315. <div class="control-sidebar ui-resizable">
  316. </div>
  317. <div class="sep-primary">
  318. <div style="background: #fff;padding-top: 10px;border: dotted 1px #ddd; position: relative;">
  319. <div id="left_Box_1">
  320. <div class="ibox float-e-margins" style=" background: #fff;padding-top: 10px; ">
  321. <div class="ibox-title">
  322. <ul class="li_ys clearfix" id="clearfix">
  323. <li class="selected">基本设置</li>
  324. <li>模版变量</li>
  325. </ul>
  326. </div>
  327. <div class="ibox-content">
  328. <form method="get" class="form-horizontal" id="form1">
  329. <div class="form-boxs">
  330. <div class="row">
  331. <div class="col-md-8" style="padding-right:0;">
  332. <div class="form-group">
  333. <label class="control-label" for="nickname"><span
  334. class="red">* </span>名称:</label>
  335. <div>
  336. <input type="text" class="form-control" id="title" name="title"
  337. autocomplete="off">
  338. <div class="help-block">必须使用英文字幕或数据组合</div>
  339. </div>
  340. <input type="hidden" id="template_id" name="template_id">
  341. </div>
  342. <div class="form-group">
  343. <label class="control-label" for="username_new">
  344. 描述:</label>
  345. <div>
  346. <textarea class="form-control" rows="5" placeholder=""
  347. id="description"
  348. name="description"></textarea>
  349. <div class="help-block">请在这里描述模板的用途</div>
  350. </div>
  351. </div>
  352. </div>
  353. <div class="col-md-4">
  354. <div class="form-group">
  355. <label class="control-label" for="username_new">
  356. 别名:</label>
  357. <div>
  358. <input type="text" placeholder="" class="form-control"
  359. id="alias" name="alias">
  360. <div class="help-block">别名允许使用中文</div>
  361. </div>
  362. </div>
  363. <div class="form-group">
  364. <label class="control-label" for="username_new">
  365. 排序编号:</label>
  366. <div>
  367. <input type="text" placeholder="" class="form-control" id="rank"
  368. name="rank">
  369. </div>
  370. </div>
  371. <div class="form-group">
  372. <label class="control-label" for="username_new">
  373. 父id:</label>
  374. <div>
  375. <input type="text" placeholder="" class="form-control"
  376. id="parent_id" name="parent_id">
  377. </div>
  378. </div>
  379. </div>
  380. </div>
  381. <div class="row">
  382. <div class="col-md-8" style="padding-right:0;">
  383. <div class="form-group">
  384. <label class="control-label" for="username_new">
  385. URL生成规则:</label>
  386. <div>
  387. <select class="form-control form-control-select"
  388. id="sub_type" name="sub_type">
  389. <option value="1">根据标题生成</option>
  390. <option value="2">根据ID生成</option>
  391. </select>
  392. </div>
  393. </div>
  394. </div>
  395. <div class="col-md-4">
  396. <div class="form-group">
  397. <label class="control-label" for="username_new">
  398. 限制URL深度:</label>
  399. <div class="input-group col-sm-4 ">
  400. <input type="text" placeholder="" class="form-control"
  401. id="url_level"
  402. name="url_level" value="0"> <span
  403. class="input-group-addon">层</span>
  404. </div>
  405. <div class="help-block">0表示不限制</div>
  406. </div>
  407. </div>
  408. </div>
  409. <div class="row">
  410. <div class="col-md-8" style="padding-right:0;">
  411. <div class="form-group">
  412. <label class="control-label" for="img">
  413. 缩略图:</label>
  414. <button type="button" class="btn btn-primary"
  415. onclick="addImages('alone')">
  416. 图片上传
  417. </button>
  418. </div>
  419. <div id="images">
  420. </div>
  421. </div>
  422. </div>
  423. </div>
  424. <div class="form-boxs">
  425. <div class="form-group" style="margin: 0;padding: 0 15px;">
  426. <div class="ibox float-e-margins">
  427. <table class="table table-datalist">
  428. <thead>
  429. <tr>
  430. <td>
  431. 变量
  432. </td>
  433. <td>
  434. 标签
  435. </td>
  436. <td>
  437. <label>
  438. <input type="checkbox" id="selectAll" name="selectAll"
  439. style="margin-right: 5px">
  440. 全选
  441. </label>
  442. </td>
  443. </tr>
  444. </thead>
  445. <tbody id="tbody">
  446. @foreach($template as $key=>$value)
  447. <tr>
  448. <td>
  449. {{$value['name']??''}}
  450. </td>
  451. <td>
  452. {{$value['description']??''}}
  453. </td>
  454. <td>
  455. <label>
  456. <input type="checkbox" name="selectBox"
  457. value="{{$value['id']??0}}"
  458. id="checkbox_{{$value['id']??0}}"
  459. style="margin-right: 5px">
  460. 应用
  461. </label>
  462. </td>
  463. </tr>
  464. @endforeach
  465. </tbody>
  466. </table>
  467. </div>
  468. </div>
  469. </div>
  470. </form>
  471. </div>
  472. <div class="form-action-fixed" style="text-align:right;">
  473. <button class="btn btn-primary" type="button" id="templateSave">
  474. 保存
  475. </button>
  476. </div>
  477. </div>
  478. </div>
  479. <div id="left_Box_2">
  480. <div class="ibox float-e-margins" style=" background: #fff;padding-top: 10px;">
  481. <div class="ibox-title">
  482. <ul class="li_ys clearfix" id="clearfix2">
  483. <li class="selected2">基本设置</li>
  484. <li>输入选项</li>
  485. <li>应用模版</li>
  486. </ul>
  487. </div>
  488. <div class="ibox-content">
  489. <div class="form-action-fixed" style="text-align:right;">
  490. <button class="btn btn-primary" type="button" id="variableSave">
  491. 保存
  492. </button>
  493. </div>
  494. <form method="get" class="form-horizontal" id="form2">
  495. <div class="form-boxs2">
  496. <div class="row">
  497. <div class="col-md-8">
  498. <div class="form-group">
  499. <label class="control-label" for="nickname">
  500. <span class="red">* </span> 变量名:
  501. </label>
  502. <div>
  503. <input type="text" class="form-control" id="title2"
  504. name="title2" autocomplete="off">
  505. <span class="help-block">变量名用于前端调取 <code>{$变量名}</code></span>
  506. </div>
  507. <input type="hidden" id="variable_id" name="variable_id">
  508. </div>
  509. <div class="form-group">
  510. <label class="control-label" for="username_new">
  511. 描述:
  512. </label>
  513. <div>
  514. <textarea class="form-control" rows="5" placeholder=""
  515. id="description2" name="description"></textarea>
  516. <div class="help-block">请在这里描述变量的说明,会在输入变量时作为提示</div>
  517. </div>
  518. </div>
  519. </div>
  520. <div class="col-md-4">
  521. <div class="form-group">
  522. <label class="control-label" for="username_new">
  523. 标签名:
  524. </label>
  525. <div>
  526. <input type="text" placeholder="" class="form-control"
  527. id="alias2" name="alias">
  528. <span class="help-block">用作输入框的名称</span>
  529. </div>
  530. </div>
  531. <div class="form-group">
  532. <label class="control-label" for="username_new">
  533. 排序编号:</label>
  534. <div>
  535. <input type="text" placeholder="" class="form-control"
  536. id="rank2"
  537. name="rank">
  538. </div>
  539. </div>
  540. </div>
  541. </div>
  542. </div>
  543. <div class="form-boxs2">
  544. <div class="form-group">
  545. <label class="control-label" for="username_new">
  546. 输入类型:</label>
  547. <div>
  548. <select class="form-control form-control-select"
  549. id="input_type" name="input_type" onchange="onchangeImages()">
  550. <option value="text">单行文本</option>
  551. <option value="textarea">多行文本</option>
  552. <option value="richtext">富文本</option>
  553. <option value="taginput">Tag Input</option>
  554. <option value="select">下拉菜单</option>
  555. <option value="checkbox">复选框</option>
  556. <option value="radio">单选钮</option>
  557. <option value="date">日期</option>
  558. <option value="file">文件上传</option>
  559. <option value="image">图片上传</option>
  560. <option value="resource">资源选择器</option>
  561. </select>
  562. </div>
  563. </div>
  564. <div class="form-group input_opts">
  565. <label class="control-label" for="username_new">
  566. 输入选项:</label>
  567. <div>
  568. <textarea class="form-control" rows="5" placeholder="" id="input_opts"
  569. name="input_opts">
  570. </textarea>
  571. </div>
  572. </div>
  573. <div class="form-group limit">
  574. <label class="control-label" for="username_new">
  575. 数量限制:</label>
  576. <div>
  577. <input type="text" placeholder="" class="form-control" id="input_length"
  578. name="input_length" value="0">
  579. </div>
  580. </div>
  581. <div class="form-group images" style="display: none">
  582. <label class="control-label" for="username_new">
  583. 图片宽度:</label>
  584. <div>
  585. <input type="text" placeholder="" class="form-control" id="width"
  586. name="width" value="0">
  587. </div>
  588. </div>
  589. <div class="form-group images" style="display: none">
  590. <label class="control-label" for="username_new">
  591. 图片高度:</label>
  592. <div>
  593. <input type="text" placeholder="" class="form-control" id="height"
  594. name="height" value="0">
  595. </div>
  596. </div>
  597. <div class="form-group images" style="display: none">
  598. <label class="control-label" for="username_new">
  599. 图片大小:</label>
  600. <div>
  601. <input type="text" placeholder="" class="form-control" id="size"
  602. name="size" value="0">
  603. </div>
  604. </div>
  605. <div class="form-group">
  606. <label class="control-label" for="username_new">
  607. 默认值:</label>
  608. <div>
  609. <textarea class="form-control" rows="5" placeholder="" id="input_value"
  610. name="input_value">
  611. </textarea>
  612. </div>
  613. </div>
  614. <div class="form-group">
  615. <label class="control-label" for="username_new">
  616. 正则检查:</label>
  617. <div>
  618. <input type="text" placeholder="" class="form-control" id="regex_match"
  619. name="regex_match">
  620. </div>
  621. </div>
  622. <div class="form-group">
  623. <label class="control-label" for="username_new">
  624. 检查提示:</label>
  625. <div>
  626. <input type="text" placeholder="" class="form-control" id="regex_error"
  627. name="regex_error" value="0">
  628. </div>
  629. </div>
  630. </div>
  631. <div class="form-boxs2">
  632. <div class="form-group">
  633. <div class="ibox float-e-margins">
  634. <table class="table table-datalist">
  635. <thead>
  636. <tr>
  637. <td>
  638. 模版
  639. </td>
  640. <td>
  641. 描述
  642. </td>
  643. <td>
  644. <input type="checkbox" name="selectAll2" id="selectAll2"
  645. style="margin-right: 5px">
  646. 全选
  647. </td>
  648. </tr>
  649. </thead>
  650. <tbody id="tbody2">
  651. @foreach($variable as $key=>$value)
  652. @if($value['level']==2)
  653. <tr>
  654. <td>
  655. {{$value['name']??''}}
  656. </td>
  657. <td>
  658. {{$value['alias']??''}}
  659. </td>
  660. <td>
  661. <label>
  662. <input class="selectBox2" type="checkbox"
  663. name="selectBox2"
  664. value="{{$value['id']??0}}"
  665. id="checkbox2_{{$value['id']??0}}"
  666. style="margin-right: 8px">应用
  667. </label>
  668. </td>
  669. </tr>
  670. @endif
  671. @endforeach
  672. </tbody>
  673. </table>
  674. </div>
  675. </div>
  676. </div>
  677. </form>
  678. </div>
  679. </div>
  680. </div>
  681. </div>
  682. </div>
  683. </div>
  684. <div id="rMenu">
  685. <ul>
  686. <li id="m_add" onclick="addTreeNode();">增加子节点</li>
  687. <li id="m_del" onclick="removeTreeNode();">删除节点</li>
  688. </ul>
  689. </div>
  690. </div>
  691. </body>
  692. @endsection
  693. @section('footer')
  694. <script src="{{asset('js/bootstrap-select.min.js')}}"></script>
  695. <script src="{{asset('js/plugins/switchery/switchery.js')}}"></script>
  696. <script src="{{asset('js/plugins/zTree_v3-master/js/jquery.ztree.core.min.js')}}"></script>
  697. <script src="{{asset('js/plugins/zTree_v3-master/js/jquery.ztree.all.min.js')}}"></script>
  698. <script src="{{asset('js/plugins/zTree_v3-master/js/jquery.ztree.excheck.min.js')}}"></script>
  699. <script src="{{asset('js/plugins/layDate-v5.0.9/laydate/laydate.js')}}"></script>
  700. <script src="{{asset('js/plugins/ace-builds-master/src-min/ace.js')}}"></script>
  701. <script src="{{asset('js/plugins/jquery-cookie/jquery.cookie.js')}}"></script>
  702. <script>
  703. $('#clearfix li:first-child').addClass('selected');
  704. $('#clearfix li').click(function () {
  705. $(this).addClass('selected').siblings().removeClass('selected');
  706. $('.form-horizontal .form-boxs').eq($(this).index()).show().siblings().hide();
  707. });
  708. $('#clearfix2 li:first-child').addClass('selected');
  709. $('#clearfix2 li').click(function () {
  710. $(this).addClass('selected').siblings().removeClass('selected');
  711. $('.form-horizontal .form-boxs2').eq($(this).index()).show().siblings().hide();
  712. });
  713. $("#selectAll").on("click", function () {
  714. if (this.checked) {
  715. $("#tbody").find("input[name='selectBox']").prop("checked", true);
  716. } else {
  717. $("#tbody").find("input[name='selectBox']").prop("checked", false);
  718. }
  719. });
  720. $("#selectAll2").on("click", function () {
  721. if (this.checked) {
  722. $("#tbody2").find("input[name='selectBox2']").prop("checked", true);
  723. } else {
  724. $("#tbody2").find("input[name='selectBox2']").prop("checked", false);
  725. }
  726. });
  727. function addImages(type) {
  728. layer.open({
  729. type: 2,
  730. content: ['/admin/stencil/images/{{$siteId}}/' + type],
  731. area: ['60%', '70%'],
  732. title: '编辑'
  733. });
  734. }
  735. var setting = {
  736. view: {
  737. fontCss: getFont,
  738. dblClickExpand: false
  739. },
  740. callback: {
  741. onExpand: onExpand,
  742. onCollapse: onCollapse,
  743. onRightClick: OnRightClick,
  744. onClick: function (event, treeId, treeNode) {
  745. console.log(treeNode);
  746. if (treeNode.type === 1) {
  747. $('#left_Box_1').show();
  748. $('#left_Box_2').hide();
  749. $('#left_Box_3').hide();
  750. $("#template_id").val(treeNode.id);
  751. $("#title").val(treeNode.title);
  752. $("#description").val(treeNode.description);
  753. $("#alias").val(treeNode.alias);
  754. $("#rank").val(treeNode.rank);
  755. $('#parent_id').val(treeNode.parent_id);
  756. $('#url_level').val(treeNode.url_level);
  757. $("#tbody").find("input[name='selectBox']").prop("checked", false);
  758. if (treeNode.varIdList.length > 0) {
  759. $(treeNode.varIdList).each(function (key, val) {
  760. $('#checkbox_' + val).prop('checked', true);
  761. });
  762. }
  763. var object = $('#images');
  764. object.empty();
  765. if (treeNode.images && treeNode.images.length > 0) {
  766. var thumb = '';
  767. $.each(treeNode.images, function (key, value) {
  768. var thumb =
  769. '<li class="image-li">' +
  770. '<div class="imageDiv">' +
  771. '<div style="justify-content: center;align-items: center;flex-direction: column;overflow: hidden;margin: auto;">' +
  772. '<img src="' + value + '" alt="' + value + '">' +
  773. '</div>' +
  774. '<div style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;padding: 10px;">' + value + '</div>' +
  775. '<a href="javascript:;" class="js-del-item-alone">' +
  776. '<i class="fa fa-remove"></i>移除' +
  777. '</a>' +
  778. '</div>' +
  779. '</li>';
  780. object.append(thumb);
  781. });
  782. object.append(thumb);
  783. }
  784. }
  785. if (treeNode.type === 2) {
  786. $('#left_Box_2').show();
  787. $('#left_Box_1').hide();
  788. $('#left_Box_3').hide();
  789. $("#variable_id").val(treeNode.id);
  790. $("#title2").val(treeNode.title);
  791. $("#description2").val(treeNode.description);
  792. $("#alias2").val(treeNode.alias);
  793. $("#rank2").val(treeNode.rank);
  794. $("#input_opts").text(treeNode.input_opts);
  795. $("#input_length").val(treeNode.input_length);
  796. $("#width").val(treeNode.width);
  797. $("#height").val(treeNode.height);
  798. $("#size").val(treeNode.size);
  799. $("#input_type").val(treeNode.input_type);
  800. $("#input_value").val(treeNode.input_value);
  801. $("#regex_match").val(treeNode.regex_match);
  802. $("#regex_error").val(treeNode.regex_error);
  803. $("#tbody2").find("input[name='selectBox2']").prop("checked", false);
  804. if (treeNode.templateIdList.length > 0) {
  805. $(treeNode.templateIdList).each(function (key, val) {
  806. $('#checkbox2_' + val).prop('checked', true);
  807. });
  808. }
  809. onchangeImages();
  810. }
  811. }
  812. }
  813. };
  814. function onExpand(event, treeId, treeNode) {
  815. var cookie = $.cookie("z_tree2");
  816. var z_tree = null;
  817. if (cookie) {
  818. z_tree = JSON.parse(cookie);
  819. }
  820. if (!z_tree) {
  821. z_tree = [];
  822. }
  823. if (jQuery.inArray(treeNode.id, z_tree) < 0) {
  824. z_tree.push(treeNode.id);
  825. }
  826. $.cookie("z_tree2", JSON.stringify(z_tree))
  827. }
  828. function onCollapse(event, treeId, treeNode) {
  829. var cookie = $.cookie("z_tree2");
  830. var z_tree = null;
  831. if (cookie) {
  832. z_tree = JSON.parse(cookie);
  833. }
  834. if (!z_tree) {
  835. z_tree = []
  836. }
  837. var index = jQuery.inArray(treeNode.id, z_tree);
  838. z_tree.splice(index, 1);
  839. $.cookie("z_tree2", JSON.stringify(z_tree))
  840. }
  841. function OnRightClick(event, treeId, treeNode) {
  842. if (!treeNode && event.target.tagName.toLowerCase() != "button" && $(event.target).parents("a").length == 0) {
  843. zTree.cancelSelectedNode();
  844. showRMenu("root", event.clientX, event.clientY);
  845. } else if (treeNode && !treeNode.noR) {
  846. zTree.selectNode(treeNode);
  847. showRMenu("node", event.clientX, event.clientY);
  848. }
  849. }
  850. function showRMenu(type, x, y) {
  851. $("#rMenu ul").show();
  852. if (type == "root") {
  853. $("#m_del").hide();
  854. $("#m_check").hide();
  855. $("#m_unCheck").hide();
  856. } else {
  857. $("#m_del").show();
  858. $("#m_check").show();
  859. $("#m_unCheck").show();
  860. }
  861. y += document.body.scrollTop;
  862. x += document.body.scrollLeft;
  863. rMenu.css({"top": y + "px", "left": x + "px", "visibility": "visible"});
  864. $("body").bind("mousedown", onBodyMouseDown);
  865. }
  866. function hideRMenu() {
  867. if (rMenu) rMenu.css({"visibility": "hidden"});
  868. $("body").unbind("mousedown", onBodyMouseDown);
  869. }
  870. function onBodyMouseDown(event) {
  871. if (!(event.target.id == "rMenu" || $(event.target).parents("#rMenu").length > 0)) {
  872. rMenu.css({"visibility": "hidden"});
  873. }
  874. }
  875. function addTreeNode() {
  876. hideRMenu();
  877. var name = "NewFile";
  878. var newNode = {name: name};
  879. if (zTree.getSelectedNodes()[0]) {
  880. zTree.addNodes(zTree.getSelectedNodes()[0], newNode);
  881. //异步添加
  882. var pid = zTree.getSelectedNodes()[0].id;
  883. var level = zTree.getSelectedNodes()[0].level;
  884. var type = zTree.getSelectedNodes()[0].type;//区分模版提交还是变量
  885. var url = '/admin/tpl/templateAddNode/{{$siteId}}';
  886. var ajaxConfig = {
  887. url: url,
  888. type: 'post',
  889. data: {pid: pid, node: name, type: type, level: level},
  890. success: function () {
  891. window.location.reload();
  892. }
  893. };
  894. tips.ajax(ajaxConfig);
  895. } else {
  896. zTree.addNodes(null, newNode);
  897. }
  898. }
  899. function removeTreeNode() {
  900. hideRMenu();
  901. var nodes = zTree.getSelectedNodes();
  902. if (nodes && nodes.length > 0) {
  903. if (nodes[0].children && nodes[0].children.length > 0) {
  904. var msg = "要删除的节点是父节点,如果删除将连同子节点一起删掉。\n\n请确认!";
  905. if (confirm(msg) == true) {
  906. zTree.removeNode(nodes[0]);
  907. }
  908. } else {
  909. zTree.removeNode(nodes[0]);
  910. }
  911. //异步删除
  912. var url = '/admin/tpl/templateDelNode/{{$siteId}}';
  913. var ajaxConfig = {
  914. url: url,
  915. type: 'post',
  916. data: {id: nodes[0].id, pid: nodes[0].parent_id},
  917. success: function () {
  918. window.location.reload();
  919. }
  920. };
  921. tips.ajax(ajaxConfig);
  922. }
  923. }
  924. function getFont(treeId, node) {
  925. return {"font-weight": "bold"};
  926. }
  927. var trees = JSON.parse('{!! addslashes(json_encode($trees)) !!}');
  928. $(document).ready(function () {
  929. zTreeObj = $.fn.zTree.init($("#treeDemo"), setting, trees);
  930. zTree = $.fn.zTree.getZTreeObj("treeDemo");
  931. rMenu = $("#rMenu");
  932. var cookie = $.cookie("z_tree2");
  933. if (cookie) {
  934. z_tree = JSON.parse(cookie);
  935. for (var i = 0; i < z_tree.length; i++) {
  936. var node = zTree.getNodeByParam('id', z_tree[i]);
  937. zTree.expandNode(node, true)
  938. }
  939. }
  940. });
  941. function onchangeImages() {
  942. var input_type = $('#input_type').val();
  943. if (input_type === 'image') {
  944. $(".images").css("display", "block");
  945. $(".limit").css("display", "block");
  946. } else {
  947. $(".images").css("display", "none");
  948. $(".limit").css("display", "none");
  949. }
  950. if (input_type === 'select' || input_type === 'radio' || input_type === 'checkbox') {
  951. $(".input_opts").css("display", "block");
  952. $(".limit").css("display", "none");
  953. }
  954. if (input_type === 'text' || input_type === 'textarea' || input_type === 'richtext' || input_type === 'date' || input_type === 'file' || input_type === 'taginput') {
  955. $(".input_opts").css("display", "none");
  956. $(".limit").css("display", "none");
  957. }
  958. if (input_type === 'resource') {
  959. $(".input_opts").css("display", "none");
  960. $(".limit").css("display", "block");
  961. }
  962. }
  963. //删除图片
  964. $(document).on('click', '.js-del-item-alone', function () {
  965. $(this).parent().parent().remove();
  966. });
  967. $("#templateSave").click(function () {
  968. var data = tips.getFormValues('#form1');
  969. var images = $('#images').find("img");
  970. var imageList = [];
  971. $(images).each(function (key, value) {
  972. imageList.push($(value).attr('src'));
  973. });
  974. data.images = imageList;
  975. var checkboxList = [];
  976. $("#tbody").find("input[name='selectBox']").each(function (i, checkbox) {
  977. if (checkbox.checked) {
  978. checkboxList.push(checkbox.value);
  979. }
  980. });
  981. data.checkboxList = checkboxList;
  982. var url = '/admin/tpl/templateSave/{{$siteId}}';
  983. var type = 'post';
  984. var ajaxConfig = {
  985. url: url,
  986. type: type,
  987. data: data,
  988. success: function (result) {
  989. layer.msg(result.message, {icon: 6, time: 1000});
  990. window.location.reload();
  991. }
  992. };
  993. tips.ajax(ajaxConfig);
  994. });
  995. $("#variableSave").click(function () {
  996. var data = tips.getFormValues('#form2');
  997. var checkboxList = [];
  998. $("#tbody2").find("input[name='selectBox2']").each(function (i, checkbox) {
  999. if (checkbox.checked) {
  1000. checkboxList.push(checkbox.value);
  1001. }
  1002. });
  1003. data.checkboxList = checkboxList;
  1004. var url = '/admin/tpl/variableSave/{{$siteId}}';
  1005. var type = 'post';
  1006. var ajaxConfig = {
  1007. url: url,
  1008. type: type,
  1009. data: data,
  1010. success: function (result) {
  1011. layer.msg(result.message, {icon: 6, time: 1000});
  1012. window.location.reload();
  1013. }
  1014. };
  1015. tips.ajax(ajaxConfig);
  1016. });
  1017. </script>
  1018. @endsection