index.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. {extend name="public/container"}
  2. {block name="content"}
  3. <div class="layui-fluid">
  4. <div class="layui-card">
  5. <div class="layui-card-header">学习计划</div>
  6. <div class="layui-card-body">
  7. <form class="layui-form layui-form-pane" action="">
  8. <div class="layui-form-item">
  9. <div class="layui-inline">
  10. <label class="layui-form-label">学习计划</label>
  11. <div class="layui-input-inline">
  12. <input type="text" name="title" class="layui-input" placeholder="学习计划名称">
  13. </div>
  14. </div>
  15. <div class="layui-inline">
  16. <label class="layui-form-label">计划状态</label>
  17. <div class="layui-input-inline">
  18. <select name="is_show">
  19. <option value="">全部</option>
  20. <option value="1">显示</option>
  21. <option value="0">不显示</option>
  22. </select>
  23. </div>
  24. </div>
  25. <div class="layui-inline">
  26. <div class="layui-input-inline">
  27. <button class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="search" lay-filter="search">
  28. <i class="layui-icon layui-icon-search"></i>搜索
  29. </button>
  30. </div>
  31. </div>
  32. </div>
  33. </form>
  34. <div class="layui-btn-container">
  35. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" data-type="add">
  36. <i class="layui-icon layui-icon-add-1"></i>添加学习计划
  37. </button>
  38. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" data-type="refresh">
  39. <i class="layui-icon layui-icon-refresh-1"></i>刷新
  40. </button>
  41. </div>
  42. <table id="List" lay-filter="List"></table>
  43. <script type="text/html" id="price">
  44. <p>{{d.price}} / {{d.sales}}</p>
  45. </script>
  46. <script type="text/html" id="is_show">
  47. <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_show' lay-text='显示|不显示' {{ d.is_show == 1 ? 'checked' : '' }}>
  48. </script>
  49. <script type="text/html" id="plan_head">
  50. <img width="50" height="50" lay-event='open_image' src="{{d.plan_head}}">
  51. </script>
  52. <script type="text/html" id="act">
  53. <button type="button" class="layui-btn layui-btn-normal layui-btn-xs" onclick="dropdown(this)">
  54. <i class="layui-icon">&#xe625;</i>操作
  55. </button>
  56. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  57. <li>
  58. <a href="javascript:void(0)" lay-event="edit">
  59. <i class="iconfont icon-bianji"></i> 步骤管理
  60. </a>
  61. </li>
  62. <li>
  63. <a href="javascript:void(0)" lay-event="edit">
  64. <i class="iconfont icon-bianji"></i> 编辑计划
  65. </a>
  66. </li>
  67. <li>
  68. <a lay-event='delstor' href="javascript:void(0)">
  69. <i class="iconfont icon-shanchu"></i> 删除计划
  70. </a>
  71. </li>
  72. </ul>
  73. </script>
  74. </div>
  75. </div>
  76. </div>
  77. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  78. {/block}
  79. {block name="script"}
  80. <script>
  81. var $ = layui.jquery;
  82. var layer = layui.layer;
  83. //实例化form
  84. layList.form.render();
  85. //加载列表
  86. layList.tableList({o:'List', done:function () {
  87. $('.layui-btn').on('mouseover', function (event) {
  88. var target = event.target;
  89. var type = target.dataset.type;
  90. if ('recommend' === type) {
  91. layer.tips('点击即可取消此推荐', target, {
  92. tips: [1, '#0093dd']
  93. });
  94. }
  95. });
  96. $('.layui-btn').on('mouseout', function (event) {
  97. var target = event.target;
  98. var type = target.dataset.type;
  99. if ('recommend' === type) {
  100. layer.closeAll();
  101. }
  102. });
  103. }},"{:Url('plan_list')}",function (){
  104. return [
  105. {field: 'id', title: '编号', align: 'center'},
  106. {field: 'plan_name', title: '计划名称',align: 'left'},
  107. {field: 'plan_head', title: '计划封面',templet:'#plan_head',align:'center',minWidth:84},
  108. {field: 'price', title: '原价/现价',align: 'center',templet:'#price'},
  109. {field: 'shelf_time', title: '上架时间',align:'center'},
  110. {field: 'is_show', title: '计划状态',templet:'#is_show',align: 'center',minWidth:92},
  111. {field: 'right', title: '操作',align:'center',toolbar:'#act',minWidth:81},
  112. ];
  113. });
  114. //下拉框
  115. $(document).click(function (e) {
  116. $('.layui-nav-child').hide();
  117. })
  118. function dropdown(that){
  119. var oEvent = arguments.callee.caller.arguments[0] || event;
  120. oEvent.stopPropagation();
  121. var offset = $(that).offset();
  122. var top=offset.top-$(window).scrollTop();
  123. var index = $(that).parents('tr').data('index');
  124. $('.layui-nav-child').each(function (key) {
  125. if (key != index) {
  126. $(this).hide();
  127. }
  128. })
  129. if($(document).height() < top+$(that).next('ul').height()){
  130. $(that).next('ul').css({
  131. 'padding': 10,
  132. 'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  133. 'min-width': 'inherit',
  134. 'position': 'absolute'
  135. }).toggle();
  136. }else{
  137. $(that).next('ul').css({
  138. 'padding': 10,
  139. 'top':$(that).parent('td').height() / 2 + $(that).height(),
  140. 'min-width': 'inherit',
  141. 'position': 'absolute'
  142. }).toggle();
  143. }
  144. }
  145. //自定义方法
  146. var action= {
  147. set_value: function (field, id, value) {
  148. layList.baseGet(layList.Url({
  149. a: 'set_value',
  150. q: {field: field, id: id, value: value}
  151. }), function (res) {
  152. layList.msg(res.msg);
  153. });
  154. },
  155. }
  156. //查询
  157. layList.search('search',function(where){
  158. layList.reload(where,true);
  159. });
  160. //快速编辑
  161. // layList.edit(function (obj) {
  162. // var id=obj.data.id,value=obj.value;
  163. // switch (obj.field) {
  164. // case 'sort':
  165. // if (value.trim()) {
  166. // if (isNaN(value.trim())) {
  167. // layList.msg('请输入正确的数字');
  168. // } else {
  169. // if (value.trim() < 0) {
  170. // layList.msg('排序不能小于0');
  171. // } else if (value.trim() > 9999) {
  172. // layList.msg('排序不能大于9999');
  173. // } else if (parseInt(value.trim()) != value.trim()) {
  174. // layList.msg('排序不能为小数');
  175. // } else {
  176. // action.set_value('sort', id, value.trim());
  177. // }
  178. // }
  179. // } else {
  180. // layList.msg('排序不能为空');
  181. // }
  182. // break;
  183. // }
  184. // });
  185. //监听并执行排序
  186. //layList.sort(['id','sort'],true);
  187. //点击事件绑定
  188. layList.tool(function (event,data,obj) {
  189. switch (event) {
  190. case 'delstor':
  191. var url=layList.U({a:'delete',q:{id:data.id}});
  192. $eb.$swal('delete',function(){
  193. $eb.axios.get(url).then(function(res){
  194. if(res.status == 200 && res.data.code == 200) {
  195. $eb.$swal('success',res.data.msg);
  196. obj.del();
  197. }else
  198. return Promise.reject(res.data.msg || '删除失败')
  199. }).catch(function(err){
  200. $eb.$swal('error',err);
  201. });
  202. })
  203. break;
  204. case 'open_image':
  205. $eb.openImage(data.plan_head);
  206. break;
  207. case 'open_images':
  208. $eb.openImage(data.image);
  209. break;
  210. case 'edit':
  211. layer.open({
  212. type: 2,
  213. title: '编辑计划',
  214. content: '{:Url('create')}?id=' + data.id,
  215. area: ['100%', '100%'],
  216. maxmin: true
  217. });
  218. break;
  219. case 'reset_pwd':
  220. var url=layList.U({c:'merchant.merchant',a:'reset_pwd',q:{id:data.mer_id}});
  221. $eb.$swal('delete',function(){
  222. $eb.axios.post(url).then(function(res){
  223. if(res.data.code == 200) {
  224. window.location.reload();
  225. $eb.$swal('success', res.data.msg);
  226. }else
  227. $eb.$swal('error',res.data.msg||'操作失败!');
  228. });
  229. },{'title':'您确定重置选择讲师后台的密码吗?','text':'重置后的密码为1234567','confirm':'您确定重置密码吗?'});
  230. break;
  231. case 'modify_success':
  232. var url=layList.U({c:'merchant.merchant',a:'modify',q:{id:data.mer_id,status:1}});
  233. $eb.$swal('delete',function(){
  234. $eb.axios.get(url).then(function(res){
  235. if(res.status == 200 && res.data.code == 200) {
  236. window.location.reload();
  237. $eb.$swal('success',res.data.msg);
  238. }else
  239. return Promise.reject(res.data.msg || '删除失败')
  240. }).catch(function(err){
  241. $eb.$swal('error',err);
  242. });
  243. },{'title':'您确定要修改讲师后台的状态吗?','text':'请谨慎操作!','confirm':'是的,我要修改'});
  244. break;
  245. case 'modify_error':
  246. var url=layList.U({c:'merchant.merchant',a:'modify',q:{id:data.mer_id,status:0}});
  247. $eb.$swal('delete',function(){
  248. $eb.axios.get(url).then(function(res){
  249. if(res.status == 200 && res.data.code == 200) {
  250. window.location.reload();
  251. $eb.$swal('success',res.data.msg);
  252. }else
  253. return Promise.reject(res.data.msg || '删除失败')
  254. }).catch(function(err){
  255. $eb.$swal('error',err);
  256. });
  257. },{'title':'您确定要修改讲师后台的状态吗?','text':'请谨慎操作!','confirm':'是的,我要修改'});
  258. break;
  259. }
  260. })
  261. //是否显示快捷按钮操作
  262. layList.switch('is_show',function (odj,value) {
  263. if(odj.elem.checked==true){
  264. layList.baseGet(layList.Url({a:'set_show',p:{is_show:1,id:value}}),function (res) {
  265. layList.msg(res.msg);
  266. });
  267. }else{
  268. layList.baseGet(layList.Url({a:'set_show',p:{is_show:0,id:value}}),function (res) {
  269. layList.msg(res.msg);
  270. });
  271. }
  272. });
  273. $(document).on('click', '.layui-btn', function (event) {
  274. var type = $(this).data('type');
  275. var id = $(this).data('id');
  276. if (type === 'mercreate') {
  277. layer.open({
  278. type: 2,
  279. title: '生成讲师后台',
  280. content: "{:Url('mercreate')}?id=" + id,
  281. area: ['800px', '700px'],
  282. end: function () {
  283. location.reload();
  284. }
  285. });
  286. } else if (type === 'add') {
  287. layer.open({
  288. type: 2,
  289. title: '添加学习计划',
  290. content: "{:Url('create')}",
  291. area: ['100%', '100%'],
  292. maxmin: true,
  293. end: function () {
  294. location.reload();
  295. }
  296. });
  297. } else if (type === 'refresh') {
  298. layList.reload();
  299. }
  300. });
  301. </script>
  302. {/block}