$(function () { $("#jqGrid").jqGrid({ url: '../brand/list', datatype: "json", colModel: [{ label: 'id', name: 'id', index: 'id', key: true, width: 140,align: 'center' }, {label: '所属商户', name: 'merchName', index: 'merchName', width: 180, align: 'center'}, {label: '所属门店', name: 'storeName', index: 'storeName', width: 180, align: 'center'}, {label: '所属分类', name: 'categoryName', index: 'categoryName', width: 180, align: 'center'}, { label: '品牌名称', name: 'name', index: 'name', width: 300 }, { label: '图片', name: 'listPicUrl', index: 'list_pic_url', width: 100, align: 'center', formatter: function (value) { return transImg(value); } }, { label: '描述', name: 'simpleDesc', index: 'simple_desc', width: 100 }, { label: '图片', name: 'picUrl', index: 'pic_url', width: 100, align: 'center', formatter: function (value) { return transImg(value); } }, { label: '排序', name: 'sortOrder', index: 'sort_order', width: 100, align: 'center' }, { label: '显示', name: 'isShow', index: 'is_show', width: 100, align: 'center', formatter: function (value) { return transIsNot(value) } }, { label: '展示价格', name: 'floorPrice', index: 'floor_Price', width: 100, align: 'right' }, { label: 'app显示图片', name: 'appListPicUrl', index: 'app_list_pic_url', align: 'center', width: 100, formatter: function (value) { return transImg(value); } }, { label: '新品牌', name: 'isNew', index: 'is_new', align: 'center', width: 100, formatter: function (value) { return transIsNot(value) } }, { label: '新品牌图片', name: 'newPicUrl', index: 'new_pic_url', align: 'center', width: 100, formatter: function (value) { return transImg(value); } }, { label: '新品牌排序', name: 'newSortOrder', index: 'new_sort_order', align: 'center', width: 80 }, {label: '操作', width: 150, align: 'center', sortable: false, formatter: function (value, col, row) { if(hasPermission('brand:saveCopyBrand')) { return "    "; }else { return '-' } } }], viewrecords: true, height: 550, rowNum: 10, rowList: [10, 30, 50], rownumbers: true, rownumWidth: 25, autowidth: true, shrinkToFit: false, autoScroll: true, //开启水平滚动条 width: 1500, 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": "scroll"}); } }); }); var vm = new Vue({ el: '#rrapp', data: { showList: true, title: null, brand: {listPicUrl: '', picUrl: '', appListPicUrl: '', newPicUrl: '', isShow: 1, isNew: 0}, ruleValidate: { name: [ {required: true, message: '品牌名称不能为空', trigger: 'blur'} ], listPicUrl: [ {required: true, message: '品牌图片不能为空', trigger: 'blur'} ], simpleDesc: [ {required: true, message: '品牌描述不能为空', trigger: 'blur'} ], picUrl: [ {required: true, message: '品牌图片不能为空', trigger: 'blur'} ], // sortOrder: [ // {required: true, message: '排序不能为空', trigger: 'blur'} // ], // floorPrice: [ // {required: true, message: '展示价格不能为空', trigger: 'blur'} // ], appListPicUrl: [ {required: true, message: 'app显示图片不能为空', trigger: 'blur'} ], newPicUrl: [ {required: true, message: '新品牌图片不能为空', trigger: 'blur'} ] }, q: { name: '', storeId: '' }, storeList: [], merchList: [], categories: [],//一级分类 copyBrandDto: {brandId: '', storeList:"", categoryList:""}, showCopyList: true, showViewList: false, stores: [], }, methods: { copyBrand: function(id){ vm.copyBrandDto.brandId = id; vm.copyBrandDto.storeList = ""; vm.copyBrandDto.categoryList = ""; vm.showCopyList = false; vm.showList = true; vm.showViewList = true; vm.title = "复制品牌"; }, handleSubmitCopyBrand: function () { if(vm.copyBrandDto.brandId == ""){ alert('品牌id不能为空'); return; } if(vm.copyBrandDto.storeList == ""){ alert('门店id批量上传数据没有上传或未上传成功'); return; } if(vm.copyBrandDto.categoryList == ""){ alert('分类id批量上传数据没有上传或未上传成功'); return; } var url = "../brand/saveCopyBrand"; $.ajax({ type: "POST", url: url, contentType: "application/json", data: JSON.stringify(vm.copyBrandDto), success: function (r) { if (r.code === 0) { alert('操作成功', function (index) { vm.showCopyList = true; vm.showList = true; vm.showViewList = false; vm.reload(); }); } else { alert(r.msg); } } }); }, uploadExcelSuccess: function (data) { if(data.code==0){ alert(data.msg, function (index) { vm.copyBrandDto.storeList = data.copyBrandDto.storeList; vm.copyBrandDto.categoryList = data.copyBrandDto.categoryList; }); }else{ alert(data.msg); } }, uploadExcelError: function (data) { console.log(data); alert('上传出现异常,请重试!'); }, uploadExcelFormatError: function (file) { this.$Notice.warning({ title: '文件格式不正确', desc: '文件 ' + file.name + ' 格式不正确,请上传 xls 或 xlsx 格式的文件。' }); }, query: function () { vm.reload(); }, add: function () { vm.showList = false; vm.showCopyList = true; vm.showViewList = true; vm.title = "新增"; vm.brand = {listPicUrl: '', picUrl: '', appListPicUrl: '', newPicUrl: '', isShow: 1, isNew: 0}; vm.storeList = []; vm.merchList = []; vm.getMerchList(); }, update: function (event) { var id = getSelectedRow(); if (id == null) { return; } vm.showList = false; vm.showCopyList = true; vm.showViewList = true; vm.title = "修改"; vm.brand = {listPicUrl: '', picUrl: '', appListPicUrl: '', newPicUrl: '', isShow: 1, isNew: 0}; vm.storeList = []; vm.merchList = []; vm.getInfo(id); vm.getMerchList(); vm.getStoresByMerch(); }, saveOrUpdate: function (event) { var url = vm.brand.id == null ? "../brand/save" : "../brand/update"; $.ajax({ type: "POST", url: url, contentType: "application/json", data: JSON.stringify(vm.brand), success: function (r) { if (r.code === 0) { alert('操作成功', function (index) { vm.reload(); }); } else { alert(r.msg); } } }); }, del: function (event) { var ids = getSelectedRows(); if (ids == null) { return; } confirm('确定要删除选中的记录?', function () { $.ajax({ type: "POST", url: "../brand/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); } } }); }); }, getInfo: function (id) { $.get("../brand/info/" + id, function (r) { vm.brand = r.brand; }); }, getStoresByMerch: function (opt) { var value = opt.value; $.get("../store/getStoresByMerch?merchSn=" + value, function (r) { vm.storeList = r.list; }); }, getCategoryByStore: function (opt) { var value = opt.value; vm.getCategories(value); }, getMerchList: function() { $.get("../merch/queryAll", function (r) { vm.merchList = r.list; }); }, getCategories: function (storeId) { $.get("../category/getCategorySelect?isShow=1&storeId=" + storeId, function (r) { vm.categories = r.list; }); }, reload: function (event) { vm.showViewList = false; vm.showList = true; vm.showCopyList = true; var page = $("#jqGrid").jqGrid('getGridParam', 'page'); $("#jqGrid").jqGrid('setGridParam', { postData: {'name': vm.q.name,'storeId':vm.q.storeId}, page: page }).trigger("reloadGrid"); vm.handleReset('formValidate'); }, handleSuccessListPicUrl: function (res, file) { vm.brand.listPicUrl = file.response.url; }, handleSuccessPicUrl: function (res, file) { vm.brand.picUrl = file.response.url; }, handleSuccessAppListPicUrl: function (res, file) { vm.brand.appListPicUrl = file.response.url; }, handleSuccessNewPicUrl: function (res, file) { vm.brand.newPicUrl = file.response.url; }, handleFormatError: function (file) { this.$Notice.warning({ title: '文件格式不正确', desc: '文件 ' + file.name + ' 格式不正确,请上传 jpg 或 png 格式的图片。' }); }, handleMaxSize: function (file) { this.$Notice.warning({ title: '超出文件大小限制', desc: '文件 ' + file.name + ' 太大,不能超过 100k。' }); }, eyeImageListPicUrl: function () { var url = vm.brand.listPicUrl; eyeImage(url); }, eyeImagePicUrl: function () { var url = vm.brand.picUrl; eyeImage(url); }, eyeImageAppListPicUrl: function () { var url = vm.brand.appListPicUrl; eyeImage(url); }, eyeImageNewPicUrl: function () { var url = vm.brand.newPicUrl; eyeImage(url); }, handleSubmit: function (name) { handleSubmitValidate(this, name, function () { vm.saveOrUpdate() }); }, handleReset: function (name) { handleResetForm(this, name); } }, mounted() { $.get("../store/queryAll", function (r) { vm.stores = r.list; }); } });