$(function () {
    $("#jqGrid").jqGrid({
        url: '../exportexceptiondata/list',
        datatype: "json",
        colModel: [
			{label: 'id', name: 'id', index: 'id', key: true, hidden: true},
			{label: '导入商品异常数据', name: 'exportExceptionData', index: 'export_exception_data', width: 550},
			{label: '导入数据类型', name: 'exportDataType', index: 'export_data_type', width: 40,align: 'center',
                formatter: function (value) {
                    if (value == '1') {
                        return '商品导入';
                    } else if (value == '2') {
                        return '普通商品导入';
                    }
                    return '-';
                }},
			// {label: '用户id', name: 'userId', index: 'user_id', width: 80},
			// {label: '创建人编号', name: 'createrSn', index: 'creater_sn', width: 80},
			{label: '创建时间', name: 'createTime', index: 'create_time', width: 40, align: 'center',formatter: function (value) {
                return transDate(value);
            }},
			// {label: '修改人编号', name: 'moderSn', index: 'moder_sn', width: 80},
			// {label: '修改时间', name: 'modTime', index: 'mod_time', width: 80},
			// {label: '时间戳', name: 'tstm', index: 'tstm', width: 80},
            // {
             //    label: '操作', width: 180, sortable: false, align: 'center',
             //    formatter: function (value, col, row) {
             //        let htmlStr = '<button class="btn btn-outline btn-info" onclick="vm.getInfoData(' + row.id + ')"><i class="fa fa-info-circle"></i>异常详情</button>&nbsp;';
             //        return htmlStr;
             //    }
            // }
            ],
		viewrecords: true,
        height: 550,
        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 () {
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
        }
    });
});

let vm = new Vue({
	el: '#rrapp',
	data: {
        showList: true,
        title: null,
		exportExceptionData: {},
		ruleValidate: {
		},
		q: {
		    name: ''
		}
	},
	methods: {
		query: function () {
			vm.reload();
		},
		getInfoData: function (id) {
            vm.getInfo(id);
            layer.prompt({title: '异常详情', formType: 3}, function(pass, index){

            	layer.close(index);
            });
		},
		getInfo: function(id){
			$.get("../exportexceptiondata/info/"+id, function (r) {
                vm.exportExceptionData = r.exportExceptionData;
            });
		},
        reloadSearch: function() {
            vm.q = {
                name: ''
            }
            vm.reload();
		},
		reload: function (event) {
			vm.showList = true;
            let page = $("#jqGrid").jqGrid('getGridParam', 'page');
			$("#jqGrid").jqGrid('setGridParam', {
                postData: {'name': vm.q.name},
                page: page
            }).trigger("reloadGrid");
            vm.handleReset('formValidate');
		},
        handleReset: function (name) {
            handleResetForm(this, name);
        }
	}
});