jc.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. var delFiles = []; //用于删除图片
  2. var filesContainer= {}; //存储最终要上传的图片
  3. var files ; //存储选择图片的数量
  4. var fContainer= {}; //用于传父级传变量,格式 parent.fContainer
  5. var depositImg =[];//用于存放弹窗图片
  6. layui.use(['form','layer','laydate','table','laytpl','layedit','upload'],function(){
  7. var form = layui.form,
  8. layer = layui.layer,
  9. $ = layui.jquery,
  10. laydate = layui.laydate,
  11. table = layui.table,
  12. layedit = layui.layedit
  13. var tableIds = 'jclist';
  14. //楼盘列表
  15. var tableIns = table.render({
  16. elem: '#'+tableIds,
  17. url : '/wx/jchomeform',
  18. method:'post',
  19. page : true,
  20. limit : 20,
  21. id:'tablerReload',
  22. cols : [[
  23. {type: "checkbox", width:50},
  24. {type:'numbers'},
  25. {field: 'name', title: '奖次', align:"center",sort: true},
  26. {field: 'state', title: '状态', align:"center",sort: true,templet:function(d){
  27. if(d.state == '未抽'){
  28. return '<span>'+d.state+' </span>';
  29. }else {
  30. return '<span style="color:red">'+d.state+' </span>';
  31. }
  32. }},
  33. {field: 'total', title: '中奖人数', align:"center",sort: true,templet:function (d) {
  34. if(d.total == 0){
  35. return '<span>'+d.total+' </span>';
  36. }else{
  37. return '<span style="color:red">'+d.total+' </span>';
  38. }
  39. }},
  40. {field: 'create_at', title: '添加时间',width:150, event:'sortData', align:'center',sort: true},
  41. {title: '操作', width:300, templet:'#housesListBar',fixed:"right",align:"center"}
  42. ]]
  43. });
  44. // table.reload('tablerReload'); //重新加载
  45. //表格头部操作菜单
  46. var $ = layui.$, active = {
  47. addData: function(){ //获取选中数据
  48. var index = layui.layer.open({
  49. title : "添加微信用户",
  50. type : 2,
  51. area:['80%','100%'],
  52. maxmin: true,
  53. content : "/wx/jccreate",
  54. end:function () {
  55. table.reload('tablerReload');
  56. }
  57. })
  58. // layui.layer.full(index);
  59. // //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  60. // $(window).on("resize",function(){
  61. // layui.layer.full(index);
  62. // })
  63. },
  64. DataClear:function () {
  65. $.ajax({
  66. type:"post", //请求方式
  67. async:true, //是否异步
  68. url:"http://wx.pinfangge.top/home/yaoclear",
  69. dataType:"jsonp", //跨域json请求一定是jsonp
  70. jsonp: "callbackparam", //跨域请求的参数名,默认是callback
  71. //jsonpCallback:"successCallback", //自定义跨域参数值,回调函数名也是一样,默认为jQuery自动生成的字符串
  72. success: function(data) {
  73. //请求成功处理,和本地回调完全一样
  74. },
  75. error: function() {
  76. //请求出错处理
  77. }
  78. });
  79. // $.post('http://wx.pinfangge.top/home/yaoclear',{},function (data) {
  80. // // layer.msg(data.msg);
  81. // })
  82. }
  83. };
  84. $('.demoTable .layui-btn').on('click', function(){
  85. var type = $(this).data('type');
  86. active[type] ? active[type].call(this) : '';
  87. });
  88. //添加
  89. form.on('submit(addjc)',function (data) {
  90. $.post('/wx/jccreateform',{name:data.field.name,sort:data.field.sort},function (data) {
  91. layer.msg(data.msg);
  92. })
  93. return false;
  94. })
  95. //修改
  96. form.on('submit(editjc)',function (data) {
  97. $.post('/wx/jceditform',{name:data.field.name,id:data.field.id,sort:data.field.sort},function (data) {
  98. layer.msg(data.msg);
  99. })
  100. return false;
  101. })
  102. //监听指定开关
  103. // form.on('switch(switchTest)', function(data){
  104. // layer.confirm('确定要修改此操作吗?',{btn: ['确定', '取消']},function () {
  105. // $.post('/house/housesortedit',{id:data.value,examineid:1},function (data) {
  106. // if(data.code == 200)
  107. // {
  108. // layer.msg(data.msg);
  109. // table.reload('tablerReload');
  110. // } else if(data.code == 300 ) {
  111. // layer.msg(data.msg);
  112. // }
  113. // })
  114. // },function (aa) {
  115. // table.reload('tablerReload'); //重新加载
  116. // })
  117. // });
  118. //表格右边操作栏目
  119. table.on('tool('+tableIds+')', function(obj){
  120. var data = obj.data;
  121. if(obj.event === 'del'){ //删除操作
  122. layer.confirm('确定要删除吗?',{btn: ['确定', '取消']},function () {
  123. $.post('/wx/jcdel',{id:data.id},function (data) {
  124. layer.msg(data.msg);
  125. table.reload('tablerReload');
  126. })
  127. })
  128. } else if(obj.event === 'edit'){ //编辑操作
  129. var index = layui.layer.open({
  130. title : "编辑",
  131. type : 2,
  132. area:['80%','100%'],
  133. maxmin: true,
  134. content : "/wx/jcedit?id="+data.id,
  135. end:function () {
  136. table.reload('tablerReload'); //重新加载
  137. }
  138. })
  139. } else if(obj.event === 'jc_clear'){
  140. layer.confirm('确定要清除记录吗?',{btn: ['确定', '取消']},function () {
  141. $.post('/wx/jcclear',{id:data.id},function (data) {
  142. layer.msg(data.msg);
  143. table.reload('tablerReload');
  144. })
  145. })
  146. } else if(obj.event === 'award'){
  147. var index = layui.layer.open({
  148. title : '获奖名单',
  149. type : 2,
  150. maxmin: true,
  151. area: ['', '100%'],
  152. content : "/wx/awardnamelist?id="+data.id,
  153. end:function () {
  154. layui.table.reload('tablerReload');
  155. }
  156. })
  157. layui.layer.full(index);
  158. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  159. $(window).on("resize",function(){
  160. layui.layer.full(index);
  161. })
  162. }
  163. });
  164. });
  165. function clearjc(a,b) {
  166. // console.log(a);
  167. // console.log(b);
  168. $.post('/wx/jcclear',{frequency:a},function (data) {
  169. layer.msg(data.msg);
  170. })
  171. }