|
52 | 52 | <el-table-column label="有效期限" align="center" prop="validityType" width="180" :formatter="validityTypeFormat" />
|
53 | 53 | <el-table-column label="状态" align="center" prop="status">
|
54 | 54 | <template slot-scope="scope">
|
55 |
| - <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> |
| 55 | + <el-switch v-model="scope.row.status" :active-value="0" :inactive-value="1" @change="handleStatusChange(scope.row)"/> |
56 | 56 | </template>
|
57 | 57 | </el-table-column>
|
58 | 58 | <el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
|
156 | 156 | </template>
|
157 | 157 |
|
158 | 158 | <script>
|
159 |
| -import { createCouponTemplate, updateCouponTemplate, deleteCouponTemplate, getCouponTemplate, getCouponTemplatePage } from "@/api/mall/promotion/couponTemplate"; |
160 |
| -import { CouponTemplateValidityTypeEnum, PromotionDiscountTypeEnum, PromotionProductScopeEnum} from "@/utils/constants"; |
| 159 | +import { |
| 160 | + createCouponTemplate, |
| 161 | + updateCouponTemplate, |
| 162 | + deleteCouponTemplate, |
| 163 | + getCouponTemplate, |
| 164 | + getCouponTemplatePage, |
| 165 | + updateCouponTemplateStatus |
| 166 | +} from "@/api/mall/promotion/couponTemplate"; |
| 167 | +import { |
| 168 | + CommonStatusEnum, |
| 169 | + CouponTemplateValidityTypeEnum, |
| 170 | + PromotionDiscountTypeEnum, |
| 171 | + PromotionProductScopeEnum |
| 172 | +} from "@/utils/constants"; |
161 | 173 | import { getSpuSimpleList } from "@/api/mall/product/spu";
|
162 | 174 | import { parseTime } from "@/utils/ruoyi";
|
| 175 | +import {changeRoleStatus} from "@/api/system/role"; |
163 | 176 |
|
164 | 177 | export default {
|
165 | 178 | name: "CouponTemplate",
|
@@ -331,6 +344,20 @@ export default {
|
331 | 344 | });
|
332 | 345 | });
|
333 | 346 | },
|
| 347 | + /** 优惠劵模板状态修改 */ |
| 348 | + handleStatusChange(row) { |
| 349 | + // 此时,row 已经变成目标状态了,所以可以直接提交请求和提示 |
| 350 | + let text = row.status === CommonStatusEnum.ENABLE ? "启用" : "停用"; |
| 351 | + this.$modal.confirm('确认要"' + text + '""' + row.name + '"优惠劵吗?').then(function() { |
| 352 | + return updateCouponTemplateStatus(row.id, row.status); |
| 353 | + }).then(() => { |
| 354 | + this.$modal.msgSuccess(text + "成功"); |
| 355 | + }).catch(function() { |
| 356 | + // 异常时,需要将 row.status 状态重置回之前的 |
| 357 | + row.status = row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE |
| 358 | + : CommonStatusEnum.ENABLE; |
| 359 | + }); |
| 360 | + }, |
334 | 361 | /** 删除按钮操作 */
|
335 | 362 | handleDelete(row) {
|
336 | 363 | const id = row.id;
|
|
0 commit comments