/** * @m-choose-class 选择分类 * @m-show-choose-class 显示已选中的分类列表 */ Vue.component('m-choose-class', { template: `
搜索

已选 {{chooseIdList.length}}/20

确定
`, props: { 'showChooseClass': { type: Boolean, default: false, }, 'usedIdList': { type: Array, default: () => { return [] }, },//已选ID列表 'storeId': { type: String, default: '', },//门店ID }, data() { return { searchForm: { exists_class_id_arr: '', class_name: '', store_id: '', page: 1, limit: 10, }, currentLen: 0, dataList: [], chooseList: [],//本次已选分类列表 chooseIdList: [],//本次已选分类ID列表 refresh: false, } }, methods: { closeDialog(type) { console.log(this.chooseList); this.$emit('close', type === 1 ? this.chooseList : []); }, seeGoods(item) { this.$root.$refs.base.chooseGoods({ goods_ids: [], store_id: this.storeId, class_id: item.id_list, needChoose: false, }); }, verifyUsed(id) { return this.chooseIdList.indexOf(id) >= 0 ? true : false; }, chooseIt(item) { this.chooseList.push(item); this.chooseIdList.push(item.id); this.refresh = true; this.$nextTick(() => { this.refresh = false; }) }, // 切换记录每页数量 limitChange(val) { this.searchForm.limit = val; this.searchForm.page = 1; this.getClassList(); }, // 切换记录页数 pageChange(val) { this.searchForm.page = val; this.getClassList(); }, // 分类列表 getClassList() { $.ajax({ url: '/index.php/Retail/Mcoupon/appointGoodsClass', type: "post", data: this.searchForm, success: (res) => { if (res.status == 1) { this.dataList = res.data.list; this.currentLen = res.data.count * 1; } else { this.dataList = []; this.currentLen = 0; } } }) }, }, watch: { showChooseClass(n, o) { if (n) { this.searchForm.store_id = this.storeId; this.$nextTick(() => { this.searchForm.exists_class_id_arr = this.chooseIdList.join(','); this.pageChange(1); }) } else { this.searchForm = { exists_class_id_arr: '', class_name: '', store_id: '', page: 1, limit: 10, }; this.currentLen = 0; this.dataList = []; this.chooseList = [];//本次已选分类列表 this.chooseIdList = [];//本次已选分类ID列表 this.refresh = false; } }, usedIdList(n) { this.chooseIdList = JSON.parse(JSON.stringify(n)); } }, }); Vue.component('m-show-choose-class', { template: ` `, props: { 'classList': { type: Array, default: () => { return []; }, }, 'storeId': { type: String, default: '', },//门店ID 'operateState': { type: Boolean, default: false, },//操作的权限 }, data() { return { formDis: true, } }, methods: { //查看商品 seeGoods(item) { this.$root.$refs.base.chooseGoods({ goods_ids: [], store_id: this.storeId, class_id: item.id_list, needChoose: false, }); }, //移除已选商品 removeClass(index, class_id) { this.classList.splice(index, 1); this.$nextTick(() => { this.$emit('del', class_id); }); }, }, });