优化促销相关代码

This commit is contained in:
paulGao
2021-12-21 18:59:45 +08:00
parent 246ba9057f
commit ab2bcb515f
11 changed files with 462 additions and 489 deletions

View File

@@ -7,7 +7,7 @@
inline
:label-width="70"
class="search-form"
@keydown.enter.native="handleSearch"
@keydown.enter.native="handleSearch"
>
<Form-item label="商品名称" prop="goodsName">
<Input
@@ -39,12 +39,19 @@
</Select>
</Form-item>
<Form-item label="商品类型" prop="status">
<Select v-model="searchForm.goodsType" placeholder="请选择" clearable style="width: 200px">
<Select
v-model="searchForm.goodsType"
placeholder="请选择"
clearable
style="width: 200px"
>
<Option value="PHYSICAL_GOODS">实物商品</Option>
<Option value="VIRTUAL_GOODS">虚拟商品</Option>
</Select>
</Form-item>
<Button @click="handleSearch" class="search-btn" type="primary" icon="ios-search" >搜索</Button>
<Button @click="handleSearch" class="search-btn" type="primary" icon="ios-search"
>搜索</Button
>
</Form>
<Table
:loading="loading"
@@ -55,25 +62,39 @@
class="mt_10"
>
<!-- 商品栏目格式化 -->
<template slot="goodsSlot" slot-scope="{row}">
<div style="margin: 5px 0px;height: 80px; display: flex;">
<template slot="goodsSlot" slot-scope="{ row }">
<div style="margin: 5px 0px; height: 80px; display: flex">
<div style="">
<img :src="row.original" style="height: 60px;margin-top: 1px;width: 60px">
<img
:src="row.original"
style="height: 60px; margin-top: 1px; width: 60px"
/>
</div>
<div style="margin-left: 13px;">
<div style="margin-left: 13px">
<div class="div-zoom">
<a @click="linkTo(row.id,row.skuId)">{{row.goodsName}}</a>
<a @click="linkTo(row.id, row.skuId)">{{ row.goodsName }}</a>
</div>
<Poptip trigger="hover" title="扫码在手机中查看" transfer>
<div slot="content">
<vue-qr :text="wapLinkTo(row.id,row.skuId)" :margin="0" colorDark="#000" colorLight="#fff" :size="150"></vue-qr>
<vue-qr
:text="wapLinkTo(row.id, row.skuId)"
:margin="0"
colorDark="#000"
colorLight="#fff"
:size="150"
></vue-qr>
</div>
<img src="../../../assets/qrcode.svg" class="hover-pointer" width="20" height="20" alt="">
<img
src="../../../assets/qrcode.svg"
class="hover-pointer"
width="20"
height="20"
alt=""
/>
</Poptip>
</div>
</div>
</template>
</Table>
<Row type="flex" justify="end" class="mt_10">
@@ -91,26 +112,15 @@
></Page>
</Row>
</Card>
<Modal
title="下架操作"
v-model="modalVisible"
:mask-closable="false"
:width="500"
>
<Form
ref="underForm"
:model="underForm"
:label-width="100"
>
<Modal title="下架操作" v-model="modalVisible" :mask-closable="false" :width="500">
<Form ref="underForm" :model="underForm" :label-width="100">
<FormItem label="下架原因" prop="reason">
<Input v-model="underForm.reason" clearable style="width: 100%" />
</FormItem>
</Form>
<div slot="footer">
<Button type="text" @click="modalVisible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="lower"
>提交</Button
>
<Button type="primary" :loading="submitLoading" @click="lower">提交</Button>
</div>
</Modal>
</div>
@@ -118,10 +128,10 @@
<script>
import { getGoodsListData, upGoods, lowGoods } from "@/api/goods";
import vueQr from 'vue-qr'
import vueQr from "vue-qr";
export default {
components: {
"vue-qr":vueQr
"vue-qr": vueQr,
},
name: "goods",
data() {
@@ -136,7 +146,8 @@ export default {
sort: "create_time", // 默认排序字段
order: "desc", // 默认排序方式
},
underForm: { // 下架原因
underForm: {
// 下架原因
reason: "",
},
submitLoading: false, // 添加或编辑提交状态
@@ -151,17 +162,14 @@ export default {
title: "商品编号",
key: "id",
minWidth: 150,
tooltip: true
tooltip: true,
},
{
title: "价格",
key: "price",
width: 130,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.price, "¥")
);
return h("div", this.$options.filters.unitPrice(params.row.price, "¥"));
},
},
{
@@ -169,12 +177,12 @@ export default {
key: "goodsType",
width: 130,
render: (h, params) => {
if (params.row.goodsType === 'PHYSICAL_GOODS') {
return h("Tag", {props: {color: "green",},}, "实物商品");
} else if (params.row.goodsType === 'VIRTUAL_GOODS') {
return h("Tag", {props: {color: "volcano",},}, "虚拟商品");
if (params.row.goodsType === "PHYSICAL_GOODS") {
return h("Tag", { props: { color: "green" } }, "实物商品");
} else if (params.row.goodsType === "VIRTUAL_GOODS") {
return h("Tag", { props: { color: "volcano" } }, "虚拟商品");
} else {
return h("Tag", {props: {color: "geekblue",},}, "电子卡券");
return h("Tag", { props: { color: "geekblue" } }, "电子卡券");
}
},
},
@@ -184,23 +192,23 @@ export default {
width: 100,
render: (h, params) => {
if (params.row.marketEnable == "DOWN") {
return h("Tag", {props: {color: "volcano"},},"下架");
return h("Tag", { props: { color: "volcano" } }, "下架");
} else if (params.row.marketEnable == "UPPER") {
return h("Tag", {props: {color: "green",},},"上架");
return h("Tag", { props: { color: "green" } }, "上架");
}
},
},
{
title: "审核状态",
key: "isAuth",
key: "authFlag",
width: 130,
render: (h, params) => {
if (params.row.isAuth == "TOBEAUDITED") {
return h("Tag", {props: {color: "volcano",},},"待审核");
} else if (params.row.isAuth == "PASS") {
return h("Tag", {props: {color: "green"},},"通过");
} else if (params.row.isAuth == "REFUSE") {
return h("Tag", {props: {color: "red",},},"拒绝");
if (params.row.authFlag == "TOBEAUDITED") {
return h("Tag", { props: { color: "volcano" } }, "待审核");
} else if (params.row.authFlag == "PASS") {
return h("Tag", { props: { color: "green" } }, "通过");
} else if (params.row.authFlag == "REFUSE") {
return h("Tag", { props: { color: "red" } }, "拒绝");
}
},
},
@@ -208,7 +216,7 @@ export default {
title: "店铺名称",
key: "storeName",
minWidth: 100,
tooltip: true
tooltip: true,
},
{
title: "操作",
@@ -236,7 +244,8 @@ export default {
},
},
"上架"
), h(
),
h(
"Button",
{
props: {
@@ -249,7 +258,7 @@ export default {
},
},
"查看"
)
),
]);
} else {
return h("div", [
@@ -270,7 +279,8 @@ export default {
},
},
"下架"
), h(
),
h(
"Button",
{
props: {
@@ -283,7 +293,7 @@ export default {
},
},
"查看"
)
),
]);
}
},
@@ -369,7 +379,7 @@ export default {
name: "goods-detail",
query: { id: id },
});
}
},
},
mounted() {
this.init();

View File

@@ -27,7 +27,9 @@
style="width: 200px"
/>
</Form-item>
<Button @click="handleSearch" class="search-btn" type="primary" icon="ios-search">搜索</Button>
<Button @click="handleSearch" class="search-btn" type="primary" icon="ios-search"
>搜索</Button
>
</Form>
<Table
:loading="loading"
@@ -39,18 +41,20 @@
>
<!-- 商品栏目格式化 -->
<template slot="goodsSlot" slot-scope="scope">
<div style="margin-top: 5px;height: 80px; display: flex;">
<div style="margin-top: 5px; height: 80px; display: flex">
<div style="">
<img :src="scope.row.original" style="height: 60px;margin-top: 3px;width: 60px">
<img
:src="scope.row.original"
style="height: 60px; margin-top: 3px; width: 60px"
/>
</div>
<div style="margin-left: 13px">
<div class="div-zoom" >
<a>{{scope.row.goodsName}}</a>
<div class="div-zoom">
<a>{{ scope.row.goodsName }}</a>
</div>
</div>
</div>
</template>
</Table>
<Row type="flex" justify="end" class="mt_10">
@@ -72,220 +76,224 @@
</template>
<script>
import {authGoods, getAuthGoodsListData} from "@/api/goods";
import { authGoods, getAuthGoodsListData } from "@/api/goods";
export default {
name: "goods",
components: {},
data() {
return {
id: "", //要操作的id
loading: true, // 表单加载状态
searchForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "create_time", // 默认排序字段
order: "desc", // 默认排序方式
export default {
name: "goods",
components: {},
data() {
return {
id: "", //要操作的id
loading: true, // 表单加载状态
searchForm: {
// 搜索框初始化对象
pageNumber: 1, // 当前页数
pageSize: 10, // 页面大小
sort: "create_time", // 默认排序字段
order: "desc", // 默认排序方式
},
goodsAuditForm: {
// 商品编辑表单
is_auth: 1,
},
columns: [
{
title: "商品名称",
key: "goodsName",
minWidth: 180,
slot: "goodsSlot",
tooltip: true,
},
goodsAuditForm: { // 商品编辑表单
is_auth: 1,
{
title: "商品编号",
key: "id",
minWidth: 100,
tooltip: true,
},
columns: [
{
title: "商品名称",
key: "goodsName",
minWidth: 180,
slot: "goodsSlot",
tooltip: true
{
title: "价格",
key: "price",
minWidth: 130,
render: (h, params) => {
return h("div", this.$options.filters.unitPrice(params.row.price, "¥"));
},
{
title: "商品编号",
key: "id",
minWidth: 100,
tooltip: true
},
{
title: "价格",
key: "price",
minWidth: 130,
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.price, "¥")
);
},
},
{
title: "审核状态",
key: "isAuth",
minWidth: 130,
render: (h, params) => {
if (params.row.isAuth == "TOBEAUDITED") {
return h("div", [
h("Badge", {
props: {
status: "error",
text: "待审核",
},
}),
]);
} else if (params.row.isAuth == "PASS") {
return h("div", [
h("Badge", {
props: {
status: "success",
text: "审核通过",
},
}),
]);
} else if (params.row.isAuth == "REFUSE") {
return h("div", [
h("Badge", {
props: {
status: "error",
text: "审核拒绝",
},
}),
]);
}
},
},
{
title: "店铺名称",
key: "storeName",
minWidth: 100,
tooltip: true
},
{
title: "操作",
key: "action",
align: "center",
fixed: "right",
width: 200,
render: (h, params) => {
},
{
title: "审核状态",
key: "authFlag",
minWidth: 130,
render: (h, params) => {
if (params.row.authFlag == "TOBEAUDITED") {
return h("div", [
h(
"Button",
{
props: {
type: "success",
size: "small",
},
style: {
marginRight: "5px",
},
on: {
click: () => {
this.examine(params.row, 1);
},
},
h("Badge", {
props: {
status: "error",
text: "待审核",
},
"通过"
),
h(
"Button",
{
props: {
type: "error",
size: "small",
},
style: {
marginRight: "5px",
},
on: {
click: () => {
this.examine(params.row, 2);
},
},
},
"拒绝"
), h(
"Button",
{
props: {
size: "small",
},
on: {
click: () => {
this.showDetail(params.row);
},
},
},
"查看"
)
}),
]);
},
} else if (params.row.authFlag == "PASS") {
return h("div", [
h("Badge", {
props: {
status: "success",
text: "审核通过",
},
}),
]);
} else if (params.row.authFlag == "REFUSE") {
return h("div", [
h("Badge", {
props: {
status: "error",
text: "审核拒绝",
},
}),
]);
}
},
],
data: [], // 表单数据
total: 0, // 表单数据总数
};
},
methods: {
init() { // 初始化数据
this.getDataList();
},
changePage(v) { // 改变页码
this.searchForm.pageNumber = v;
this.getDataList();
},
changePageSize(v) { // 改变每页数量
this.searchForm.pageSize = v;
this.getDataList();
},
handleSearch() { // 搜索
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
this.getDataList();
},
getDataList() { // 获取列表数据
this.loading = true;
// 带多条件搜索参数获取表单数据
this.searchForm.isAuth = 0;
getAuthGoodsListData(this.searchForm).then((res) => {
this.loading = false;
if (res.records) {
this.data = res.records;
this.total = res.total;
}
});
},
examine(v, isAuth) { // 审核商品
let examine = "通过";
this.goodsAuditForm.isAuth = "PASS";
if (isAuth != 1) {
examine = "拒绝";
this.goodsAuditForm.isAuth = "REFUSE";
}
this.$Modal.confirm({
title: "确认审核",
content: "您确认要审核" + examine + " " + v.goodsName + " ?",
loading: true,
onOk: () => {
authGoods(v.id, this.goodsAuditForm).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("审核成功");
this.getDataList();
}
});
},
});
},
//查看商品详情
showDetail(v) {
let id = v.id;
this.$router.push({
name: "goods-detail",
query: { id: id },
});
},
},
mounted() {
this.init();
},
};
</script>
},
{
title: "店铺名称",
key: "storeName",
minWidth: 100,
tooltip: true,
},
{
title: "操作",
key: "action",
align: "center",
fixed: "right",
width: 200,
render: (h, params) => {
return h("div", [
h(
"Button",
{
props: {
type: "success",
size: "small",
},
style: {
marginRight: "5px",
},
on: {
click: () => {
this.examine(params.row, 1);
},
},
},
"通过"
),
h(
"Button",
{
props: {
type: "error",
size: "small",
},
style: {
marginRight: "5px",
},
on: {
click: () => {
this.examine(params.row, 2);
},
},
},
"拒绝"
),
h(
"Button",
{
props: {
size: "small",
},
on: {
click: () => {
this.showDetail(params.row);
},
},
},
"查看"
),
]);
},
},
],
data: [], // 表单数据
total: 0, // 表单数据总数
};
},
methods: {
init() {
// 初始化数据
this.getDataList();
},
changePage(v) {
// 改变页码
this.searchForm.pageNumber = v;
this.getDataList();
},
changePageSize(v) {
// 改变每页数量
this.searchForm.pageSize = v;
this.getDataList();
},
handleSearch() {
// 搜索
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
this.getDataList();
},
getDataList() {
// 获取列表数据
this.loading = true;
// 带多条件搜索参数获取表单数据
this.searchForm.authFlag = 0;
getAuthGoodsListData(this.searchForm).then((res) => {
this.loading = false;
if (res.records) {
this.data = res.records;
this.total = res.total;
}
});
},
examine(v, authFlag) {
// 审核商品
let examine = "通过";
this.goodsAuditForm.authFlag = "PASS";
if (authFlag != 1) {
examine = "拒绝";
this.goodsAuditForm.authFlag = "REFUSE";
}
this.$Modal.confirm({
title: "确认审核",
content: "您确认要审核" + examine + " " + v.goodsName + " ?",
loading: true,
onOk: () => {
authGoods(v.id, this.goodsAuditForm).then((res) => {
this.$Modal.remove();
if (res.success) {
this.$Message.success("审核成功");
this.getDataList();
}
});
},
});
},
//查看商品详情
showDetail(v) {
let id = v.id;
this.$router.push({
name: "goods-detail",
query: { id: id },
});
},
},
mounted() {
this.init();
},
};
</script>

View File

@@ -53,7 +53,7 @@ export default {
sn: "",
categoryPath: "",
marketEnable: "UPPER",
isAuth: "PASS",
authFlag: "PASS",
},
category: [], // 分类
goodsData: [], // 商品数据

View File

@@ -54,12 +54,12 @@
</FormItem>
<FormItem label="优惠方式">
<RadioGroup type="button" button-style="solid" v-model="form.discountType">
<Radio label="isFullMinus" disabled>减现金</Radio>
<Radio label="isFullRate" disabled>打折</Radio>
<Radio label="fullMinusFlag" disabled>减现金</Radio>
<Radio label="fullRateFlag" disabled>打折</Radio>
</RadioGroup>
</FormItem>
<FormItem
v-if="form.discountType == 'isFullMinus'"
v-if="form.discountType == 'fullMinusFlag'"
label="优惠金额"
prop="fullMinus"
>
@@ -73,7 +73,7 @@
/>
</FormItem>
<FormItem
v-if="form.discountType == 'isFullRate'"
v-if="form.discountType == 'fullRateFlag'"
label="优惠折扣"
prop="fullRate"
>
@@ -88,12 +88,12 @@
<span class="describe">优惠折扣为0-10之间数字可有一位小数</span>
</FormItem>
<FormItem label="额外赠送">
<Checkbox v-model="form.isFreeFreight" disabled>免邮费</Checkbox>&nbsp;
<Checkbox v-model="form.isCoupon" disabled>送优惠券</Checkbox>&nbsp;
<Checkbox v-model="form.isGift" disabled>送赠品</Checkbox>&nbsp;
<Checkbox v-model="form.isPoint" disabled>送积分</Checkbox>
<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.isCoupon" label="赠送优惠券" prop="couponId">
<FormItem v-if="form.couponFlag" label="赠送优惠券" prop="couponId">
<Select
v-model="form.couponId"
filterable
@@ -108,7 +108,7 @@
}}</Option>
</Select>
</FormItem>
<FormItem v-if="form.isGift" label="赠品" prop="giftId">
<FormItem v-if="form.giftFlag" label="赠品" prop="giftId">
<Select
v-model="form.giftId"
filterable
@@ -123,7 +123,7 @@
}}</Option>
</Select>
</FormItem>
<FormItem v-if="form.isPoint" label="赠积分" prop="point">
<FormItem v-if="form.pointFlag" label="赠积分" prop="point">
<Input v-model="form.point" type="number" disabled style="width: 260px" />
</FormItem>
<FormItem label="使用范围" prop="scopeType">
@@ -187,7 +187,7 @@ export default {
return {
form: {
// 表单
discountType: "isFullMinus",
discountType: "fullMinusFlag",
scopeType: "ALL",
promotionGoodsList: [],
},
@@ -242,12 +242,12 @@ export default {
if (!data.scopeType === "ALL") {
data.promotionGoodsList = [];
}
if (data.isFullMinus) {
data.discountType = "isFullMinus";
delete data.isFullMinus;
if (data.fullMinusFlag) {
data.discountType = "fullMinusFlag";
delete data.fullMinusFlag;
} else {
data.discountType = "isFullMinus";
delete data.isFullRate;
data.discountType = "fullMinusFlag";
delete data.fullRateFlag;
}
data.rangeTime = [];
data.rangeTime.push(new Date(data.startTime), new Date(data.endTime));

View File

@@ -63,7 +63,7 @@
{{ unixDate(row.applyEndTime) }}
</template>
<template slot-scope="{ row }" slot="promotionType">
{{ row.isFullMinus ? "满减" : "满折" }}
{{ row.fullMinusFlag ? "满减" : "满折" }}
</template>
<template slot-scope="{ row }" slot="hours">
<Tag v-for="item in unixHours(row.hours)" :key="item">{{ item }}</Tag>