| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392 |
- <template id="com-distribution">
- <div class="com-distribution">
- <el-card class="edit-card" shadow="never">
- <div slot="header" class="clearfix">
- <div class="card-title">分销设置<span class="card-sub-title"></span></div>
- </div>
- <el-form :model="form" size="small">
- <el-tabs v-model="activeName" @tab-click="handleClick">
- <el-tab-pane v-for="(config,key) in form" v-if="commission_type_map[key]" :label="commission_type_map[key]" :name="key" :key="key">
- <el-form-item label="是否开启分销" prop="is_enable">
- <el-switch :active-value="1" :inactive-value="0" v-model="config.is_enable"></el-switch>
- </el-form-item>
- <el-row :gutter="24" v-if="config.is_enable == 1">
- <el-col :span="24">
- <el-card shadow="always">
- <el-form-item label="分销类型" prop="is_percent">
- <el-radio-group v-model="config.is_percent">
- <el-radio :label="0" class="grid-content bg-purple">百分比</el-radio>
- <el-radio :label="1" class="grid-content bg-purple">固定{{commission_type_map[config.commission_type]}}</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item>
- <template v-if="config.settings == 0 || is_attr == 0">
- <el-table ref="normal" :data="level_arr.Distribution" border stripe style="width: 100%;" @selection-change="handleSelectionChange">
- <el-table-column width="100" label="等级名称" prop="name"></el-table-column>
- <el-table-column label="一级分销" width="300" v-if="levels>=1">
- <template slot-scope="scope">
- <el-input v-model="config.detail[scope.row.level].first_prize" onInput="value=toNumber(value,2)">
- <template slot="append" v-if="config.is_percent == 0">%</template>
- <template slot="append" v-if="config.is_percent == 1">
- <template v-if="config.commission_type == 'commission'">元</template>
- <template v-else-if="config.commission_type == 'hi_bei' || config.commission_type == 'hi_value'">枚</template>
- <template v-else="config.commission_type == 'score'">{{commission_type_map[config.commission_type]}}</template>
- </template>
- </el-input>
- </template>
- </el-table-column>
- <el-table-column label="二级分销" width="300" v-if="levels>=2">
- <template slot-scope="scope">
- <el-input v-model="config.detail[scope.row.level].second_prize" onInput="value=toNumber(value,2)">
- <template slot="append" v-if="config.is_percent == 0">%</template>
- <template slot="append" v-if="config.is_percent == 1">
- <template v-if="config.commission_type == 'commission'">元</template>
- <template v-else-if="config.commission_type == 'hi_value' || config.commission_type == 'hi_bei'">枚</template>
- <template v-else="config.commission_type == 'score'">{{commission_type_map[config.commission_type]}}</template>
- </template>
- </el-input>
- </template>
- </el-table-column>
- <el-table-column label="三级分销" width="300" v-if="levels>=3">
- <template slot-scope="scope">
- <el-input v-model="config.detail[scope.row.level].third_prize" onInput="value=toNumber(value,2)">
- <template slot="append" v-if="config.is_percent == 0">%</template>
- <template slot="append" v-if="config.is_percent == 1">
- <template v-if="config.commission_type == 'commission'">元</template>
- <template v-else-if="config.commission_type == 'hi_value' || config.commission_type == 'hi_bei'">枚</template>
- <template v-else="config.commission_type == 'score'">{{commission_type_map[config.commission_type]}}</template>
- </template>
- </el-input>
- </template>
- </el-table-column>
- </el-table>
- </template>
- </el-form-item>
- </el-card>
- </el-col>
- </el-row>
- <template v-if="config.is_enable == 1 && key == 'score'">
- <div style="padding-top:20px"></div>
- <el-form-item label="是否开启发放等级">
-
- <template>
- <el-switch :active-value="1" :inactive-value="0" v-model="form[key].extra.score.enable_limit_level"></el-switch>
- <p style="color:#C0C4CC">开关开启后选的等级下单才会触发奖励</p>
- </template>
- <template v-if="form[key].extra.score.enable_limit_level == 1">
- <el-checkbox-group v-model="form[key].extra.score.limit_level">
- <el-checkbox v-for="(item, index) in level_list" :label="item.level" :key="index">{{item.name}}</el-checkbox>
- </el-checkbox-group>
- </template>
- </el-form-item>
- </template>
- </el-tab-pane>
- </el-tabs>
- <el-form-item label="单独设置复购等于报单">
- <el-switch v-model="form.distribution_is_alone" :active-value="1" :inactive-value="0">
- </el-switch>
- </el-form-item>
- <el-form-item label="是否单独设置计算方式" v-if="extend_data?.is_show_alone_computing_method">
- <el-switch v-model="form.is_alone_computing_method" :active-value="1" :inactive-value="0">
- </el-switch>
- <el-form-item prop="computing_method" label="" v-if="form.is_alone_computing_method == 1">
- <el-radio-group v-model="form.computing_method" size="small">
- <el-radio :label="0" border>支付价格</el-radio>
- <el-radio :label="1" border>商品售价</el-radio>
- <el-radio :label="2" border>商品利润</el-radio>
- </el-radio-group>
- </el-form-item>
- </el-form-item>
- <template v-if="is_install_regular_bonus == 1">
- <template v-if="activeName == 'commission'">
- <el-form-item label="是否启用返佣设置">
- <el-switch v-model="is_enable_regular_bonus" :active-value="1" :inactive-value="0" @change="handleEnableRegularBonus">
- </el-switch>
- </el-form-item>
- <el-row :gutter="24" v-if="is_enable_regular_bonus == 1">
- <el-col :span="24">
-
- <el-card shadow="always" v-for="(config,key) in form.commission.extra.RegularBonus" :key="key">
- <el-form-item label="分销类型" prop="is_percent">
- <el-radio-group v-model="config.is_percent">
- <el-radio :label="0" class="grid-content bg-purple">百分比</el-radio>
- <el-radio :label="1" class="grid-content bg-purple">固定{{commission_type_map[config.commission_type]}}</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item>
- <template>
- <el-table ref="normal" :data="level_arr.Distribution" border stripe style="width: 100%;" @selection-change="handleSelectionChange">
- <el-table-column width="100" label="等级名称" prop="name"></el-table-column>
- <el-table-column label="一级分销" width="300" v-if="levels>=1">
- <template slot-scope="scope">
- <el-input v-model="config.detail[scope.row.level].first_prize" onInput="value=toNumber(value,2)">
- <template slot="append" v-if="config.is_percent == 0">%</template>
- <template slot="append" v-if="config.is_percent == 1">
- <template v-if="config.commission_type == 'commission'">元</template>
- <template v-else-if="config.commission_type == 'hi_bei' || config.commission_type == 'hi_value'">枚</template>
- <template v-else="config.commission_type == 'score'">{{commission_type_map[config.commission_type]}}</template>
- </template>
- </el-input>
- </template>
- </el-table-column>
- <el-table-column label="二级分销" width="300" v-if="levels>=2">
- <template slot-scope="scope">
- <el-input v-model="config.detail[scope.row.level].second_prize" onInput="value=toNumber(value,2)">
- <template slot="append" v-if="config.is_percent == 0">%</template>
- <template slot="append" v-if="config.is_percent == 1">
- <template v-if="config.commission_type == 'commission'">元</template>
- <template v-else-if="config.commission_type == 'hi_value' || config.commission_type == 'hi_bei'">枚</template>
- <template v-else="config.commission_type == 'score'">{{commission_type_map[config.commission_type]}}</template>
- </template>
- </el-input>
- </template>
- </el-table-column>
- <el-table-column label="三级分销" width="300" v-if="levels>=3">
- <template slot-scope="scope">
- <el-input v-model="config.detail[scope.row.level].third_prize" onInput="value=toNumber(value,2)">
- <template slot="append" v-if="config.is_percent == 0">%</template>
- <template slot="append" v-if="config.is_percent == 1">
- <template v-if="config.commission_type == 'commission'">元</template>
- <template v-else-if="config.commission_type == 'hi_value' || config.commission_type == 'hi_bei'">枚</template>
- <template v-else="config.commission_type == 'score'">{{commission_type_map[config.commission_type]}}</template>
- </template>
- </el-input>
- </template>
- </el-table-column>
- </el-table>
- </template>
- </el-form-item>
- </el-card>
- </el-col>
- </el-row>
- </template>
- </template>
- </el-form>
- </el-card>
- </div>
- </template>
- <script>
- Vue.component('com-distribution', {
- template: "#com-distribution",
- props: {
- level_arr: {
- type: Object,
- default: () => {
- return {};
- }
- },
- setting: {
- type: Object,
- default: () => {
- return {};
- }
- },
- commission_type_map: {
- type: Object,
- default: () => {
- return {};
- }
- },
- extend_data: {
- type: Object,
- default: () => {
- return {
- is_show_alone_computing_method: false,
- };
- }
- }
- },
- data: function() {
- return {
- levels: 2,
- activeName: 'commission',
- form: {
- },
- black_list: [
- 'distribution_is_alone',
- 'distribution_setting'
- ],
- is_attr: 0,
- install: { // 初始化数据
- is_enable: 0,
- is_percent: 0,
- item_type: 'goods',
- commission_type: '',
- settings: 0,
- detail: {},
- extra:{
- },
- is_enable_regular_bonus: 0,
- },
- extra:{
- score: {
- enable_limit_level: 0,
- limit_level: []
- },
- RegularBonus: {
- commission: {
- is_percent: 0,
- commission_type: 'commission',
- detail: [],
- },
- }
- },
- level_list: [],
- is_install_regular_bonus: 0,
- is_enable_regular_bonus: 0,
- }
- },
- mounted() {
- this.loadData();
- },
- watch: {
- setting: {
- deep: true,
- immediate: true,
- handler(value) {
- if (!isEmpty(value)) {
- this.form = value;
- this.is_enable_regular_bonus = this.form.commission ? Number(this.form.commission.is_enable_regular_bonus) : 0
- }
- if (!this.form.distribution_is_alone) {
- this.$set(this.form, 'distribution_is_alone', 0)
- }
- }
- },
- level_arr: {
- deep: true,
- immediate: true,
- handler(value) {
- if (!isEmpty(value)) {
- let self = this;
- var data = value.Distribution;
- // 初始化赋值
- for (let name in self.commission_type_map) {
- let detail = {};
- var prize = isEmpty(self.form[name]) ? {} : self.form[name].detail;
- if (data) {
- Object.keys(data).forEach(function(key) {
- var formKey = data[key].level;
- Object.assign(detail, {
- [formKey]: {
- level: data[key].level,
- first_prize: !isEmpty(prize[formKey]) ? prize[formKey].first_prize : 0,
- second_prize: !isEmpty(prize[formKey]) ? prize[formKey].second_prize : 0,
- third_prize: !isEmpty(prize[formKey]) ? prize[formKey].third_prize : 0,
- }
- });
- });
- }
- // let extra = self.form[name] && !isEmpty(self.form[name].extra) ? self.form[name].extra : self.extra
- let extra = {}
- let baseExtra = JSON.parse(JSON.stringify(self.extra))
- let extra_fields = Object.keys(baseExtra)
- extra_fields.forEach(function(fields, key){
- let exists = false
- if(!isEmpty(self.form[name]) && !isEmpty(self.form[name].extra)){
- if(!isEmpty(self.form[name].extra[fields])){
- exists = true
- }
- }
- if(!exists) {
- extra[fields] = {}
- Object.assign(extra[fields], baseExtra[fields])
- let ckey = Object.keys(baseExtra[fields])[0]
- extra[fields][name] = JSON.parse(JSON.stringify(baseExtra[fields][ckey]))
- baseExtra[fields].ckey = undefined
- extra[fields] = JSON.parse(JSON.stringify(baseExtra[fields]))
- }else{
- extra[fields] = self.form[name].extra[fields]
- }
-
- if(fields == 'RegularBonus'){
- let detail2 = {}
- let prize2 = {}
- if(!isEmpty(self.form[name]) && !isEmpty(self.form[name].extra) && !isEmpty(self.form[name].extra[fields]) && !isEmpty(self.form[name].extra[fields][name]) && !isEmpty(self.form[name].extra[fields][name].detail)){
- prize2 = self.form[name].extra[fields][name]['detail']
- }
- if (data) {
- Object.keys(data).forEach(function(key) {
- let formKey = data[key].level
- Object.assign(detail2, {
- [formKey]: {
- level: data[key].level,
- first_prize: !isEmpty(prize2[formKey]) ? prize2[formKey].first_prize : 0,
- second_prize: !isEmpty(prize2[formKey]) ? prize2[formKey].second_prize : 0,
- third_prize: !isEmpty(prize2[formKey]) ? prize2[formKey].third_prize : 0,
- }
- });
- });
- if(!isEmpty(extra[fields]) && !isEmpty(extra[fields][name])){
- extra[fields][name]['detail'] = detail2
- }
- }
- }
- })
- self.install = {
- is_enable: isEmpty(self.form[name]) ? 0 : self.form[name].is_enable,
- is_percent: isEmpty(self.form[name]) ? 0 : self.form[name].is_percent,
- item_type: isEmpty(self.form[name]) ? 'goods' : self.form[name].item_type,
- commission_type: name,
- detail: detail,
- extra,
- is_enable_regular_bonus: isEmpty(self.form[name]) ? 0 : self.form[name].is_enable_regular_bonus
- };
-
- this.$set(self.form, name, JSON.parse(JSON.stringify(self.install)));
- }
- }
- }
- },
- form: {
- deep: true,
- immediate: true,
- handler(value) {
- this.$emit("change", JSON.stringify(value), "Distribution");
- }
- },
- },
- methods: {
- loadData() {
- this.cardLoading = true;
- request({
- params: {
- r: 'distribution/setting/config-setting',
- id: getQuery('id'),
- },
- method: 'get'
- }).then(e => {
- this.cardLoading = false;
- if (e.data.code == 0) {
- this.levels = e.data.data.levels;
- this.level_list = e.data.data.level_list
- this.is_install_regular_bonus = e.data.data.is_install_regular_bonus
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log(e);
- });
- },
- handleSelectionChange() {},
- handleClick(tab, event) {
- console.log(tab, event);
- },
- handleEnableRegularBonus(data) {
- for(let name in this.form) {
- if(name == 'commission'){
- this.form[name].is_enable_regular_bonus = data
- }
- }
- },
- }
- });
- </script>
|