define({ name:"auth", template:`
权限
{{item.title}}
仅控制购买权限,浏览权限按整个商品;选全部规格按整个商品控制
{{item.level_name}}
{{item.level_name}}
{{item.group_name}}
{{item.group_name}}
每次下单限购数量
会员限购的总数
会员每天限购数量
会员每周限购数量
会员每月限购数量
会员单次最少购买数量,为空、0不限制
如设置为1,则今日售出1件(需已支付),会员今天无法再购买此商品
会员单次最少购买数量,为空、0不限制
`, style:` .auth .checkbo-group { display: flex; flex-flow: wrap; white-space: pre-wrap; } .auth .checkbo-group .el-checkbox { line-height: 25px; } `, props: { form: { default() { return {} } } }, data(){ // let intReg = /^[0-9]*$/; // let validateNum = (rule,value, callback) => { // let regular = intReg.test(value); // if(!value){ // callback(); // }else{ // if (regular) { // callback(); // }else{ // callback(new Error("请输入正整数")); // } // } // }; return { goodsOptionIds:[], //商品规格购物权限 levelAccessList:[],//会员等级浏览权限 levelBuyList:[],//会员等级购买权限 vipAccessList:[],//会员组浏览权限 vipBuyList:[],//会员组购买权限 levels: [], groups: [], goodsOption:[], json: { show_levels: '', show_groups: '', buy_levels: '', buy_groups: '', once_buy_limit: '', total_buy_limit: '', day_buy_limit: '', week_buy_limit: '', month_buy_limit: '', min_buy_limit: '', day_buy_total_limit:'', buy_multiple:'', option_buy_limit:'', }, // rules:{ // once_buy_limit: {validator: validateNum }, // total_buy_limit: {validator: validateNum }, // day_buy_limit: {validator: validateNum }, // week_buy_limit: {validator: validateNum }, // month_buy_limit: {validator: validateNum }, // min_buy_limit: {validator: validateNum }, // }, } }, mounted(){ if (this.form && this.form.privilege) { let data = this.form.privilege; this.json = this.pick(data, [ "show_levels", "show_groups", "buy_levels", "buy_groups", 'once_buy_limit', 'total_buy_limit', 'day_buy_limit', 'week_buy_limit', 'month_buy_limit', 'min_buy_limit', 'day_buy_total_limit', 'buy_multiple', 'option_buy_limit', ]); this.levelAccessList = data.show_levels ? data.show_levels.split(",") : ['']; this.vipAccessList = data.show_groups ? data.show_groups.split(",") : ['']; this.levelBuyList = data.buy_levels ? data.buy_levels.split(",") : ['']; this.vipBuyList = data.buy_groups ? data.buy_groups.split(",") : ['']; this.goodsOptionIds = data.option_buy_limit ? data.option_buy_limit.split(",") : ['']; } this.levels = this.form.levels ? JSON.parse(JSON.stringify(this.form.levels)) : []; this.groups = this.form.groups ? JSON.parse(JSON.stringify(this.form.groups)) : []; this.goodsOption = this.form.goods_option ? JSON.parse(JSON.stringify(this.form.goods_option)) : []; }, methods:{ pick(obj, params) { return params.reduce((iter, val) => (val in obj && (iter[val] = obj[val]?obj[val]:''), iter), {}); }, async validate(){ return this.json; }, handleCheckedChange(checked,type) { console.log(checked); let isCheckAll = false; let checkAll = []; checked.forEach((item, index) => { if (item === '' && checked.length > 1) { if (index !== 0) { isCheckAll = true; checkAll = ['']; } } else { checkAll.push(item); } }); let levelStr = isCheckAll ? '' : checkAll.join(','); if(type == 'option') { this.json.option_buy_limit = levelStr; this.goodsOptionIds = checkAll; } if(type == 'watch') { this.json.show_levels = levelStr; this.levelAccessList = checkAll; } if(type == 'buy') { this.json.buy_levels = levelStr; this.levelBuyList = checkAll; } if(type == 'watches'){ this.json.show_groups = levelStr; this.vipAccessList = checkAll; } if(type == 'buys'){ this.json.buy_groups = levelStr; this.vipBuyList = checkAll; } }, } })