doum
3 天以前 7c626e30b790489978150e57a2c7359934df32c7
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
<template>
  <div class="box" style="max-height:calc(100% - 60px);margin-bottom:50px;overflow-y: auto" >
    <el-form :model="form" ref="form">
      <div class="header">
        <span style="font-size: 15px; font-weight: bold">【1】注册奖励</span>
      </div>
      <div class="item-content">
        <el-form-item label="积分奖励" label-width="150px"  prop="regIntegralRewardStatus">
          <el-switch  v-model="form.regIntegralRewardStatus" :active-value="0" :inactive-value="1"    active-color="#13ce66"   inactive-color="#ff4949"  ></el-switch>
        </el-form-item>
        <el-form-item label="新人注册送" label-width="250px" prop="regIntegralReward">
          <el-input  style="width: 200px;margin: 0px 20px" type="number"   v-model="form.regIntegralReward"   placeholder="请输入"   v-trim>
            <template slot="append">积分</template>
          </el-input>
        </el-form-item>
      </div>
      <div class="item-content">
        <el-form-item label="优惠券奖励" label-width="150px"  prop="regCouponRewardStatus">
          <el-switch  v-model="form.regCouponRewardStatus" :active-value="0" :inactive-value="1"    active-color="#13ce66"   inactive-color="#ff4949"  ></el-switch>
        </el-form-item>
        <div  >
          <el-form-item label="新人注册送优惠券" label-width="250px" prop="regCouponRewardList">
          </el-form-item>
          <div  style="margin-left: 150px;border: 1px solid #f2f2f2">
            <el-table style="width: 600px;"  :data="form.regCouponRewardList">
              <el-table-column prop="shopPrice" label="优惠券" min-width="300px" align="center">
                <template slot-scope="{row}" >
                  <el-select v-model="row.couponId" style="width: 200px;margin: 0px 20px" clearable filterable   placeholder="请选择优惠券"  >
                    <el-option v-for="item in couponList"   :label="item.name"  :value="item.id">  </el-option>
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column prop="num" label="数量" min-width="200px" align="center">
                <template slot-scope="{row}" >
                  <el-input  style="width: 100px;margin: 0px 20px" type="number"   v-model="row.num"   placeholder="请输入数量"   v-trim/>
                </template>
              </el-table-column>
              <el-table-column  label="操作" min-width="100px" align="center">
                <template slot-scope="scope" >
                  <el-button style="color: red;border: none;" @click="delCoupon(0,scope.$index)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <el-button s type="primary" icon="el-icon-plus" @click="addCoupon(0)" style="height: 30px;margin: 10px;">添加</el-button>
          </div>
        </div>
      </div>
      <div class="header">
        <span style="font-size: 15px; font-weight: bold">【2】邀请好友奖励</span>
      </div>
      <div class="item-content">
        <el-form-item label="积分奖励" label-width="150px"  prop="shareIntegralRewardStatus">
          <el-switch  v-model="form.shareIntegralRewardStatus" :active-value="0" :inactive-value="1"    active-color="#13ce66"   inactive-color="#ff4949"  ></el-switch>
        </el-form-item>
        <el-form-item label="好友成功注册送邀请人" label-width="250px" prop="shareIntegralReward">
          <el-input  style="width: 200px;margin: 0px 20px" type="number"   v-model="form.shareIntegralReward"   placeholder="请输入"   v-trim>
            <template slot="append">积分</template>
          </el-input>
        </el-form-item>
      </div>
      <div class="item-content">
        <el-form-item label="优惠券奖励" label-width="150px"  prop="shareCouponRewardStatus">
          <el-switch  v-model="form.shareCouponRewardStatus" :active-value="0" :inactive-value="1"    active-color="#13ce66"   inactive-color="#ff4949"  ></el-switch>
        </el-form-item>
        <div  >
          <el-form-item label="好友完成首单送邀请人优惠券" label-width="250px" prop="shareCouponRewardList">
          </el-form-item>
          <div  style="margin-left: 150px;border: 1px solid #f2f2f2">
            <el-table style="width: 600px;"  :data="form.shareCouponRewardList">
              <el-table-column prop="couponId" label="优惠券" min-width="300px" align="center">
                <template slot-scope="{row}" >
                  <el-select v-model="row.couponId" style="width: 200px;margin: 0px 20px"  clearable filterable   placeholder="请选择优惠券"  >
                    <el-option v-for="item in couponList"   :label="item.name"  :value="item.id">  </el-option>
                  </el-select>
                </template>
              </el-table-column>
              <el-table-column prop="num" label="数量" min-width="200px" align="center">
                <template slot-scope="{row}" >
                  <el-input  style="width: 100px;margin: 0px 20px" type="number"   v-model="row.num"   placeholder="请输入数量"   v-trim/>
                </template>
              </el-table-column>
              <el-table-column  label="操作" min-width="100px" align="center">
                <template slot-scope="scope" >
                  <el-button style="color: red;border: none;" @click="delCoupon(1,scope.$index)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <el-button s type="primary" icon="el-icon-plus" @click="addCoupon(1)" style="height: 30px;margin: 10px;">添加</el-button>
          </div>
        </div>
      </div>
      <div class="header">
        <span style="font-size: 15px; font-weight: bold">【3】消费返积分</span>
      </div>
      <div class="item-content">
        <el-form-item label="返用户积分" label-width="150px"  prop="returnMemberIntegralStatus">
          <el-switch  v-model="form.returnMemberIntegralStatus" :active-value="0" :inactive-value="1"    active-color="#13ce66"   inactive-color="#ff4949"  ></el-switch>
        </el-form-item>
        <el-form-item label="订单实付金额每满" label-width="250px" prop="returnMemberIntegral">
          <el-input  style="width: 250px;margin: 0px 20px" type="number"   v-model="form.returnMemberIntegral"   placeholder="请输入"   v-trim>
            <template slot="append">元返用户1积分</template>
          </el-input>
          <p class="tip-warn" style="margin-bottom: 1px;"><i class="el-icon-warning"></i>提醒:实付金额去除运费</p>
        </el-form-item>
      </div>
      <div class="item-content">
        <el-form-item label="返经销商积分" label-width="150px"  prop="returnShopIntegralStatus">
          <el-switch  v-model="form.returnShopIntegralStatus" :active-value="0" :inactive-value="1"    active-color="#13ce66"   inactive-color="#ff4949"  ></el-switch>
        </el-form-item>
        <el-form-item label="订单实付金额每满" label-width="250px" prop="returnShopIntegral">
          <el-input  style="width: 250px;margin: 0px 20px" type="number"   v-model="form.returnShopIntegral"   placeholder="请输入"   v-trim>
            <template slot="append">元返经销商1积分</template>
          </el-input>
          <p class="tip-warn" style="margin-bottom: 1px;"><i class="el-icon-warning"></i>提醒:实付金额去除运费</p>
        </el-form-item>
      </div>
      <div class="header">
        <span style="font-size: 15px; font-weight: bold">【4】合计优惠承担比例</span>
      </div>
      <div class="item-content">
        <el-form-item label="总部承担" label-width="150px" prop="totalRate">
          <el-input  style="width: 200px;margin: 0px 20px" type="number"   v-model="form.totalRate"   placeholder="请输入"   v-trim>
            <template slot="append">%</template>
          </el-input>
          <p class="tip-warn" style="margin-bottom: 1px;"><i class="el-icon-warning"></i>提醒:设置总部和经销商在订单合计优惠金额中(优惠券+积分抵扣)各自承担的比例</p>
        </el-form-item>
      </div>
      <el-form-item style="margin-top: 100px;width: 100%;text-align: center">
        <el-button type="primary" style="width: 300px"  :loading="working" @click="submit">保存配置项</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
 
<script>
import { getPlatformConfig, updPlatformConfig } from '@/api/system/dictData'
import { allList } from '@/api/business/coupon'
export default {
  name: '',
  data () {
    return {
      uploadData: {
        folder: ''
      },
      isUploading: false,
      working: false,
      couponList: [],
      form: {
        dictCode: 'ORDER_SET',
        regIntegralRewardStatus: 0,
        shareIntegralRewardStatus: 0,
        regCouponRewardStatus: 0,
        shareCouponRewardStatus: 0,
        regIntegralReward: 0,
        shareIntegralReward: 0,
        regCouponRewardList: [],
        shareCouponRewardList: [],
        returnMemberIntegralStatus: 0,
        returnShopIntegralStatus: 0,
        returnMemberIntegral: 0,
        returnShopIntegral: 0,
        totalRate: 0
      }
    }
  },
 
  created () {
    this.getCouponList()
    this.getData()
  },
 
  methods: {
    getCouponList () {
      allList({})
        .then(res => {
          if (res) {
            this.couponList = res || []
          }
        })
    },
    delCoupon (type, index) {
      if (type === 0) {
        this.form.regCouponRewardList.splice(index, 1)
      } else if (type === 1) {
        this.form.shareCouponRewardList.splice(index, 1)
      }
    },
    addCoupon (type) {
      if (type === 0) {
        this.form.regCouponRewardList.push({ couponId: null, num: null })
      } else if (type === 1) {
        this.form.shareCouponRewardList.push({ couponId: null, num: null })
      }
    },
    getData () {
      getPlatformConfig({})
        .then(res => {
          if (res) {
            this.form = {
              dictCode: 'ORDER_SET',
              regIntegralRewardStatus: res.regIntegralRewardStatus || 0,
              shareIntegralRewardStatus: res.shareIntegralRewardStatus || 0,
              regCouponRewardStatus: res.regCouponRewardStatus || 0,
              shareCouponRewardStatus: res.shareCouponRewardStatus || 0,
              regIntegralReward: res.regIntegralReward || 0,
              shareIntegralReward: res.shareIntegralReward || 0,
              regCouponRewardList: res.regCouponRewardList || [],
              shareCouponRewardList: res.shareCouponRewardList || [],
              returnMemberIntegralStatus: res.returnMemberIntegralStatus || 0,
              returnShopIntegralStatus: res.returnShopIntegralStatus || 0,
              returnMemberIntegral: res.returnMemberIntegral || 0,
              returnShopIntegral: res.returnShopIntegral || 0,
              totalRate: res.totalRate || 0
            }
          }
        })
    },
    submit () {
      console.log(this.form)
      this.$refs.form.validate((valid) => {
        if (!valid) {
          return
        }
        // 调用新建接口
        this.isWorking = true
        updPlatformConfig(this.form).then(res => {
          this.$message.success('保存成功')
          this.getData()
        })
          .catch(e => {
            this.$tip.apiFailed(e)
          })
          .finally(() => {
            this.isWorking = false
          })
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.el-container /deep/  .el-main{
  width: 100%;
  overflow-y: auto  !important ;
  height: calc(100% - 94px);
}
.item-content{
  display: flex;
  width: 100%;
}
.header{
  margin: 20px 0 20px 0;padding:10px;background-color: #E0DEDE;
}
/deep/ .el-main{
  width: 100%;
  //height: 100%;
  overflow-y: auto  !important ;
  height: calc(100% - 94px);
}
.box {
  width: 100%;
  padding: 0 30px;
  box-sizing: border-box;
  background: #ffffff;
}
</style>