123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- var indexOpen;
- layui.use([ 'laypage', 'layer', 'table', 'element','form','upload'], function(){
- var laypage = layui.laypage //分页
- ,$ = layui.jquery
- ,layer = layui.layer //弹层
- ,table = layui.table //表格
- var tableIds = 'videolist'; //表格ID
- var $ = layui.$, active = {
- house_reload:function(){
- var form = pfgs_serialize($('form'));
- console.log(form);
- table.reload('houseReload',{
- where:{
- name:form.input_house_text
- }
- })
- }
- };
- $('.demoTable .layui-btn').on('click', function(){
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
- // $('.The_house').focus(function(){
- // indexOpen = parent.layui.layer.open({
- // type: 2,
- // title: '选择需要添加的楼盘',
- // area: ['','100%'],
- // content: '/routinevideo/allhouse',
- // success:function (layero, index) {
- // },
- // end:function(){
- // }
- // });
- // parent.layui.layer.full(indexOpen);
- // //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
- // $(window).on("resize",function(){
- // parent.layui.layer.full(indexOpen);
- // })
- // })
- table.render({
- elem: '#houselist'
- ,url: '/publicuse/citypriceform' //数据接口
- ,where:{token:csrfToken}
- ,method:'post'
- ,page: true //开启分页
- ,limit : 20
- ,text:'数据加载中'
- ,id:'houseReload'
- ,cols: [[ //表头
- {type: "checkbox", width:50},
- // {title:'选择',event:'checkbox',width:50,align:'center',templet:"#checkBox",templet:function(d){
- // return '<div class="layui-inline" style="width: 100%"><input type="checkbox" name="sex" ></div>'
- // }},
- {type:'numbers',title:'序号'},
- {field: 'city_name', title: '区域名称', align:'center'},
- ]]
- });
- //选择所属楼盘添加
- var _data = [];
- // table.on('tool(houselist)', function(obj){
- // var layEvent = obj.event,
- // data = obj.data;
- // if(layEvent === 'check'){
- // console.log($(this).children('input'));
- //
- // if($(this).checked)
- // {
- // _data.push(data);
- // console.log(_data)
- // }
- // // _data = data;
- //
- //
- // }
- // });
- table.on('checkbox(houselist)', function(obj){
- if(obj.checked == true){
- _data.push(obj.data);
- }
- if(obj.checked == false){
- var del = [];
- $.each(_data,function(key,val){
- console.log(val.city_name);
- if(val.city_name == obj.data.city_name){
- del.push(key);
- }
- })
- if(del.length >0){
- $.each(del,function(key,val){
- console.log(key);
- _data.splice(key,1);
- })
- }
- }
- });
- // 提交按钮
- $('.xuanzhouse').click(function () {
- var a = parent.layer.getChildFrame('body', indexOpen);
- var type = $('#types').html();
- // console.log(type);
- if(type == 1){
- var _length = a.find('input#hiddenBox[type="hidden"]');
- if(_length.length > 0){
- _length.remove();
- }
- if(_data.length > 1){
- layer.msg('请勿选择多个');
- return ;
- }
- // console.log(_data[0].city_name);
- a.find('#house_name').val(_data[0].city_name)
- a.find('form').append('<input type="hidden" id="hiddenBox" name="city_id" value="'+_data[0].city_id+'" />');
- } else {
- a.find('tbody').html('');
- if(typeof _data == 'object'){
- for(var i=0;i<_data.length;i++){
- var tr ='<tr>'
- +'<td lay-event="del">'
- +'<div class="layui-table-cell del"><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="layui-table-cell"><input type="text" name="matingName" value="'+_data[i].city_name+'" autocomplete="off" class="layui-input" ><input type="hidden" name="id" value="'+_data[i].city_id+'"></div>'
- +'</td>'
- +'</tr>'
- a.find('tbody').append(tr);
- }
- }
- }
- TableClose();
- })
- });
|