1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<template>
  <!--
          作者:luoyiming
          时间:2019-06-04
          描述:插件中心-分销-分销设置-基础设置
      -->
  <div class="product-add mt30">
    <!--form表单-->
    <el-form size="small" ref="form" :model="form" label-width="200px">
      <el-form-item label="是否开启代理收益功能">
        <div>
          <el-radio v-model="form.is_open" label="1">开启</el-radio>
          <el-radio v-model="form.is_open" label="0">关闭</el-radio>
        </div>
      </el-form-item>
      <el-form-item label="可申请成为代理条件">
        <div>
          <el-radio-group @change="chooseBecomeType" v-model="form.become">
            <el-radio :label="10">无条件</el-radio>
            <el-radio :label="40">下级分销商总数</el-radio>
            <el-radio :label="50">累计佣金总数</el-radio>
            <el-radio :label="90">单次消费</el-radio>
            <el-radio :label="100">购买指定商品</el-radio>
          </el-radio-group>
        </div>
      </el-form-item>
      <el-form-item :label="label_name" v-if="form.become!=10&&form.become!=100">
        <div>
          <el-input v-model="form.province_condition" type="number" class="max-w460">
            <template slot="prepend">省运营中心满</template>
            <template slot="append">{{unit}}</template>
          </el-input>
        </div>
        <div>
          <el-input v-model="form.city_condition" type="number" class="max-w460 mt10">
            <template slot="prepend">市运营中心满</template>
            <template slot="append">{{unit}}</template>
          </el-input>
        </div>
        <div>
          <el-input v-model="form.area_condition" type="number" class="max-w460 mt10">
            <template slot="prepend">区/县运营中心满</template>
            <template slot="append">{{unit}}</template>
          </el-input>
        </div>
      </el-form-item>
 
      <el-form-item label="" v-if="form.become == 100">
        <div>
          <el-row>
            <el-button type="primary" @click="openProduct">选择商品</el-button>
            <div v-if="form.product_image && form.product_image.length > 0" class="d-s-c f-w">
              <div v-for="(item, index) in form.product_image" :key="index" class="img pr">
                <a href="javascript:void(0)" class="delete-btn" @click="deleteFunc(index)"><i class="el-icon-error"></i></a>
                <img :src="item.image" width="100" height="100" />
                <p class="text-ellipsis">{{ item.product_name }}</p>
              </div>
            </div>
          </el-row>
        </div>
      </el-form-item>
      <!--提交-->
      <div class="common-button-wrapper">
        <el-button size="small" type="primary" @click="onSubmit" :loading="loading">提交</el-button>
      </div>
    </el-form>
    <!--产品列表弹出层组件-->
    <Product :isproduct="isproduct" @closeDialog="closeDialogFunc($event)">产品列表弹出层</Product>
  </div>
</template>
 
<script>
import PlusApi from '@/api/plus/operations.js';
import Product from '@/components/product/Product';
export default {
  components: {
    /*产品列表组件*/
    Product: Product
  },
  data() {
    return {
      /*form表单数据*/
      form: {
        is_open: '',
        level: '',
        self_buy: '',
        self_buy_money: '',
        become: 10
      },
      /*是否打开产品弹出层*/
      isproduct: false,
      /*是否正在加载*/
      loading: false,
      label_name: '',
      unit: ''
    };
  },
  props:{
    settingData:Object
  },
  created() {
    this.form = this.settingData.data.basic.values;
    this.form.become = parseInt(this.form.become);
    this.chooseBecomeType(this.form.become);
    if (!this.form.product_image) {
      this.form.product_image = [];
    }
  },
  methods: {
 
    /*提交表单*/
    onSubmit() {
      let self = this;
      self.loading = true;
      let params = this.form;
      PlusApi.basic(params, true)
        .then(data => {
          self.loading = false;
          self.$message({
            message: '恭喜你,设置成功',
            type: 'success'
          });
 
        })
        .catch(error => {
          self.loading = false;
        });
    },
    chooseBecomeType(e) {
      switch(e) {
        case 40:
          this.label_name = '下级分销商总数'
          break;
        case 50:
          this.label_name = '累计佣金总数'
          break;
        case 70:
          this.label_name = '累计团队业绩'
          break;
        case 80:
          this.label_name = '团队总人数'
          break;
        case 90:
          this.label_name = '单次消费'
          break;
      }
      if (e == 40 || e == 80) {
        this.form.province_condition = parseInt(this.form.province_condition);
        this.form.city_condition = parseInt(this.form.city_condition);
        this.form.area_condition = parseInt(this.form.area_condition);
        this.unit = '人';
      } else {
        this.unit = '元';
      }
    },
    /*删除商品*/
    deleteFunc(i) {
      this.form.become__buy_product_ids.splice(i, 1);
      this.form.product_image.splice(i, 1);
    },
 
    /*产品列表弹出层*/
    openProduct() {
      this.isproduct = true;
    },
 
    /*关闭弹窗*/
    closeDialogFunc(e) {
      this.isproduct = e.openDialog;
      if (e.type == 'success') {
        if (this.form.become__buy_product_ids.indexOf(e.params.product_id) == -1) {
          this.form.become__buy_product_ids.push(e.params.product_id);
          this.form.product_image.push({ product_id: e.params.product_id, image: e.params.image,product_name: e.params.product_name });
        } else {
          this.$message({
            message: '已选择该商品',
            type: 'warning'
          });
        }
      }
    }
  }
};
</script>
 
<style>
.tips {
  color: #ccc;
}
</style>