优化cdn动态加载管理端,修复砍价金额bug,删除部分不规范代码

This commit is contained in:
lemon橪
2021-09-01 10:11:12 +08:00
parent 84cfb26512
commit 71e4c49c3e
59 changed files with 1181 additions and 1527 deletions

View File

@@ -8,69 +8,39 @@
<FormItem label="选择商品" prop="scopeType">
<Button type="primary" @click="openSkuList">选择商品</Button>
<Button
type="error"
ghost
style="margin-left: 10px"
@click="delSelectGoods"
>批量删除
</Button
>
<Button type="error" ghost style="margin-left: 10px" @click="delSelectGoods">批量删除
</Button>
</FormItem>
<FormItem astyle="width: 100%">
<Table
border
:columns="columns"
:data="form.promotionGoodsList"
@on-selection-change="changeSelect"
>
<Table border :columns="columns" :data="form.promotionGoodsList" @on-selection-change="changeSelect">
<template slot-scope="{ row }" slot="skuId">
<div>{{ row.skuId }}</div>
</template>
<template slot-scope="{ index }" slot="settlementPrice">
<Input
type="number"
v-model="form.promotionGoodsList[index].settlementPrice"
/>
<Input type="number" v-model="form.promotionGoodsList[index].settlementPrice" />
</template>
<template slot-scope="{ index }" slot="lowestPrice">
<Input
type="number"
v-model="form.promotionGoodsList[index].lowestPrice"
/>
<Input type="number" v-model="form.promotionGoodsList[index].lowestPrice" />
</template>
<template slot-scope="{ index }" slot="highestPrice">
<Input
type="number"
v-model="form.promotionGoodsList[index].highestPrice"
/>
<Input type="number" v-model="form.promotionGoodsList[index].highestPrice" />
</template>
<template slot-scope="{ index }" slot="purchasePrice">
<Input
type="number"
v-model="form.promotionGoodsList[index].purchasePrice"
/>
<Input type="number" v-model="form.promotionGoodsList[index].purchasePrice" />
</template>
<template slot-scope="{ index }" slot="stock">
<Input
type="number"
v-model="form.promotionGoodsList[index].stock"
/>
<Input type="number" v-model="form.promotionGoodsList[index].stock" />
</template>
</Table>
</FormItem>
<FormItem label="活动时间" prop="rangeTime">
<DatePicker
type="datetimerange"
v-model="form.rangeTime"
format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择"
:options="options"
style="width: 260px"
>
<DatePicker type="datetimerange" v-model="form.rangeTime" format="yyyy-MM-dd HH:mm:ss" placeholder="请选择"
:options="options" style="width: 260px">
</DatePicker>
</FormItem>
<div>
@@ -81,335 +51,330 @@
</div>
</Form>
</Card>
<sku-select
ref="skuSelect"
@selectedGoodsData="selectedGoodsData"
></sku-select>
<sku-select ref="skuSelect" @selectedGoodsData="selectedGoodsData"></sku-select>
</div>
</template>
<script>
import {
saveKanJiaActivityGoods,
editKanJiaActivityGoods
} from "@/api/promotion";
import {regular} from "@/utils";
import skuSelect from "@/views/lili-dialog";
import { saveKanJiaActivityGoods } from "@/api/promotion";
import { regular } from "@/utils";
import skuSelect from "@/views/lili-dialog";
export default {
name: "addKanJiaActivityGoods",
components: {
skuSelect,
},
watch: {},
data() {
return {
modalType: 0, // 是否编辑
form: {
promotionGoodsList: [], // 活动商品列表
},
id: this.$route.query.id, // 砍价活动id
submitLoading: false, // 添加或编辑提交状态
selectedGoods: [], // 已选商品列表,便于删除
export default {
name: "addKanJiaActivityGoods",
components: {
skuSelect,
},
watch: {},
data() {
return {
modalType: 0, // 是否编辑
form: {
promotionGoodsList: [], // 活动商品列表
formRule: {
rangeTime: [{required: true, message: "请选择活动时间"}],
},
id: this.$route.query.id, // 砍价活动id
submitLoading: false, // 添加或编辑提交状态
selectedGoods: [], // 已选商品列表,便于删除
promotionGoodsList: [], // 活动商品列表
formRule: {
rangeTime: [{ required: true, message: "请选择活动时间" }],
},
columns: [
{
type: "selection",
width: 60,
align: "center",
},
columns: [
{
type: "selection",
width: 60,
align: "center",
},
{
title: "商品名称",
key: "goodsName",
tooltip: true,
minWidth: 100,
},
{
title: "商品价格",
key: "price",
width: 120,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.price, "¥")
);
},
},
{
title: "库存",
key: "quantity",
width: 100,
},
{
title: "结算价格",
slot: "settlementPrice",
width: 110,
},
{
title: "最低砍",
slot: "lowestPrice",
width: 110,
},
{
title: "最高砍",
slot: "highestPrice",
width: 110,
{
title: "商品名称",
key: "goodsName",
tooltip: true,
minWidth: 100,
},
{
title: "商品价格",
key: "price",
width: 120,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.price, "¥")
);
},
},
{
title: "库存",
key: "quantity",
width: 100,
},
{
title: "结算价格",
slot: "settlementPrice",
width: 110,
},
{
title: "最低砍",
slot: "lowestPrice",
width: 110,
},
{
title: "最高砍",
slot: "highestPrice",
width: 110,
},
{
title: "最低购买金额",
slot: "purchasePrice",
width: 110,
},
{
title: "活动库存",
slot: "stock",
width: 110,
},
{
title: "操作",
key: "action",
align: "center",
width: 100,
render: (h, params) => {
return h(
"Button",
{
props: {
size: "small",
type: "error",
ghost: true,
},
on: {
click: () => {
this.delGoods(params.index);
},
{
title: "最低购买金额",
slot: "purchasePrice",
width: 110,
},
{
title: "活动库存",
slot: "stock",
width: 110,
},
{
title: "操作",
key: "action",
align: "center",
width: 100,
render: (h, params) => {
return h(
"Button",
{
props: {
size: "small",
type: "error",
ghost: true,
},
on: {
click: () => {
this.delGoods(params.index);
},
},
"删除"
);
},
},
],
options: {
disabledDate(date) {
return date && date.valueOf() < Date.now() - 86400000;
},
"删除"
);
},
},
};
},
async mounted() {
// 如果id不为空则查询信息
if (this.id) {
this.getCoupon();
this.modalType = 1;
}
},
methods: {
openSkuList() { // 显示商品选择器
this.$refs.skuSelect.open("goods");
let data = JSON.parse(JSON.stringify(this.promotionGoodsList))
data.forEach(e => {
e.id = e.skuId
})
this.$refs.skuSelect.goodsData = data;
],
options: {
disabledDate(date) {
return date && date.valueOf() < Date.now() - 86400000;
},
},
};
},
async mounted() {
// 如果id不为空则查询信息
if (this.id) {
this.getCoupon();
this.modalType = 1;
}
},
methods: {
openSkuList() {
// 显示商品选择器
this.$refs.skuSelect.open("goods");
let data = JSON.parse(JSON.stringify(this.promotionGoodsList));
data.forEach((e) => {
e.id = e.skuId;
});
this.$refs.skuSelect.goodsData = data;
},
/** 保存砍价活动 */
handleSubmit() {
this.$refs.form.validate((valid) => {
if (valid) {
const params = JSON.parse(JSON.stringify(this.form));
if (this.form.rangeTime[0] === '' || this.form.rangeTime[0] === '') {
this.$Message.error("请选择活动时间");
return
}
params.startTime = this.$options.filters.unixToDate(
this.form.rangeTime[0] / 1000
);
params.endTime = this.$options.filters.unixToDate(
this.form.rangeTime[1] / 1000
);
delete params.rangeTime
let checkResult = true
//如果添加活动的时候选择了商品 则对选择的商品参数做一些校验
if (this.form.promotionGoodsList.length > 0) {
this.form.promotionGoodsList.forEach((res) => {
//校验库存参数
if (res.stock <= 0 || res.stock > res.quantity) {
checkResult = false
this.$Message.error("活动库存不能为0且不能超过商品库存");
return
}
// 最低购买金额格式校验
if (!regular.money.test(res.purchasePrice)) {
checkResult = false
this.$Message.error("最低购买金额格式不正确");
}
// 结算价格金额格式校验
if (!regular.money.test(res.settlementPrice)) {
checkResult = false
this.$Message.error("结算价格金额格式不正确");
return
}
// 结算价格金额格式校验
if (res.settlementPrice < 0 || res.settlementPrice > res.price) {
checkResult = false
this.$Message.error("结算价格金额不能为0且不能超过商品价格");
return
}
//最高砍价校验
if (!regular.money.test(res.highestPrice)) {
checkResult = false
this.$Message.error("最高可砍金额格式错误");
return
}
if (res.highestPrice <= 0 || res.highestPrice > res.price) {
checkResult = false
this.$Message.error("最高可砍金额不能为0且不能超过商品价格");
return
}
//最低砍价校验
if (!regular.money.test(res.lowestPrice)) {
checkResult = false
this.$Message.error("最低可砍金额格式错误");
return
}
if (res.lowestPrice <= 0 || res.lowestPrice > res.price) {
checkResult = false
this.$Message.error("最低可砍金额不能为0");
return
}
//校验最高最低砍价金额
if (res.lowestPrice > res.highestPrice) {
checkResult = false
this.$Message.error("最低砍价金额不能大于最高砍价金额");
return
}
});
}
if (!checkResult) {
return;
}
this.submitLoading = true;
saveKanJiaActivityGoods(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("砍价活动修改成功");
this.closeCurrentPage();
/** 保存砍价活动 */
handleSubmit() {
this.$refs.form.validate((valid) => {
if (valid) {
const params = JSON.parse(JSON.stringify(this.form));
if (this.form.rangeTime[0] === "" || this.form.rangeTime[0] === "") {
this.$Message.error("请选择活动时间");
return;
}
params.startTime = this.$options.filters.unixToDate(
this.form.rangeTime[0] / 1000
);
params.endTime = this.$options.filters.unixToDate(
this.form.rangeTime[1] / 1000
);
delete params.rangeTime;
let checkResult = true;
//如果添加活动的时候选择了商品 则对选择的商品参数做一些校验
if (this.form.promotionGoodsList.length > 0) {
this.form.promotionGoodsList.forEach((res) => {
//校验库存参数
if (res.stock <= 0 || res.stock > res.quantity) {
checkResult = false;
this.$Message.error("活动库存不能为0且不能超过商品库存");
return;
}
// 最低购买金额格式校验
if (!regular.money.test(res.purchasePrice)) {
checkResult = false;
this.$Message.error("最低购买金额格式不正确");
}
// 结算价格金额格式校验
if (!regular.money.test(res.settlementPrice)) {
checkResult = false;
this.$Message.error("结算价格金额格式不正确");
return;
}
// 结算价格金额格式校验
if (res.settlementPrice < 0 || res.settlementPrice > res.price) {
checkResult = false;
this.$Message.error("结算价格金额不能为0且不能超过商品价格");
return;
}
//最高砍价校验
if (!regular.money.test(res.highestPrice)) {
checkResult = false;
this.$Message.error("最高可砍金额格式错误");
return;
}
if (res.highestPrice <= 0 || res.highestPrice > res.price) {
checkResult = false;
this.$Message.error("最高可砍金额不能为0且不能超过商品价格");
return;
}
//最低砍价校验
if (!regular.money.test(res.lowestPrice)) {
checkResult = false;
this.$Message.error("最低可砍金额格式错误");
return;
}
if (res.lowestPrice <= 0 || res.lowestPrice > res.price) {
checkResult = false;
this.$Message.error("最低可砍金额不能为0");
return;
}
//校验最高最低砍价金额
if (parseInt(res.lowestPrice) > parseInt(res.highestPrice)) {
checkResult = false;
this.$Message.error("最低砍价金额不能大于最高砍价金额");
return;
}
});
}
});
},
// 关闭当前页面
closeCurrentPage() {
this.$store.commit("removeTag", "add-kan-jia-goods");
localStorage.pageOpenedList = JSON.stringify(
this.$store.state.app.pageOpenedList
);
this.$router.go(-1);
},
openSkuList() {
// 显示商品选择器
this.$refs.skuSelect.open("goods");
let data = JSON.parse(JSON.stringify(this.form.promotionGoodsList));
data.forEach((e) => {
e.id = e.skuId;
});
this.$refs.skuSelect.goodsData = data;
},
changeSelect(e) {
// 已选商品批量选择
this.selectedGoods = e;
},
delSelectGoods() {
// 多选删除商品
if (this.selectedGoods.length <= 0) {
this.$Message.warning("您还未选择要删除的数据");
return;
}
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除所选商品吗?",
onOk: () => {
let ids = [];
this.selectedGoods.forEach(function (e) {
ids.push(e.id);
});
this.form.promotionGoodsList = this.form.promotionGoodsList.filter(
(item) => {
return !ids.includes(item.id);
}
);
},
});
},
delGoods(index) {
// 删除商品
this.form.promotionGoodsList.splice(index, 1);
},
selectedGoodsData(item) {
// 回显已选商品
let list = [];
item.forEach((e) => {
list.push({
settlementPrice: e.settlementPrice || 0,
purchasePrice: e.purchasePrice || 0,
lowestPrice: e.lowestPrice || 0,
highestPrice: e.highestPrice || 0,
stock: e.stock || 0,
goodsName: e.goodsName,
price: e.price,
originalPrice: e.price,
quantity: e.quantity,
storeId: e.storeId,
storeName: e.storeName,
skuId: e.id,
if (!checkResult) {
return;
}
this.submitLoading = true;
saveKanJiaActivityGoods(params).then((res) => {
this.submitLoading = false;
if (res.success) {
this.$Message.success("砍价活动修改成功");
this.closeCurrentPage();
}
});
});
console.warn(list)
this.form.promotionGoodsList = list;
},
}
});
},
};
// 关闭当前页面
closeCurrentPage() {
this.$store.commit("removeTag", "add-kan-jia-goods");
localStorage.pageOpenedList = JSON.stringify(
this.$store.state.app.pageOpenedList
);
this.$router.go(-1);
},
openSkuList() {
// 显示商品选择器
this.$refs.skuSelect.open("goods");
let data = JSON.parse(JSON.stringify(this.form.promotionGoodsList));
data.forEach((e) => {
e.id = e.skuId;
});
this.$refs.skuSelect.goodsData = data;
},
changeSelect(e) {
// 已选商品批量选择
this.selectedGoods = e;
},
delSelectGoods() {
// 多选删除商品
if (this.selectedGoods.length <= 0) {
this.$Message.warning("您还未选择要删除的数据");
return;
}
this.$Modal.confirm({
title: "确认删除",
content: "您确认要删除所选商品吗?",
onOk: () => {
let ids = [];
this.selectedGoods.forEach(function (e) {
ids.push(e.id);
});
this.form.promotionGoodsList = this.form.promotionGoodsList.filter(
(item) => {
return !ids.includes(item.id);
}
);
},
});
},
delGoods(index) {
// 删除商品
this.form.promotionGoodsList.splice(index, 1);
},
selectedGoodsData(item) {
// 回显已选商品
let list = [];
item.forEach((e) => {
list.push({
settlementPrice: e.settlementPrice || 0,
purchasePrice: e.purchasePrice || 0,
lowestPrice: e.lowestPrice || 0,
highestPrice: e.highestPrice || 0,
stock: e.stock || 0,
goodsName: e.goodsName,
price: e.price,
originalPrice: e.price,
quantity: e.quantity,
storeId: e.storeId,
storeName: e.storeName,
skuId: e.id,
});
});
console.warn(list);
this.form.promotionGoodsList = list;
},
},
};
</script>
<style lang="scss" scpoed>
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;
}
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;
}
.describe {
font-size: 12px;
margin-left: 10px;
color: #999;
}
.effectiveDays {
font-size: 12px;
color: #999;
.effectiveDays {
font-size: 12px;
color: #999;
> * {
margin: 0 4px;
}
> * {
margin: 0 4px;
}
}
.tips {
font-size: 12px;
color: #999;
}
.tips {
font-size: 12px;
color: #999;
}
</style>

View File

@@ -86,10 +86,7 @@
</div>
</Form>
</Card>
<sku-select
ref="skuSelect"
@selectedGoodsData="selectedGoodsData"
></sku-select>
</div>
</template>
@@ -99,13 +96,11 @@
editKanJiaActivityGoods,
} from "@/api/promotion";
import {regular} from "@/utils";
import skuSelect from "@/views/lili-dialog";
export default {
name: "editKanjiaActivityGoods",
components: {
skuSelect,
},
watch: {},
data() {
const checkSettlementPrice = (rule, value, callback) => {

View File

@@ -4,7 +4,7 @@
<Row>
<Form ref="searchForm" :model="searchForm" inline :label-width="70" class="search-form">
<Form-item label="商品名称" prop="goodsName">
<Input type="text" v-model="searchForm.goodsName" placeholder="请输入商品名称" clearable style="width: 200px"/>
<Input type="text" v-model="searchForm.goodsName" placeholder="请输入商品名称" clearable style="width: 200px" />
</Form-item>
<Form-item label="活动状态" prop="promotionStatus">
<Select v-model="searchForm.promotionStatus" placeholder="请选择" clearable style="width: 200px">
@@ -15,8 +15,8 @@
</Select>
</Form-item>
<Form-item label="活动时间">
<DatePicker v-model="selectDate" type="daterange" clearable placeholder="选择起始时间"
style="width: 200px"></DatePicker>
<DatePicker v-model="selectDate" type="daterange" clearable placeholder="选择起始时间" style="width: 200px">
</DatePicker>
</Form-item>
<Button @click="handleSearch" type="primary" icon="ios-search" class="search-btn">搜索</Button>
</Form>
@@ -25,7 +25,7 @@
<Button @click="add" type="primary">添加砍价</Button>
</Row>
<Table :loading="loading" border :columns="columns" :data="data" ref="table" sortable="custom"
@on-sort-change="changeSort">
@on-sort-change="changeSort">
<template slot-scope="{ row }" slot="goodsName">
<div>
<a class="mr_10" @click="linkTo(row.goodsSku.goodsId,row.skuId)">{{row.goodsName}}</a>
@@ -33,10 +33,10 @@
<div slot="content">
<vue-qr :text="wapLinkTo(row.goodsSku.goodsId,row.skuId)" :margin="0" colorDark="#000" colorLight="#fff"
:size="150"></vue-qr>
:size="150"></vue-qr>
</div>
<img src="../../../assets/qrcode.svg" style="vertical-align:middle;" class="hover-pointer" width="20"
height="20" alt="">
height="20" alt="">
</Poptip>
</div>
</template>
@@ -48,279 +48,272 @@
<div>{{ row.goodsSku.quantity }}</div>
</template>
<template slot-scope="{ row,index }" slot="action">
<Button v-if="row.promotionStatus === 'NEW'" type="info"
size="small" style="margin-right: 10px" @click="edit(row)">编辑
<Button v-if="row.promotionStatus === 'NEW'" type="info" size="small" style="margin-right: 10px"
@click="edit(row)">编辑
</Button>
<Button v-if="row.promotionStatus === 'NEW' || row.promotionStatus === 'END'" type="error"
size="small" style="margin-right: 10px" @click="delAll(row)">删除
<Button v-if="row.promotionStatus === 'NEW' || row.promotionStatus === 'END'" type="error" size="small"
style="margin-right: 10px" @click="delAll(row)">删除
</Button>
</template>
</Table>
<Row type="flex" justify="end" class="page">
<Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage"
@on-page-size-change="changePageSize" :page-size-opts="[10, 20, 50]" size="small"
show-total show-elevator show-sizer></Page>
@on-page-size-change="changePageSize" :page-size-opts="[10, 20, 50]" size="small" show-total show-elevator
show-sizer></Page>
</Row>
</Card>
</div>
</template>
<script>
import {
getKanJiaGoodsList,
delKanJiaGoods,
} from "@/api/promotion";
import { getKanJiaGoodsList, delKanJiaGoods } from "@/api/promotion";
import vueQr from "vue-qr";
export default {
name: "coupon",
components: {},
export default {
name: "coupon",
components: {
"vue-qr": vueQr,
},
data() {
return {
loading: true, // 表单加载状态
modalType: 0, // 添加或编辑标识
modalVisible: false, // 添加或编辑显示
modalTitle: "", // 添加或编辑标题
searchForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "startTime", // 默认排序字段
order: "desc", // 默认排序方式
goodsName: ""
data() {
return {
selectDate: [], //选中的数据
loading: true, // 表单加载状态
modalType: 0, // 添加或编辑标识
modalVisible: false, // 添加或编辑显示
modalTitle: "", // 添加或编辑标题
searchForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "startTime", // 默认排序字段
order: "desc", // 默认排序方式
goodsName: "",
},
form: {
// 添加或编辑表单对象初始化数据
},
// 表单验证规则
formValidate: {},
submitLoading: false, // 添加或编辑提交状态
selectList: [], // 多选数据
selectCount: 0, // 多选计数
columns: [
{
title: "商品名称",
slot: "goodsName",
minWidth: 150,
tooltip: true,
},
form: {
// 添加或编辑表单对象初始化数据
{
title: "库存数量",
slot: "quantity",
width: 100,
},
// 表单验证规则
formValidate: {},
submitLoading: false, // 添加或编辑提交状态
selectList: [], // 多选数据
selectCount: 0, // 多选计数
columns: [
{
title: "商品名称",
slot: "goodsName",
minWidth: 150,
tooltip: true,
{
title: "剩余活动库存",
key: "stock",
width: 110,
},
{
title: "最低购买金额",
key: "lowestPrice",
minWidth: 110,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.lowestPrice, "¥")
);
},
{
title: "库存数量",
slot: "quantity",
width: 100,
},
{
title: "每人最低砍",
key: "lowestPrice",
minWidth: 100,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.lowestPrice, "¥")
);
},
{
title: "剩余活动库存",
key: "stock",
width: 110,
},
{
title: "每人最高砍",
key: "highestPrice",
minWidth: 100,
tooltip: true,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.highestPrice, "¥")
);
},
{
title: "最低购买金额",
key: "lowestPrice",
minWidth: 110,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.lowestPrice, "¥")
);
},
},
{
title: "结算价格",
key: "settlementPrice",
minWidth: 100,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.settlementPrice, "¥")
);
},
{
title: "每人最低砍",
key: "lowestPrice",
minWidth: 100,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.lowestPrice, "")
);
},
},
{
title: "每人最高砍",
key: "highestPrice",
minWidth: 100,
tooltip: true,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.highestPrice, "")
);
},
},
{
title: "结算价格",
key: "settlementPrice",
minWidth: 100,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.settlementPrice, "¥")
);
},
},
{
title: "活动开始时间",
slot: "startTime",
minWidth: 150,
},
{
title: "状态",
key: "promotionStatus",
render: (h, params) => {
let text = "未知",
color = "red";
if (params.row.promotionStatus == "NEW") {
text = "未开始";
color = "geekblue";
} else if (params.row.promotionStatus == "START") {
text = "已开始";
color = "green";
} else if (params.row.promotionStatus == "END") {
text = "已结束";
color = "red";
} else if (params.row.promotionStatus == "CLOSE") {
text = "已关闭";
color = "red";
}
return h("div", [
h(
"Tag",
{
props: {
color: color,
},
},
{
title: "活动开始时间",
slot: "startTime",
minWidth: 150,
},
{
title: "状态",
key: "promotionStatus",
render: (h, params) => {
let text = "未知",
color = "red";
if (params.row.promotionStatus == "NEW") {
text = "未开始";
color = "geekblue";
} else if (params.row.promotionStatus == "START") {
text = "已开始";
color = "green";
} else if (params.row.promotionStatus == "END") {
text = "已结束";
color = "red";
} else if (params.row.promotionStatus == "CLOSE") {
text = "已关闭";
color = "red";
}
return h("div", [
h(
"Tag",
{
props: {
color: color,
},
text
),
]);
},
width: 100,
},
text
),
]);
},
{
title: "操作",
slot: "action",
align: "center",
fixed: "right",
width: 150,
},
],
data: [], // 表单数据
total: 0, // 表单数据总数
selectCoupon: [], //本级选中的优惠券
};
},
props: {},
watch: {
$route(to, from) {
if (to.fullPath == "/promotion/manager-coupon") {
this.init();
}
},
},
methods: {
// 选中优惠券 父级传值
selectedList: {
handler(val) {
// 判断是否是父级回调给自己已选择优惠券
if (val.length != 0) {
this.selectCoupon = val;
}
width: 100,
},
deep: true,
immediate: true,
},
check() {
// this.selectCoupon.push(this.selectList)
this.$emit("selected", this.selectCoupon);
},
init() {
this.getDataList();
},
// 添加砍价活动跳转
add() {
this.$router.push({name: "add-kanJia-activity-goods"});
},
{
title: "操作",
slot: "action",
align: "center",
fixed: "right",
width: 150,
},
],
data: [], // 表单数据
total: 0, // 表单数据总数
selectCoupon: [], //本级选中的优惠券
};
},
props: {},
watch: {
$route(to, from) {
if (to.fullPath == "/promotion/manager-coupon") {
this.init();
}
},
},
methods: {
check() {
// this.selectCoupon.push(this.selectList)
this.$emit("selected", this.selectCoupon);
},
init() {
this.getDataList();
},
// 添加砍价活动跳转
add() {
this.$router.push({ name: "add-kanJia-activity-goods" });
},
info(v) {
this.$router.push({name: "platform-coupon-info", query: {id: v.id}});
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getDataList();
// this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getDataList();
},
handleSearch() {
this.searchForm.pageNumber = 0;
this.searchForm.pageSize = 10;
this.getDataList();
},
changeSort(e) {
this.searchForm.sort = e.key;
this.searchForm.order = e.order;
if (e.order === "normal") {
this.searchForm.order = "";
}
this.getDataList();
},
clearSelectAll() {
this.$refs.table.selectAll(false);
},
info(v) {
this.$router.push({ name: "platform-coupon-info", query: { id: v.id } });
},
changePage(v) {
this.searchForm.pageNumber = v;
this.getDataList();
// this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getDataList();
},
handleSearch() {
this.searchForm.pageNumber = 0;
this.searchForm.pageSize = 10;
this.getDataList();
},
changeSort(e) {
this.searchForm.sort = e.key;
this.searchForm.order = e.order;
if (e.order === "normal") {
this.searchForm.order = "";
}
this.getDataList();
},
clearSelectAll() {
this.$refs.table.selectAll(false);
},
getDataList() {
this.loading = true;
if (this.selectDate && this.selectDate[0] && this.selectDate[1]) {
this.searchForm.startTime = this.selectDate[0].getTime();
this.searchForm.endTime = this.selectDate[1].getTime();
} else {
this.searchForm.startTime = null;
this.searchForm.endTime = null;
}
// 带多条件搜索参数获取表单数据 请自行修改接口
getKanJiaGoodsList(this.searchForm).then((res) => {
this.loading = false;
if (res.success) {
this.data = res.result.records;
this.total = res.result.total;
}
});
this.total = this.data.length;
getDataList() {
this.loading = true;
if (this.selectDate && this.selectDate[0] && this.selectDate[1]) {
this.searchForm.startTime = this.selectDate[0].getTime();
this.searchForm.endTime = this.selectDate[1].getTime();
} else {
this.searchForm.startTime = null;
this.searchForm.endTime = null;
}
// 带多条件搜索参数获取表单数据 请自行修改接口
getKanJiaGoodsList(this.searchForm).then((res) => {
this.loading = false;
},
edit(v) {
this.$router.push({name: "edit-kanJia-activity-goods", query: {id: v.id}});
},
delAll(row) {
this.$Modal.confirm({
title: "确认删除",
content: "确认需要删除此砍价商品",
loading: true,
onOk: () => {
let ids = [];
this.selectList.forEach(function (e) {
ids.push(e.id);
});
// 批量删除
delKanJiaGoods(row.id).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("删除成功");
this.getDataList();
}
});
},
});
},
if (res.success) {
this.data = res.result.records;
this.total = res.result.total;
}
});
this.total = this.data.length;
this.loading = false;
},
mounted() {
this.init();
edit(v) {
this.$router.push({
name: "edit-kanJia-activity-goods",
query: { id: v.id },
});
},
};
delAll(row) {
this.$Modal.confirm({
title: "确认删除",
content: "确认需要删除此砍价商品",
loading: true,
onOk: () => {
let ids = [];
this.selectList.forEach(function (e) {
ids.push(e.id);
});
// 批量删除
delKanJiaGoods(row.id).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("删除成功");
this.getDataList();
}
});
},
});
},
},
mounted() {
this.init();
},
};
</script>
<style lang="scss">
@import "@/styles/table-common.scss";
@import "@/styles/table-common.scss";
</style>