123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789 |
- layui.use(['form','layer','laydate','table','laytpl','layedit','upload'],function(){
- var form = layui.form,
-
- layer = layui.layer,
- $ = layui.jquery,
- laydate = layui.laydate,
- laytpl = layui.laytpl,
- table = layui.table,
- layedit = layui.layedit
- ,upload = layui.upload;
-
- var tableIds = 'housesList';
- var reloadId = 'tablerReload';
-
- var tableIns = table.render({
- elem: '#'+tableIds,
- url : '/housech/indexform',
- cellMinWidth : 95,
- method:'post',
- page : true,
- height : 600,
- limit : 20,
- id:reloadId,
-
- cols : [[
- {type: "checkbox", width:50},
- {field: 'id', title: 'ID', width:80, align:"center",sort: true},
- {field: 'name', title: '标题', align:"center",templet:function(d){
- var html = '<ul style="width:200px;float:left;">';
- if(d.is_push == 2){
- html += '<li style="float:left; padding: 0 5px;"><img src="/img/house/housezhutui.png"></li>';
- }
- if(d.thumb != null && d.thumb != ""){
- html += '<li style="float:left;padding: 0 5px;"><img src="/img/house/housetu.png"></li>';
- }
- if(d.evaluating != null && d.evaluating != ""){
- html += '<li style="float:left;padding: 0 5px;"><img src="/img/house/houseping.png"></li>';
- }
- if(d.video == 1){
- html += '<li style="float:left;padding: 0 5px;"><img src="/img/house/hangpai.png"></li>';
- }
- if(d.permit != 0){
- 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>';
- }
- html += '</ul>';
- html += ' <a href="http://www.pinfanghw.com/housech/'+d.id+'/" target="_blank">'+d.name+'</a>';
- return html;
- }},
- {field: 'city_name', title: '区域',width:90,sort:true, align:'center'},
-
-
-
- {field: 'album_num', title: '相册',width:70, event:'housesPhoto', align:'center',templet:"#housesPhoto",templet:function(d){
- return '<a href="javascript:;">['+d.album_num+']</a>'
- }},
- {field: 'type_num', title: '户型',width:70,event:'housesType', align:'center',templet:"#housesType",templet:function(d){
- return '<a href="#">['+d.type_num+']</a>'
- }},
- {field: 'peitao_num', title: '周边配套',width:85, event:'houseFacilities', align:'center',templet:"#houseFacilities",templet:function(d){
- return '<a href="#">['+d.peitao_num+']</a>'
- }},
- {field: 'click_num', title: '点击',width:80, align:'center',sort: true},
- {field: 'sort', title: '排序',width:80, edit: 'text',align:'center',sort: true,templet:"#sortBox"},
-
- {field: 'create_at', title: '添加时间',width:150, align:'center'},
- {field: 'is_view', title: '审核',width:70, align:'center', templet:"#Toexamine",templet:function(d){
- switch (d.is_view){
- case '2':
- return '<input type="checkbox" value="'+d.id+'" name="'+d.is_view+'" house="'+d.name+'" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
- break;
- case '1':
- return '<input type="checkbox" checked value="'+d.id+'" name="'+d.is_view+'" house="'+d.name+'" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
- break;
- }
- }},
- {title: '操作', width:200, templet:'#housesListBar',fixed:"right",align:"center"}
- ]]
- });
- tableIns.reload('tablerReload');
- var $ = layui.$, active = {
- addData: function(){
- var index = layui.layer.open({
- title : "添加楼盘",
- type : 2,
- area:['','100%'],
- maxmin: true,
- content : "/house/create.html",
- })
- layui.layer.full(index);
-
- $(window).on("resize",function(){
- layui.layer.full(index);
- })
- },saveData:function () {
- var index = layui.layer.open({
- title : "批量操作",
- type : 2,
- area:['50%','100%'],
- maxmin: true,
- content : "/housech/batchsave",
- })
- },
- clearSort:function () {
- var checkStatus = table.checkStatus('tablerReload');
- var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8});
- if(typeof checkStatus.data[0] == 'object'){
- layer.confirm('您确定要清零排序吗?',{btn:['确认','取消']},function(){
- var formdat = new FormData();
- $.each(checkStatus.data,function (key,val) {
- formdat.append('hid[]',val.id);
- })
- $.ajax({
- cache : true,
- type : "post",
- url : "/housech/clearsort",
- data : formdat,
-
- contentType: false,
- processData: false,
- error : function(request) {
- layer.close(index);
- layer.alert("网络超时");
- },
- success : function(data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- reloadTable(reloadId);
- } else {
- layer.msg(data.msg);
- }
- }
- });
- })
- return false;
- }
- layer.msg('请选择需要清零的楼盘',{icon:5});
- return false;
- },
- reload:function () {
- var form = pfgs_serialize($('form'));
- var name = '';
- var id = '';
-
- if(form.input_house == 'name'){
- name = form.input_house_text;
- } else if(form.input_house == 'id'){
- id = form.input_house_text;
- }
- var city = '';
- if(form.province != ''){
- city = form.province;
- }
- if(form.city != ''){
- city = form.city;
- }
- table.reload('tablerReload',{
- where:{
- sort:form.input_sort,
- id:id,
- name:name,
- city:city,
- is_view:form.show,
- end_time:form.end_time,
- start_time:form.start_time,
- is_push:form.is_push
- },
- page:{
- curr:1
- }
- })
- },
- clearPush:function(){
- var checkStatus = table.checkStatus('tablerReload');
- var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8});
- if(typeof checkStatus.data[0] == 'object'){
- layer.confirm('您确定要主推吗?',{btn:['确认','取消']},function(){
- var formdat = new FormData();
- $.each(checkStatus.data,function (key,val) {
- formdat.append('hid[]',val.id);
- })
- $.ajax({
- cache : true,
- type : "post",
- url : "/housech/clearpush",
- data : formdat,
-
- contentType: false,
- processData: false,
- error : function(request) {
- layer.close(index);
- layer.alert("网络超时");
- },
- success : function(data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- reloadTable(reloadId);
- } else {
- layer.msg(data.msg);
- }
- }
- });
- })
- return false;
- }
- layer.msg('请选择需要操作的楼盘',{icon:5});
- return false;
- }
- };
- $('.demoTable .layui-btn').on('click', function(){
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
-
- laydate.render({
- elem: '#date1'
- });
- laydate.render({
- elem: '#date2'
- });
-
-
-
-
-
-
-
-
- $('.layui-tab-title .site-demo-active').on('click', function(){
- $(this).addClass('layui-this').siblings().removeClass('layui-this');
- var lay_id = $(this).attr('lay-id');
- $('.layui-tab-item').removeClass('layui-show')
- $('.layui-tab-content #'+lay_id).addClass('layui-show')
- });
-
- form.on('switch(switchTest)', function(data){
- var house = data.elem.attributes.house.value;
- layer.open({
- title :'修改<span style="color:red" >['+house+']</span>状态',
- type : 2,
- area:['50%','80%'],
- maxmin: true,
- content : "/housech/openstate?hid="+data.value+"&name="+house,
- end:function () {
- table.reload('tablerReload');
- }
- })
- });
- form.on('submit(del_alls_house)',function (data) {
- var checkStatus = table.checkStatus('tablerReload');
- var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8});
- if(typeof checkStatus.data[0] == 'object'){
- layer.confirm('您确定要删除吗?',{btn:['确认','取消']},function(){
- var formdat = new FormData();
- $.each(checkStatus.data,function (key,val) {
- formdat.append('hid[]',val.id);
- })
- $.ajax({
- cache : true,
- type : "post",
- url : "/housech/housedel",
- data : formdat,
-
- contentType: false,
- processData: false,
- error : function(request) {
- layer.close(index);
- layer.alert("网络超时");
- },
- success : function(data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- reloadTable(reloadId);
- } else {
- layer.msg(data.msg);
- }
- }
- });
- })
- return false;
- }
- layer.msg('请选择需要删除的楼盘',{icon:5});
- return false;
- })
-
- table.on('edit('+tableIds+')', function(obj){
- var data = obj.data;
- $.post('/housech/housesortedit',{id:data.id,sort:data.sort},function (data) {
- if(data.code == 200)
- {
- layer.msg(data.msg);
-
-
-
-
- } else if(data.code == 300 ) {
- layer.msg(data.msg);
- }
- })
- })
-
- table.on('tool('+tableIds+')', function(obj){
- var data = obj.data;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if(obj.event === 'housesNews'){
- var index =layui.layer.open({
- title :'<span style="color:red" >['+data.name+']</span>楼盘资讯',
- type : 2,
- area:['','100%'],
- maxmin: true,
- content : "/housech/newslist?id="+data.id+"&name="+data.name,
- end:function () {
- table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
-
- $(window).on("resize",function(){
- layui.layer.full(index);
- })
- } else if(obj.event === 'edit'){
- var index = layui.layer.open({
- title : '<span style="color:red" >['+data.name+']</span>修改楼盘信息',
- type : 2,
- area:['','100%'],
- maxmin: true,
- content : "/housech/edit?id="+data.id,
- end:function(){
- layui.table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
-
- $(window).on("resize",function(){
- layui.layer.full(index);
- })
- } else if(obj.event === 'del'){
- layer.confirm('您确认要删除吗?',{btn:['确认','取消']},function () {
- $.post('/housech/housedel',{id:data.id},function (data) {
- if (data.code == 200) {
- layer.msg(data.msg);
-
- table.reload('tablerReload');
-
- } else {
- layer.msg(data.msg);
- }
- })
- })
- }else if(obj.event === 'housesPhoto'){
- var index =layui.layer.open({
- title :'<span style="color:red" >['+data.name+']</span>楼盘相册',
- type : 2,
- area:['','100%'],
- maxmin: true,
- content : "/housech/album?id="+data.id+"&name="+data.name,
- end:function () {
- table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
-
- $(window).on("resize",function(){
- layui.layer.full(index);
- })
- } else if(obj.event === 'housesType'){
- var index =layui.layer.open({
- title :'<span style="color:red" >['+data.name+']</span>楼盘户型',
- type : 2,
- area:['','100%'],
- maxmin: true,
- content : "/housech/housetype?id="+data.id+"&name="+data.name,
- end:function () {
- table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
-
- $(window).on("resize",function(){
- layui.layer.full(index);
- })
- }else if(obj.event === 'house_price'){
- var index =layui.layer.open({
- title :'<span style="color:red" >['+data.name+']</span>楼盘历史价格',
- type : 2,
- area:['','100%'],
- maxmin: true,
- content : "/housech/priceview?id="+data.id+"&name="+data.name+'&price='+data.sale_price,
- end:function(){
- table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
-
- $(window).on("resize",function(){
- layui.layer.full(index);
- })
- }else if(obj.event === 'houseFacilities'){
- var index =layui.layer.open({
- title :'<span style="color:red" >['+data.name+']</span>楼盘周边配套',
- type : 2,
- area:['','100%'],
- maxmin: true,
- content : "/housech/peitao?id="+data.id+"&name="+data.name,
- end:function () {
- table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
-
- $(window).on("resize",function(){
- layui.layer.full(index);
- })
- }else if(obj.event === 'house_presell'){
- var index =layui.layer.open({
- title :'<span style="color:red" >['+data.name+']</span>预售许可证',
- type : 2,
- area:['','100%'],
- maxmin: true,
- content : "/housech/presell?id="+data.id+"&name="+data.name,
- end:function () {
- table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
-
- $(window).on("resize",function(){
- layui.layer.full(index);
- })
- }
- });
-
-
- upload.render({
- elem: '#test1'
- ,url: '/housech/createimg'
- ,data:{token:csrfToken}
- ,field:'img'
- ,size:1000
- ,exts: 'png|jpg|jpeg'
- ,auto:false
- ,bindAction:'#addcity'
- ,choose: function(obj){
- obj.preview(function(index, file, result){
- $('#demo1').attr('src', result);
- });
- }
- });
-
- $('#demo1').on('click', function(){
- var _src = $(this).attr('src');
- layui.layer.open({
- type: 1,
- title: false,
- area: ['60%', '80%'],
- shade: 0.6,
- closeBtn: 1,
- shadeClose: true,
- content: '<img style="width:100%;height:100%" src="'+_src+'">',
- });
- });
-
- var verdict = $('#editor').html();
- if(typeof verdict == "string"){
- var ue = UE.getEditor('editor');
- }
-
- function reloadTable(obj){
- table.reload(obj);
- }
- form.on('submit(tijiao)',function (data) {
- var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8});
- var formData = new FormData($('#house_form')[0]);
-
-
-
-
-
-
-
-
-
-
- $.ajax({
- cache : true,
- type : "post",
- url : "/housech/createfrom",
- data : formData,
-
- contentType: false,
- processData: false,
- error : function(request) {
- layer.close(index);
- layer.alert("网络超时");
- },
- success : function(data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- parent.layui.table.reload('tablerReload');
- TableClose();
- } else if(data.code == 300){
- layer.msg(data.msg);
- layer.msg(ReturnInfo(data.data),{icon:5});
- }
- }
- });
- return false;
- })
- form.on('submit(edit)',function (data) {
- var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8});
- var formData = new FormData($('#house_edit_form')[0]);
-
-
-
-
-
-
-
-
-
- $.ajax({
- cache : true,
- type : "post",
- url : "/housech/editfrom",
- data : formData,
-
- contentType: false,
- processData: false,
- error : function(request) {
- layer.close(index);
- layer.alert("请联系管理员");
- },
- success : function(data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- } else if(data.code == 300){
- layer.msg(data.msg);
- layer.msg(ReturnInfo(data.data),{icon:5});
- }
- }
- });
- return false;
- });
-
- form.on('submit(openstate)',function (data) {
- var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8});
- $.ajax({
- cache : true,
- type : "post",
- url : "/housech/openstateform",
- data : data.field,
-
-
-
- error : function(request) {
- layer.close(index);
- layer.alert("请联系管理员");
- },
- success : function(data) {
- if(data.data != null){
- layer.msg(ReturnInfo(data.data),{icon:5});
- return ;
- }
- layer.msg(data.msg);
- }
- });
- return false;
- });
-
- function loadProvince(data) {
- $.ajax({
- url : '/categorycity/citypid',
- type : 'post',
- async: false,
- data : {'pid':0},
- success : function(data){
-
- var areaData = data.data;
- var proHtml = '';
- for (var i = 0; i < areaData.length; i++) {
- proHtml += '<option value="' + areaData[i].id +'">' + areaData[i].city_name + '</option>';
- }
-
- $('select[name=province]').append(proHtml);
- form.render();
- },
- fail:function(){
- }
- });
- }
- loadProvince();
- form.on('select(province)',function (data) {
- $.post('/categorycity/citypid',{'pid':data.value},function (data) {
- var areaData = data.data;
- var proHtml = '';
- $('select[name=city]').html('');
- proHtml = '<option value="">请选择市/区/县</option>';
- for (var i = 0; i < areaData.length; i++) {
- proHtml += '<option value="' + areaData[i].id +'">' + areaData[i].city_name + '</option>';
- }
-
- $('select[name=city]').append(proHtml);
- form.render();
- })
- })
-
- var leng =50;
- $('.layui_w_addbtn').on('click',function(){
- datumInsert(leng)
- $('body').append('<script id="ue'+leng+'">UE.getEditor("evaluating'+leng+'")</script>')
- var ue =UE.getEditor("evaluating"+leng);
- ue.ready(function() {
-
- });
- leng++;
- })
-
- $('.layui_w_licence table.layui-table tbody.mai').on('click','.del',function(){
- var _this = $(this)
- var oid = _this.parents('.otr').attr('id');
- var index =layer.confirm('确定要删除吗?',{btn: ['确定', '取消']},function () {
-
- _this.parents('#'+oid).remove();
- $('body script#'+oid).remove();
- layer.msg('已成功删除!');
- })
- })
- })
- $(function(){
- $('.editmai tr.otr').each(function(){
- var _ind = $(this).attr('data-id');
- UE.getEditor("evaluating"+_ind);
-
- })
-
- $('.layui-tab-title .site-demo-active').on('click', function(){
- $(this).addClass('layui-this').siblings().removeClass('layui-this');
- var lay_id = $(this).attr('lay-id');
- $('.layui-tab-item').removeClass('layui-show')
- $('.layui-tab-content #'+lay_id).addClass('layui-show')
- });
-
- $('.layui_w_name').on('keyup ',function(){
- var _txt = $(this).val();
- var _convert = pinyinUtil.getPinyin(_txt,' ',false).replace(/\s/g, "");
- $('.layui_w_spell').val(_convert)
- })
-
- var _btn = '<div class="layui-inline " style="float:left;position:relative;left:10px;bottom:35px">'
- + '<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>'
- + '</div>'
- $('.layui-form').append(_btn)
-
- var i=0;
- $('li[lay-id="assign_4"]').on('click',function(){
- var _text = UE.getEditor('editor').getContent()
- if(_text != ''){
- if(i <1){
- var editorHeight = UE.getEditor('editor').iframe.clientHeight;
- if(editorHeight > 400){
- var _setHeight = parseInt(UE.getEditor('editor').iframe.clientHeight/7.5);
- $('#assign_4').find('#edui1_iframeholder').css('height',_setHeight);
- }
- i++;
- }
- }
- })
-
-
-
-
-
- })
- function datumInsert(leng){
-
-
- var tr ='<tr class="otr" id="ue'+leng+'">'
- +'<td lay-event="del">'
- +'<div class="layui-table-cell del" lay-oid=""><i class="layui-icon" style="font-size: 30px; color: #1E9FFF;cursor: pointer"></i></div>'
- +'</td>'
- +'<td data-field="matingName" align="center" data-content="">'
- +'<div class="editor_box layui-form-item" style="width:99%;height:400">'
- +'<textarea name="evaluating[]" id="evaluating'+leng+'" cols="20" rows="10" style="width:100%;float:left;"></textarea>'
- +'</div>'
- +'</td>'
- +'</tr>';
- $(".layui_w_licence table.layui-table tbody.mai").append(tr);
- }
-
|