123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- layui.use(['form','layer','laydate','table','laytpl','layedit'],function(){
- var form = layui.form,
- layer = parent.layer === undefined ? layui.layer : top.layer,
- $ = layui.jquery,
- table = layui.table;
- var tableIds = 'newsList';
- var tableIns = table.render({
- elem: '#'+tableIds,
- url : '/housech/newslistform',
- where:{hid:$('#houseId').val()},
- method:'post',
- page : true,
- height:600,
- limit : 20,
- id:'tablerReload',
- cols : [[
- {type:'numbers'},
- {type: "checkbox", width:50},
- {field: 'id', title: 'ID', width:80, align:"center",sort: true},
- {field: 'subject', title: '标题',align:'left'},
-
- {field: 'name', title: '添加人',width:75, align:'center'},
- {field: 'news_name', title: '栏目',width:150, align:'center'},
-
-
-
-
- {field: 'clicks', title: '点击数',width:100, align:'center',sort: true},
- {field: 'create_at', title: '添加时间',width:180, event:'sortData', align:'center',sort: true},
- {title: '操作', width:200, templet:'#housesListBar',fixed:"right",align:"center"}
- ]]
- });
-
- tableIns.reload('tablerReload');
- $('.demoTable .layui-btn').on('click', function(){
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
- var $ = layui.$, active = {
- loadnews: function(){
- var index = parent.layui.layer.open({
- title : "加载资讯",
- type : 2,
- area:['','100%'],
- maxmin: true,
- content : "/housech/loadnews",
- })
- parent.layui.layer.full(index);
-
- $(window).on("resize",function(){
- parent.layui.layer.full(index);
- })
- },
- 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;
- }
- table.reload('tablerReload',{
- where:{
- sort:form.input_sort,
- id:id,
- name:name,
- category:form.category
- }
- })
- },
- load_news_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;
- }
- table.reload('loadnewsId',{
- where:{
- id:id,
- name:name,
- news:form.category
- }
- })
- }
- };
-
- table.on('tool('+tableIds+')', function(obj){
- var data = obj.data;
- if(obj.event === 'del'){
- layer.confirm('您确定要删除吗?',{btn:['确认','取消']},function () {
- $.post('/housech/housenewsdel',{dataid:data.hnid},function (data) {
- if(data.code == 200){
- layer.msg(data.msg);
- table.reload('tablerReload');
- }else if(data.code == 300){
- layer.msg(data.msg);
- }
- })
- })
- }else if(obj.event === 'Relieve'){
- var _this = $(this);
- layer.confirm('您确定要解审吗?',{btn:['确认','取消']},function () {
- $.post('/housech/housenewsdel',{dataid:data.hnid,type:2},function (data) {
- if(data.code == 200){
-
- layer.msg('操作成功');
- table.reload('tablerReload');
- }else if(data.code == 300){
- layer.msg('操作失败');
- }
- })
- })
- }
- });
-
- $('.loadnews').click(function () {
- var index = parent.layui.layer.open({
- title :'<span style="color:red" >'+$('.house_name').html()+'</span>加载资讯',
- type : 2,
- area:['','100%'],
- maxmin: true,
- content : "/housech/loadnews?hid="+$('#houseId').val(),
- end:function () {
- layui.table.reload('tablerReload');
- }
- })
- parent.layui.layer.full(index);
-
- $(window).on("resize",function(){
- parent.layui.layer.full(index);
- })
- })
-
- table.render({
- elem: '#loadnewsList',
- url : '/housech/loadnewslist',
- method:'post',
- where:{hid:$('#houseId').val()},
-
- id:'loadnewsId',
- page : true,
- limit : 20,
- cols : [[
- {type: "checkbox", fixed:"left", width:50},
- {field: 'id', title: 'ID', width:80, align:"center",sort: true},
- {field: 'subject', title: '标题',align:'left'},
-
-
- {field: 'state', title: '审核',width:80, event:'housesNews', align:'center'},
-
-
-
- {field: 'clicks', title: '点击数',width:100, align:'center',sort: true},
- {field: 'create_at', title: '添加时间',width:150, event:'sortData', align:'center',sort: true},
-
- ]]
- });
- form.on('submit(add_load_news)',function (data) {
- var checkStatus = table.checkStatus('loadnewsId');
- var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8});
-
-
-
- if(typeof checkStatus.data[0] == 'object'){
- var Hid = $('#houseId').val();
- var formdat = new FormData();
- $.each(checkStatus.data,function (key,val) {
- formdat.append('nid[]',val.id);
- })
- formdat.append('hid',Hid);
- $.ajax({
- cache : true,
- type : "post",
- url : "/housech/relationnews",
- 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);
-
- TableClose();
- } else {
- layer.msg(data.msg);
- TableClose();
- }
- }
- });
- return false;
- }
- layer.msg('请选择资讯');
- return false;
- })
- })
|