zxl
2025-05-23 5d5b0f7ab0f34019e11901ddcd59cd8b51ea9ff9
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<template>
  <div>
    <Card>
      <Form ref="form" :model="form" :label-width="120">
        <div class="base-info-item">
          <h4>基本信息</h4>
          <div class="form-item-view">
            <FormItem label="活动名称" prop="promotionName">
              <Input
                type="text"
                v-model="form.promotionName"
                disabled
                placeholder="活动名称"
                clearable
                style="width: 260px"
              />
            </FormItem>
            <FormItem label="活动时间" prop="rangeTime">
              <DatePicker
                type="datetimerange"
                v-model="form.rangeTime"
                disabled
                format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择"
                :options="options"
                style="width: 320px"
              >
              </DatePicker>
            </FormItem>
            <FormItem label="活动描述" prop="description">
              <Input
                v-model="form.description"
                disabled
                type="textarea"
                :rows="4"
                clearable
                style="width: 260px"
              />
            </FormItem>
          </div>
 
          <h4>优惠设置</h4>
          <div class="form-item-view">
            <FormItem label="优惠门槛" prop="fullMoney">
              <Input
                type="text"
                v-model="form.fullMoney"
                disabled
                placeholder="优惠门槛"
                clearable
                style="width: 260px"
              />
              <span class="describe">消费达到当前金额可以参与优惠</span>
            </FormItem>
            <FormItem label="赠送优惠券">
              <RadioGroup
                type="button"
                button-style="solid"
                v-model="form.discountType"
              >
                <Radio label="fullMinusFlag" disabled>减现金</Radio>
                <Radio label="fullRateFlag" disabled>打折</Radio>
              </RadioGroup>
            </FormItem>
            <FormItem
              v-if="form.discountType == 'fullMinusFlag'"
              label="优惠金额"
              prop="fullMinus"
            >
              <Input
                type="text"
                disabled
                v-model="form.fullMinus"
                placeholder="优惠金额"
                clearable
                style="width: 260px"
              />
            </FormItem>
            <FormItem
              v-if="form.discountType == 'fullRateFlag'"
              label="优惠折扣"
              prop="fullRate"
            >
              <Input
                type="text"
                v-model="form.fullRate"
                placeholder="优惠折扣"
                disabled
                clearable
                style="width: 260px"
              />
              <span class="describe">优惠折扣为0-10之间数字,可有一位小数</span>
            </FormItem>
            <FormItem label="额外赠送">
              <Checkbox v-model="form.freeFreightFlag" disabled>免邮费</Checkbox
              >&nbsp;
              <Checkbox v-model="form.couponFlag" disabled>送优惠券</Checkbox
              >&nbsp;
              <Checkbox v-model="form.giftFlag" disabled>送赠品</Checkbox>&nbsp;
              <Checkbox v-model="form.pointFlag" disabled>送积分</Checkbox>
            </FormItem>
            <FormItem v-if="form.couponFlag" label="赠送优惠券" prop="couponId">
              <Select
                v-model="form.couponId"
                :disabled="form.promotionStatus != 'NEW'"
                filterable
                :remote-method="getCouponList"
                placeholder="输入优惠券名称搜索"
                :loading="couponLoading"
                style="width: 280px"
              >
                <Option
                  v-for="item in couponList"
                  :value="item.id"
                  :key="item.id"
                  >{{ item.couponName }}</Option
                >
              </Select>
            </FormItem>
            <FormItem v-if="form.giftFlag" label="赠品" prop="giftId">
              <Select
                v-model="form.giftId"
                filterable
                :remote-method="getGiftList"
                placeholder="输入赠品名称搜索"
                disabled
                :loading="giftLoading"
                style="width: 260px"
              >
                <Option
                  v-for="item in giftList"
                  :value="item.id"
                  :key="item.id"
                  >{{ item.goodsName }}</Option
                >
              </Select>
            </FormItem>
            <FormItem v-if="form.pointFlag" label="赠积分" prop="point">
              <Input
                v-model="form.point"
                type="number"
                disabled
                style="width: 260px"
              />
            </FormItem>
            <FormItem label="使用范围" prop="scopeType">
              <RadioGroup
                type="button"
                button-style="solid"
                v-model="form.scopeType"
              >
                <Radio label="ALL" disabled>全品类</Radio>
                <Radio label="PORTION_GOODS" disabled>指定商品</Radio>
              </RadioGroup>
            </FormItem>
 
            <FormItem
              style="width: 100%"
              v-if="form.scopeType == 'PORTION_GOODS'"
            >
              <Table border :columns="columns" :data="form.promotionGoodsList">
                <template slot-scope="{ row }" slot="goodsName">
                  <div>
                    <a class="mr_10" @click="linkTo(row.goodsId, row.skuId)">{{
                      row.goodsName
                    }}</a>
                    <Poptip trigger="hover" title="扫码在手机中查看" transfer>
                      <div slot="content">
                        <vue-qr
                          :text="wapLinkTo(row.goodsId, row.skuId)"
                          :margin="0"
                          colorDark="#000"
                          colorLight="#fff"
                          :size="150"
                        ></vue-qr>
                      </div>
                      <img
                        src="../../../assets/qrcode.svg"
                        style="vertical-align: middle"
                        class="hover-pointer"
                        width="20"
                        height="20"
                        alt=""
                      />
                    </Poptip>
                  </div>
                </template>
              </Table>
            </FormItem>
 
            <div>
              <Button
                @click="$router.push({ name: 'promotions/full-discount' })"
                >返回</Button
              >
            </div>
          </div>
        </div>
      </Form>
    </Card>
  </div>
</template>
 
<script>
import { getPlatformCouponList, getFullDiscountById } from "@/api/promotion";
import { getGoodsSkuData } from "@/api/goods";
import vueQr from "vue-qr";
export default {
  name: "add-full-discount",
  components: {
    "vue-qr": vueQr,
  },
  data() {
    return {
      form: {
        // 表单
        discountType: "fullMinusFlag",
        scopeType: "ALL",
        promotionGoodsList: [],
      },
      id: this.$route.query.id, // 活动id
      couponList: [], // 优惠券列表
      giftList: [], // 赠品列表
      giftLoading: false, // 赠品加载状态
      columns: [
        {
          type: "selection",
          width: 60,
          align: "center",
        },
        {
          title: "商品名称",
          slot: "goodsName",
          minWidth: 120,
        },
        {
          title: "商品价格",
          key: "price",
          minWidth: 40,
          render: (h, params) => {
            return h("priceColorScheme", {props:{value:params.row.price,color:this.$mainColor}} );
          },
        },
        {
          title: "库存",
          key: "quantity",
          minWidth: 40,
        },
      ],
      options: {
        disabledDate(date) {
          return date && date.valueOf() < Date.now() - 86400000;
        },
      },
    };
  },
  async mounted() {
    if (this.id) {
      this.getDetail();
    }
    this.getCouponList();
    this.getGiftList();
  },
  methods: {
    getDetail() {
      // 获取活动详情
      getFullDiscountById(this.id).then((res) => {
        let data = res.result;
        if (!data.scopeType === "ALL") {
          data.promotionGoodsList = [];
        }
        if (data.fullMinusFlag) {
          data.discountType = "fullMinusFlag";
          delete data.fullMinusFlag;
        } else {
          data.discountType = "fullMinusFlag";
          delete data.fullRateFlag;
        }
        data.rangeTime = [];
        data.rangeTime.push(new Date(data.startTime), new Date(data.endTime));
 
        this.form = data;
      });
    },
    getCouponList(query) {
      // 优惠券列表
      let params = {
        pageSize: 10,
        pageNumber: 0,
        getType: "ACTIVITY",
        storeId: "",
        couponName: query,
        promotionStatus: "START",
      };
      this.couponLoading = true;
      getPlatformCouponList(params).then((res) => {
        this.couponLoading = false;
        if (res.success) {
          this.couponList = res.result.records;
        }
      });
    },
    getGiftList(query) {
      // 赠品列表
      let params = {
        pageSize: 10,
        pageNumber: 1,
        id: query === this.form.giftId ? this.form.giftId : null,
        goodsName: query === this.form.giftId ? null : query,
        marketEnable: "UPPER",
        authFlag: "PASS"
      };
      this.giftLoading = true;
      getGoodsSkuData(params).then((res) => {
        this.giftLoading = false;
        if (res.success) {
          this.giftList = res.result.records;
        }
      });
    },
  },
};
</script>
 
<style lang="scss" scoped>
h4 {
  margin-bottom: 10px;
  padding: 0 10px;
  border: 1px solid #ddd;
  background-color: #f8f8f8;
  font-weight: bold;
  color: #333;
  font-size: 14px;
  line-height: 40px;
  text-align: left;
}
.describe {
  font-size: 12px;
  margin-left: 10px;
  color: #999;
}
</style>