cloudapplyinput.js 4.95 KB
var type = T.p("type");

$(function () {
	if(type=="user"){
        vm.showList = false;
        vm.showCancelButton=false;
	}
	else{
    $("#jqGrid").jqGrid({
        url: '../cloud/apply/userlist',
        datatype: "json",
        colModel: [			
			{ label: 'ID', name: 'id', index: "id", width: 45, key: true },
            { label: '类型', name: 'type', index: "type", width: 45,formatter: function (value,options,row){
            	if(value===1){
            		return '推优入党'
				}else if(value ===2){
            		return '法律援助'
				}else if(value===3){
            		return '信访接待'
				}else{
            		return '未知'
				}
			}
			},
			{ label: '状态', name: 'status', index: "status", width: 45,formatter: function (value,options,row){
                    if (value === 0) {
                        return '<span class="label label-primary">未处理</span>';
                    }
                    else if (value === 3) {
                        return '<span class="label label-danger">已拒绝</span>';
                    }
                    else if (value === 1) {
                        return '<span class="label label-success">已处理</span>';
                    }  else if (value === 2) {
                        return '<span class="label label-info">已撤销</span>';
                    }else{
                    	return '未知'
					}
                }
            },

            { label: '工会名', name: 'unionName', index: "union_name", width: 45},
            { label: '申请者', name: 'apName', index: "apName", width: 45},

        ],
		viewrecords: true,
        height: 385,
        rowNum: 10,
		rowList : [10,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	//$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });


        }
    });}
});


var setting = {
	data: {
		simpleData: {
			enable: true,
			idKey: "id",
			rootPId: -1
		},
		key: {
			url:"nourl"
		}
	},
	check:{
		enable:true,
		nocheckInherit:true
	}
};
var ztree;
	
var vm = new Vue({
	el:'#rrapp',
	data:{
		q:{
			askContext: null
		},
		showList: true,
		title:null,
		apply:{},
		showCancelButton:true,
	},

	mounted:function(){

	},

	methods: {
		query: function () {
			vm.reload();
		},
		add: function(){
           vm.showList=false;
           vm.title="新增";
           vm.apply={};
		},
		update: function () {
			var roleId = getSelectedRow();
			if(roleId == null){
				return ;
			}
			
			vm.showList = false;

            $.get("../cloud/apply/info/"+roleId, function(r){
                vm.showList = false;
                vm.apply = r.apply;
                vm.title="上次更新时间:"+vm.apply.updateTime+",操作者:"+vm.apply.makerName;

            });
		},
		del: function (event) {
			var roleIds = getSelectedRows();
			if(roleIds == null){
				return ;
			}
			confirm('确定要删除选中的记录?', function(){
				$.ajax({
					type: "POST",
				    url: "../cloud/apply/delete",
				    data: JSON.stringify(roleIds),
				    success: function(r){
						if(r.code == 0){
							alert('操作成功', function(index){
								vm.reload();
							});
						}else{
							alert(r.msg);
						}
					}
				});
			});
		},
		saveOrUpdate: function (event) {
            var reTel = /^1\d{10}$/
            if(vm.apply.apTel ==null || !reTel.test(vm.apply.apTel)){


                alert("手机号格式有误")
                return
            }


            $('#baseInfoSave').prop('disabled', true)
			var url = vm.apply.id == null ? "../cloud/apply/user/save" : "../cloud/apply/user/update";
            vm.apply.apTime = $("#pubDate").val();
            //console.log(vm.baseinfo)
            $.ajax({
				type: "POST",
			    url: url,
			    data:JSON.stringify(vm.apply),

			    success: function(r){
			    	if(r.code === 0){
						alert('操作成功', function(index){

								vm.reload();
                            $('#baseInfoSave').prop('disabled', false)
						});
					}else{
						alert(r.msg);
                        $('#baseInfoSave').prop('disabled', false)
					}
				}
			});
		},
	    reload: function (event) {

	    	vm.showList = true;
			var page = $("#jqGrid").jqGrid('getGridParam','page');
			$("#jqGrid").jqGrid('setGridParam',{ 
                postData:{'askContext': vm.q.askContext},
                page:page
            }).trigger("reloadGrid");
			}

	}
});