morecomment.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. layui.use([ 'laypage', 'layer', 'table', 'element','form'], function(){
  2. var laypage = layui.laypage //分页
  3. ,$ = layui.jquery
  4. ,layer = layui.layer //弹层
  5. ,table = layui.table //表格
  6. ,form = layui.form;
  7. var tableId = 'citylist';
  8. var dataObj = {};
  9. //第一个实例
  10. table.render({
  11. elem: '#'+tableId
  12. ,url: '/routinecomment/morecommentform' //数据接口
  13. ,where:{token:csrfToken,hid:$('input[name="hid"]').val()}
  14. ,method:'post'
  15. ,page: true //开启分页
  16. ,text:'数据加载中'
  17. ,id:'tablerReload'
  18. ,limit:20
  19. ,cols: [[ //表头
  20. // {field: 'id', title: 'ID', width:80, sort: true,align:'center'}
  21. {field: 'mobile', title: '手机号',align:'center'}
  22. // ,{field: 'content', title: '点评内容',align:'center'}
  23. // ,{field: 'diduan', title: '地段',align:'center'}
  24. // ,{field: 'jiaotong', title: '交通',align:'center'}
  25. // ,{field: 'peitao', title: '配套',align:'center'}
  26. // ,{field: 'huanjing', title: '环境',align:'center'}
  27. // ,{field: 'xingjiabi', title: '性价比',align:'center'}
  28. ,{field: 'read', title: '阅读状态',width:100,align:'center',sort: true,templet:function (e) {
  29. var str = '';
  30. if(e.read == '已读'){
  31. str = '<span >'+e.read+' </span>';
  32. }else if(e.read == '未读'){
  33. str = '<span style="color: red">'+e.read+' </span>';
  34. }
  35. return str;
  36. }}
  37. ,{field: 'reply', title: '回复状态',width:200,align:'center',sort: true,templet:function (e) {
  38. var str = '';
  39. if(e.reply == 1){
  40. str = '<span style="color: red" > 未回复 </span>';
  41. }else if(e.reply == 2){
  42. str = '<span >已回复 </span>';
  43. }
  44. return str;
  45. }}
  46. ,{field: 'is_show', title: '审核',width:80, align:'center', templet:"#Toexamine",templet:function(d){
  47. if(d.is_show == 2){
  48. return '<input type="checkbox" value="'+d.id+'" name="'+d.is_show+'" show="" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  49. } else {
  50. return '<input type="checkbox" checked value="'+d.id+'" name="'+d.is_show+'" show="" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  51. }
  52. }}
  53. ,{field: 'create_at', title: '添加时间', width:200,align:'center'}
  54. ,{fixed: 'right',title:'操作', width: 165, align:'center', toolbar: '#operate'}
  55. ]]
  56. });
  57. //监听指定开关
  58. form.on('switch(switchTest)', function(data){
  59. var show;
  60. switch (data.elem.name){
  61. case '1':
  62. show = 2;
  63. break;
  64. case '2':
  65. show = 1;
  66. break;
  67. }
  68. layer.confirm('确定要修改此操作吗?',{btn: ['确定', '取消']},function () {
  69. $.post('/routinecomment/delandshow',{id:data.value,is_show:show},function (data) {
  70. layer.msg(data.msg);
  71. table.reload('tablerReload');
  72. })
  73. },function (aa) {
  74. table.reload('tablerReload'); //重新加载
  75. })
  76. });
  77. //table.reload('tablerReload'); //重新加载
  78. //列表操作
  79. table.on('tool('+tableId+')', function(obj){
  80. var layEvent = obj.event,
  81. data = obj.data;
  82. switch (layEvent){
  83. case 'yuedu': //阅读
  84. var index = layer.open({
  85. type: 2,
  86. title: false,
  87. area: ['70%', '100%'],
  88. content: '/routinecomment/read?id='+data.id,
  89. end:function(){
  90. table.reload('tablerReload');
  91. }
  92. });
  93. // layer.full(index);
  94. // //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  95. // $(window).on("resize",function(){
  96. // layer.full(index);
  97. // })
  98. break;
  99. case 'edit'://修改
  100. var index = layui.layer.open({
  101. type: 2,
  102. title: '修改点评信息',
  103. maxmin: true,
  104. area: ['', '100%'],
  105. content: '/routinecomment/edit?id='+data.id,
  106. });
  107. layui.layer.full(index);
  108. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  109. $(window).on("resize",function(){
  110. layui.layer.full(index);
  111. })
  112. break;
  113. case 'del': //删除
  114. layer.confirm('确定要修改此操作吗?',{btn: ['确定', '取消']},function () {
  115. $.post('/routinecomment/delandshow',{id:data.id,del:2},function (data) {
  116. layer.msg(data.msg);
  117. table.reload('tablerReload');
  118. })
  119. })
  120. break;
  121. }
  122. });
  123. $('.The_house').click(function(){
  124. // $('form').append('<input type="hidden" name="aa" value="aaa">');
  125. indexOpen = parent.layui.layer.open({
  126. type: 2,
  127. title: '选择需要添加的楼盘',
  128. area: ['60%','100%'],
  129. content: '/publicuse/housename',
  130. success:function (layero, index) {
  131. },
  132. end:function(){
  133. }
  134. });
  135. // parent.layui.layer.full(indexOpen);
  136. // //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  137. // $(window).on("resize",function(){
  138. // parent.layui.layer.full(indexOpen);
  139. // })
  140. })
  141. var $ = layui.$, active = {
  142. reload:function () {
  143. var formdara = pfgs_serialize($('form'));
  144. table.reload('tablerReload',{
  145. where:{
  146. content_status:formdara.content_status,
  147. reply_status:formdara.reply_status,
  148. }
  149. })
  150. }
  151. };
  152. $('.demoTable .layui-btn').on('click', function(){
  153. var type = $(this).data('type');
  154. active[type] ? active[type].call(this) : '';
  155. });
  156. form.on('submit(editform)', function(data){
  157. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  158. var formData = new FormData($('form')[0]);
  159. $.ajax({
  160. type : "post",
  161. url : '/routinecomment/editform',
  162. data : formData, // 你的formid
  163. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  164. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  165. error : function(request) {
  166. layer.close(index); //关闭数据提交信息
  167. layer.alert("网络超时");
  168. },
  169. success : function(data) {
  170. // if(data.data != null){
  171. // layer.msg(ReturnInfo(data.data),{icon:5});
  172. // return ;
  173. // }
  174. layer.msg(data.msg);
  175. // parent.layui.table.reload('tablerReload');
  176. }
  177. });
  178. return false;
  179. });
  180. //添加
  181. form.on('submit(tijiao)', function(data){
  182. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  183. var formData = new FormData($('form')[0]);
  184. $.ajax({
  185. type : "post",
  186. url : '/routinecomment/createreply',
  187. data : formData, // 你的formid
  188. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  189. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  190. error : function(request) {
  191. layer.close(index); //关闭数据提交信息
  192. layer.alert("网络超时");
  193. },
  194. success : function(data) {
  195. if(data.data != null){
  196. layer.msg(ReturnInfo(data.data),{icon:5});
  197. return ;
  198. }
  199. layer.msg(data.msg);
  200. parent.layui.table.reload('tablerReload');
  201. }
  202. });
  203. return false;
  204. });
  205. // 满意程度
  206. /*
  207. * prevAll() 当前位置之前
  208. * nextAll() 当前位置之后
  209. * 以上两个都不包括当前位置
  210. */
  211. $('.w_up_degree_con dl dd').on('click',function(){
  212. var that = $(this);
  213. var txt = that.parent().attr('data-title');
  214. var subscript = that.index();
  215. that.addClass('in').prevAll('dd').addClass('in');
  216. that.nextAll().removeClass('in');
  217. FnSatisfaction(txt,(subscript + 1));
  218. console.log(subscript)
  219. })
  220. // 满意程度存储值
  221. function FnSatisfaction(label,index){
  222. switch(label)
  223. {
  224. case "地段":
  225. dataObj.diduan = index;
  226. $('#diduan').val(index);
  227. break;
  228. case "交通":
  229. dataObj.jiaotong = index;
  230. $('#jiaotong').val(index);
  231. break;
  232. case "配套":
  233. dataObj.peitao = index;
  234. $('#peitao').val(index);
  235. break;
  236. case "环境":
  237. dataObj.huanjing = index;
  238. $('#huanjing').val(index);
  239. break;
  240. case "性价比":
  241. dataObj.xingjiabi = index;
  242. $('#xingjiabi').val(index);
  243. break;
  244. }
  245. }
  246. });