$(function () { $("#jqGrid").jqGrid({ url: '../mk2goodstopicprice/list', datatype: "json", colModel: [ {label: 'mgthpId', name: 'mgthpId', index: 'mgthp_id', key: true, hidden: true}, {label: '活动id', name: 'topicId', index: 'topic_id', align: 'center',width: 80}, {label: '活动类别', name: 'topicType', index: 'topic_type', align: 'center',width: 80}, {label: '活动价格', name: 'topicPrice', index: 'topic_price',align: 'center', width: 80}, {label: '活动名称', name: 'topicName', index: 'topic_name' ,align: 'center',width: 80}, {label: '活动内容', name: 'topicContent', index: 'topic_content', align: 'center',width: 80}, {label: '活动产品', name: 'goodsName', index: 'goodsName', align: 'center',width: 80}, {label: '活动开始时间', name: 'topicBeginTime', index: 'topic_begin_time', width: 80,align: 'center', formatter: function (value) { return transDate(value, 'yyyy-MM-dd hh:mm:ss'); }}, {label: '活动结束时间', name: 'topicEndTime', index: 'topic_end_time', width: 80,align: 'center', 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, 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, mk2GoodsTopicPrice: {}, ruleValidate: { name: [ {required: true, message: '名称不能为空', trigger: 'blur'} ] }, q: { topicName: '' } }, methods: { query: function () { vm.reload(); }, add: function () { vm.showList = false; vm.title = "新增"; vm.mk2GoodsTopicPrice = {}; }, update: function (event) { let mgthpId = getSelectedRow(); if (mgthpId == null) { return; } vm.showList = false; vm.title = "修改"; vm.getInfo(mgthpId) }, saveOrUpdate: function (event) { let url = vm.mk2GoodsTopicPrice.mgthpId == null ? "../mk2goodstopicprice/save" : "../mk2goodstopicprice/update"; $.ajax({ type: "POST", url: url, contentType: "application/json", data: JSON.stringify(vm.mk2GoodsTopicPrice), success: function (r) { if (r.code === 0) { alert('操作成功', function (index) { vm.reload(); }); } else { alert(r.msg); } } }); }, del: function (event) { let mgthpIds = getSelectedRows(); if (mgthpIds == null){ return; } confirm('确定要删除选中的记录?', function () { $.ajax({ type: "POST", url: "../mk2goodstopicprice/delete", contentType: "application/json", data: JSON.stringify(mgthpIds), success: function (r) { if (r.code == 0) { alert('操作成功', function (index) { $("#jqGrid").trigger("reloadGrid"); }); } else { alert(r.msg); } } }); }); }, getInfo: function(mgthpId){ $.get("../mk2goodstopicprice/info/"+mgthpId, function (r) { vm.mk2GoodsTopicPrice = r.mk2GoodsTopicPrice; }); }, reloadSearch: function() { vm.q = { topicName: '' } vm.reload(); }, reload: function (event) { vm.showList = true; let page = $("#jqGrid").jqGrid('getGridParam', 'page'); $("#jqGrid").jqGrid('setGridParam', { postData: {'topicName': vm.q.topicName}, page: page }).trigger("reloadGrid"); vm.handleReset('formValidate'); }, uploadExcelSuccess: function () { alert('上传成功', function (index) { $("#jqGrid").trigger("reloadGrid"); }); }, uploadExcelError: function () { alert('上传出现异常'); }, uploadExcelSuccess: function (data) { if(data.code==0){ alert('导入成功', function (index) { vm.reload(); }); }else{ if(data.msg == '导入成功!'){ alert(data.msg); vm.reload(); }else { alert(data.msg); } } }, uploadExcelError: function (data) { console.log(data); alert('上传出现异常,请重试!'); }, handleSubmit: function (name) { handleSubmitValidate(this, name, function () { vm.saveOrUpdate() }); }, handleReset: function (name) { handleResetForm(this, name); }, uploadExcelFormatError: function (file) { this.$Notice.warning({ title: '文件格式不正确', desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。' }); } } });