$(function () { let mkaId = getQueryString("mkaId"); if(mkaId){ vm.mkaId = mkaId; } // var interval; $("#isDisplay").on("click",function () { $("#isDisplay").attr("disabled","true") // interval = setInterval(function () { // $("#isDisplay").removeAttr("disabled") // window.clearInterval(interval) // }, 10000); }); $.ajax({ type: "POST", url: "../mall2pointsrules/getRulesDetilId/?mkaId="+vm.mkaId, contentType: "application/json", success: function (r) { if (r.code == 0) { var pointsType = r.msg; vm.pointsType=r.msg; var rulesId,pointsRulesName; if (pointsType == 0){ rulesId="门店"; pointsRulesName="门店ID"; }else if(pointsType == 1){ rulesId="分类名称"; pointsRulesName="商品分类ID"; }else if (pointsType == 2){ rulesId="商品"; pointsRulesName="商品sku"; } $("#jqGrid").jqGrid({ url: '../mall2pointsrules/detilList', datatype: "json", colModel: [ {label: 'ID', name: 'id', index: 'id', width: 30, align: 'center'}, { label: '积分类型', name: 'rulesType', index: 'points_rules_type', width: 80,align: 'center', formatter: function (value) { if (value === '0' || value === 0) { return '门店'; } if (value == '1' || value === 1) { return '商品类别'; } if (value == '2' || value === 2) { return '门店商品'; } } }, {label: rulesId, name: 'pointsRulesName', index: 'points_detil_name', width: 80, align: 'center'}, {label: pointsRulesName, name: 'rulesId', index: 'points_detil_name_id', width: 80, align: 'center'}, {label: '对应的商品门店名称', name: 'storeName', index: 'points_store_name', width: 80, align: 'center'}, {label: '备注', name: 'remark', index: 'remark', width: 80, align: 'center'},], viewrecords: true, postData: {'mkaId': vm.mkaId}, 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"}); } }); } else { alert(r.msg); } } }); }); let vm = new Vue({ el: '#rrapp', data: { showList: true, title: null, categories: [],//商品条码 categories2: [],//门店名称 categories3: [],//商品类别 mkActivitiesHalfPrice: {}, ruleValidate: { name: [ {required: true, message: '名称不能为空', trigger: 'blur'} ] }, q: { pointsDetilNameId:"", pointsDetilName:"" }, isMkactivitiesShow: true, mkCode: '', uploadData:[], storeId : '', mkaId : '', mall2PointsRulesDetil:{}, pointsType:"" }, methods: { query: function () { vm.reload(); }, add: function () { vm.showList = false; vm.title = "新增"; // vm.getCategories(); // vm.getCategories2(); // vm.getCategories3(); vm.mall2PointsRulesDetil = {}; }, update: function (event) { let id = getSelectedRow(); if (id == null) { return; } console.log("id") console.log(id) // vm.getCategories(); // vm.getCategories2(); // vm.getCategories3(); vm.showList = false; vm.title = "修改"; vm.getInfo(id) }, saveOrUpdate: function (event) { console.log(vm.mall2PointsRulesDetil.id) let url = vm.mall2PointsRulesDetil.id == null ? "../mall2pointsrulesdetil/save" : "../mall2pointsrulesdetil/update"; vm.mall2PointsRulesDetil.mkaId = vm.mkaId; $.ajax({ type: "POST", url: url, contentType: "application/json", data: JSON.stringify(vm.mall2PointsRulesDetil), success: function (r) { if (r.code === 0) { alert('操作成功', function (index) { vm.reload(); }); } else { alert(r.msg); } } }); }, del: function (event) { let mafrIds = getSelectedRows(); if (mafrIds == null){ return; } confirm('确定要删除选中的记录?', function () { $.ajax({ type: "POST", url: "../mall2pointsrules/deleteDetil/"+vm.mkaId, contentType: "application/json", data: JSON.stringify(mafrIds), success: function (r) { if (r.code == 0) { alert('操作成功', function (index) { $("#jqGrid").trigger("reloadGrid"); }); } else { alert(r.msg); } } }); }); }, getInfo: function(id){ $.get("../mall2pointsrulesdetil/info/"+id, function (r) { vm.mall2PointsRulesDetil = r.mall2PointsRulesDetil; vm.mall2PointsRulesDetil.pointsRulesName=r.mall2PointsRulesDetil.pointsDetilNameId; vm.mall2PointsRulesDetil.storeName=r.mall2PointsRulesDetil.pointsStoreName; }); }, reloadSearch: function() { vm.q={ pointsDetilNameId:null, pointsDetilName:null }, vm.reload(); }, reload: function (event) { vm.showList = true; let page = $("#jqGrid").jqGrid('getGridParam', 'page'); $("#jqGrid").jqGrid('setGridParam', { postData: {'pointsDetilNameId': vm.q.pointsDetilNameId,'pointsDetilName':vm.q.pointsDetilName,'mkaId': vm.mkaId}, page: page }).trigger("reloadGrid"); vm.handleReset('formValidate'); }, handleSubmit: function (name) { handleSubmitValidate(this, name, function () { vm.saveOrUpdate() }); }, //商品条码 getCategories: function () { $.get("../sys/macro/queryMacrosByValueRuRules?id=70", function (r) { vm.categories = r.list; }); }, //门店名称 getCategories2: function () { $.get("../sys/macro/queryMacrosByValueRuRules?id=70", function (r) { vm.categories2 = r.list; }); }, //商品类别 getCategories3: function () { $.get("../sys/macro/queryMacrosByValueRuRules?id=70", function (r) { vm.categories3 = r.list; }); }, handleReset: function (name) { vm.mall2PointsRulesDetil={} handleResetForm(this, name); }, //返回积分规则设置页 reloadMkactivities: function () { window.location.href = "/vip/mall2pointsrules.html"; }, uploadExcelSuccess: function (data) { // console.log(data); if(data.code==0){ alert('导入成功', function (index) { $("#jqGrid").trigger("reloadGrid"); }); }else{ alert(data.msg); } $("#isDisplay").removeAttr("disabled") }, uploadExcelError: function () { alert('上传出现异常,请重试!'); }, uploadExcelFormatError: function (file) { this.$Notice.warning({ title: '文件格式不正确', desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。' }); },beforeUpload(){ vm.uploadData = { mkaId : vm.mkaId } let promise = new Promise((resolve) => { this.$nextTick(function () { resolve(true); }); }); return promise; //通过返回一个promis对象解决 }, } });