tash.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. {extend name="public/container"}
  2. {block name="content"}
  3. <div class="layui-fluid">
  4. <div class="layui-row layui-col-space15" id="app">
  5. <div class="layui-col-md12">
  6. <div class="layui-card">
  7. <div class="layui-card-header">搜索条件</div>
  8. <div class="layui-card-body">
  9. <form class="layui-form layui-form-pane" action="">
  10. <div class="layui-form-item">
  11. <div class="layui-inline">
  12. <label class="layui-form-label">是否显示</label>
  13. <div class="layui-input-block">
  14. <select name="is_show">
  15. <option value="">是否显示</option>
  16. <option value="1">显示</option>
  17. <option value="0">不显示</option>
  18. </select>
  19. </div>
  20. </div>
  21. <div class="layui-inline">
  22. <label class="layui-form-label">任务名称</label>
  23. <div class="layui-input-block">
  24. <input type="text" name="title" class="layui-input" placeholder="请输入任务名称">
  25. </div>
  26. </div>
  27. <div class="layui-inline">
  28. <div class="layui-input-inline">
  29. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
  30. <i class="layui-icon layui-icon-search"></i>搜索</button>
  31. </div>
  32. </div>
  33. </div>
  34. </form>
  35. </div>
  36. </div>
  37. </div>
  38. <!--产品列表-->
  39. <div class="layui-col-md12">
  40. <div class="layui-card">
  41. <div class="layui-card-header">任务列表</div>
  42. <div class="layui-card-body">
  43. <div class="alert alert-info" role="alert">
  44. 添加等级任务,任务类型中的{literal}{$num}{/literal}会自动替换成限定数量+系统预设的单位生成任务名
  45. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  46. </div>
  47. <div class="layui-btn-container">
  48. <button class="layui-btn layui-btn-sm" onclick="$eb.createModalFrame(this.innerText,'{:Url('create_tash',['level_id'=>$level_id])}')">添加会员任务</button>
  49. <button class="layui-btn layui-btn-normal layui-btn-sm" onclick="window.location.reload()"><i class="layui-icon layui-icon-refresh"></i> 刷新</button>
  50. </div>
  51. <table class="layui-hide" id="List" lay-filter="List"></table>
  52. <script type="text/html" id="image">
  53. <img style="cursor: pointer" lay-event='open_image' src="{{d.image}}">
  54. </script>
  55. <script type="text/html" id="is_show">
  56. <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_show' lay-text='开启|关闭' {{ d.is_show == 1 ? 'checked' : '' }}>
  57. </script>
  58. <script type="text/html" id="is_must">
  59. <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_must' lay-text='全部完成|达成其一' {{ d.is_must == 1 ? 'checked' : '' }}>
  60. </script>
  61. <script type="text/html" id="act">
  62. <button class="layui-btn layui-btn-xs" onclick="$eb.createModalFrame('编辑','{:Url('create_tash')}?level_id={$level_id}&id={{d.id}}')">
  63. <i class="fa fa-edit"></i> 编辑
  64. </button>
  65. <button class="layui-btn layui-btn-xs layui-btn-danger" lay-event='delete'>
  66. <i class="fa fa-times"></i> 删除
  67. </button>
  68. </script>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  75. {/block}
  76. {block name="script"}
  77. <script>
  78. //实例化form
  79. layList.form.render();
  80. //加载列表
  81. layList.tableList('List',"{:Url('get_tash_list',['level_id'=>$level_id])}",function (){
  82. return [
  83. {field: 'id', title: '编号', sort: true,event:'id'},
  84. {field: 'level_name', title: '等级名称',},
  85. {field: 'name', title: '任务名称',},
  86. {field: 'sort', title: '排序',sort: true,event:'sort',edit:'sort',width:'7%'},
  87. {field: 'is_show', title: '是否使用',templet:'#is_show',width:'10%'},
  88. {field: 'is_must', title: '务必达成',templet:'#is_must',width:'15%'},
  89. {field: 'illustrate', title: '任务说明'},
  90. {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'13%'},
  91. ];
  92. });
  93. //自定义方法
  94. var action= {
  95. set_value: function (field, id, value) {
  96. layList.baseGet(layList.Url({
  97. a: 'set_tash_value',
  98. q: {field: field, id: id, value: value}
  99. }), function (res) {
  100. layList.msg(res.msg);
  101. });
  102. },
  103. }
  104. //查询
  105. layList.search('search',function(where){
  106. layList.reload(where,true);
  107. });
  108. layList.switch('is_show',function (odj,value) {
  109. if(odj.elem.checked==true){
  110. layList.baseGet(layList.Url({a:'set_tash_show',p:{is_show:1,id:value}}),function (res) {
  111. layList.msg(res.msg);
  112. });
  113. }else{
  114. layList.baseGet(layList.Url({a:'set_tash_show',p:{is_show:0,id:value}}),function (res) {
  115. layList.msg(res.msg);
  116. });
  117. }
  118. });
  119. layList.switch('is_must',function (odj,value) {
  120. if(odj.elem.checked==true){
  121. layList.baseGet(layList.Url({a:'set_tash_must',p:{is_must:1,id:value}}),function (res) {
  122. layList.msg(res.msg);
  123. });
  124. }else{
  125. layList.baseGet(layList.Url({a:'set_tash_must',p:{is_must:0,id:value}}),function (res) {
  126. layList.msg(res.msg);
  127. });
  128. }
  129. });
  130. //快速编辑
  131. layList.edit(function (obj) {
  132. var id=obj.data.id,value=obj.value;
  133. switch (obj.field) {
  134. case 'title':
  135. action.set_value('title',id,value);
  136. break;
  137. case 'sort':
  138. action.set_value('sort',id,value);
  139. break;
  140. }
  141. });
  142. //监听并执行排序
  143. layList.sort(['id','sort'],true);
  144. //点击事件绑定
  145. layList.tool(function (event,data,obj) {
  146. switch (event) {
  147. case 'delete':
  148. var url=layList.U({a:'delete_tash',q:{id:data.id}});
  149. $eb.$swal('delete',function(){
  150. $eb.axios.get(url).then(function(res){
  151. if(res.status == 200 && res.data.code == 200) {
  152. $eb.$swal('success',res.data.msg);
  153. obj.del();
  154. }else
  155. return Promise.reject(res.data.msg || '删除失败')
  156. }).catch(function(err){
  157. $eb.$swal('error',err);
  158. });
  159. })
  160. break;
  161. case 'open_image':
  162. $eb.openImage(data.image);
  163. break;
  164. }
  165. })
  166. </script>
  167. {/block}