添加优惠券相关

This commit is contained in:
GaoHao 2024-10-25 09:55:57 +08:00
parent ae82be372d
commit 01eeccaecf
10 changed files with 1413 additions and 129 deletions

View File

@ -0,0 +1,388 @@
<template>
<div>
<el-dialog :title="form.id ? '编辑酒品' : '添加酒品'" :visible.sync="dialogVisible" @close="reset">
<div class="head-container" v-if="!form.id">
<div class="tab_wrap">
<div class="tab" :style="{ '--index': form.source }">
<div class="item" v-for="(item, index) in tabs" :key="item.value"
:class="{ active: index == form.source }" @click="tabChange(item)">
{{ item.label }}
</div>
</div>
</div>
</div>
<el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="left">
<template v-if="form.source == 0">
<el-form-item label="酒品名" prop="name">
<el-input v-model="form.name" placeholder="请输入酒品名" />
</el-form-item>
<el-form-item label="酒品图片">
<uploadImg ref="uploadImg" :limit="1" @success="e => form.imgUrl = e[0]"
@remove="form.imgUrl = ''" />
</el-form-item>
</template>
<template v-else>
<template v-if="!form.id">
<el-form-item label="选择商品" prop="name">
<div>
<el-button type="primary" icon="el-icon-plus"
@click="$refs.shopListRef.show([...productIds])">
添加商品
</el-button>
</div>
<div class="shop_list">
<div class="item_wrap" v-for="(item, index) in productIds" :key="item.id"
@click="productIds.splice(index, 1)">
<div class="item" :data-index="index + 1">
<el-image :src="item.coverImg" style="width: 100%;height: 100%;"></el-image>
</div>
<div class="name">{{ item.name }}</div>
</div>
</div>
</el-form-item>
</template>
<template v-else>
<el-form-item label="商品">
<div class="goods_info">
<el-image :src="form.imgUrl" style="width: 50px;height: 50px;"></el-image>
<div class="info">{{ form.name }}</div>
</div>
</el-form-item>
</template>
</template>
<el-form-item label="单位">
<el-input v-model="form.unit" placeholder="请输入单位" style="width: 200px;" />
<!-- <el-select v-model="form.unitId" placeholder="请选择单位" style="width: 200px;" @change="selectUnitt">
<el-option :label="item.name" :value="item.id" v-for="item in units" :key="item.id"></el-option>
</el-select>
<el-button type="primary" plain icon="el-icon-plus"
@click="$refs.addUnitRef.show()">添加单位</el-button> -->
</el-form-item>
<el-form-item label="有效期(天)">
<el-input-number v-model="form.period" controls-position="right" step-strictly :min="1"
placeholder="请输入有效期(天)"></el-input-number>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="onSubmitHandle"> </el-button>
</span>
</el-dialog>
<addUnit ref="addUnitRef" @success="tbShopUnit" />
<shopList ref="shopListRef" @success="slectShop" />
</div>
</template>
<script>
import { tbShopStorageGood } from '@/api/application'
import { queryAllShopUser, tbShopUnit } from '@/api/shop'
import uploadImg from '@/components/uploadImg'
import addUnit from '@/views/product/components/addUnit'
import shopList from '@/components/shopList'
export default {
components: {
uploadImg,
addUnit,
shopList
},
data() {
const nameValidator = (rule, value, callback) => {
if (this.form.source == 0) {
if (!this.form.name) {
callback(new Error('请输入酒名名'))
} else {
callback()
}
} else {
if (!this.productIds.length) {
callback(new Error('请选择商品'))
} else {
callback()
}
}
}
return {
dialogVisible: false,
tabs: [
{
value: 0,
label: '手动添加'
},
{
value: 1,
label: '从商品添加'
}
],
units: [],
loading: false,
options: [],
productIds: [],
form: {
name: '',
imgUrl: '',
source: 0,
id: '',
goods: [
{
imgUrl: '',
name: '',
}
],
period: '',
unit: ''
},
resetForm: '',
rules: {
name: [
{
required: true,
validator: nameValidator,
trigger: 'change'
}
]
}
}
},
mounted() {
this.resetForm = { ...this.form }
// this.getTableData()
this.tbShopUnit()
},
methods: {
slectShop(res) {
if (this.productIds.length) {
res.map(async item => {
if (!await this.checkShop(item.id)) {
this.productIds.push({ ...item })
}
})
} else {
this.productIds = res
}
},
selectUnitt(e) {
this.form.unit = this.units.find(item => item.id == e).name
},
//
async tbShopUnit() {
try {
const res = await tbShopUnit({
shopId: localStorage.getItem('shopId'),
sort: 'id',
page: 0,
size: 100
})
this.units = res.content
} catch (error) { }
},
//
tabChange(item) {
this.form.source = this.tabs.findIndex(i => i.value == item.value)
},
//
async getTableData(query = '') {
this.loading = true
try {
const res = await queryAllShopUser({
telephone: query,
})
this.loading = false
this.options = res.content
} catch (error) {
this.loading = false
console.log(error)
}
},
//
onSubmitHandle() {
this.$refs.form.validate(async valid => {
if (valid) {
try {
if (this.form.source == 0) {
//
this.form.goods = [{
name: this.form.name,
imgUrl: this.form.imgUrl
}]
} else {
this.form.goods = this.productIds.map(item => {
return {
name: item.name,
imgUrl: item.coverImg
}
})
}
let res = await tbShopStorageGood(this.form, this.form.id ? 'put' : 'post')
this.$emit('success', res)
this.close()
this.$notify({
title: '成功',
message: `${this.form.id ? '编辑' : '添加'}成功`,
type: 'success'
});
} catch (error) {
console.log(error)
}
}
})
},
show(obj) {
this.dialogVisible = true
if (obj && obj.id) {
this.form = obj
if (obj.imgUrl && obj.source == 0) {
setTimeout(() => {
this.$refs.uploadImg.fileList = [
{
url: obj.imgUrl
}
]
}, 100)
}
}
},
close() {
this.dialogVisible = false
},
reset() {
if (this.form.source == 0) {
this.$refs.uploadImg.clearFiles()
}
this.form = { ...this.resetForm }
this.$refs.form.resetFields()
}
}
}
</script>
<style scoped lang="scss">
.goods_info {
background-color: #f9f9f9;
padding: 10px;
display: flex;
align-items: center;
.info {
flex: 1;
padding-left: 10px;
}
}
.head-container {
display: flex;
justify-content: center;
}
.tab_wrap {
background-color: #DCF0E8;
padding: 4px;
.tab {
--w: 120px;
height: 35px;
display: flex;
position: relative;
&::after {
content: "";
width: var(--w);
height: inherit;
background-color: #39D47A;
position: absolute;
top: 0;
left: calc(var(--index) * var(--w));
z-index: 1;
transition: left .3s ease-in-out;
}
.item {
width: var(--w);
height: inherit;
display: flex;
align-items: center;
justify-content: center;
position: relative;
z-index: 2;
color: #39D47A;
transition: all .1s ease-in-out .15s;
&:hover {
cursor: pointer;
}
&.active {
color: #fff;
}
}
}
}
.shop_list {
display: flex;
flex-wrap: wrap;
.item_wrap {
$size: 80px;
.item {
$radius: 4px;
width: $size;
height: $size;
border-radius: $radius;
overflow: hidden;
position: relative;
margin-right: 10px;
margin-top: 10px;
&:hover {
cursor: pointer;
}
&::after {
content: attr(data-index);
font-size: 12px;
height: 20px;
display: flex;
padding: 0 10px;
border-radius: 0 0 $radius 0;
align-items: center;
background-color: rgba(0, 0, 0, 0.3);
backdrop-filter: blur(10px);
color: #fff;
position: absolute;
top: 0;
left: 0;
z-index: 10;
}
&::before {
content: '删除';
font-size: 12px;
width: 100%;
height: 20px;
display: flex;
padding: 0 10px;
align-items: center;
justify-content: center;
background-color: rgba(0, 0, 0, 0.3);
backdrop-filter: blur(10px);
color: #fff;
position: absolute;
bottom: 0;
left: 0;
z-index: 10;
transition: all .1s ease-in-out;
}
}
.name {
width: $size;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
</style>

View File

@ -0,0 +1,145 @@
<template>
<div class="head-container">
<div class="head-container">
<el-form :model="query" inline>
<el-form-item>
<el-button type="primary" @click="$refs.addModal.show()">添加酒品</el-button>
</el-form-item>
<el-form-item label="搜索">
<el-input v-model="query.name" placeholder="酒名"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getTableData">查询</el-button>
<el-button @click="resetHandle">重置</el-button>
</el-form-item>
</el-form>
</div>
<div class="head-container">
<el-table :data="tableData.data" v-loading="tableData.loading">
<el-table-column label="酒名" prop="name">
<template v-slot="scope">
<div style="display: flex;align-items: center;">
<el-image :src="scope.row.imgUrl"
style="width:40px;height: 40px;border-radius: 4px;background-color: #efefef;">
<div class="img_error" slot="error">
<i class="icon el-icon-document-delete"></i>
</div>
</el-image>
<span style="margin-left: 10px;">{{ scope.row.name }}</span>
</div>
</template>
</el-table-column>
<el-table-column label="单位" prop="unit">
<template v-slot="scope">
<el-tag type="primary">{{ scope.row.unit }}</el-tag>
</template>
</el-table-column>
<el-table-column label="有效期(天)" prop="period"></el-table-column>
<el-table-column label="来源" prop="source">
<template v-slot="scope">
<span v-if="scope.row.source == 0">手动导入</span>
<span v-if="scope.row.source == 1">商品导入</span>
</template>
</el-table-column>
<el-table-column label="操作" width="120">
<template v-slot="scope">
<div style="display: flex;gap: 10px;">
<el-button type="text"
@click="$refs.winAddModal.show({ name: scope.row.name, imgUrl: scope.row.imgUrl, expDay: scope.row.period, unit: scope.row.unit }, true)">存酒</el-button>
<el-button type="text" @click="$refs.addModal.show(scope.row)">编辑</el-button>
<el-popconfirm title="确定删除吗?" @confirm="delHandle(scope.row)">
<el-button type="text" slot="reference">删除</el-button>
</el-popconfirm>
</div>
</template>
</el-table-column>
</el-table>
</div>
<div class="head-container">
<el-pagination :total="tableData.total" :current-page="tableData.page + 1" :page-size="tableData.size"
@current-change="paginationChange" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
</div>
<addModal ref="addModal" @success="getTableData" />
<winAddModal ref="winAddModal" />
</div>
</template>
<script>
import { tbShopStorageGoodlist, tbShopStorageGood } from '@/api/application'
import addModal from './addModal'
import winAddModal from '../winestorage/addModal'
export default {
components: {
addModal,
winAddModal
},
data() {
return {
statusList: [
{
value: 0,
label: '已取完'
},
{
value: 1,
label: '未取完'
}
],
query: {
name: ""
},
tableData: {
data: [],
page: 0,
size: 10,
loading: false,
total: 0
}
}
},
mounted() {
this.getTableData()
},
methods: {
//
async delHandle(row) {
try {
let obj = { ...row }
obj.isDel = 1
await tbShopStorageGood(obj, 'put')
this.$notify.success('删除成功')
this.getTableData()
} catch (error) {
console.log(error);
}
},
//
resetHandle() {
this.tableData.page = 0;
this.query.name = ''
this.getTableData()
},
//
paginationChange(e) {
this.tableData.page = e - 1;
this.getTableData()
},
//
async getTableData() {
this.tableData.loading = true
try {
const res = await tbShopStorageGoodlist({
name: this.query.name,
page: this.tableData.page,
size: this.tableData.size
})
this.tableData.loading = false
this.tableData.data = res.content
this.tableData.total = res.totalElements
} catch (error) {
console.log(error)
}
}
}
}
</script>

View File

@ -0,0 +1,188 @@
<template>
<el-dialog :title="form.id ? '编辑存酒' : '添加存酒'" width="500px" :visible.sync="dialogVisible" @close="reset">
<el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="left">
<template v-if="!form.id">
<el-form-item label="选择用户" prop="userid">
<el-select v-model="form.userid" placeholder="请输入用户昵称" filterable remote
:remote-method="queryAllShopUser" :loading="loading" @change="userChange">
<el-option v-for="item in options" :key="item.id" :label="`${item.nickName}-${item.telephone}`"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="选择酒品">
<el-select v-model="form.name" @change="wineChange" v-if="!wine">
<el-option :label="item.name" :value="item.name" v-for="(item, index) in wineList"
:key="index"></el-option>
</el-select>
<div class="goods_info" v-else>
<el-image :src="form.imgUrl" style="width: 50px;height: 50px;"></el-image>
<div class="info">{{ form.name }}</div>
</div>
</el-form-item>
<el-form-item label="数量">
<el-input-number v-model="form.num" :step="1" step-strictly :min="1"></el-input-number>
</el-form-item>
</template>
<el-form-item label="数量" v-else>
<el-input-number v-model="num" :step="1" step-strictly :min="1" :max="form.num"></el-input-number>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" @click="onSubmitHandle"> </el-button>
</span>
</el-dialog>
</template>
<script>
import { queryAllShopUser } from '@/api/shop'
import { tbShopStorageGoodlist, storageWin, storagePut } from '@/api/application'
export default {
data() {
return {
dialogVisible: false,
loading: false,
options: [],
num: '',
wine: false,
form: {
id: '',
imgUrl: '',
name: '',
nickname: '',
num: 1,
status: '',
telphone: '',
unit: '',
userid: '',
expDay: ''
},
resetForm: '',
rules: {
userid: [
{
required: true,
message: ' ',
trigger: 'blur'
}
]
},
wineList: []
}
},
mounted() {
this.resetForm = { ...this.form }
this.queryAllShopUser()
this.tbShopStorageGoodlist()
},
methods: {
//
userChange(e) {
let user = this.options.find(item => item.id == e)
this.form.nickname = user.nickName
this.form.telphone = user.telephone
},
//
wineChange(e) {
let wine = this.wineList.find(item => item.name == e)
this.form.imgUrl = wine.imgUrl
this.form.expDay = wine.period
this.form.unit = wine.unit
},
//
async tbShopStorageGoodlist() {
try {
const res = await tbShopStorageGoodlist({
page: 0,
size: 100
})
this.wineList = res.content
} catch (error) {
console.log(error)
}
},
//
async queryAllShopUser(query = '') {
this.loading = true
try {
const res = await queryAllShopUser({
name: query,
})
this.loading = false
this.options = res.content
} catch (error) {
this.loading = false
console.log(error)
}
},
//
onSubmitHandle() {
console.log(this.form)
this.$refs.form.validate(async valid => {
if (valid) {
try {
let res = ''
if (this.form.id) {
res = await storagePut({
id: this.form.id,
num: this.num,
type: 0
})
this.$notify({
title: '成功',
message: `取酒成功`,
type: 'success'
});
} else {
res = await storageWin(this.form)
this.$notify({
title: '成功',
message: `存酒成功`,
type: 'success'
});
}
this.$emit('success', res)
this.close()
} catch (error) {
console.log(error)
}
}
})
},
async show(obj = {}, wine = false) {
this.dialogVisible = true
if (obj && obj.id) {
this.form = { ...obj }
}
if (obj && obj.name) {
this.form.name = obj.name
this.form.imgUrl = obj.imgUrl
this.form.expDay = obj.expDay
this.form.unit = obj.unit
}
this.wine = wine
},
close() {
this.dialogVisible = false
},
reset() {
this.form = { ...this.resetForm }
}
}
}
</script>
<style scoped lang="scss">
.goods_info {
background-color: #f9f9f9;
padding: 10px;
display: flex;
align-items: center;
.info {
flex: 1;
padding-left: 10px;
}
}
</style>

View File

@ -0,0 +1,38 @@
<template>
<el-dialog title="记录" width="500px" :visible.sync="dialogVisible">
<el-steps :active="list.length" direction="vertical" :space="100">
<el-step :title="item.content" :description="item.time" v-for="item in list" :key="item.id"></el-step>
</el-steps>
<el-empty description="暂无记录" v-if="!list.length"></el-empty>
</el-dialog>
</template>
<script>
import { recordList } from '@/api/application'
export default {
data() {
return {
dialogVisible: false,
loading: false,
list: []
}
},
methods: {
//
async recordList(storageId) {
try {
this.loading = true
const res = await recordList({ storageId: storageId })
this.list = res.content
this.loading = false
} catch (error) {
console.log(error);
}
},
show(id) {
this.dialogVisible = true
this.recordList(id)
}
}
}
</script>

View File

@ -0,0 +1,166 @@
<template>
<div class="head-container">
<div class="head-container">
<el-form :model="query" inline>
<el-form-item>
<el-button type="primary" @click="$refs.addModal.show()">添加存酒</el-button>
</el-form-item>
<el-form-item label="搜索">
<el-input v-model="query.name" placeholder="酒名/用户昵称"></el-input>
</el-form-item>
<el-form-item label="手机号">
<el-input v-model="query.telphone" placeholder="手机号"></el-input>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="query.status">
<el-option v-for="item in statusList" :key="item.value" :value="item.value"
:label="item.label"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getTableData">查询</el-button>
<el-button @click="resetHandle">重置</el-button>
</el-form-item>
</el-form>
</div>
<div class="head-container">
<el-table :data="tableData.data" v-loading="tableData.loading" row-key="id">
<el-table-column label="用户名" prop="nickname">
<template v-slot="scope">
<div style="display: flex;align-items: center;">
<el-image src=""
style="width:40px;height: 40px;background-color: #efefef;display: flex;align-items: center;justify-content: center;">
<i class="el-icon-folder-delete" slot="error" style="font-size: 20px;color: #999;"></i>
</el-image>
<span style="margin-left: 10px;">{{ scope.row.telphone }}</span>
</div>
</template>
</el-table-column>
<el-table-column label="酒品名" prop="name">
<template v-slot="scope">
<div style="display: flex;align-items: center;">
<el-image :src="scope.row.imgUrl" style="width:40px;height: 40px;">
<i class="el-icon-folder-delete" slot="error"></i>
</el-image>
<span style="margin-left: 10px;">{{ scope.row.name }}</span>
</div>
</template>
</el-table-column>
<el-table-column label="数量" prop="name">
<template v-slot="scope">
<span>{{ scope.row.num }}({{ scope.row.unit }})</span>
</template>
</el-table-column>
<el-table-column label="存酒时间" prop="savTime"></el-table-column>
<el-table-column label="到期时间" prop="expTime"></el-table-column>
<el-table-column label="状态" prop="status">
<template v-slot="scope">
<el-tag :type="statusList.find(item => item.value === scope.row.status).type">{{
statusList.find(item => item.value === scope.row.status).label }}</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="120">
<template v-slot="scope">
<div style="display: flex;gap: 10px;">
<el-button type="text" @click="$refs.HistoryModal.show(scope.row.id)">查看记录</el-button>
<el-button type="text" v-if="scope.row.status == 0" disabled>已取完</el-button>
<el-button type="text" @click="$refs.addModal.show(scope.row)"
v-if="scope.row.status == 1">取酒</el-button>
<el-button type="text" v-if="scope.row.status == 2" disabled>已过期</el-button>
</div>
</template>
</el-table-column>
</el-table>
</div>
<div class="head-container">
<el-pagination :total="tableData.total" :current-page="tableData.page + 1" :page-size="tableData.size"
@current-change="paginationChange" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
</div>
<addModal ref="addModal" @success="getTableData" />
<HistoryModal ref="HistoryModal" />
</div>
</template>
<script>
import addModal from './addModal'
import HistoryModal from './historyModal'
import { storageList } from '@/api/application'
export default {
components: {
addModal,
HistoryModal
},
data() {
return {
statusList: [
{
value: '',
label: '全部',
type: 'warning'
},
{
value: 0,
label: '已取完',
type: 'warning'
},
{
value: 1,
label: '存储中',
type: 'primary'
},
{
value: 2,
label: '已过期',
type: 'info'
}
],
query: {
name: "",
telphone: "",
status: ''
},
tableData: {
data: [],
page: 0,
size: 10,
loading: false,
total: 0
}
}
},
mounted() {
this.getTableData()
},
methods: {
//
resetHandle() {
this.tableData.page = 0
this.query.name = ''
this.query.telphone = ''
this.query.status = ''
this.getTableData()
},
//
paginationChange(e) {
this.tableData.page = e - 1;
this.getTableData()
},
//
async getTableData() {
try {
this.tableData.loading = true
const res = await storageList({
...this.query,
page: this.tableData.page,
size: this.tableData.size
})
this.tableData.loading = false
this.tableData.data = res.content
this.tableData.total = res.totalElements
} catch (error) {
console.log(error)
}
}
}
}
</script>

View File

@ -0,0 +1,82 @@
<template>
<div class="head-container">
<el-table :data="tableData.data" v-loading="tableData.loading">
<el-table-column label="商品信息">
<template v-slot="scope">
<div class="shop_info">
<el-image :src="scope.row.imgUrl"
style="width: 50px;height: 50px;border-radius: 4px;background-color: #efefef;">
<div class="img_error" slot="error">
<i class="icon el-icon-document-delete"></i>
</div>
</el-image>
<div class="info">
<span>{{ scope.row.name }}</span>
</div>
</div>
</template>
</el-table-column>
<el-table-column label="有效存酒" prop="savNum"></el-table-column>
<el-table-column label="已过期存酒" prop="expNum"></el-table-column>
</el-table>
</div>
</template>
<script>
import { countRecord } from '@/api/application'
export default {
data() {
return {
tableData: {
data: [],
page: 0,
size: 10,
loading: false,
total: 0
}
}
},
mounted() {
this.getTableData()
},
methods: {
//
paginationChange(e) {
this.tableData.page = e - 1
this.getTableData()
},
//
async getTableData() {
try {
this.tableData.loading = true
const res = await countRecord({
page: this.tableData.page,
size: this.tableData.size
})
this.tableData.loading = false
this.tableData.data = res.content
this.tableData.total = res.totalElements
} catch (error) {
console.log(error)
}
}
}
}
</script>
<style scoped lang="scss">
.shop_info {
display: flex;
.info {
flex: 1;
padding-left: 8px;
display: flex;
flex-direction: column;
.tag_wrap {
display: flex;
}
}
}
</style>

View File

@ -1,83 +1,111 @@
<template>
<div>
<el-dialog title="添加优惠券" :visible.sync="dialogVisible" @close="reset">
<div class="app-container">
<div class="tab">
<div class="tab_item" @click="tabClick(item)" :class="{active: tabActive == item.type}" v-for="(item,index) in tabList" :key="index"> {{ item.name }} <span class="bor"></span></div>
</div>
<!-- 优惠券 -->
<div class="content" v-if="tabActive == 1">
<el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="left">
<el-form-item label="优惠卷名称" prop="title">
<el-input v-model="form.title" placeholder="请输入优惠卷名称" style="width: 200px;"></el-input>
<el-form-item label="优惠卷名" prop="title">
<el-input v-model="form.title" placeholder="" style="width: 289px;"></el-input>
</el-form-item>
<el-form-item label="类型">
<el-radio-group v-model="form.classType">
<el-radio :label="item.value" v-for="item in couponEnum.classType" :key="item.value">
<el-form-item label="使用门槛" prop="title">
<el-input v-model="form.title" placeholder="" style="width: 180px;margin-right: 66px;">
<template slot="prepend"></template>
<template slot="append"></template>
</el-input>
<el-input v-model="form.title" placeholder="" style="width: 180px;">
<template slot="prepend"></template>
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="有效期类型">
<el-radio-group v-model="form.validityType">
<el-radio :label="item.value" v-for="item in couponEnum.validityType" :key="item.value">
{{ item.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="选择商品" v-if="form.classType == 'product'" prop="classType">
<div>
<el-button type="primary" icon="el-icon-plus" @click="$refs.shopListRef.show([...productIds])">
添加商品
</el-button>
</div>
<div class="shop_list">
<div class="item_wrap" v-for="(item, index) in productIds" :key="item.id"
@click="productIds.splice(index, 1)">
<div class="item" :data-index="index + 1">
<el-image :src="item.coverImg" style="width: 100%;height: 100%;"></el-image>
</div>
<div class="name">{{ item.name }}</div>
</div>
</div>
<el-form-item label="有效时间" v-if="form.validityType == 1">
<el-date-picker v-model="selectTime" type="daterange" range-separator="" start-placeholder="开始日期"
end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']"
value-format="yyyy-MM-dd HH:mm:ss">
</el-date-picker>
</el-form-item>
<el-form-item label="优惠类型">
<el-radio-group v-model="form.type">
<el-radio :label="item.value" v-for="item in couponEnum.type" :key="item.value">
{{ item.label }}
</el-radio>
</el-radio-group>
<el-form-item label="使用门槛" prop="title">
<el-input v-model="form.title" placeholder="" style="width: 200px;">
<template slot="prepend"></template>
<template slot="append">天生效</template>
</el-input>
</el-form-item>
<el-form-item label="满减限制" v-if="form.type == '0'">
<el-input-number v-model="form.limitAmount" controls-position="right" :min="0"></el-input-number>
<el-form-item label="可用周期" prop="title">
<el-checkbox-group v-model="form.checkedCycle" >
<el-checkbox v-for="(city,index) in couponEnum.cycle" :label="city.label" :key="index">{{city.label}}</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="折扣" v-if="form.type == '1'">
<el-input-number v-model="form.ratio" controls-position="right" :min="1"></el-input-number>
</el-form-item>
<el-form-item label="优惠券面额">
<el-input-number v-model="form.amount" controls-position="right" :min="0"></el-input-number>
</el-form-item>
<el-form-item label="发放数量">
<el-input-number v-model="form.number" controls-position="right" :min="1"></el-input-number>
</el-form-item>
<el-form-item label="限领数量">
<el-input-number v-model="form.limitNumber" controls-position="right" :min="1"></el-input-number>
</el-form-item>
<el-form-item label="有效期">
<el-form-item label="指定时间段">
<el-radio-group v-model="form.effectType">
<el-radio :label="item.value" v-for="item in couponEnum.effectType" :key="item.value">
{{ item.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="有效时间" v-if="form.effectType == 1">
<el-form-item label="指定时间段" v-if="form.effectType == 1">
<el-date-picker v-model="selectTime" type="daterange" range-separator="" start-placeholder="开始日期"
end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']"
value-format="yyyy-MM-dd HH:mm:ss">
</el-date-picker>
</el-form-item>
<el-form-item label="状态">
<el-switch v-model="form.status" :active-value="1" :inactive-value="0"></el-switch>
<el-form-item label="发放数量" prop="title">
<el-input v-model="form.title" placeholder="" style="width: 200px;"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" :loading="loading" @click="onSubmitHandle"> </el-button>
</span>
</el-dialog>
</div>
<!-- 商品券 -->
<div class="content" v-if="tabActive == 2">
<el-form ref="form" :model="formTwo" :rules="rulesTwo" label-width="120px" label-position="left">
<el-form-item label="商品卷卷名" prop="title">
<el-input v-model="form.title" placeholder="" style="width: 289px;"></el-input>
</el-form-item>
<el-form-item label="发放数量" >
<el-input v-model="form.title" placeholder="" style="width: 289px;"></el-input>
</el-form-item>
<el-form-item label="使用门槛" >
全额满<el-input v-model="form.title" placeholder="" style="width: 100px;margin: 0 23px;"><template slot="suffix"></template></el-input>可用
</el-form-item>
<el-form-item label="赠送商品" v-if="form.classType == 'product'" prop="classType">
<div>
<el-button type="primary" icon="el-icon-plus" @click="$refs.shopListRef.show([...productIds])">
添加 </el-button>
</div>
<div class="shop_list">
<div class="item_wrap" v-for="(item, index) in productIds" :key="item.id"
@click="productIds.splice(index, 1)">
<div class="name">{{ item.name }}</div>
<el-input v-model="form.title" placeholder="请填写数量" style="width: 100px;"></el-input>
<div class="del">删除</div>
</div>
</div>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false"> </el-button>
<el-button type="primary" :loading="loading" @click="onSubmitHandle"> </el-button>
</span>
</div>
<shopList ref="shopListRef" @success="slectShop" />
</div>
</template>
<script>
import couponEnum from './../couponEnum'
import couponEnum from './couponEnum'
import shopList from '@/components/shopList'
import { tbMerchantCoupon } from '@/api/shop'
export default {
@ -91,15 +119,23 @@ export default {
}
}
return {
tabList: [
{ name: "新增优惠券", type: 1},
{ name: "新增商品券", type: 2},
],
tabActive: 1,
couponEnum,
dialogVisible: false,
loading: false,
selectTime: [],
form: {
id: '',
validityType: '0',
checkedCycle: [],
type: '0',
title: '',
classType: 'product',
type: '0',
limitAmount: '',
ratio: '1',
amount: '',
@ -110,6 +146,9 @@ export default {
toTime: '',
relationIds: '',
status: 1
},
formTwo: {
},
rules: {
title: [
@ -127,14 +166,37 @@ export default {
}
]
},
rulesTwo: {
title: [
{
required: true,
message: ' ',
trigger: 'blur'
}
],
classType: [
{
required: true,
validator: validateProduct,
trigger: 'change'
}
]
},
resetForm: '',
productIds: []
}
},
mounted() {
this.resetForm = { ...this.form }
console.log(this.$route.query.type)
this.tabActive = this.$route.query.type;
},
methods: {
tabClick (item) {
console.log(item)
this.tabActive = item.type;
},
//
slectShop(res) {
if (this.productIds.length) {
@ -208,70 +270,59 @@ export default {
</script>
<style scoped lang="scss">
.tab{
display: flex;
margin-bottom: 30px;
padding-top: 40px;
padding-left: 10px;
.tab_item{
margin-right: 64px;
font-weight: 400;
font-size: 16px;
color: #666666;
cursor: pointer;
.bor{
display: block;
width: 56px;
height: 6px;
background-color: transparent;
border-radius: 3px 3px 3px 3px;
margin: 5px auto 0;
}
}
.active{
color: #3F9EFF;
.bor{
background-color: #3F9EFF;
}
}
}
.content{
font-weight: 400;
font-size: 16px;
color: #666666;
}
.shop_list {
display: flex;
flex-wrap: wrap;
margin-top: 15px;
.item_wrap {
$size: 80px;
.item {
$radius: 4px;
width: $size;
height: $size;
border-radius: $radius;
overflow: hidden;
position: relative;
margin-right: 10px;
margin-top: 10px;
&:hover {
cursor: pointer;
}
&::after {
content: attr(data-index);
font-size: 12px;
height: 20px;
display: flex;
padding: 0 10px;
border-radius: 0 0 $radius 0;
align-items: center;
background-color: rgba(0, 0, 0, 0.3);
backdrop-filter: blur(10px);
color: #fff;
position: absolute;
top: 0;
left: 0;
z-index: 10;
}
&::before {
content: '删除';
font-size: 12px;
width: 100%;
height: 20px;
display: flex;
padding: 0 10px;
align-items: center;
justify-content: center;
background-color: rgba(0, 0, 0, 0.3);
backdrop-filter: blur(10px);
color: #fff;
position: absolute;
bottom: 0;
left: 0;
z-index: 10;
transition: all .1s ease-in-out;
}
}
display: flex;
align-items: center;
.name {
width: $size;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.del{
font-weight: 400;
font-size: 14px;
color: #3F9EFF;
margin-left: 11px;
}
}
}
</style>

View File

@ -0,0 +1,204 @@
<template>
<div>
<el-dialog title="领取详情" :visible.sync="dialogVisible" width="70%" @close="reset">
<div class="search">
<el-form :model="query" inline label-position="left">
<el-form-item>
<el-input v-model="query.name" placeholder="用户ID/用户昵称/用户手机" style="width: 180px;" />
</el-form-item>
<el-form-item>
<el-select v-model="query.state" placeholder="选择状态" style="width: 154px;">
<el-option
v-for="item in stateList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item />
<el-form-item label="领取时间">
<el-date-picker
v-model="query.createdAt"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
value-format="yyyy-MM-dd HH:mm:ss"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getTableData">查询</el-button>
<el-button v-loading="downloadLoading" icon="el-icon-download" @click="downloadHandle">
<span v-if="!downloadLoading">导出</span>
<span v-else>下载中...</span>
</el-button>
</el-form-item>
</el-form>
</div>
<div>
<el-table v-loading="loading" :data="tableData">
<el-table-column label="用户ID" prop="id" />
<el-table-column label="用户名" prop="areaName" />
<el-table-column label="领取时间" prop="tableName" />
<el-table-column label="使用时间" prop="tableName" />
<el-table-column label="获得来源" prop="tableName" />
<el-table-column label="状态" prop="tableName" />
<el-table-column label="使用门店" prop="tableName" />
<el-table-column label="订单数量" prop="orderCount">
<template v-slot="scope">
<div class="cursor-pointer" @click="toTableOrderList(scope.row)">
{{ scope.row.orderCount }}
</div>
</template>
</el-table-column>
</el-table>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
data() {
return {
dialogVisible: true,
downloadLoading: false,
loading: false,
stateList: [
{ label: '未使用', value: 1 },
{ label: '已使用', value: 2 }
],
query: {
name: '',
createdAt: [],
state: ''
},
tableData: null
}
},
mounted() {
},
methods: {
/**
* 查询
*/
getTableData() {
},
// Excel
async downloadHandle() {
try {
this.downloadLoading = true
// eslint-disable-next-line no-undef
const file = await summaryTableDownload({
startTime: this.query.createdAt[0],
endTime: this.query.createdAt[1]
})
// eslint-disable-next-line no-undef
downloadFile(file, '数据', 'xlsx')
this.downloadLoading = false
} catch (error) {
this.downloadLoading = false
console.log(error)
}
},
//
onSubmitHandle() {
},
/**
* 打开详情
* @param obj
*/
show(obj) {
this.dialogVisible = true
// if (obj && obj.id) {
// this.form = { ...obj }
// }
},
/**
* 关闭详情
*/
close() {
this.dialogVisible = false
},
reset() {
this.form = { ...this.resetForm }
}
}
}
</script>
<style scoped lang="scss">
.shop_list {
display: flex;
flex-wrap: wrap;
.item_wrap {
$size: 80px;
.item {
$radius: 4px;
width: $size;
height: $size;
border-radius: $radius;
overflow: hidden;
position: relative;
margin-right: 10px;
margin-top: 10px;
&:hover {
cursor: pointer;
}
&::after {
content: attr(data-index);
font-size: 12px;
height: 20px;
display: flex;
padding: 0 10px;
border-radius: 0 0 $radius 0;
align-items: center;
background-color: rgba(0, 0, 0, 0.3);
backdrop-filter: blur(10px);
color: #fff;
position: absolute;
top: 0;
left: 0;
z-index: 10;
}
&::before {
content: '删除';
font-size: 12px;
width: 100%;
height: 20px;
display: flex;
padding: 0 10px;
align-items: center;
justify-content: center;
background-color: rgba(0, 0, 0, 0.3);
backdrop-filter: blur(10px);
color: #fff;
position: absolute;
bottom: 0;
left: 0;
z-index: 10;
transition: all .1s ease-in-out;
}
}
.name {
width: $size;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
</style>

View File

@ -19,14 +19,33 @@ export default {
label: '折扣'
}
],
effectType: [
cycle: [
{ label: '周一'},
{ label: '周二'},
{ label: '周三'},
{ label: '周四'},
{ label: '周五'},
{ label: '周六'},
{ label: '周七'},
],
validityType: [
{
value: '0',
label: '一直有效'
label: '领券后有效期内可用'
},
{
value: '1',
label: '时限有效'
label: '固定有效期范围内可用'
}
],
effectType: [
{
value: '0',
label: '全时段可用'
},
{
value: '1',
label: '指定时间段'
}
]
}

View File

@ -1,42 +1,43 @@
<template>
<div class="app-container">
<div class="head-container">
<el-button type="primary" icon="el-icon-plus" @click="$refs.addCoupon.show()">
<!-- <el-button type="primary" icon="el-icon-plus" @click="$refs.addCoupon.show()">
添加优惠券
</el-button> -->
<el-button type="primary" icon="el-icon-plus" @click="$router.push({name: 'add_coupon', query: {type:1}})">
添加优惠券
</el-button>
<el-button type="primary" icon="el-icon-plus" @click="$router.push({name: 'add_coupon', query: {type:2}})">
添加商品券
</el-button>
</div>
<div class="head-container">
<el-table :data="tableData.data" v-loading="tableData.loading">
<el-table-column label="优惠券名称" prop="title"></el-table-column>
<el-table-column label="类型" prop="classType">
<template v-slot="scope">
{{ scope.row.classType | classTypeFilter }}
</template>
</el-table-column>
<el-table-column label="ID" prop="title"></el-table-column>
<el-table-column label="名称" prop="title"></el-table-column>
<el-table-column label="优惠类型" prop="type">
<template v-slot="scope">
{{ scope.row.type | typeFilter }}
</template>
</el-table-column>
<el-table-column label="折扣" prop="ratio"></el-table-column>
<el-table-column label="面额" prop="amount"></el-table-column>
<el-table-column label="满减限制" prop="limitAmount"></el-table-column>
<el-table-column label="发放数量" prop="number"></el-table-column>
<el-table-column label="限领数量" prop="limitNumber"></el-table-column>
<el-table-column label="剩余数量" prop="leftNumber"></el-table-column>
<el-table-column label="使用门槛" prop="ratio"></el-table-column>
<el-table-column label="有效期" prop="effectType">
<template v-slot="scope">
{{ scope.row.effectType | effectTypeFilter }}
</template>
</el-table-column>
<el-table-column label="开始时间" prop="fromTime"></el-table-column>
<el-table-column label="到期时间" prop="toTime"></el-table-column>
<el-table-column label="商品列表" prop="relationIds" width="200">
<el-table-column label="用户领取方式" prop="ratio"></el-table-column>
<el-table-column label="总发放数量" prop="ratio"></el-table-column>
<el-table-column label="已领取" prop="ratio"></el-table-column>
<el-table-column label="已使用" prop="ratio"></el-table-column>
<el-table-column label="剩余" prop="ratio"></el-table-column>
<el-table-column label="操作" width="150">
<template v-slot="scope">
<div style="display: flex;" v-if="scope.row.classType == 'product'">
<el-image :src="scope.row.coverImg" style="width: 30px;height: 30px;"></el-image>
<span style="margin-left: 10px;">{{ scope.row.name }}</span>
</div>
<el-button type="text" icon="el-icon-edit" @click="toPath( '/product/add_shop' ,scope.row )">编辑</el-button>
<el-popconfirm title="确定删除吗?" @confirm="delTableHandle([scope.row.id])">
<el-button type="text" icon="el-icon-delete" style="margin-left: 20px !important;"
slot="reference">删除</el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
@ -52,7 +53,7 @@
<script>
import couponEnum from './couponEnum'
import addCoupon from './components/addCoupon.vue'
import addCoupon from './components/coupon_details.vue'
import { tbMerchantCouponGet } from '@/api/shop'
export default {
components: { addCoupon },
@ -68,9 +69,7 @@ export default {
}
},
filters: {
classTypeFilter(value) {
return couponEnum.classType.find(item => item.value == value).label
},
typeFilter(value) {
return couponEnum.type.find(item => item.value == value).label
},
@ -82,6 +81,10 @@ export default {
this.getTableData()
},
methods: {
//
toPath ( path , row) {
this.$router.push({path: path, query: row})
},
//
resetHandle() {
this.page = 0