123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- var indexOpen;
- layui.use([ 'laypage', 'layer', 'table', 'element','form','upload'], function(){
- var laypage = layui.laypage //分页
- ,$ = layui.jquery
- ,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);
- })
- })
- var indexO = table.render({
- elem: '#houselist'
- ,url: '/publicuse/allhouseform' //数据接口
- ,where:{token:csrfToken}
- ,method:'post'
- ,page: true //开启分页
- ,text:'数据加载中'
- ,id:'houseReload'
- ,cols: [[ //表头
- {title:'选择',event:'check',width:60,align:'center',templet:"#checkBox",templet:function(d){
- return '<div class="layui-inline"><input type="radio" name="sex" ></div>'
- }},
- {type:'numbers',title:'序号'},
- {field: 'name', title: '楼盘名称', align:'center'},
- ]]
- });
- table.reload('houseReload'); //重新加载
- //选择所属楼盘添加
- var _data;
- table.on('tool(houselist)', function(obj){
- var layEvent = obj.event,
- data = obj.data;
- if(layEvent === 'check'){
- _data = data;
- }
- });
- // 提交按钮
- $('.xuanzhouse').click(function () {
- var a = parent.layer.getChildFrame('body', indexOpen);
- // var _length = a.find('input#hiddenBox[type="hidden"]');
- // if(_length.length > 0){
- // _length.remove();
- // }
- // if(typeof _data == 'object'){
- // a.find('#house_name').val(_data.name)
- // a.find('form').append('<input type="hidden" id="hiddenBox" name="hid" value="'+_data.id+'" />');
- // TableClose();
- // }
- if(a.find('#feng_houseall').length<=0){
- // var a = parent.layer.getChildFrame('body', indexOpen);
- var _length = a.find('input#hiddenBox[type="hidden"]');
- if(_length.length > 0){
- _length.remove();
- }
- if(typeof _data == 'object'){
- a.find('#house_name').val(_data.name)
- a.find('form').append('<input type="hidden" id="hiddenBox" name="hid" value="'+_data.id+'" />');
- TableClose();
- }
- }else{
- // var checkStatus = table.checkStatus('houseReload');
- // var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
- // var a = parent.layer.getChildFrame('body', indexOpen);
- var _length = a.find('input#hiddenBox[type="hidden"]');
- if(_length.length > 0){
- _length.remove();
- }
- if(typeof _data == 'object'){
- var formdat = new FormData();
- var htmlStr = '';
- var tong = false;
- htmlStr += '<tr><td>'+_data.name+' <input type="hidden" name="hid[]" class="hids" value="'+_data.id+'" ></td><td class="feng_houseallnamedel"> <a class="layui-btn layui-btn-danger layui-btn-xs" >删除</a></td></tr>';
- a.find('.hids').each(function (key,val) {
- if(_data.id == $(val).val()){
- layer.msg('该楼盘已选择')
- tong = true;
- return false;
- }
- })
- if(tong){
- return false;
- }
- var tb = $('.layui-table').length;
- var html = '';
- if(a.find('.layui-table').length<=0){
- html += ' <table class="layui-table">\n' +
- ' <colgroup>\n' +
- ' <col width="150">\n' +
- ' <col width="50">\n' +
- ' <col>\n' +
- ' </colgroup>\n' +
- ' <thead>\n' +
- ' <tr>\n' +
- ' <th>楼盘名称</th>\n' +
- ' <th>操作</th>\n' +
- ' </tr>\n' +
- ' </thead>\n' +
- ' <tbody>\n'+
- htmlStr +
- ' </tbody>\n'+
- ' \n' +
- ' </table>';
- }
- if(a.find('.layui-table').length>0){
- a.find('.layui-table').append(htmlStr);
- }else{
- a.find('#feng_houseall').append(html);
- }
- TableClose();
- return false;
- }
- layer.msg('请选择楼盘',{icon:5});
- return false;
- var _length = a.find('input#hiddenBox[type="hidden"]');
- if(_length.length > 0){
- _length.remove();
- }
- if(typeof _data == 'object'){
- a.find('#house_name').val(_data.name)
- a.find('form').append('<input type="hidden" id="hiddenBox" name="hid" value="'+_data.id+'" />');
- TableClose();
- }
- }
-
- })
- });
|