123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- // var delFiles = []; //用于删除图片
- // var filesContainer= {}; //存储最终要上传的图片
- // var files ; //存储选择图片的数量
- var trNum = [];
- var trIndex;
- var delNum = [];
- var dataId =new Array();
- layui.use(['form','layer','upload','table'],function(){
- var form = layui.form,
- // layer = parent.layer === undefined ? layui.layer : top.layer,
- layer = layui.layer ,
- table = layui.table,
- $ = layui.jquery;
- var inputId = $('input[name="hid"]').val();
- var inputName = $('input[name="name"]').val();
- var longitude_latitude = $('input[name="longitude_latitude"]').val();
- //楼盘列表
- var indexTtable = table.render({
- elem: '#housepeitaolist',
- url : '/housech/peitaoform',
- where:{hid:inputId},
- method:'post',
- id:'tablerReload',
- cols : [[
- // {type: "checkbox", fixed:"left", width:50},
- {type:'numbers'},
- {field: 'name', title: '配套类目', align:"center",sort: true},
- {field: 'num', title: '数量', align:"center",sort: true,width:100},
- {title: '操作', width:200, templet:'#housesalbumListBar',fixed:"right",align:"center"}
- ]]
- });
- indexTtable.reload('tablerReload'); //重新加载
- // var onerange = getRandom(99);
- //配套设施修改
- var inputFid = $('input[name="fid"]').val();
- var editTable = table.render({
- elem: '#facilitysss',
- url: '/housech/peitaoedit',
- method:'post',
- cellMinWidth: 98,
- where: {fid: inputFid, hid: inputId},
- id: "facility",
- cols: [[
- {type: "", fixed: "left", width: 50, event: 'del', templet: function (d) {
- return '<i class="layui-icon" style="font-size: 30px; color: #1E9FFF;"></i>'
- }},
- { field: "id", title: "ID", width: 100,display:"none",align: "center", templet: function (d) {
- return '<input type="text" style="display: none;" name="edit_id" value="' + d.id + '" autocomplete="off" class="layui-input" >'
- }},
- {field: "name", title: "配套名称", width: 250, align: "center", templet: function (d) {
- return '<input type="text" name="matingName['+d.id+']" value="' + d.name + '" autocomplete="off" class="layui-input" >'
- }},
- {field: "distance", title: "距离", width: 150, align: "center", templet: function (d) {
- return '<input type="text" name="distance['+d.id+']" value="' + d.distance + '" autocomplete="off" class="layui-input" >'
- }},
- {field: "latitude_longitude",title: "经纬度",width: 200,align: "center",sort: true,templet: function (d) {
- return '<input type="text" id="jwd' + d.id + '" name="longitude['+d.id+']" value="' + d.latitude_longitude + '" autocomplete="off" class="layui-input" >';
- }}
- ]],done:function (res, curr, count) {
- $("[data-field='id']").css('display','none');
- }
- })
- //修改的工具条
- table.on('tool(facilitysss)', function(obj){
- var data = obj.data;
- var _this = $(this);
- if(obj.event === 'del'){
- layer.confirm('确定删除数据?', function(index){
- if(data.id > 0){
- dataId.push(data.id);
- }
- if(typeof data.id =='undefined'){
- _this.parents('tr').remove();
- }
- obj.del();
- layer.close(index);
- });
- }
- });
- //监听工具条
- table.on('tool(housepeitaolist)', function(obj){
- var data = obj.data;
- if(obj.event === 'edit' ){
- var index = parent.layui.layer.open({
- title : '<span style="color:red" >['+inputName+']</span> 楼盘周边配套修改',
- type : 2,
- maxmin: true,
- area: ['', '100%'],
- content : "/housech/peitaoedit?id="+inputId+'&fid='+data.fid+'&name='+data.name +'&ll='+longitude_latitude,
- end:function () {
- layui.table.reload('tablerReload');
- }
- })
- parent.layui.layer.full(index);
- //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
- $(window).on("resize",function(){
- parent.layui.layer.full(index);
- })
- }else if(obj.event === 'del'){
- var index =layui.layer.confirm('确定要删除吗?',{btn: ['确定', '取消']},function () {
- $.post('/housech/peitaodel',{hid:inputId,type_id:data.fid},function (data) {
- if(data.code == 200)
- {
- layer.msg(data.msg);
- table.reload('tablerReload');
- } else if(data.code == 300 ) {
- layer.msg(data.msg);
- }
- })
- })
- }
- });
- $('.layui_map .layui_close').on('click',function(){
- location.reload(); // 父页面刷新
- })
- /*
- * 弹出添加配套页面
- * */
- function addAlbum(edit){
- var index = parent.layui.layer.open({
- title : '<span style="color:red" >['+inputName+']</span> 楼盘添加周边配套',
- type : 2,
- maxmin: true,
- area: ['', '100%'],
- content : "/housech/peitaoadd?id="+inputId+'&name='+inputName+'&ll='+longitude_latitude,
- end:function () {
- layui.table.reload('tablerReload');
- }
- })
- parent.layui.layer.full(index);
- //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
- $(window).on("resize",function(){
- parent.layui.layer.full(index);
- })
- }
- //添加配套
- $("#add-album").click(function(){
- addAlbum()
- });
- // 添加页面提交
- form.on('submit(add_load_mating)',function (data) {
- var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
- var form = pfgs_serialize($('#peitao_form'));
- var trArry = $('.layui-input-block table.layui-table tbody tr');
- var dataObj = [{}];
- var dataArry = new Array();
- $.each(trArry,function(key,val){
- var _title = $(this).find('input[name="matingName"]').val();
- var _rout = $(this).find('input[name="distance"]').val();
- var _point = $(this).find('input[name="longitude"]').val();
- dataObj[key] = {title:_title,rout:_rout,point:_point} //把数据以数组对象的方式保存
- dataArry.push(dataObj[key])
- })
- $.post("/housech/peitaoaddform",{data:dataArry,hid:inputId,type_id:form.city},function(data){
- if (data.code == 200) {
- layer.msg(data.msg);
- indexTtable.reload('tablerReload');
- TableClose();
- } else if(data.code == 300){
- layer.msg(data.msg);
- if(data.data.length > 0){
- layer.msg(ReturnInfo(data.data),{icon:5});
- }
- }
- })
- return false;
- })
- // 修改提交
- form.on('submit(edit_load_mating)',function (data) {
- var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
- var form = pfgs_serialize($('#peitao_form'));
- var trArry = $('.layui-table-main table.layui-table tbody tr');
- var dataObj = [{}];
- var dataArry = new Array();
- $.each(trArry,function(key,val){
- var _title = $(this).find('input[name="matingName"]').val();
- var _rout = $(this).find('input[name="distance"]').val();
- var _point = $(this).find('input[name="longitude"]').val();
- dataObj[key] = {title:_title,rout:_rout,point:_point} //把数据以数组对象的方式保存
- dataArry.push(dataObj[key])
- })
- $.post("/housech/peitaoeditform",{data:dataArry,dataId:dataId,hid:inputId,type_id:form.fid},function(data){
- layer.msg(data.msg);
- // if (data.code == 200) {
- // layer.msg(data.msg);
- // indexTtable.reload('tablerReload');
- //
- // } else if(data.code == 300){
- // layer.msg(data.msg);
- // if(data.data.length > 0){
- // layer.msg(ReturnInfo(data.data),{icon:5});
- // }
- // }
- })
- return false;
- })
- });
- //生产随机数
- // function getRandom(n) {
- // return Math.floor(Math.random() * n + 1)
- // }
- //
- // function uniqueidArr(arr) {
- // var newArr = {};
- // console.log(newArr);
- // if(arr.length >0){
- // $.each(arr,function (k,v) {
- // newArr[v] = v;
- // })
- // return newArr;
- // }
- //
- // }
|