housesort.js 31 KB

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