index.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. {extend name="public/container"}
  2. {block name="head"}
  3. <style>
  4. .layui-table-cell img{max-width: 100%;height: 50px;cursor: pointer;}
  5. .layui-table-cell .layui-btn-container{overflow: hidden;}
  6. </style>
  7. {/block}
  8. {block name="content"}
  9. <div class="layui-fluid">
  10. <div class="layui-card">
  11. <div class="layui-card-header">资料列表</div>
  12. <div class="layui-card-body">
  13. <div class="layui-row layui-col-space15">
  14. <div class="layui-col-md12">
  15. <form class="layui-form layui-form-pane" action="">
  16. <div class="layui-form-item">
  17. <div class="layui-inline">
  18. <label class="layui-form-label">资料搜索</label>
  19. <div class="layui-input-inline">
  20. <input type="text" name="title" class="layui-input" placeholder="资料名称、简介">
  21. </div>
  22. </div>
  23. <div class="layui-inline">
  24. <label class="layui-form-label">资料分类</label>
  25. <div class="layui-input-inline">
  26. <select name="cate_id" lay-search="">
  27. <option value="0">全部</option>
  28. {volist name='cate_list' id='vc'}
  29. <option {if $vc.pid==0}disabled{/if} value="{$vc.id}">{$vc.html}{$vc.title}</option>
  30. {/volist}
  31. </select>
  32. </div>
  33. </div>
  34. <div class="layui-inline">
  35. <label class="layui-form-label">讲师</label>
  36. <div class="layui-input-inline">
  37. <select name="mer_id" lay-search="">
  38. <option value="">全部</option>
  39. <option value="0">总平台</option>
  40. {volist name='mer_list' id='vc'}
  41. <option value="{$vc.id}">{$vc.mer_name}</option>
  42. {/volist}
  43. </select>
  44. </div>
  45. </div>
  46. <div class="layui-inline">
  47. <label class="layui-form-label">状态</label>
  48. <div class="layui-input-inline">
  49. <select name="is_show">
  50. <option value="">全部</option>
  51. <option value="1">上架</option>
  52. <option value="0">下架</option>
  53. </select>
  54. </div>
  55. </div>
  56. <div class="layui-inline">
  57. <label class="layui-form-label">时间范围</label>
  58. <div class="layui-input-inline" style="width: 260px;">
  59. <input type="text" name="datetime" class="layui-input" id="datetime" placeholder="时间范围">
  60. </div>
  61. </div>
  62. <div class="layui-inline">
  63. <div class="layui-input-inline">
  64. <div class="layui-btn-group">
  65. <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
  66. <i class="layui-icon layui-icon-search"></i>搜索
  67. </button>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </form>
  73. </div>
  74. <div class="layui-col-md12">
  75. <div class="layui-btn-group">
  76. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" data-type="add" onclick="action.open_add('{:Url('add')}','添加资料')">
  77. <i class="layui-icon">&#xe608;</i>添加资料
  78. </button>
  79. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" data-type="refresh" onclick="window.location.reload()">
  80. <i class="layui-icon">&#xe669;</i>刷新
  81. </button>
  82. </div>
  83. <table id="List" lay-filter="List"></table>
  84. <script type="text/html" id="recommend">
  85. <div class="layui-btn-container">
  86. {{# layui.each(d.recommend, function(index, item){ }}
  87. <button type="button" class="layui-btn layui-btn-yd layui-btn-normal layui-btn-xs" data-type="recommend" data-id="{{index}}" data-pid="{{d.id}}">yd-{{item}}</button>
  88. {{# }); }}
  89. </div>
  90. <div class="layui-btn-container">
  91. {{# layui.each(d.web_recommend, function(index, item){ }}
  92. <button type="button" class="layui-btn layui-btn-pc layui-btn-normal layui-btn-xs" data-type="recommend" data-id="{{index}}" data-pid="{{d.id}}">pc-{{item}}</button>
  93. {{# }); }}
  94. </div>
  95. </script>
  96. <script type="text/html" id="is_show">
  97. <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_show' lay-text='上架|下架' {{ d.is_show == 1 ? 'checked' : '' }}>
  98. </script>
  99. <script type="text/html" id="image">
  100. <img lay-event='open_image' src="{{d.image}}" width="89" height="50">
  101. </script>
  102. <script type="text/html" id="act">
  103. <button type="button" class="layui-btn layui-btn-normal layui-btn-xs" onclick="dropdown(this)">
  104. <i class="layui-icon">&#xe625;</i>操作
  105. </button>
  106. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  107. <li>
  108. <a href="javascript:void(0)" onclick="action.open_add('{:Url('add')}?id={{d.id}}','编辑资料')">
  109. <i class="iconfont icon-bianji"></i> 编辑资料
  110. </a>
  111. </li>
  112. <li>
  113. <a href="javascript:void(0)" onclick="$eb.createModalFrame('{{d.title}}-推荐管理','{:Url('recommend')}?data_id={{d.id}}',{h:300,w:400})">
  114. <i class="iconfont icon-yidongshouye"></i> 推至移动首页
  115. </a>
  116. </li>
  117. <li>
  118. <a href="javascript:void(0)" onclick="$eb.createModalFrame('{{d.title}}-推荐管理','{:Url('web_recommend')}?data_id={{d.id}}',{h:300,w:400})">
  119. <i class="iconfont icon-PCshouye"></i> 推至PC首页
  120. </a>
  121. </li>
  122. <li>
  123. <a href="javascript:void(0)" lay-event='records'>
  124. <i class="iconfont icon-xiazai"></i> 下载记录
  125. </a>
  126. </li>
  127. <li>
  128. <a lay-event='delect' href="javascript:void(0)">
  129. <i class="iconfont icon-shanchu"></i> 删除资料
  130. </a>
  131. </li>
  132. </ul>
  133. </script>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  140. {/block}
  141. {block name="script"}
  142. <script>
  143. var $ = layui.jquery;
  144. var layer = layui.layer;
  145. //实例化form
  146. layList.form.render();
  147. layList.date({elem: '#datetime', type: 'datetime', range: '~'});
  148. //加载列表
  149. layList.tableList({o:'List', done:function () {
  150. $('.layui-btn').on('mouseover', function (event) {
  151. var target = event.target;
  152. var type = target.dataset.type;
  153. if ('recommend' === type) {
  154. layer.tips('点击即可取消此推荐', target, {
  155. tips: [1, '#0093dd']
  156. });
  157. }
  158. });
  159. $('.layui-btn').on('mouseout', function (event) {
  160. var target = event.target;
  161. var type = target.dataset.type;
  162. if ('recommend' === type) {
  163. layer.closeAll();
  164. }
  165. });
  166. $('.layui-btn-yd').on('click', function (event) {
  167. var target = event.target;
  168. var type = target.dataset.type;
  169. if ('recommend' === type) {
  170. var id = target.dataset.id;
  171. var pid = target.dataset.pid;
  172. var url = layList.U({ a: 'cancel_recommendation', q: { id: id, data_id: pid } });
  173. $eb.$swal(
  174. 'delete',
  175. function () {
  176. $eb.axios
  177. .get(url)
  178. .then(function (res) {
  179. if (res.data.code == 200) {
  180. $eb.$swal('success', res.data.msg);
  181. layList.reload()
  182. } else {
  183. return Promise.reject(res.data.msg || '取消失败');
  184. }
  185. })
  186. .catch(function (err) {
  187. $eb.$swal('error', err);
  188. });
  189. },
  190. {
  191. title: '确定取消此推荐?',
  192. text: '取消后无法撤销,请谨慎操作!',
  193. confirm: '确定取消'
  194. }
  195. );
  196. }
  197. });
  198. $('.layui-btn-pc').on('click', function (event) {
  199. var target = event.target;
  200. var type = target.dataset.type;
  201. if ('recommend' === type) {
  202. var id = target.dataset.id;
  203. var pid = target.dataset.pid;
  204. var url = layList.U({ a: 'cancel_web_recommendation', q: { id: id, data_id: pid } });
  205. $eb.$swal(
  206. 'delete',
  207. function () {
  208. $eb.axios
  209. .get(url)
  210. .then(function (res) {
  211. if (res.data.code == 200) {
  212. $eb.$swal('success', res.data.msg);
  213. layList.reload()
  214. } else {
  215. return Promise.reject(res.data.msg || '取消失败');
  216. }
  217. })
  218. .catch(function (err) {
  219. $eb.$swal('error', err);
  220. });
  221. },
  222. {
  223. title: '确定取消此推荐?',
  224. text: '取消后无法撤销,请谨慎操作!',
  225. confirm: '确定取消'
  226. }
  227. );
  228. }
  229. });
  230. }},"{:Url('data_download_list')}",function (){
  231. return [
  232. {field: 'id', title: '编号', width:'6%',align: 'center'},
  233. {field: 'title', title: '名称',align: 'left'},
  234. {field: 'cate_name', title: '分类',align: 'center',width:'6%'},
  235. // {field: 'mer_name', title: '讲师',align: 'center',width:'6%'},
  236. {field: 'image', title: '封面',templet:'#image',align: 'center',minWidth:119,width:'8%'},
  237. {field: 'recommend', title: '推荐[yd:移动端]',templet:'#recommend',align: 'center'}, //,pc:PC端
  238. {field: 'money', title: '价格',align: 'center',width:'8%'},
  239. // {field: 'member_money', title: '会员价',align: 'center',width:'8%'},
  240. {field: 'ficti', title: '虚拟下载',event:'ficti',edit:'ficti',align: 'center',width:'6%'},
  241. {field: 'sales', title: '下载量',align: 'center',sort: true,width:'6%'},
  242. {field: 'sort', title: '排序',sort: true,event:'sort',edit:'sort',align: 'center',width:'6%'},
  243. {field: 'is_show', title: '状态',templet:'#is_show',align: 'center',minWidth:92,width:'7%'},
  244. {field: 'right', title: '操作',align:'center',toolbar:'#act',minWidth:81,width:'8%'}
  245. ];
  246. });
  247. //下拉框
  248. $(document).click(function (e) {
  249. $('.layui-nav-child').hide();
  250. });
  251. function dropdown(that){
  252. var oEvent = arguments.callee.caller.arguments[0] || event;
  253. oEvent.stopPropagation();
  254. var offset = $(that).offset();
  255. var top=offset.top-$(window).scrollTop();
  256. var index = $(that).parents('tr').data('index');
  257. $('.layui-nav-child').each(function (key) {
  258. if (key != index) {
  259. $(this).hide();
  260. }
  261. })
  262. if($(document).height() < top+$(that).next('ul').height()){
  263. $(that).next('ul').css({
  264. 'padding': 10,
  265. 'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  266. 'min-width': 'inherit',
  267. 'position': 'absolute'
  268. }).toggle();
  269. }else{
  270. $(that).next('ul').css({
  271. 'padding': 10,
  272. 'top':$(that).parent('td').height() / 2 + $(that).height(),
  273. 'min-width': 'inherit',
  274. 'position': 'absolute'
  275. }).toggle();
  276. }
  277. }
  278. //自定义方法
  279. var action= {
  280. set_value: function (field, id, value) {
  281. layList.baseGet(layList.Url({
  282. a: 'set_value',
  283. q: {field: field, id: id, value: value}
  284. }), function (res) {
  285. layList.msg(res.msg);
  286. });
  287. },
  288. //打开新添加页面
  289. open_add: function (url,title) {
  290. layer.open({
  291. type: 2 //Page层类型
  292. ,area: ['100%', '100%']
  293. ,title: title
  294. ,shade: 0.6 //遮罩透明度
  295. ,maxmin: true //允许全屏最小化
  296. ,anim: 1 //0-6的动画形式,-1不开启
  297. ,content: url
  298. ,end:function() {
  299. location.reload();
  300. }
  301. });
  302. }
  303. };
  304. //查询
  305. layList.search('search',function(where){
  306. var arr_time = [];
  307. var start_time = '';
  308. var end_time = '';
  309. if (where.datetime) {
  310. arr_time = where.datetime.split('~');
  311. start_time = arr_time[0].trim();
  312. end_time = arr_time[1].trim();
  313. }
  314. layList.reload({
  315. cate_id: where.cate_id,
  316. mer_id: where.mer_id,
  317. is_show: where.is_show,
  318. start_time: start_time,
  319. end_time: end_time,
  320. title: where.title
  321. },true);
  322. });
  323. layList.switch('is_show',function (odj,value) {
  324. var is_show_value = 0;
  325. if(odj.elem.checked==true){
  326. var is_show_value = 1
  327. }
  328. action.set_value('is_show',value,is_show_value);
  329. });
  330. //快速编辑
  331. layList.edit(function (obj) {
  332. var id=obj.data.id,value=obj.value;
  333. switch (obj.field) {
  334. case 'sort':
  335. if (value.trim()) {
  336. if (isNaN(value.trim())) {
  337. layList.msg('请输入正确的数字');
  338. } else {
  339. if (value.trim() < 0) {
  340. layList.msg('排序不能小于0');
  341. } else if (value.trim() > 9999) {
  342. layList.msg('排序不能大于9999');
  343. } else if (parseInt(value.trim()) != value.trim()) {
  344. layList.msg('排序不能为小数');
  345. } else {
  346. action.set_value('sort', id, value.trim());
  347. }
  348. }
  349. } else {
  350. layList.msg('排序不能为空');
  351. }
  352. break;
  353. case 'ficti':
  354. if(value < 0) return layList.msg('虚拟下载不能小于0');
  355. action.set_value('ficti',id,value);
  356. break;
  357. }
  358. });
  359. //监听并执行排序
  360. layList.sort(['id','sort'],true);
  361. //点击事件绑定
  362. layList.tool(function (event,data,obj) {
  363. switch (event) {
  364. case 'delect':
  365. var url=layList.U({a:'delete',q:{id:data.id}});
  366. $eb.$swal('delete',function(){
  367. $eb.axios.get(url).then(function(res){
  368. if(res.status == 200 && res.data.code == 200) {
  369. $eb.$swal('success',res.data.msg);
  370. obj.del();
  371. }else
  372. return Promise.reject(res.data.msg || '删除失败')
  373. }).catch(function(err){
  374. $eb.$swal('error',err);
  375. });
  376. });
  377. break;
  378. case 'records':
  379. layer.open({
  380. type: 2,
  381. title: data.title + '—下载记录',
  382. content: '{:Url('records')}?id=' + data.id,
  383. area: ['100%', '100%'],
  384. maxmin: true
  385. });
  386. break;
  387. case 'open_image':
  388. $eb.openImage(data.image);
  389. break;
  390. }
  391. })
  392. </script>
  393. {/block}