ownhome.js 11 KB

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