form.html 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. {extend name='admin@main'}
  2. {block name="content"}
  3. {include file='mall@store_goods/form_style'}
  4. <header>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  8. <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css"/>
  9. <style>
  10. .layui-layedit{
  11. width: 1200px;
  12. height: 500px;
  13. }
  14. .layui-form-select{
  15. margin-right: 10px !important;
  16. }
  17. .layui-col-xs9{
  18. width: 90%;
  19. }
  20. .amap-icon img,
  21. .amap-marker-content img{
  22. width: 25px;
  23. height: 34px;
  24. }
  25. .marker {
  26. position: absolute;
  27. top: -20px;
  28. right: -118px;
  29. color: #fff;
  30. padding: 4px 10px;
  31. box-shadow: 1px 1px 1px rgba(10, 10, 10, .2);
  32. white-space: nowrap;
  33. font-size: 12px;
  34. background-color: #25A5F7;
  35. border-radius: 3px;
  36. }
  37. .input-card{
  38. width: 18rem;
  39. z-index: 170;
  40. }
  41. .input-card .btn{
  42. margin-right: .8rem;
  43. }
  44. .input-card .btn:last-child{
  45. margin-right: 0;
  46. }
  47. .input-item-text, input[type=text], input[type=date], select {
  48. height: calc(3rem + 2px) !important;
  49. }
  50. .layui-form-radio{
  51. margin: 0 !important;
  52. padding-right:0 !important;
  53. }
  54. .layui-form-select{
  55. margin-right: 10px !important;
  56. }
  57. #panel {
  58. position: absolute;
  59. background-color: white;
  60. max-height: 90%;
  61. overflow-y: auto;
  62. top: 35px;
  63. right: 10px;
  64. width: 280px;
  65. }
  66. </style>
  67. </header>
  68. <form onsubmit="return false;" id="GoodsForm" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
  69. <div class="layui-card-body think-box-shadow padding-left-40">
  70. <div class="layui-tab">
  71. <ul class="layui-tab-title">
  72. <li class="layui-this">基础设置</li>
  73. <li class="">其他</li>
  74. </ul>
  75. <div class="layui-tab-content">
  76. <!--基础设置-->
  77. <div class="layui-tab-item layui-show">
  78. <div class="layui-form-item layui-row layui-col-space15">
  79. <label class="layui-col-xs9 relative">
  80. <span class="color-green">标题</span>
  81. <input name="title" required class="layui-input" placeholder="请输入活动标题" value="{$vo.title|default=''}">
  82. </label>
  83. </div>
  84. <div class="layui-form-item layui-row layui-col-space15">
  85. <label class="layui-col-xs9 relative">
  86. <span class="color-green">请输入活动标签</span>
  87. <textarea placeholder="请输入活动标签" required class="layui-textarea" name="label">{$vo.label|default=""}</textarea>
  88. </label>
  89. </div>
  90. <div class="layui-form-item">
  91. <span class="color-green label-required-prev">海报</span>
  92. <table class="layui-table">
  93. <thead>
  94. <tr>
  95. <td width="90px" class="text-left"><input name="cover" type="hidden" value="{$vo.cover|default=''}"></td>
  96. </tr>
  97. </thead>
  98. </table>
  99. <script>$('[name="cover"]').uploadOneImage()</script>
  100. </div>
  101. <div class="layui-form-item layui-row layui-col-space15">
  102. <label class="layui-col-xs3 relative">
  103. <span class="color-green">报名模板</span>
  104. <select class="layui-select" name="template_id" id="template_id" lay-filter="template_id" lay-search>
  105. <option value="0">请选择</option>
  106. {foreach $template_list as $vk=>$vv}
  107. <option {if isset($vo.template_id) && $vo.template_id == $vv['id'] }selected{/if} value="{$vv['id']}">{$vv['title']}</option>
  108. {/foreach}
  109. </select>
  110. </label>
  111. <label class="layui-col-xs3 relative">
  112. <span class="color-green">评论开关</span>
  113. <select class="layui-select" name="comment_switch" id="comment_switch" lay-filter="comment_switch" lay-search>
  114. <option {if isset($vo.comment_switch) && $vo.comment_switch == 1 }selected{/if} value="1">开启</option>
  115. <option {if isset($vo.comment_switch) && $vo.comment_switch == 0 }selected{/if} value="0">关闭</option>
  116. </select>
  117. </label>
  118. {notempty name='vo.id'}
  119. <label class="layui-col-xs3 relative">
  120. <span class="color-green">消息推送</span>
  121. <select class="layui-select" name="push_switch" lay-filter="push_switch" lay-search>
  122. <option value="0">否</option>
  123. <option value="1">是</option>
  124. </select>
  125. </label>
  126. {/notempty}
  127. </div>
  128. <div class="layui-form-item layui-row layui-col-space15">
  129. <label class="layui-col-xs3 relative">
  130. <span class="color-green">主办方</span>
  131. <select class="layui-select" name="sponsor_id" id="sponsor_id" lay-filter="sponsor_id" lay-search>
  132. <option value="0">请选择</option>
  133. {foreach $sponsor_list as $vk=>$vv}
  134. <option {if isset($vo.sponsor_id) && $vo.sponsor_id == $vv['id'] }selected{/if} data-vl_key="{$vk}" value="{$vv['id']}">{$vv['title']}</option>
  135. {/foreach}
  136. </select>
  137. </label>
  138. <label class="layui-col-xs3 relative">
  139. <span class="color-green">会员账号</span>
  140. <input name="phone" class="layui-input" placeholder="请输入会员账号" value="{$vo.phone|default=''}">
  141. </label>
  142. <label class="layui-col-xs3 relative">
  143. <span class="color-green">阅读量</span>
  144. <input name="read_num" class="layui-input" placeholder="" value="{$vo.read_num|default=''}">
  145. </label>
  146. </div>
  147. <div class="layui-form-item layui-row layui-col-space15">
  148. <label class="layui-col-xs3 relative">
  149. <span class="color-green">热搜阅读量</span>
  150. <input name="hot_num" value='{$vo.hot_num|default=""}' placeholder="请输入热搜阅读量" class="layui-input">
  151. <input name="hot_num_old" type="hidden" value='{$vo.hot_num|default=""}' class="layui-input">
  152. </label>
  153. </div>
  154. <div class="layui-form-item layui-row layui-col-space15">
  155. <label class="layui-col-xs3 relative">
  156. <span class="color-green">开始时间</span>
  157. <input name="start_time" id="start_time" required class="layui-input" placeholder="请输入开始时间" value="{$vo.start_time|default=''}">
  158. </label>
  159. <label class="layui-col-xs3 relative">
  160. <span class="color-green">结束时间</span>
  161. <input name="end_time" id="end_time" required class="layui-input" placeholder="请输入结束时间" value="{$vo.end_time|default=''}">
  162. </label>
  163. <label class="layui-col-xs3 relative">
  164. <span class="color-green">上架时间</span>
  165. <input name="release_time" id="release_time" required class="layui-input" placeholder="" value="{$vo.release_time|default=''}">
  166. </label>
  167. </div>
  168. <div class="layui-form-item layui-row layui-col-space15">
  169. <label class="layui-col-xs12 relative">
  170. <span class="color-green">关联资料</span>
  171. </label>
  172. <div class="layui-inline" style="top: -15px;margin-bottom: -25px">
  173. <div class="layui-input-inline">
  174. <select name="datum_id" lay-filter ="datum_id" lay-search>
  175. <option value="0">请选择</option>
  176. {foreach $datum_list as $dk=>$dv}
  177. <option {if isset($vo.datum_id) && $vo.datum_id == $dv['id'] }selected{/if} data-dl_key="{$dk}" value="{$dv['id']}">{$dv['title']}</option>
  178. {/foreach}
  179. </select>
  180. </div>
  181. <div class="layui-input-inline">
  182. <select name="datum_item" lay-filter ="datum_item" lay-search>
  183. <option value="0">请选择</option>
  184. {foreach $datum_list as $vk=>$vv}
  185. {if isset($vo.datum_id) && $vo.datum_id == $vv['id'] }
  186. {foreach $vv['url_arr'] as $cln}
  187. <option {if isset($vo.datum_item) && $vo.datum_item == $cln['id']} selected {/if} value="{$cln['id']}">{$cln['title']}</option>
  188. {/foreach}
  189. {/if}
  190. {/foreach}
  191. </select>
  192. </div>
  193. </div>
  194. </div>
  195. <div class="layui-form-item layui-row layui-col-space15">
  196. <label class="layui-col-xs12 relative">
  197. <span class="color-green">视频</span>
  198. </label>
  199. <div class="layui-inline" style="top: -15px;margin-bottom: -25px;margin-right: 20px;">
  200. <div class="layui-input-inline">
  201. <select name="video_id" lay-filter ="video_id" lay-search>
  202. <option value="0">请选择</option>
  203. {foreach $video_list as $vk=>$vv}
  204. <option {if isset($vo.video_id) && $vo.video_id == $vv['id'] }selected{/if} data-vl_key="{$vk}" value="{$vv['id']}">{$vv['title']}</option>
  205. {/foreach}
  206. </select>
  207. </div>
  208. <div class="layui-input-inline">
  209. <select name="video_item" lay-filter ="video_item" lay-search>
  210. <option value="0">请选择</option>
  211. {foreach $video_list as $vk=>$vv}
  212. {if isset($vo.video_id) && $vo.video_id == $vv['id'] }
  213. {foreach $vv['video_arr'] as $cln}
  214. <option {if isset($vo.video_item) && $vo.video_item == $cln['id']} selected {/if} value="{$cln['id']}">{$cln['title']}</option>
  215. {/foreach}
  216. {/if}
  217. {/foreach}
  218. </select>
  219. </div>
  220. </div>
  221. </div>
  222. <div class="layui-form-item layui-row layui-col-space15">
  223. <label class="layui-col-xs12 relative">
  224. <span class="color-green">图文</span>
  225. </label>
  226. <div class="layui-inline" style="top: -15px;margin-bottom: -25px;margin-right: 20px;">
  227. <div class="layui-input-inline">
  228. <select name="article_id" lay-filter ="article_id" lay-search>
  229. <option value="0">请选择</option>
  230. {foreach $article_list as $vk=>$vv}
  231. <option {if isset($vo.article_id) && $vo.article_id == $vv['id'] }selected{/if} data-vl_key="{$vk}" value="{$vv['id']}">{$vv['title']}</option>
  232. {/foreach}
  233. </select>
  234. </div>
  235. <div class="layui-input-inline">
  236. <select name="article_item" lay-filter ="article_item" lay-search>
  237. <option value="0">请选择</option>
  238. {foreach $article_list as $vk=>$vv}
  239. {if isset($vo.article_id) && $vo.article_id == $vv['id'] }
  240. {foreach $vv['item_children'] as $cln}
  241. <option {if isset($vo.article_item) && $vo.article_item == $cln['id']} selected {/if} value="{$cln['id']}">{$cln['title']}</option>
  242. {/foreach}
  243. {/if}
  244. {/foreach}
  245. </select>
  246. </div>
  247. </div>
  248. </div>
  249. <div class="layui-form-item layui-row layui-col-space15">
  250. <label class="layui-col-xs9 relative">
  251. <span class="color-green label-required-prev">地址</span>
  252. </label>
  253. <div class="layui-inline" style="top: -15px;margin-bottom: -25px">
  254. <div class="layui-input-inline">
  255. <select name="province" lay-filter ="province">
  256. <option value="0">请选择</option>
  257. {foreach $all_area as $ak=>$cv}
  258. {if isset($vo.province) && $vo.province == $cv['name'] }
  259. <option selected data-al_key="{$ak}" value="{$cv['name']}">{$cv['name']}</option>
  260. {else}
  261. <option data-al_key="{$ak}" value="{$cv['name']}">{$cv['name']}</option>
  262. {/if}
  263. {/foreach}
  264. </select>
  265. </div>
  266. <div class="layui-input-inline">
  267. <select name="city" lay-filter ="city">
  268. <option value="0">请选择</option>
  269. {foreach $all_area as $ck=>$cv}
  270. {if isset($vo.province) && $vo.province == $cv['name'] }
  271. {foreach $cv['children'] as $clk=>$cln}
  272. {if isset($vo.city) && $vo.city == $cln['name'] }
  273. <option selected data-bl_key="{$clk}" value="{$cln['name']}">{$cln['name']}</option>
  274. {else}
  275. <option data-bl_key="{$clk}" value="{$cln['name']}">{$cln['name']}</option>
  276. {/if}
  277. {/foreach}
  278. {/if}
  279. {/foreach}
  280. </select>
  281. </div>
  282. <div class="layui-input-inline">
  283. <select name="county" lay-filter ="county">
  284. <option value="0">请选择</option>
  285. {foreach $all_area as $ck=>$cv}
  286. {if isset($vo.province) && $vo.province == $cv['name']}
  287. {foreach $cv['children'] as $cln}
  288. {if isset($vo.city) && $vo.city == $cln['name']}
  289. {foreach $cln['children'] as $dln}
  290. {if isset($vo.county) && $vo.county == $dln['name'] }
  291. <option selected value="{$dln['name']}">{$dln['name']}</option>
  292. {else}
  293. <option value="{$dln['name']}">{$dln['name']}</option>
  294. {/if}
  295. {/foreach}
  296. {/if}
  297. {/foreach}
  298. {/if}
  299. {/foreach}
  300. </select>
  301. </div>
  302. <div class="layui-input-inline">
  303. <input name="address" style="width: 400px" required class="layui-input" placeholder="请输入公司地址" value="{$vo.address|default=''}">
  304. </div>
  305. </div>
  306. </div>
  307. <div class="layui-form-item layui-row layui-col-space15">
  308. <label class="layui-col-xs9 relative">
  309. <span class="color-green">地图</span>
  310. <div>
  311. <div id="container" style="width:100%; height: 600px;"></div>
  312. <div id="panel" ></div>
  313. </div>
  314. <div class="layui-input-inline">
  315. <input type="hidden" id="longitude" name="longitude" value="{$vo.longitude|default=''}">
  316. <input type="hidden" id="latitude" name="latitude" value="{$vo.latitude|default=''}">
  317. <input id='lnglat' type="hidden" value="{$vo.longitude|default=''},{$vo.latitude|default=''}">
  318. </div>
  319. </label>
  320. </div>
  321. </div>
  322. <div class="layui-tab-item">
  323. <div class="layui-form-item layui-row layui-col-space15">
  324. <label class="layui-col-xs12 relative" >
  325. <span class="color-green label-required-prev">报名价格设置</span>
  326. <table class="layui-table" style="margin-right: 20px;">
  327. <thead>
  328. <tr>
  329. <th class="text-left">标题</th>
  330. <th class="text-left">发行量</th>
  331. {notempty name='vo.id'}
  332. <th class="text-left">剩余量</th>
  333. {/notempty}
  334. <th class="text-left">价格</th>
  335. <th class="text-left">满减张数</th>
  336. <th class="text-left">满减优惠/张</th>
  337. <th class="text-left">审核</th>
  338. <th class="text-left">状态</th>
  339. <th class="text-left">备注</th>
  340. <th class="text-left">操作</th>
  341. </tr>
  342. <tbody class="no_html">
  343. </tbody>
  344. </thead>
  345. </table>
  346. </label>
  347. </div>
  348. <!-- 线下支付设置-->
  349. <div class="layui-form-item layui-row layui-col-space15">
  350. <label class="layui-col-xs3 relative">
  351. <span class="color-green">线下支付</span>
  352. <select class="layui-select" name="pay_offline" id="pay_offline" lay-filter="pay_offline" lay-search>
  353. <option {if isset($vo.pay_offline) && $vo.pay_offline == 0 }selected{/if} value="0">关闭</option>
  354. <option {if isset($vo.pay_offline) && $vo.pay_offline == 1 }selected{/if} value="1">开启</option>
  355. </select>
  356. </label>
  357. </div>
  358. <div class="layui-form-item layui-row layui-col-space15 offline_div" {if !isset($vo.pay_offline) || !$vo.pay_offline}style="display:none"{/if}>
  359. <label class="layui-col-xs3 relative">
  360. <span class="color-green">户名</span>
  361. <input name="offline_user" class="layui-input" value="{$vo.offline_user|default=''}">
  362. </label>
  363. <label class="layui-col-xs3 relative">
  364. <span class="color-green">开户行</span>
  365. <input name="offline_bank" class="layui-input" value="{$vo.offline_bank|default=''}">
  366. </label>
  367. <label class="layui-col-xs3 relative">
  368. <span class="color-green">账号</span>
  369. <input name="offline_card" class="layui-input" value="{$vo.offline_card|default=''}">
  370. </label>
  371. </div>
  372. <!-- 线下支付设置-->
  373. <div class="layui-form-item layui-row layui-col-space9">
  374. <label class="layui-col-xs20 relative">
  375. <span class="color-green">详情</span>
  376. <textarea id="demo" name="content">{$vo.content|default=""}</textarea>
  377. </label>
  378. </div>
  379. <div class="layui-form-item text-center">
  380. {notempty name='vo.id'}<input type="hidden" name="id" value="{$vo.id}">{/notempty}
  381. <button class="layui-btn" type="submit">保存</button>
  382. <button class="layui-btn layui-btn-danger" type='button' onclick="history.go(-1)" data-close>返回</button>
  383. </div>
  384. </div>
  385. </div>
  386. </div>
  387. </div>
  388. </form>
  389. {/block}
  390. {block name='script'}
  391. <script type="text/javascript" src="https://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
  392. <script src="https://webapi.amap.com/maps?v=1.4.15&key=5295cbb966c063bde1ed33c1de7ed6bd&callback=init"></script>
  393. <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
  394. <script>
  395. layui.config({}).extend({}).use(['index', 'form'], function(){ var $ = layui.$,form = layui.form;})
  396. var longitude = "{$vo.longitude|default='118.356655'}";
  397. var latitude = "{$vo.latitude|default='35.102929'}";
  398. window._AMapSecurityConfig = {
  399. securityJsCode: "d9ec1c40b3aa3504369f304e359586b0",
  400. }
  401. var placeSearch , sel_list;
  402. window.init = function(){
  403. var marker, map = new AMap.Map('container', {
  404. center:[longitude,latitude],
  405. resizeEnable: true,
  406. zoom:13
  407. });
  408. AMap.service(["AMap.PlaceSearch"], function() {
  409. //构造地点查询类
  410. placeSearch = new AMap.PlaceSearch({
  411. pageSize: 5, // 单页显示结果条数
  412. pageIndex: 1, // 页码
  413. city: "", // 兴趣点城市
  414. citylimit: true, //是否强制限制在设置的城市内搜索
  415. map: map, // 展现结果的地图实例
  416. panel: "panel", // 结果列表将在此容器中进行展示。
  417. autoFitView: true, // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
  418. extensions: 'all' ,
  419. callback: 'aaa' ,
  420. });
  421. //关键字查询
  422. });
  423. addMark(longitude,latitude)
  424. map.on( 'click', function (e) {
  425. lnglatInput.value = e.lnglat.toString();
  426. var inputVal = lnglatInput.value.split(',');
  427. clearMarker();
  428. addMark(inputVal[0], inputVal[1])
  429. $("longitude").value =inputVal[0] ;
  430. $("latitude").value = inputVal[1];
  431. });
  432. var $ = function(elementId){
  433. return document.getElementById(elementId);
  434. };
  435. var lnglatInput = $('lnglat');
  436. var pixelInput = $('pixel');
  437. lnglat2container();
  438. // 经纬度坐标转成容器像素坐标
  439. function lnglat2container() {
  440. if(!lnglatInput.value) return
  441. var inputVal = lnglatInput.value.split(',');
  442. var lnglat = new AMap.LngLat(inputVal[0], inputVal[1]);
  443. var pixel = map.lngLatToContainer(lnglat);
  444. pixelInput.value = pixel.round();
  445. }
  446. // 添加mark
  447. function addMark(lng,pix) {
  448. console.log(lng,pix)
  449. if(!lng || !pix) return ;
  450. marker = new AMap.Marker({
  451. icon: "https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png",
  452. position: [lng, pix],
  453. offset: new AMap.Pixel(-13, -30)
  454. });
  455. marker.setMap(map);
  456. }
  457. // 清除 marker
  458. function clearMarker() {
  459. if (marker) {
  460. marker.setMap(null);
  461. marker = null;
  462. }
  463. }
  464. }
  465. $(document).on('click','.poibox',function (){
  466. var click_poi = $(".poibox").index(this);
  467. // console.log(sel_list[click_poi]);
  468. //console.log(sel_list[click_poi].location.lng);
  469. $("#longitude").val(sel_list[click_poi].location.lng);
  470. $("#latitude").val(sel_list[click_poi].location.lat);
  471. $("#lnglat").val(sel_list[click_poi].location.lng + ',' + sel_list[click_poi].location.lat ) ;
  472. })
  473. $("input[name='address']").on('change',function (e) {
  474. placeSearch.search( $("input[name='address']").val(),function (a,ls) {
  475. sel_list = ls.poiList.pois;
  476. }) ;
  477. })
  478. </script>
  479. <script src="https://webapi.amap.com/maps?v=1.4.15&key=5295cbb966c063bde1ed33c1de7ed6bd&callback=init"></script>
  480. <script src="https://webapi.amap.com/js/require.js" data-main="./require-init"></script>
  481. <script src="https://webapi.amap.com/loader.js"></script>
  482. <script>
  483. // layui.use('layedit', function(){
  484. // var layedit = layui.layedit;
  485. // layedit.set({
  486. // uploadImage: {
  487. // url: '/api/upload/uploadlay' //接口url
  488. // ,type: '', //默认post
  489. // data: {
  490. // type: 1
  491. // }
  492. // }
  493. // });
  494. // var index= layedit.build('demo',{
  495. // height: 500
  496. // }); //建立编辑器
  497. // $("#LAY_layedit_"+index).contents().find("img").css("width","auto");
  498. // });
  499. </script>
  500. <script>
  501. layui.form.render();
  502. require(['ckeditor', 'angular'], function () {
  503. window.createEditor('[name="content"]', {
  504. height: 500,
  505. });
  506. })
  507. layui.use('form', function () {
  508. var form = layui.form;
  509. //日期时间范围
  510. laydate.render({
  511. elem: '#start_time'
  512. ,type: 'datetime'
  513. });
  514. laydate.render({
  515. elem: '#end_time'
  516. ,type: 'datetime'
  517. });
  518. laydate.render({
  519. elem: '#release_time'
  520. ,type: 'datetime'
  521. });
  522. //监听指定开关
  523. form.on('select(pay_offline)', function(data) {
  524. if (data.value == 0) {
  525. $(".offline_div").hide();
  526. } else {
  527. $(".offline_div").show();
  528. }
  529. })
  530. })
  531. // 添加设置
  532. $(document).on('click',".add_goods_no",function () {
  533. var knum = $('.no_html tr').length;
  534. var no_html = get_ht(knum);
  535. $(".no_html").append(no_html);
  536. form.render();
  537. console.log(a);// 别删这个!!!
  538. })
  539. // 删除设置
  540. $(document).on('click',".del_no",function (){
  541. var knum = $('.no_html tr').length;
  542. if(knum == 1) {
  543. layer.msg('不能全部删除!')
  544. form.render();
  545. console.log(a);// 别删这个!!!
  546. }
  547. var index= $(".del_no").index(this);
  548. $(".no_detail").eq(index).remove();
  549. form.render();
  550. console.log(a);// 别删这个!!!
  551. })
  552. var is_add = parseInt('{$isAddMode|default=0}');
  553. if(is_add){
  554. $(".no_html").html(get_ht(0));
  555. form.render();
  556. }else{
  557. var ladder = {:json_encode($ladder)};
  558. console.log(ladder);
  559. if(ladder && ladder.length > 0) {
  560. var no_html = '';
  561. $.each(ladder,function (lk,lv) {
  562. no_html += ' <tr class="no_detail change_del" data-dh ="'+lk+'">';
  563. no_html += "<td class='text-left nowrap'>" +
  564. "<input type='text' class='layui-input' name='ladder_title[]' value='"+lv.ladder_title+"'/>" +
  565. "<input type='hidden' name='ladder_id[]' value='"+lv.id+"'/>" +
  566. "</td>";
  567. no_html += "<td class='text-left nowrap'>" +
  568. "<input type='number'min='0' class='layui-input' name='ladder_num[]' value='"+lv.ladder_num+"'/>" +
  569. "</td>";
  570. if(!is_add) {
  571. no_html += "<td class='text-left nowrap'>" +
  572. "<input type='number'min='0' class='layui-input' name='stock[]' value='"+lv.stock+"'/>" +
  573. "</td>";
  574. }
  575. no_html += "<td class='text-left nowrap'>" +
  576. "<input type='' class='layui-input' name='ladder_price[]' value='"+lv.ladder_price+"'/>" +
  577. "</td>";
  578. no_html += "<td class='text-left nowrap'>" +
  579. "<input type='number' class='layui-input' name='fill_num[]' value='"+lv.fill_num+"'/>" +
  580. "</td>";
  581. no_html += "<td class='text-left nowrap'>" +
  582. "<input type='number' class='layui-input' name='sub_money[]' value='"+lv.sub_money+"'/>" +
  583. "</td>";
  584. if(lv.is_sh)
  585. {
  586. no_html += "<td class='text-left nowrap'>" +
  587. "<select name='is_sh[]'>" +
  588. "<option value='0'>否</option>"+
  589. "<option value='1' selected>是</option>"+
  590. "</select>"+
  591. "</td>";
  592. }else{
  593. no_html += "<td class='text-left nowrap'>" +
  594. "<select name='is_sh[]'>" +
  595. "<option value='0'>否</option>"+
  596. "<option value='1'>是</option>"+
  597. "</select>"+
  598. "</td>";
  599. }
  600. if(lv.ladder_status) {
  601. no_html += "<td class='text-left nowrap'>" +
  602. "<select name='ladder_status[]'>" +
  603. "<option value='1' selected>上架</option>"+
  604. "<option value='0'>下架</option>"+
  605. "</select>"+
  606. "</td>";
  607. }else{
  608. no_html += "<td class='text-left nowrap'>" +
  609. "<select name='ladder_status[]'>" +
  610. "<option value='1'>上架</option>"+
  611. "<option value='0'>下架</option>"+
  612. "</select>"+
  613. "</td>";
  614. }
  615. no_html += "<td class='text-left nowrap'>" +
  616. "<input type='' class='layui-input' name='ladder_remark[]' value='"+lv.ladder_remark+"'/>" +
  617. "</td>";
  618. no_html += "<td class='text-left nowrap'>" +
  619. "<a class=\"layui-btn layui-btn-sm layui-btn-danger del_no\">删 除</a>" +
  620. "<a class=\"layui-btn layui-btn-sm layui-btn-sm add_goods_no\">添 加</a>" +
  621. "</td>"
  622. no_html += "</tr>";
  623. })
  624. $(".no_html").html(no_html);
  625. }else{
  626. $(".no_html").html(get_ht(0));
  627. }
  628. window.form.render();
  629. }
  630. function get_ht(k) {
  631. var award_length = $(".no_detail").length;
  632. var no_html = '';
  633. no_html += ' <tr class="no_detail change_del" data-dh ="'+k+'">';
  634. no_html += "<td class='text-left nowrap'>" +
  635. "<input type='text' class='layui-input' name='ladder_title[]' value=''/>" +
  636. "<input type='hidden' name='ladder_id[]' value='0'/>" +
  637. "</td>";
  638. no_html += "<td class='text-left nowrap'>" +
  639. "<input type='number' min='0' class='layui-input' name='ladder_num[]' value=''/>" +
  640. "</td>";
  641. if(!is_add) {
  642. no_html += "<td class='text-left nowrap'>" +
  643. "<input type='number'min='0' class='layui-input' name='stock[]' value=''/>" +
  644. "</td>";
  645. }
  646. no_html += "<td class='text-left nowrap'>" +
  647. "<input type='' class='layui-input' name='ladder_price[]' value=''/>" +
  648. "</td>";
  649. no_html += "<td class='text-left nowrap'>" +
  650. "<input type='number' class='layui-input' name='fill_num[]' value=''/>" +
  651. "</td>";
  652. no_html += "<td class='text-left nowrap'>" +
  653. "<input type='number' class='layui-input' name='sub_money[]' value=''/>" +
  654. "</td>";
  655. no_html += "<td class='text-left nowrap'>" +
  656. "<select name='is_sh[]'>" +
  657. "<option value='0'>否</option>"+
  658. "<option value='1'>是</option>"+
  659. "</select>"+
  660. "</td>";
  661. no_html += "<td class='text-left nowrap'>" +
  662. "<select name='ladder_status[]'>" +
  663. "<option value='1'>上架</option>"+
  664. "<option value='0'>下架</option>"+
  665. "</select>"+
  666. "</td>";
  667. no_html += "<td class='text-left nowrap'>" +
  668. "<input type='text' class='layui-input' name='ladder_remark[]' value=''/>" +
  669. "</td>";
  670. no_html += "<td class='text-left nowrap'>" +
  671. "<a class=\"layui-btn layui-btn-sm layui-btn-danger del_no\">删 除</a>" +
  672. "<a class=\"layui-btn layui-btn-sm layui-btn-sm add_goods_no\">添 加</a>" +
  673. "</td>"
  674. no_html += "</tr>";
  675. return no_html;
  676. }
  677. // 文章监听
  678. form.on('select(article_id)', function(data){
  679. var cl_html = '<option value="0">请选择</option>';
  680. if(data.value == 0) {
  681. $("select[name='article_item']").html(cl_html);
  682. }else{
  683. var vl_key = data.elem[data.elem.selectedIndex].dataset.vl_key;
  684. var article_list = {:json_encode($article_list)};
  685. $.each(article_list[vl_key]['item_children'],function (ck,cv) {
  686. cl_html +='<option value="'+cv.id+'">'+cv.title+'</option>';
  687. })
  688. $("select[name='article_item']").html(cl_html);
  689. }
  690. window.form.render();
  691. });
  692. // 关联视频监听
  693. form.on('select(video_id)', function(data){
  694. var cl_html = '<option value="0">请选择</option>';
  695. if(data.value == 0) {
  696. $("select[name='video_item']").html(cl_html);
  697. }else{
  698. var vl_key = data.elem[data.elem.selectedIndex].dataset.vl_key;
  699. var video_list = {:json_encode($video_list)};
  700. $.each(video_list[vl_key]['video_arr'],function (ck,cv) {
  701. cl_html +='<option value="'+cv.id+'">'+cv.title+'</option>';
  702. })
  703. $("select[name='video_item']").html(cl_html);
  704. }
  705. window.form.render();
  706. });
  707. // 关联资料监听
  708. form.on('select(datum_id)', function(data){
  709. var cl_html = '<option value="0">请选择</option>';
  710. if(data.value == 0) {
  711. $("select[name='datum_item']").html(cl_html);
  712. }else{
  713. var dl_key = data.elem[data.elem.selectedIndex].dataset.dl_key;
  714. var datum_list = {:json_encode($datum_list)};
  715. $.each(datum_list[dl_key]['url_arr'],function (ck,cv) {
  716. cl_html +='<option value="'+cv.id+'">'+cv.title+'</option>';
  717. })
  718. $("select[name='datum_item']").html(cl_html);
  719. }
  720. window.form.render();
  721. });
  722. //地址监听
  723. var goods_spec = {:json_encode($all_area)};
  724. form.on('select(province)', function(data){
  725. var cl_html = '<option value="0">请选择</option>';
  726. if(data.value == 0) {
  727. $("select[name='city']").html(cl_html);
  728. $("select[name='county']").html(cl_html);
  729. }else{
  730. var cl_key = data.elem[data.elem.selectedIndex].dataset.al_key;
  731. $.each(goods_spec[cl_key]['children'],function (ck,cv) {
  732. cl_html +='<option data-bl_key="'+ck+'" value="'+cv.name+'">'+cv.name+'</option>';
  733. })
  734. $("select[name='city']").html(cl_html);
  735. }
  736. $("select[name='county']").html('');
  737. window.form.render();
  738. });
  739. form.on('select(city)', function(data){
  740. second()
  741. })
  742. function second() {
  743. var cl_html = '<option value="0">请选择</option>';
  744. var first_key = $("select[name='province']").find("option:selected").data("al_key");
  745. var second_key = $("select[name='city']").find("option:selected").data("bl_key");
  746. console.log(first_key,second_key)
  747. var to_each = goods_spec[first_key]['children'][second_key]['children'];
  748. console.log(to_each);
  749. $.each(to_each,function (ck,cv) {
  750. cl_html +='<option value="'+cv.name+'">'+cv.name+'</option>';
  751. })
  752. $("select[name='county']").html(cl_html);
  753. window.form.render();
  754. }
  755. </script>
  756. {/block}