quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<template>
  <!--
      作者 luoyiming
      时间:2020-06-09
      描述:会员-等级管理-添加等级
  -->
  <el-dialog title="添加等级" :visible.sync="dialogVisible" @close='dialogFormVisible' :close-on-click-modal="false"
    :close-on-press-escape="false" width="600px">
    <el-form size="small" :model="form" ref="form">
      <el-form-item label="等级名称" :label-width="formLabelWidth" prop="name" :rules="[{required: true,message: '请输入等级名称'}]">
        <el-input v-model="form.name" placeholder="请输入等级名称"></el-input>
      </el-form-item>
      <el-form-item label="等级权重" :label-width="formLabelWidth" prop="weight" :rules="[{required: true,message: '请输入等级权重'}]">
        <el-input v-model="form.weight" type="number" placeholder="请输入等级权重"></el-input>
        <div class="gray9">权重越大,等级越高</div>
      </el-form-item>
      <el-form-item label="分红比例" :label-width="formLabelWidth" prop="equity" :rules="[{required: true,message: '请输入分红比例'}]">
        <el-input type="number" :precision="1" :step="1" :min="0" :max="100" placeholder="请输入分红比例" v-model="form.equity">
            <template slot="append">%</template>
        </el-input>
         <div class="gray9">队长分红=(实际付款金额 + 余额抵扣 - 运费)* 分红比例</div>
      </el-form-item>
      <el-form-item label="自动升级" :label-width="formLabelWidth" prop="auto_upgrade">
        <el-radio-group v-model="form.auto_upgrade">
          <el-radio :label="1">允许自动升级</el-radio>
          <el-radio :label="0">禁止自动升级</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="升级条件" :label-width="formLabelWidth">
        <div>
          <el-radio-group v-model="form.condition_type">
            <el-radio label="and">满足勾选的所有条件</el-radio>
            <el-radio label="or">满足勾选的任意条件</el-radio>
          </el-radio-group>
        </div>
        <div class="d-s-c mt16">
          <div class="mr10">
            <el-checkbox v-model="form.open_agent_money">累计佣金</el-checkbox>
            <el-input v-model="form.agent_money" type="number" :disabled="form.open_agent_money==0" style="width: 160px; margin-left: 10px;" >
              <template slot="append">元</template>
            </el-input>
          </div>
          <div>
            <el-checkbox v-model="form.open_agent_user">直推分销商</el-checkbox>
          <el-input v-model="form.agent_user" type="number" :disabled="form.open_agent_user==0" style="width: 160px;margin-left: 10px;">
            <template slot="append">人</template>
          </el-input>
          </div>
        </div>
        <div class="d-s-c mt16">
          <div class="mr10">
            <el-checkbox v-model="form.open_team_user">团队人数</el-checkbox>
            <el-input v-model="form.team_user" type="number" :disabled="form.open_team_user==0" style="width: 160px;margin-left: 10px;">
              <template slot="append">人</template>
            </el-input>
          </div>
          <div class="d-s-c">
            <el-checkbox v-model="form.open_team_money">团队业绩</el-checkbox>
            <el-input v-model="form.team_money" type="number" :disabled="form.open_team_money==0" style="width: 160px;margin-left: 10px;">
              <template slot="append">元</template>
            </el-input>
            <div><el-checkbox v-model="form.self_buy_money" class="pl10">包含个人业绩</el-checkbox></div>
          </div>
        </div>
        <div class="d-s-c mt16">
          <el-checkbox v-model="form.open_buy_product">购买指定商品</el-checkbox>
          <el-button type="primary" :disabled="form.open_buy_product==0" @click="openProduct">选择商品</el-button>
          <el-checkbox style="margin-left: 10px;" v-model="form.open_type_product">购买商品就升级</el-checkbox>
        </div>
        <div v-if="form.product_image && form.product_image.length > 0" class="d-s-c f-w product-team-image">
          <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" height="100" />
            <p class="text-ellipsis">{{ item.product_name }}</p>
          </div>
        </div>
      </el-form-item>
    </el-form>
 
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible">取 消</el-button>
      <el-button type="primary" @click="addGrade()" :disabled="submit_loading">确 定</el-button>
    </div>
    <!--产品列表弹出层组件-->
    <Product :isproduct="isproduct" append-to-body @closeDialog="closeDialogFunc($event)">产品列表弹出层</Product>
  </el-dialog>
</template>
 
<script>
  import UserApi from '@/api/plus/team.js';
  import Product from '@/components/product/Product';
  export default {
    components: {
      Product
    },
    data() {
      return {
        form: {
          /*昵称*/
          name: '',
          /*等级折扣*/
          equity: '',
          /*是否打开累计消费满*/
          open_money:0,
          /*累计消费满*/
          upgrade_money:0,
          /*是否打开累计积分满*/
          open_points:0,
          /*累计积分满*/
          upgrade_points:0,
          /*是否推荐人数满*/
          open_invite:0,
          /*推荐人数满*/
          upgrade_invite:0,
          /*等级权重*/
          weight: 100,
          /*自动升级*/
          auto_upgrade: 1,
          /*升级条件*/
          condition_type: 'and',
          /*是否开放累计推广佣金*/
          open_agent_money: 0,
          /*累计推广佣金*/
          agent_money: 0,
          /*是否开放直推分销商*/
          open_agent_user: 0,
          /*直推分销商*/
          agent_user: 0,
          /*是否开放团队人数*/
          open_team_user: 0,
          /*团队人数*/
          team_user: 0,
          /*是否开放团队业绩*/
          open_team_money: 0,
          /*团队业绩*/
          team_money: 0,
          /*是否包含个人业绩*/
          self_buy_money: 0,
          /*是否开放购买指定商品*/
          open_buy_product: 0,
          /*购买指定商品id列表*/
          product_ids: [],
          /*购买指定商品图片及名称列表*/
          product_image: [],
          /*购买商品就升级*/
          open_type_product: 0,
        },
        /*左边长度*/
        formLabelWidth: '120px',
        /*是否显示*/
        dialogVisible: false,
        /*是否正在提交*/
        submit_loading: false,
        /*是否显示产品列表弹出层*/
        isproduct: false
      };
    },
    props: ['open_add'],
    created() {
      this.dialogVisible = this.open_add;
    },
    methods: {
 
      /*添加等级*/
      addGrade() {
        let self = this;
        let params = this.form;
        self.$refs.form.validate((valid) => {
          if (valid) {
            self.submit_loading = true;
            params.open_agent_money = params.open_agent_money == true ? 1 : 0;
            params.open_agent_user = params.open_agent_user == true ? 1 : 0;
            params.open_team_money = params.open_team_money == true ? 1 : 0;
            params.open_team_user = params.open_team_user == true ? 1 : 0;
            params.self_buy_money = params.self_buy_money == true ? 1 : 0;
            params.open_buy_product = params.open_buy_product == true ? 1 : 0;
            params.open_type_product = params.open_type_product == true ? 1 : 0;
            UserApi.addgrade(params, true).then(data => {
                self.submit_loading = false;
                self.$message({
                  message: data.msg,
                  type: 'success'
                });
                self.dialogFormVisible(true);
              })
              .catch(error => {
                self.submit_loading = false;
              });
          }
        });
      },
      /*关闭弹窗*/
      dialogFormVisible(e) {
        if (e) {
          this.$emit('closeDialog', {
            type: 'success',
            openDialog: false
          })
        } else {
          this.$emit('closeDialog', {
            type: 'error',
            openDialog: false
          })
        }
      },
      /*删除商品*/
      deleteFunc(i) {
        this.form.product_ids.splice(i, 1);
        this.form.product_image.splice(i, 1);
      },
      /*产品列表弹出层*/
      openProduct() {
        this.isproduct = true;
        this.$nextTick(() => {
          setTimeout(() => {
            // 强制提升所有弹窗和遮罩层的z-index
            const dialogWrappers = document.querySelectorAll('.el-dialog__wrapper');
            const modals = document.querySelectorAll('.v-modal');
 
            // 为每个弹窗设置递增的z-index
            dialogWrappers.forEach((dialog, index) => {
              dialog.style.zIndex = 2000 + (index * 10) + 5;
            });
 
            // 为每个遮罩层设置递增的z-index(略低于对应弹窗)
            modals.forEach((modal, index) => {
              modal.style.zIndex = 2000 + (index * 10);
            });
          }, 50);
        });
      },
      /*关闭弹窗*/
      closeDialogFunc(e) {
        this.isproduct = e.openDialog;
        if (e.type == 'success') {
          if (this.form.product_ids == '') {
            this.form.product_ids = [];
            this.form.product_image = [];
          }
          if (this.form.product_ids.indexOf(e.params.product_id) == -1) {
            this.form.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>
.product-team-image p{
  width: 100px;
}
.product-team-image{
  margin-top: 10px;
  .delete-btn {
    position: absolute;
    display: block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    right: -8px;
    top: -8px;
    color: red;
  }
}
</style>