Vue.component('template-manage-brand', { template: `
查询 新增
保存
`, props: { 'type': { type: Number, default: 1, },//请求用户类型 1商户 2门店 }, data() { return { brandList: [], // 数据 searchForm: { add_time: '', name: '', },//搜索表单 page: 1, // 分页 limit: 10, // 每页显示条数 count: 0, // 总条数 showAddBrand: false, //是否显示添加 operate: {}, //权限 addForm: { id: 0, name: '', },//新增、编辑表单 }; }, methods: { /* 获取数据 */ getBrandList() { this.brandList = []; this.loading = true; $.ajax({ url: '/index.php/Retail/GoodsBrand/getGoodsBrandList', type: "post", data: { page: this.page, limit: this.limit, type: this.type, ...this.searchForm, }, success: (res) => { this.loading = false; if (res.status == 1) { this.count = res.total; this.brandList = res.data; } }, error: () => { this.loading = false; } }) }, //查询 searchData() { this.page = 1; this.getBrandList(); }, /* 切换每页数量 */ sizeChange(val) { this.limit = val; this.page = 1; this.getBrandList(); }, /* 切换页数 */ currentChange(val) { this.page = val; this.getBrandList(); }, //编辑 editBrand(item) { this.addForm = { id: item.id, name: item.name, }; this.showAddBrand = true; }, //保存品牌 saveBrand() { this.$confirm("确认要保存该品牌的设置吗?", "温馨提示", { confirmButtonText: '保存', cancelButtonText: '取消', type: 'info' }).then(() => { this.$loading({ lock: true, text: '保存中,请等待', spinner: 'el-icon-loading', background: 'rgba(255, 255, 255, 0.7)' }); $.ajax({ url: '/index.php/Retail/GoodsBrand/goodsBrandAdd', type: "post", data: this.addForm, success: (res) => { this.$loading().close(); if (res.status == 1) { this.showAddBrand = false; this.$message({ message: res.msg, type: 'success', duration: 1000 }); this.getBrandList(); this.addForm = { id: 0, name: '', }; } else { this.$message({ message: res.msg, type: 'error', duration: 1500 }) } }, error: () => { this.$loading().close(); } }) }).catch(() => { }) }, //删除品牌 delBrand(id) { this.$confirm("确认要删除该品牌吗?", "温馨提示", { confirmButtonText: '删除', cancelButtonText: '取消', type: 'info' }).then(() => { this.$loading({ lock: true, text: '删除中,请等待', spinner: 'el-icon-loading', background: 'rgba(255, 255, 255, 0.7)' }); $.ajax({ url: '/index.php/Retail/GoodsBrand/delGoodsBrand', type: "post", data: { id: id }, success: (res) => { this.$loading().close(); if (res.status == 1) { this.$message({ message: res.msg, type: 'success', duration: 1000 }); this.getBrandList(); } else { this.$message({ message: res.msg, type: 'error', duration: 1500 }) } }, error: () => { this.$loading().close(); } }) }).catch(() => { }) }, //获取用户权限 getOperate() { var auth_list = { goodsBrandAdd: '/index.php/Retail/GoodsBrand/goodsBrandAdd', }; $.ajax({ url: '/index.php/Retail/Component/checkOperateAuth', type: "post", data: { auth_list: JSON.stringify(auth_list), }, success: (res) => { if (res.status == 1) { this.operate = res.data; } } }) } }, created: function () { this.getOperate(); this.getBrandList(); }, })