index.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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="steps">
  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. <li>
  73. <a href="javascript:void(0)" onclick="$eb.createModalFrame('关联证书','{:Url('certificate')}?related_id='+{{d.id}},{w:800,h:350})">
  74. <i class="iconfont icon-guanlianzhengshu"></i> 关联证书
  75. </a>
  76. </li>
  77. </ul>
  78. </script>
  79. </div>
  80. </div>
  81. </div>
  82. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  83. {/block}
  84. {block name="script"}
  85. <script>
  86. var $ = layui.jquery;
  87. var layer = layui.layer;
  88. //实例化form
  89. layList.form.render();
  90. //加载列表
  91. layList.tableList({o:'List', done:function () {
  92. $('.layui-btn').on('mouseover', function (event) {
  93. var target = event.target;
  94. var type = target.dataset.type;
  95. if ('recommend' === type) {
  96. layer.tips('点击即可取消此推荐', target, {
  97. tips: [1, '#0093dd']
  98. });
  99. }
  100. });
  101. $('.layui-btn').on('mouseout', function (event) {
  102. var target = event.target;
  103. var type = target.dataset.type;
  104. if ('recommend' === type) {
  105. layer.closeAll();
  106. }
  107. });
  108. }},"{:Url('plan_list')}",function (){
  109. return [
  110. {field: 'id', title: '编号', align: 'center'},
  111. {field: 'plan_name', title: '计划名称',align: 'left'},
  112. {field: 'plan_head', title: '计划封面',templet:'#plan_head',align:'center',minWidth:84},
  113. {field: 'price', title: '原价/现价',align: 'center',templet:'#price'},
  114. {field: 'shelf_time', title: '上架时间',align:'center'},
  115. {field: 'is_show', title: '计划状态',templet:'#is_show',align: 'center',minWidth:92},
  116. {field: 'right', title: '操作',align:'center',toolbar:'#act',minWidth:81},
  117. ];
  118. });
  119. //下拉框
  120. $(document).click(function (e) {
  121. $('.layui-nav-child').hide();
  122. })
  123. function dropdown(that){
  124. var oEvent = arguments.callee.caller.arguments[0] || event;
  125. oEvent.stopPropagation();
  126. var offset = $(that).offset();
  127. var top=offset.top-$(window).scrollTop();
  128. var index = $(that).parents('tr').data('index');
  129. $('.layui-nav-child').each(function (key) {
  130. if (key != index) {
  131. $(this).hide();
  132. }
  133. })
  134. if($(document).height() < top+$(that).next('ul').height()){
  135. $(that).next('ul').css({
  136. 'padding': 10,
  137. 'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  138. 'min-width': 'inherit',
  139. 'position': 'absolute'
  140. }).toggle();
  141. }else{
  142. $(that).next('ul').css({
  143. 'padding': 10,
  144. 'top':$(that).parent('td').height() / 2 + $(that).height(),
  145. 'min-width': 'inherit',
  146. 'position': 'absolute'
  147. }).toggle();
  148. }
  149. }
  150. //自定义方法
  151. var action= {
  152. set_value: function (field, id, value) {
  153. layList.baseGet(layList.Url({
  154. a: 'set_value',
  155. q: {field: field, id: id, value: value}
  156. }), function (res) {
  157. layList.msg(res.msg);
  158. });
  159. },
  160. }
  161. //查询
  162. layList.search('search',function(where){
  163. layList.reload(where,true);
  164. });
  165. //快速编辑
  166. // layList.edit(function (obj) {
  167. // var id=obj.data.id,value=obj.value;
  168. // switch (obj.field) {
  169. // case 'sort':
  170. // if (value.trim()) {
  171. // if (isNaN(value.trim())) {
  172. // layList.msg('请输入正确的数字');
  173. // } else {
  174. // if (value.trim() < 0) {
  175. // layList.msg('排序不能小于0');
  176. // } else if (value.trim() > 9999) {
  177. // layList.msg('排序不能大于9999');
  178. // } else if (parseInt(value.trim()) != value.trim()) {
  179. // layList.msg('排序不能为小数');
  180. // } else {
  181. // action.set_value('sort', id, value.trim());
  182. // }
  183. // }
  184. // } else {
  185. // layList.msg('排序不能为空');
  186. // }
  187. // break;
  188. // }
  189. // });
  190. //监听并执行排序
  191. //layList.sort(['id','sort'],true);
  192. //点击事件绑定
  193. layList.tool(function (event,data,obj) {
  194. switch (event) {
  195. case 'delstor':
  196. var url=layList.U({a:'delete',q:{id:data.id}});
  197. $eb.$swal('delete',function(){
  198. $eb.axios.get(url).then(function(res){
  199. if(res.status == 200 && res.data.code == 200) {
  200. $eb.$swal('success',res.data.msg);
  201. obj.del();
  202. }else
  203. return Promise.reject(res.data.msg || '删除失败')
  204. }).catch(function(err){
  205. $eb.$swal('error',err);
  206. });
  207. })
  208. break;
  209. case 'open_image':
  210. $eb.openImage(data.plan_head);
  211. break;
  212. case 'open_images':
  213. $eb.openImage(data.image);
  214. break;
  215. case 'steps':
  216. layer.open({
  217. type: 2,
  218. title: '步骤管理',
  219. content: '{:Url('steps')}?pid=' + data.id,
  220. area: ['100%', '100%'],
  221. maxmin: true
  222. });
  223. break;
  224. case 'edit':
  225. layer.open({
  226. type: 2,
  227. title: '编辑计划',
  228. content: '{:Url('create')}?id=' + data.id,
  229. area: ['100%', '100%'],
  230. maxmin: true
  231. });
  232. break;
  233. case 'reset_pwd':
  234. var url=layList.U({c:'merchant.merchant',a:'reset_pwd',q:{id:data.mer_id}});
  235. $eb.$swal('delete',function(){
  236. $eb.axios.post(url).then(function(res){
  237. if(res.data.code == 200) {
  238. window.location.reload();
  239. $eb.$swal('success', res.data.msg);
  240. }else
  241. $eb.$swal('error',res.data.msg||'操作失败!');
  242. });
  243. },{'title':'您确定重置选择讲师后台的密码吗?','text':'重置后的密码为1234567','confirm':'您确定重置密码吗?'});
  244. break;
  245. case 'modify_success':
  246. var url=layList.U({c:'merchant.merchant',a:'modify',q:{id:data.mer_id,status:1}});
  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. case 'modify_error':
  260. var url=layList.U({c:'merchant.merchant',a:'modify',q:{id:data.mer_id,status:0}});
  261. $eb.$swal('delete',function(){
  262. $eb.axios.get(url).then(function(res){
  263. if(res.status == 200 && res.data.code == 200) {
  264. window.location.reload();
  265. $eb.$swal('success',res.data.msg);
  266. }else
  267. return Promise.reject(res.data.msg || '删除失败')
  268. }).catch(function(err){
  269. $eb.$swal('error',err);
  270. });
  271. },{'title':'您确定要修改讲师后台的状态吗?','text':'请谨慎操作!','confirm':'是的,我要修改'});
  272. break;
  273. }
  274. })
  275. //是否显示快捷按钮操作
  276. layList.switch('is_show',function (odj,value) {
  277. if(odj.elem.checked==true){
  278. layList.baseGet(layList.Url({a:'set_show',p:{is_show:1,id:value}}),function (res) {
  279. layList.msg(res.msg);
  280. });
  281. }else{
  282. layList.baseGet(layList.Url({a:'set_show',p:{is_show:0,id:value}}),function (res) {
  283. layList.msg(res.msg);
  284. });
  285. }
  286. });
  287. $(document).on('click', '.layui-btn', function (event) {
  288. var type = $(this).data('type');
  289. var id = $(this).data('id');
  290. if (type === 'add') {
  291. layer.open({
  292. type: 2,
  293. title: '添加学习计划',
  294. content: "{:Url('create')}",
  295. area: ['100%', '100%'],
  296. maxmin: true,
  297. end: function () {
  298. location.reload();
  299. }
  300. });
  301. } else if (type === 'refresh') {
  302. layList.reload();
  303. }
  304. });
  305. </script>
  306. {/block}