peng
12 小时以前 5fdd241436e8cddeababec363809988306667a8a
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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
<template>
  <div>
    <Card>
      <Form ref="form" :model="form" :label-width="120" :rules="formRule">
        <div class="base-info-item">
          <h4>积分商品信息</h4>
          <div class="form-item-view">
            <FormItem label="商品名称">
              <div>{{ form.goodsSku.goodsName }}</div>
            </FormItem>
            <FormItem label="SKU编码">
              <div>{{ form.goodsSku.id }}</div>
            </FormItem>
            <FormItem label="店铺名称">
              <div>{{ form.goodsSku.storeName }}</div>
            </FormItem>
            <FormItem label="商品价格">
              <div>
                <priceColorScheme :value="form.goodsSku.price" :color="$mainColor"></priceColorScheme>
              </div>
            </FormItem>
            <FormItem label="库存">
              <div>{{ form.goodsSku.quantity }}</div>
            </FormItem>
            <FormItem label="结算价格" prop="settlementPrice">
              <Input
                type="number"
                v-model="form.settlementPrice"
                placeholder="请填写结算价格"
                clearable
                style="width: 260px"
              />
            </FormItem>
            <FormItem label="分类" prop="pointsGoodsCategoryId">
              <Select
                v-model="form.pointsGoodsCategoryId"
                :label-in-value="true"
                @on-change="changeCategory"
              >
                <Option v-for="item in categoryList" :value="item.id" :key="item.id">{{
                  item.name
                }}</Option>
              </Select>
            </FormItem>
            <FormItem label="活动库存" prop="activeStock">
              <Input
                type="number"
                v-model="form.activeStock"
                placeholder="请填写活动库存"
                clearable
                style="width: 260px"
              />
            </FormItem>
            <FormItem label="兑换积分" prop="points">
              <Input
                type="number"
                v-model="form.points"
                placeholder="请填写兑换积分"
                clearable
                style="width: 260px"
              />
            </FormItem>
            <FormItem label="活动开始时间">
              <DatePicker
                type="datetimerange"
                v-model="form.rangeTime"
                format="yyyy-MM-dd HH:mm:ss"
                placeholder="请选择"
                :options="options"
                style="width: 260px"
              >
              </DatePicker>
            </FormItem>
          </div>
          <div class="footer">
            <Button @click="closeCurrentPage" style="margin-right: 5px">返回</Button>
            <Button type="primary" :loading="submitLoading" @click="handleSubmit"
              >保存</Button
            >
          </div>
        </div>
      </Form>
    </Card>
  </div>
</template>
 
<script>
import {
  updatePointsGoods,
  getPointsGoodsById,
  getPointsGoodsCategoryList,
} from "@/api/promotion";
 
export default {
  name: "editPointsGoods",
  data() {
    return {
      pointsGoodsCategoryId:'',
      pointsGoodsCategoryName:'',
      form: {
 
        /** 活动名称 */
        promotionName: "",
        /** 报名截止时间 */
        applyEndTime: "",
        /** 活动开始时间 */
        startTime: "",
        /** 抢购时间段 */
        seckillPeriod: [],
        /** 申请规则 */
        seckillRule: "",
        goodsSku: {},
        promotionStatus: "NEW",
 
      },
      categoryList: [], // 分类列表
      id: this.$route.query.id, // 活动id
      submitLoading: false, // 添加或编辑提交状态
      formRule: {
        settlementPrice: [{ required: true, message: "请填写结算价格" }],
        pointsGoodsCategoryId: [{ required: true, message: "请选择积分商品分类" }],
        points: [{ required: true, message: "请填写兑换积分" }],
        activeStock: [{ required: true, message: "请填写库存" }],
      },
      options: {
        disabledDate(date) {
          return date && date.valueOf() < Date.now() - 86400000;
        },
      },
    };
  },
  async mounted() {
    await this.getCategory();
    // 如果id不为空则查询信息
    if (this.id) {
      this.getData();
    }
  },
  methods: {
    // 分类
    changeCategory(v){
      console.log(v);
      this.pointsGoodsCategoryId=v.value
      this.pointsGoodsCategoryName=v.label
    },
    // 关闭当前页面
    closeCurrentPage() {
      this.$store.commit("removeTag", "edit-points-goods");
      localStorage.pageOpenedList = JSON.stringify(this.$store.state.app.pageOpenedList);
      this.$router.go(-1);
    },
    // 获取商品数据
    getData() {
      getPointsGoodsById(this.id).then((res) => {
        if (res.success) {
          let data = res.result;
          this.form = data;
          data.rangeTime = [];
          if (data.startTime && data.endTime) {
            data.rangeTime.push(new Date(data.startTime), new Date(data.endTime));
          }
        }
      });
    },
    // 获取分类
    async getCategory() {
      let res = await getPointsGoodsCategoryList();
      this.categoryList = res.result.records;
    },
    /** 保存 */
    handleSubmit() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          const start = this.$options.filters.unixToDate(this.form.rangeTime[0] / 1000);
          const end = this.$options.filters.unixToDate(this.form.rangeTime[1] / 1000);
          this.form.startTime = start;
          this.form.endTime = end;
          this.submitLoading = true;
          let params={
            ...this.form,
            pointsGoodsCategoryId: this.pointsGoodsCategoryId,
            pointsGoodsCategoryName:this.pointsGoodsCategoryName
          }
          updatePointsGoods(params).then((res) => {
            this.submitLoading = false;
            if (res.success) {
              this.$Message.success("积分商品修改成功");
              this.closeCurrentPage();
            }
          });
        }
      });
    },
  },
};
</script>
 
<style lang="scss" scoped>
/*编辑基本信息*/
.el-form {
  padding-bottom: 80px;
 
  .el-form-item {
    width: 100%;
    color: gray;
    text-align: left;
  }
}
 
/*平铺*/
div.base-info-item > div {
  margin-left: 5%;
}
 
div.base-info-item {
  margin-bottom: 10px;
 
  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;
  }
 
  .form-item-view {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    padding-left: 80px;
 
    .shop-category-text {
      font-size: 12px;
    }
  }
 
  .item-goods-properts-row {
    display: flex;
    flex-direction: row;
    word-break: break-all;
    white-space: normal;
    width: 300px;
    height: 100px;
  }
 
  .item-goods-properts {
    display: flex;
    flex-direction: row;
    margin-bottom: 10px;
  }
 
  .form-item {
    display: flex;
    align-items: center;
  }
 
  /** 审核信息-拒绝原因 */
  .auth-info {
    color: red;
  }
 
  .el-form-item {
    width: 30%;
    min-width: 300px;
  }
 
  .goods-name-width {
    width: 50%;
    min-width: 300px;
  }
 
  .el-form-item__content {
    margin-left: 120px;
    text-align: left;
  }
 
  p.goods-group-manager {
    padding-left: 7.5%;
    text-align: left;
    color: #999;
    font-size: 13px;
  }
 
  /*teatarea*/
  /deep/ .el-textarea {
    width: 150%;
  }
 
  .seo-text {
    width: 150%;
  }
}
 
/*商品描述*/
.goods-intro {
  line-height: 40;
}
 
/** 底部步骤 */
.footer {
  width: 100%;
  padding: 10px;
  background-color: #ffc;
  position: fixed;
  bottom: 0px;
  right: 0;
  text-align: center;
  z-index: 9999;
}
 
/*图片上传组件第一张图设置封面*/
.goods-images {
  /deep/ li.el-upload-list__item:first-child {
    position: relative;
  }
 
  /deep/ li.el-upload-list__item:first-child:after {
    content: "封";
    color: #fff;
    font-weight: bold;
    font-size: 12px;
    position: absolute;
    left: -15px;
    top: -6px;
    width: 40px;
    height: 24px;
    padding-top: 6px;
    background: #13ce66;
    text-align: center;
    -webkit-transform: rotate(-45deg);
    transform: rotate(-45deg);
    -webkit-box-shadow: 0 0 1pc 1px rgba(0, 0, 0, 0.2);
    box-shadow: 0 0 1pc 1px rgba(0, 0, 0, 0.2);
  }
}
 
.el-form-item__label {
  word-break: break-all;
}
 
.step-view {
  width: 33%;
  height: 40px;
  font-size: 19px;
  text-align: center;
  display: flex;
  background-color: #fff;
  justify-content: center;
  align-items: center;
}
 
.page {
  margin-top: 2vh;
  margin-bottom: 5vh;
}
</style>