123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654 |
- layui.use(['form', 'layer', 'laydate', 'table', 'laytpl', 'layedit', 'upload'], function () {
- var form = layui.form,
- // layer = parent.layer === undefined ? layui.layer : top.layer,
- 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: '/house/indexform',
- cellMinWidth: 95,
- method: 'post',
- page: true,
- height: 600,
- limit: 20,
- id: reloadId,
- // limits : [10,15,20,25],is_view
- 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/house/' + d.id + '" target="_blank">' + d.name + '</a>';
- return html;
- }
- },
- {field: 'city_name', title: '区域', width: 90, sort: true, align: 'center'},
- {
- field: 'album_num',
- title: '相册',
- width: 80,
- event: 'housesPhoto',
- align: 'center',
- templet: "#housesPhoto",
- templet: function (d) {
- return '<a href="javascript:;">[' + d.album_num + ']</a>'
- }
- },
- {field: 'news_num', title: '资讯',width:70, event:'housesNews', align:'center',templet:"#housesNews",templet:function(d){
- return '<a href="javascript:;">['+d.news_num+']</a>'
- }},
- {
- field: 'type_num',
- title: '户型',
- width: 80,
- event: 'housesType',
- align: 'center',
- templet: "#housesType",
- templet: function (d) {
- return '<a href="#">[' + d.type_num + ']</a>'
- }
- },
- {
- field: 'peitao_num',
- title: '周边配套',
- width: 90,
- 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 = {
- 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
- }
- })
- },
- };
- $('.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: "/house/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: "/house/housedel",
- data: formdat, // 你的formid
- // async : false, //async 默认为true异步,修改为false为同步
- contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
- processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
- 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;
- })
- //检测关键词
- form.on('submit(check_words)',function (data) {
- var content=UE.getEditor('editor').getContentTxt();
- var centhtml = UE.getEditor('editor').getContent();
- $.ajax({
- //cache : false,
- type : "post",
- url : "/sensitivewords/checkword",
- data:{content:content}, // 你的formid
- //contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
- //processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
- error : function(request) {
- layer.close(index);
- layer.alert("网络超时");
- },
- success : function(data) {
- if(data.data!=null){
- var index=layer.open({
- type: 1,
- // skin: 'layui-layer-rim', //加上边框
- title:'违禁词信息',
- area: ['420px', '240px'], //宽高
- content: '<div style="color:red;">'+data.data+'</div>'
- });
- for(var i=0;i<data.data.length;i++){
- centhtml = centhtml.replace(data.data[i],"<span style='color: rgb(255, 0, 0);'>"+data.data[i]+"</span>");
- }
- UE.getEditor('editor_content').setContent(centhtml);
- layer.msg(data.msg)
- }else{
- layer.msg(data.msg)
- }
- }
- });
- return false;
- })
- /* 列表操作 edit 修改后执行 */
- table.on('edit(' + tableIds + ')', function (obj) {
- var data = obj.data;
- $.post('/house/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);
- }
- })
- })
- /* 列表操作 tool 点击执行 */
- table.on('tool(' + tableIds + ')', function (obj) {
- var data = obj.data;
- if (obj.event === 'edit') {
- var index = layui.layer.open({
- title: '<span style="color:red" >[' + data.name + ']</span>修改楼盘信息',
- type: 2,
- area: ['', '100%'],
- maxmin: true,
- content: "/house/edit?id=" + data.id,
- end: function () {
- layui.table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
- // // //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
- $(window).on("resize", function () {
- layui.layer.full(index);
- })
- } else if (obj.event === 'del') {
- layer.confirm('您确认要删除吗?', {btn: ['确认', '取消']}, function () {
- $.post('/house/housedel', {id: data.id}, function (data) {
- if (data.code == 200) {
- layer.msg(data.msg);
- // parent.layui.
- table.reload('tablerReload');
- // TableClose();
- } else {
- layer.msg(data.msg);
- }
- })
- })
- }else if(obj.event === 'housesNews'){
- var index =layui.layer.open({
- title :'<span style="color:red" >['+data.name+']</span>楼盘资讯',
- type : 2,
- area:['','100%'],
- maxmin: true,
- content : "/house/newslist?id="+data.id+"&name="+data.name,
- end:function () {
- table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
- //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
- $(window).on("resize",function(){
- layui.layer.full(index);
- })
- } 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: "/house/album?id=" + data.id + "&name=" + data.name,
- end: function () {
- table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
- //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
- $(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: "/house/housetype?id=" + data.id + "&name=" + data.name,
- end: function () {
- table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
- //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
- $(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: "/house/priceview?id=" + data.id + "&name=" + data.name + '&price=' + data.sale_price,
- end: function () {
- table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
- //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
- $(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: "/house/peitao?id=" + data.id + "&name=" + data.name,
- end: function () {
- table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
- //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
- $(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: "/house/presell?id=" + data.id + "&name=" + data.name,
- end: function () {
- table.reload('tablerReload');
- }
- })
- layui.layer.full(index);
- //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
- $(window).on("resize", function () {
- layui.layer.full(index);
- })
- }
- });
- //楼盘名称,区域, 注释装修情况
- //添加图片上传
- upload.render({
- elem: '#test1'
- , url: '/house/createimg'
- , data: {token: csrfToken}
- , field: 'img'
- , size: 1000 //限制上传图片的大小,单位为KB
- , exts: 'png|jpg|jpeg' //只允许上传压缩文件
- , auto: false
- , bindAction: '#addcity'
- , choose: function (obj) {
- obj.preview(function (index, file, result) {
- $('#demo1').attr('src', result); //图片链接(base64)
- });
- }
- });
- // 点击放大图片
- $('#demo1').on('click', function () {
- var _src = $(this).attr('src');
- layui.layer.open({
- type: 1,
- title: false, //是否显示标题
- area: ['60%', '80%'],
- shade: 0.6, //透明度
- closeBtn: 1, //按钮 1有,0无
- 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(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: "/house/editfrom",
- data: formData, // 你的formid
- // async : false, //async 默认为true异步,修改为false为同步
- contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
- processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
- 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: "/house/openstateform",
- data: data.field, // 你的formid
- // async : false, //async 默认为true异步,修改为false为同步
- // contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
- // processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
- 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,//使用同步的方式,true为异步方式
- data: {'pid': 0},//这里使用json对象
- success: function (data) {
- // console.log(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 () {
- // ue.setContent('<p>编辑器1的内容</p>', true);
- });
- 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 () {
- // layer.close(index)
- _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);
- // console.log(_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 leng = $(".layui_w_licence table.layui-table tbody tr").length;
- // console.log(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);
- }
-
|