houses.js 32 KB

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