houses.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. layui.use(['form','layer','laydate','table','laytpl','layedit','upload'],function(){
  2. var form = layui.form,
  3. // layer = parent.layer === undefined ? layui.layer : top.layer,
  4. layer = layui.layer,
  5. $ = layui.jquery,
  6. laydate = layui.laydate,
  7. laytpl = layui.laytpl,
  8. table = layui.table,
  9. layedit = layui.layedit
  10. ,upload = layui.upload;
  11. //调用编辑器
  12. var tableIds = 'housesList';
  13. var reloadId = 'tablerReload';
  14. //楼盘列表
  15. var tableIns = table.render({
  16. elem: '#'+tableIds,
  17. url : '/house/indexform',
  18. cellMinWidth : 95,
  19. method:'post',
  20. page : true,
  21. height : 540,
  22. limit : 20,
  23. id:reloadId,
  24. // limits : [10,15,20,25],is_view
  25. cols : [[
  26. {type: "checkbox", width:50},
  27. {field: 'id', title: 'ID', width:80, align:"center",sort: true},
  28. {field: 'name', title: '标题', align:"center",templet:function(d){
  29. var html = '<ul style="width:200px;float:left;">';
  30. if(d.is_push == 2){
  31. html += '<li style="float:left; padding: 0 5px;"><img src="/img/house/housezhutui.png"></li>';
  32. }
  33. if(d.thumb != null && d.thumb != ""){
  34. html += '<li style="float:left;padding: 0 5px;"><img src="/img/house/housetu.png"></li>';
  35. }
  36. if(d.evaluating != null && d.evaluating != ""){
  37. html += '<li style="float:left;padding: 0 5px;"><img src="/img/house/houseping.png"></li>';
  38. }
  39. if(d.video == 1){
  40. html += '<li style="float:left;padding: 0 5px;"><img src="/img/house/hangpai.png"></li>';
  41. }
  42. if(d.permit != 0){
  43. html += '<li style="float:left;padding: 0 5px;position:relative;"><img src="/img/house/houseyushouzheng.png"><span style="font-size:12px;;position:absolute;right:7px;top:1px;display:inline-block;width:22px;text-align:center;color:#fff;">'+d.permit+'</span></li>';
  44. }
  45. html += '</ul>';
  46. html += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.yigouf.com/house/'+d.id+'/" target="_blank">'+d.name+'</a>';
  47. return html;
  48. }},
  49. {field: 'city_name', title: '区域',width:80,sort:true, align:'center'},
  50. {field: 'news_num', title: '资讯',width:70, event:'housesNews', align:'center',templet:"#housesNews",templet:function(d){
  51. return '<a href="javascript:;">['+d.news_num+']</a>'
  52. }},
  53. {field: 'album_num', title: '相册',width:70, event:'housesPhoto', align:'center',templet:"#housesPhoto",templet:function(d){
  54. return '<a href="javascript:;">['+d.album_num+']</a>'
  55. }},
  56. {field: 'type_num', title: '户型',width:70,event:'housesType', align:'center',templet:"#housesType",templet:function(d){
  57. return '<a href="#">['+d.type_num+']</a>'
  58. }},
  59. {field: 'peitao_num', title: '周边配套',width:85, event:'houseFacilities', align:'center',templet:"#houseFacilities",templet:function(d){
  60. return '<a href="#">['+d.peitao_num+']</a>'
  61. }},
  62. // {field: 'click_num', title: '点击',width:70, align:'center',sort: true},
  63. // {field: 'sort', title: '排序',width:80, edit: 'text',align:'center',sort: true,templet:"#sortBox"},
  64. // {field: 'allsort', title: '全国排序',width:80, edit: 'text',align:'center',sort: true},
  65. {field: 'user_name', title: '添加人',width:75, align:'center'},
  66. {field: 'create_at', title: '添加时间',width:150, align:'center'},
  67. {field: 'is_view', title: '审核',width:70, align:'center', templet:"#Toexamine",templet:function(d){
  68. switch (d.is_view){
  69. case '2':
  70. return '<input type="checkbox" value="'+d.id+'" name="'+d.is_view+'" house="'+d.name+'" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  71. break;
  72. case '1':
  73. return '<input type="checkbox" checked value="'+d.id+'" name="'+d.is_view+'" house="'+d.name+'" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  74. break;
  75. }
  76. }},
  77. {title: '操作', width:200, templet:'#housesListBar',fixed:"right",align:"center"}
  78. ]],
  79. done: function (res, curr, count) {
  80. $('.layui-form #wdels').show(); //批量删除按钮,加载完成才显示
  81. }
  82. });
  83. tableIns.reload('tablerReload'); //重新加载
  84. var $ = layui.$, active = {
  85. addData: function(){ //获取选中数据
  86. var index = layui.layer.open({
  87. title : "添加楼盘",
  88. type : 2,
  89. area:['','100%'],
  90. maxmin: true,
  91. content : "/house/create.html",
  92. })
  93. layui.layer.full(index);
  94. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  95. $(window).on("resize",function(){
  96. layui.layer.full(index);
  97. })
  98. },saveData:function () {
  99. var index = layui.layer.open({
  100. title : "批量操作",
  101. type : 2,
  102. area:['50%','100%'],
  103. maxmin: true,
  104. content : "/house/batchsave",
  105. })
  106. },
  107. housesort: function(){ //获取选中数据
  108. var index = layui.layer.open({
  109. title : "楼盘排序",
  110. type : 2,
  111. area:['','100%'],
  112. maxmin: true,
  113. content : "/house/housesort",
  114. })
  115. layui.layer.full(index);
  116. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  117. $(window).on("resize",function(){
  118. layui.layer.full(index);
  119. })
  120. },
  121. reload:function () {
  122. var form = pfgs_serialize($('form'));
  123. var name = '';
  124. var id = '';
  125. // console.log($('form').serializeArray());
  126. if(form.input_house == 'name'){
  127. name = form.input_house_text;
  128. } else if(form.input_house == 'id'){
  129. id = form.input_house_text;
  130. }
  131. var city = '';
  132. if(form.province != ''){
  133. city = form.province;
  134. }
  135. if(form.city != ''){
  136. city = form.city;
  137. }
  138. table.reload('tablerReload',{
  139. where:{
  140. sort:form.input_sort,
  141. id:id,
  142. name:name,
  143. city:city,
  144. is_view:form.show,
  145. end_time:form.end_time,
  146. start_time:form.start_time,
  147. is_push:form.is_push,
  148. price_unit:form.price_unit,
  149. },
  150. page:{
  151. curr:1
  152. }
  153. })
  154. }
  155. };
  156. $('.demoTable .layui-btn').on('click', function(event){
  157. var type = $(this).data('type');
  158. active[type] ? active[type].call(this) : '';
  159. });
  160. //日期
  161. laydate.render({
  162. elem: '#date1'
  163. });
  164. laydate.render({
  165. elem: '#date2'
  166. });
  167. //
  168. // laydate.render({
  169. // elem: '#date1_1'
  170. // });
  171. // laydate.render({
  172. // elem: '#date1_2'
  173. // });
  174. //选项卡切换
  175. $('.layui-tab-title .site-demo-active').on('click', function(){
  176. $(this).addClass('layui-this').siblings().removeClass('layui-this');
  177. var lay_id = $(this).attr('lay-id');
  178. $('.layui-tab-item').removeClass('layui-show')
  179. $('.layui-tab-content #'+lay_id).addClass('layui-show')
  180. });
  181. //监听指定开关
  182. form.on('switch(switchTest)', function(data){
  183. var house = data.elem.attributes.house.value;
  184. layer.open({
  185. title :'修改<span style="color:red" >['+house+']</span>状态',
  186. type : 2,
  187. area:['50%','80%'],
  188. maxmin: true,
  189. content : "/house/openstate?hid="+data.value+"&name="+house,
  190. end:function () {
  191. table.reload('tablerReload');
  192. }
  193. })
  194. });
  195. form.on('submit(del_alls_house)',function (data) {
  196. var checkStatus = table.checkStatus('tablerReload');
  197. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  198. if(typeof checkStatus.data[0] == 'object'){
  199. layer.confirm('您确定要删除吗?',{btn:['确认','取消']},function(){
  200. var formdat = new FormData();
  201. $.each(checkStatus.data,function (key,val) {
  202. formdat.append('hid[]',val.id);
  203. })
  204. $.ajax({
  205. cache : true,
  206. type : "post",
  207. url : "/house/housedel",
  208. data : formdat, // 你的formid
  209. // async : false, //async 默认为true异步,修改为false为同步
  210. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  211. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  212. error : function(request) {
  213. layer.close(index); //关闭数据提交信息
  214. layer.alert("网络超时");
  215. },
  216. success : function(data) {
  217. if (data.code == 200) {
  218. layer.msg(data.msg);
  219. reloadTable(reloadId);
  220. } else {
  221. layer.msg(data.msg);
  222. }
  223. }
  224. });
  225. })
  226. return false;
  227. }
  228. layer.msg('请选择需要删除的楼盘',{icon:5});
  229. return false;
  230. })
  231. //检测关键词
  232. form.on('submit(check_words)',function (data) {
  233. var content=UE.getEditor('editor').getContentTxt();
  234. var centhtml = UE.getEditor('editor').getContent();
  235. $.ajax({
  236. //cache : false,
  237. type : "post",
  238. url : "/sensitivewords/checkword",
  239. data:{content:content}, // 你的formid
  240. //contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  241. //processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  242. error : function(request) {
  243. layer.close(index);
  244. layer.alert("网络超时");
  245. },
  246. success : function(data) {
  247. if(data.data!=null){
  248. var index=layer.open({
  249. type: 1,
  250. // skin: 'layui-layer-rim', //加上边框
  251. title:'违禁词信息',
  252. area: ['420px', '240px'], //宽高
  253. content: '<div style="color:red;">'+data.data+'</div>'
  254. });
  255. for(var i=0;i<data.data.length;i++){
  256. centhtml = centhtml.replace(data.data[i],"<span style='color: rgb(255, 0, 0);'>"+data.data[i]+"</span>");
  257. }
  258. UE.getEditor('editor_content').setContent(centhtml);
  259. layer.msg(data.msg)
  260. }else{
  261. layer.msg(data.msg)
  262. }
  263. }
  264. });
  265. return false;
  266. })
  267. /* 列表操作 edit 修改后执行 */
  268. /* table.on('edit('+tableIds+')', function(obj){
  269. var data = obj.data;
  270. $.post('/house/housesortedit',{id:data.id,sort:data.sort},function (data) {
  271. if(data.code == 200)
  272. {
  273. layer.msg(data.msg);
  274. // obj.update({
  275. // sort: data.sort
  276. // });
  277. // TableClose();
  278. } else if(data.code == 300 ) {
  279. layer.msg(data.msg);
  280. }
  281. })
  282. })*/
  283. /* 列表操作 edit 修改后执行 */
  284. table.on('edit('+tableIds+')', function(obj){
  285. var data = obj.data;
  286. switch (obj.field){
  287. case 'sort':
  288. $.post('/house/housesortedit',{id:data.id,sort:data.sort,type:'sort'},function (data) {
  289. if(data.code == 200)
  290. {
  291. layer.msg(data.msg);
  292. } else if(data.code == 300 ) {
  293. layer.msg(data.msg);
  294. }
  295. })
  296. break;
  297. case 'deal_num':
  298. $.post('/house/housesortedit',{id:data.id,deal_num:data.deal_num,type:'deal_num'},function (data) {
  299. if(data.code == 200)
  300. {
  301. layer.msg(data.msg);
  302. } else if(data.code == 300 ) {
  303. layer.msg(data.msg);
  304. }
  305. })
  306. break;
  307. case 'stars':
  308. $.post('/house/housesortedit',{id:data.id,stars:data.stars,type:'stars'},function (data) {
  309. if(data.code == 200)
  310. {
  311. layer.msg(data.msg);
  312. } else if(data.code == 300 ) {
  313. layer.msg(data.msg);
  314. }
  315. })
  316. break;
  317. case 'allsort':
  318. $.post('/house/housesortedit',{id:data.id,allsort:data.allsort,type:'allsort'},function (data) {
  319. if(data.code == 200)
  320. {
  321. layer.msg(data.msg);
  322. } else if(data.code == 300 ) {
  323. layer.msg(data.msg);
  324. }
  325. })
  326. break;
  327. }
  328. })
  329. /* 列表操作 tool 点击执行 */
  330. table.on('tool('+tableIds+')', function(obj){
  331. var data = obj.data;
  332. // if(obj.event === 'sortData'){ //修改排序
  333. // layer.prompt({
  334. // formType: 2
  335. // ,title: '排序楼盘:'+data.name
  336. // ,value: data.sort
  337. // }, function(value, index){
  338. // $.post('/house/housesortedit',{id:data.id,sort:value},function (data) {
  339. // if(data.code == 200)
  340. // {
  341. // layer.msg(data.msg);
  342. // layer.close(index);
  343. // obj.update({
  344. // sort: value
  345. // });
  346. // // TableClose();
  347. // } else if(data.code == 300 ) {
  348. // layer.msg(data.msg);
  349. // }
  350. // })
  351. // });
  352. // }else
  353. if(obj.event === 'housesNews'){
  354. var index =layui.layer.open({
  355. title :'<span style="color:red" >['+data.name+']</span>楼盘资讯',
  356. type : 2,
  357. area:['','100%'],
  358. maxmin: true,
  359. content : "/house/newslist?id="+data.id+"&name="+data.name,
  360. end:function () {
  361. table.reload('tablerReload');
  362. }
  363. })
  364. layui.layer.full(index);
  365. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  366. $(window).on("resize",function(){
  367. layui.layer.full(index);
  368. })
  369. } else if(obj.event === 'edit'){
  370. var index = layui.layer.open({
  371. title : '<span style="color:red" >['+data.name+']</span>修改楼盘信息',
  372. type : 2,
  373. area:['','100%'],
  374. maxmin: true,
  375. content : "/house/edit?id="+data.id,
  376. end:function(){
  377. layui.table.reload('tablerReload');
  378. }
  379. })
  380. layui.layer.full(index);
  381. // // //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  382. $(window).on("resize",function(){
  383. layui.layer.full(index);
  384. })
  385. } else if(obj.event === 'del'){
  386. layer.confirm('您确认要删除吗?',{btn:['确认','取消']},function () {
  387. $.post('/house/housedel',{id:data.id},function (data) {
  388. if (data.code == 200) {
  389. layer.msg(data.msg);
  390. // parent.layui.
  391. table.reload('tablerReload');
  392. // TableClose();
  393. } else {
  394. layer.msg(data.msg);
  395. }
  396. })
  397. })
  398. }else if(obj.event === 'housesPhoto'){
  399. var index =layui.layer.open({
  400. title :'<span style="color:red" >['+data.name+']</span>楼盘相册',
  401. type : 2,
  402. area:['','100%'],
  403. maxmin: true,
  404. content : "/house/album?id="+data.id+"&name="+data.name,
  405. end:function () {
  406. table.reload('tablerReload');
  407. }
  408. })
  409. layui.layer.full(index);
  410. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  411. $(window).on("resize",function(){
  412. layui.layer.full(index);
  413. })
  414. } else if(obj.event === 'housesType'){
  415. var index =layui.layer.open({
  416. title :'<span style="color:red" >['+data.name+']</span>楼盘户型',
  417. type : 2,
  418. area:['','100%'],
  419. maxmin: true,
  420. content : "/house/housetype?id="+data.id+"&name="+data.name,
  421. end:function () {
  422. table.reload('tablerReload');
  423. }
  424. })
  425. layui.layer.full(index);
  426. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  427. $(window).on("resize",function(){
  428. layui.layer.full(index);
  429. })
  430. }else if(obj.event === 'house_price'){
  431. var index =layui.layer.open({
  432. title :'<span style="color:red" >['+data.name+']</span>楼盘历史价格',
  433. type : 2,
  434. area:['','100%'],
  435. maxmin: true,
  436. content : "/house/priceview?id="+data.id+"&name="+data.name+'&price='+data.sale_price,
  437. end:function(){
  438. table.reload('tablerReload');
  439. }
  440. })
  441. layui.layer.full(index);
  442. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  443. $(window).on("resize",function(){
  444. layui.layer.full(index);
  445. })
  446. }else if(obj.event === 'houseFacilities'){
  447. var index =layui.layer.open({
  448. title :'<span style="color:red" >['+data.name+']</span>楼盘周边配套',
  449. type : 2,
  450. area:['','100%'],
  451. maxmin: true,
  452. content : "/house/peitao?id="+data.id+"&name="+data.name,
  453. end:function () {
  454. table.reload('tablerReload');
  455. }
  456. })
  457. layui.layer.full(index);
  458. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  459. $(window).on("resize",function(){
  460. layui.layer.full(index);
  461. })
  462. }else if(obj.event === 'house_presell'){
  463. var index =layui.layer.open({
  464. title :'<span style="color:red" >['+data.name+']</span>预售许可证',
  465. type : 2,
  466. area:['','100%'],
  467. maxmin: true,
  468. content : "/house/presell?id="+data.id+"&name="+data.name,
  469. end:function () {
  470. table.reload('tablerReload');
  471. }
  472. })
  473. layui.layer.full(index);
  474. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  475. $(window).on("resize",function(){
  476. layui.layer.full(index);
  477. })
  478. }
  479. });
  480. //楼盘名称,区域, 注释装修情况
  481. //添加图片上传
  482. upload.render({
  483. elem: '#test1'
  484. ,url: '/house/createimg'
  485. ,data:{token:csrfToken}
  486. ,field:'img'
  487. ,size:1000 //限制上传图片的大小,单位为KB
  488. ,exts: 'png|jpg|jpeg' //只允许上传压缩文件
  489. ,auto:false
  490. ,bindAction:'#addcity'
  491. ,choose: function(obj){
  492. obj.preview(function(index, file, result){
  493. $('#demo1').attr('src', result); //图片链接(base64)
  494. });
  495. }
  496. });
  497. // 点击放大图片
  498. $('#demo1').on('click', function(){
  499. var _src = $(this).attr('src');
  500. layui.layer.open({
  501. type: 1,
  502. title: false, //是否显示标题
  503. area: ['60%', '80%'],
  504. shade: 0.6, //透明度
  505. closeBtn: 1, //按钮 1有,0无
  506. shadeClose: true,
  507. content: '<img style="width:100%;height:100%" src="'+_src+'">',
  508. });
  509. });
  510. //判断是否需要编辑,需要才加载
  511. var verdict = $('#editor').html();
  512. if(typeof verdict == "string"){
  513. var ue = UE.getEditor('editor'); //编辑器
  514. }
  515. //重载表格
  516. function reloadTable(obj){
  517. table.reload(obj);
  518. }
  519. form.on('submit(tijiao)',function (data) {
  520. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  521. var formData = new FormData($('#house_form')[0]);
  522. /*
  523. * 许可证号提交数据
  524. */
  525. // var trArry = $('.layui_w_licence table.layui-table tbody.mai tr.otr');
  526. // $.each(trArry,function(i,v){
  527. // var _licenseKey =$(this).find('textarea[name="evaluating"]').val();
  528. // // if(_licenseKey !=""){ //判断许可证号是否为空
  529. // formData.append('evaluating[]',_licenseKey);
  530. // // }
  531. // console.log(_licenseKey)
  532. // })
  533. // console.log(formData)
  534. $.ajax({
  535. cache : true,
  536. type : "post",
  537. url : "/house/createfrom",
  538. data : formData, // 你的formid
  539. // async : false, //async 默认为true异步,修改为false为同步
  540. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  541. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  542. error : function(request) {
  543. layer.close(index); //关闭数据提交信息
  544. layer.alert("网络超时");
  545. },
  546. success : function(data) {
  547. if (data.code == 200) {
  548. layer.msg(data.msg);
  549. parent.layui.table.reload('tablerReload');
  550. TableClose();
  551. } else if(data.code == 300){
  552. layer.msg(data.msg);
  553. layer.msg(ReturnInfo(data.data),{icon:5});
  554. }
  555. }
  556. });
  557. return false;
  558. })
  559. form.on('submit(edit)',function (data) {
  560. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  561. var formData = new FormData($('#house_edit_form')[0]);
  562. // var trArry = $('.layui_w_licence table.layui-table tbody tr');
  563. // $.each(trArry,function(i,v){
  564. // var _licenseKey =$(this).find('input[name="licenseKey"]').val();
  565. // if(_licenseKey !=""){ //判断许可证号是否为空
  566. // formData.append('licenseKey[]',_licenseKey);
  567. // formData.append('issueDate[]',$(this).find('input[name="issueDate"]').val());
  568. // formData.append('buildingName[]',$(this).find('input[name="buildingName"]').val());
  569. // }
  570. // })
  571. $.ajax({
  572. cache : true,
  573. type : "post",
  574. url : "/house/editfrom",
  575. data : formData, // 你的formid
  576. // async : false, //async 默认为true异步,修改为false为同步
  577. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  578. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  579. error : function(request) {
  580. layer.close(index); //关闭数据提交信息
  581. layer.alert("请联系管理员");
  582. },
  583. success : function(data) {
  584. if (data.code == 200) {
  585. layer.msg(data.msg);
  586. } else if(data.code == 300){
  587. layer.msg(data.msg);
  588. layer.msg(ReturnInfo(data.data),{icon:5});
  589. }
  590. }
  591. });
  592. return false;
  593. });
  594. //楼盘上架下架操作
  595. form.on('submit(openstate)',function (data) {
  596. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  597. $.ajax({
  598. cache : true,
  599. type : "post",
  600. url : "/house/openstateform",
  601. data : data.field, // 你的formid
  602. // async : false, //async 默认为true异步,修改为false为同步
  603. // contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  604. // processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  605. error : function(request) {
  606. layer.close(index); //关闭数据提交信息
  607. layer.alert("请联系管理员");
  608. },
  609. success : function(data) {
  610. if(data.data != null){
  611. layer.msg(ReturnInfo(data.data),{icon:5});
  612. return ;
  613. }
  614. layer.msg(data.msg);
  615. }
  616. });
  617. return false;
  618. });
  619. //加载省数据
  620. function loadProvince() {
  621. $.ajax({
  622. url : '/categorycity/citypid',
  623. type : 'post',
  624. async: false,//使用同步的方式,true为异步方式
  625. data : {'pid':0},//这里使用json对象
  626. success : function(data){
  627. var areaData = data.data;
  628. var proHtml = '';
  629. for (var i = 0; i < areaData.length; i++) {
  630. proHtml += '<option value="' + areaData[i].id +'">' + areaData[i].city_name + '</option>';
  631. }
  632. //初始化省数据
  633. $('select[name=province]').append(proHtml);
  634. form.render();
  635. },
  636. fail:function(){
  637. }
  638. });
  639. }
  640. loadProvince();
  641. form.on('select(province)',function (data) {
  642. $.post('/categorycity/citypid',{'pid':data.value},function (data) {
  643. var areaData = data.data;
  644. var proHtml = '';
  645. $('select[name=city]').html('');
  646. proHtml = '<option value="">请选择市/区/县</option>';
  647. for (var i = 0; i < areaData.length; i++) {
  648. proHtml += '<option value="' + areaData[i].id +'">' + areaData[i].city_name + '</option>';
  649. }
  650. //初始化省数据
  651. $('select[name=city]').append(proHtml);
  652. form.render();
  653. })
  654. })
  655. // 添加楼盘评测
  656. var leng =50;
  657. $('.layui_w_addbtn').on('click',function(){
  658. datumInsert(leng)
  659. $('body').append('<script id="ue'+leng+'">UE.getEditor("evaluating'+leng+'")</script>') //编辑器
  660. var ue =UE.getEditor("evaluating"+leng);
  661. ue.ready(function() {
  662. // ue.setContent('<p>编辑器1的内容</p>', true);
  663. });
  664. leng++;
  665. })
  666. //展示数据删除按钮
  667. $('.layui_w_licence table.layui-table tbody.mai').on('click','.del',function(){
  668. var _this = $(this)
  669. var oid = _this.parents('.otr').attr('id');
  670. var index =layer.confirm('确定要删除吗?',{btn: ['确定', '取消']},function () {
  671. // layer.close(index)
  672. _this.parents('#'+oid).remove();
  673. $('body script#'+oid).remove();
  674. layer.msg('已成功删除!');
  675. })
  676. })
  677. })
  678. $(function(){
  679. $('.editmai tr.otr').each(function(){
  680. var _ind = $(this).attr('data-id');
  681. UE.getEditor("evaluating"+_ind);
  682. })
  683. //选项卡切换
  684. $('.layui-tab-title .site-demo-active').on('click', function(){
  685. $(this).addClass('layui-this').siblings().removeClass('layui-this');
  686. var lay_id = $(this).attr('lay-id');
  687. $('.layui-tab-item').removeClass('layui-show')
  688. $('.layui-tab-content #'+lay_id).addClass('layui-show')
  689. });
  690. // 转换拼音
  691. $('.layui_w_name').on('keyup ',function(){
  692. var _txt = $(this).val();
  693. var _convert = pinyinUtil.getPinyin(_txt,' ',false).replace(/\s/g, "");
  694. $('.layui_w_spell').val(_convert)
  695. })
  696. // 动态添加批量删除按钮
  697. var _btn = '<div class="layui-inline" id="wdels" style="float:left;position:relative;left:10px;bottom:35px;display:none;margin-top:0;">'
  698. + '<a class="layui-btn layui-btn-danger search_btn layui_w_btn" style="height:30px;line-height:30px;font-size:14px;" lay-submit="" lay-filter="del_alls_house">批量删除</a>'
  699. + '</div>'
  700. $('.layui-form').append(_btn)
  701. // 修改楼盘编辑高度问题
  702. var i=0;
  703. $('li[lay-id="assign_4"]').on('click',function(){
  704. var _text = UE.getEditor('editor').getContent()
  705. if(_text != ''){
  706. if(i <1){
  707. var editorHeight = UE.getEditor('editor').iframe.clientHeight;
  708. if(editorHeight > 400){
  709. var _setHeight = parseInt(UE.getEditor('editor').iframe.clientHeight/7.5);
  710. $('#assign_4').find('#edui1_iframeholder').css('height',_setHeight);
  711. }
  712. i++;
  713. }
  714. }
  715. })
  716. // 特色主题 限制checkbox 选中的数量(修改与添加共用)
  717. // $('.layui_w_acti ').on('click','.layui-form-checkbox[lay-skin=primary]',function(){
  718. // var inputArry = $('.layui_w_acti').find('input[name="characteristic[]"]');
  719. // check(inputArry,3); //调用方法,方法定义在csrftoken.js中
  720. // })
  721. })
  722. //楼盘评测 添加
  723. function datumInsert(leng){
  724. // var leng = $(".layui_w_licence table.layui-table tbody tr").length;
  725. // console.log(leng)
  726. var tr ='<tr class="otr" id="ue'+leng+'">'
  727. +'<td lay-event="del">'
  728. +'<div class="layui-table-cell del" lay-oid=""><i class="layui-icon" style="font-size: 30px; color: #1E9FFF;cursor: pointer">&#xe640;</i></div>'
  729. +'</td>'
  730. +'<td data-field="matingName" align="center" data-content="">'
  731. +'<div class="editor_box layui-form-item" style="width:99%;height:400">'
  732. +'<textarea name="evaluating[]" id="evaluating'+leng+'" cols="20" rows="10" style="width:100%;float:left;"></textarea>'
  733. +'</div>'
  734. +'</td>'
  735. +'</tr>';
  736. $(".layui_w_licence table.layui-table tbody.mai").append(tr);
  737. }