$(function () { $("#jqGrid").jqGrid({ url: '../addressinfo/list', datatype: "json", colModel: [ {label: 'id', name: 'id', index: 'id', key: true, hidden: true}, {label: '商家名称', name: 'storeName', index: 'store_name', width: 80}, {label: '快递名称', name: 'expressName', index: 'express_name', width: 80}, {label: '是否启用', name: 'isValid', index: 'is_valid', width: 80, formatter: function (value) { return value === 0 ? '禁用' : '正常'; } }, {label: '创建人编号', name: 'createrSn', index: 'creater_sn', width: 80}, {label: '创建时间', name: 'createTime', index: 'create_time', width: 80, formatter: function (value) { return transDate(value,'yyyy-MM-dd hh:mm:ss'); }}, {label: '修改人编号', name: 'moderSn', index: 'moder_sn', width: 80}, {label: '修改时间', name: 'modTime', index: 'mod_time', width: 80, formatter: function (value) { return transDate(value,'yyyy-MM-dd hh:mm:ss'); }} ], 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, storeId: '', expcomId:'', status:'', addressInfo: {}, storeList: [], expressCompanySys:[], ruleValidate: { /*storeId: [ {required: true, message: '门店不能为空', trigger: 'blur'} ],*/ /*expcomId: [ {required: true, message: '快递公司不能为空', trigger: 'blur'} ],*/ }, q: { storeId: '' } }, methods: { query: function () { vm.reload(); }, add: function () { vm.showList = false; vm.title = "新增"; vm.addressInfo = {}; vm.storeList = []; vm.expressCompanySys=[]; vm.status=2; vm.getStoresByMerch(); vm.getCompantByThirdMerch(); }, update: function (event) { let id = getSelectedRow(); if (id == null) { return; } vm.showList = false; vm.title = "修改"; vm.status=1; vm.getInfo(id) }, saveOrUpdate: function (event) { let url = vm.addressInfo.id == null ? "../addressinfo/save" : "../addressinfo/update"; $.ajax({ type: "POST", url: url, contentType: "application/json", data: JSON.stringify(vm.addressInfo), success: function (r) { if (r.code === 0) { alert('操作成功', function (index) { vm.reload(); }); } else { alert(r.msg); } } }); }, del: function (event) { let ids = getSelectedRows(); if (ids == null){ return; } confirm('确定要删除选中的记录?', function () { $.ajax({ type: "POST", url: "../addressinfo/delete", contentType: "application/json", data: JSON.stringify(ids), success: function (r) { if (r.code == 0) { alert('操作成功', function (index) { $("#jqGrid").trigger("reloadGrid"); }); } else { alert(r.msg); } } }); }); }, getStoresByMerch: function (opt) { $.get("../expresscompanysys/getStoresByMerch", function (r) { vm.storeList = r.list; }); }, getCompantByThirdMerch: function (opt) { $.get("../expresscompanysys/getCompantByThirdMerch", function (r) { vm.expressCompanySys = r.list; }); }, saveStoreAndComp: function (event) { let url = "../addressinfo/saveStoreAndComp"; let storesId = vm.addressInfo.storeId; let expcomId = vm.addressInfo.expcomId; let pames={"outletsId":storesId,"exprId":expcomId}; console.log(JSON.stringify(pames)); $.ajax({ type: "POST", url: url, contentType: "application/json", data: JSON.stringify(pames), success: function (r) { if (r.code === 0) { alert('操作成功', function (index) { vm.reload(); }); } else { alert(r.msg); } } }); }, checketStatus: function (event) { let id = getSelectedRow(); if (id == null) { return; } vm.getInfo(id); let status = vm.addressInfo.isValid; let name = ''; if (status == 1 ){ name='禁用'; status = 0; }else if (status == 0 ){ name='启用'; status= 1; } let pames={"id":id,"status":status}; confirm('确定要'+name+'?', function () { $.ajax({ type: "POST", url: "../addressinfo/getStatus", contentType: "application/json", data: JSON.stringify(pames), success: function (r) { if (r.code == 0) { alert('操作成功', function (index) { $("#jqGrid").trigger("reloadGrid"); }); } else { alert(r.msg); vm.reload(); } } }); }); }, getInfo: function(id){ $.get("../addressinfo/info/"+id, function (r) { vm.addressInfo = r.addressInfo; }); }, reloadSearch: function() { vm.q = { storeId: '' } vm.reload(); }, reload: function (event) { vm.showList = true; vm.status=''; let page = $("#jqGrid").jqGrid('getGridParam', 'page'); $("#jqGrid").jqGrid('setGridParam', { postData: {'storeId': vm.q.storeId}, page: page }).trigger("reloadGrid"); vm.handleReset('formValidate'); }, handleSubmit: function (name) { handleSubmitValidate(this, name, function () { vm.saveOrUpdate() }); }, handleComSubmit: function (name) { handleSubmitValidate(this, name, function () { // vm.saveOrUpdate() vm.saveStoreAndComp(); }); }, handleReset: function (name) { handleResetForm(this, name); } } });