fix:项目初始化
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="Visible" calss="ac-dialog" center top="50px" id="activity" width="800px" @close="close">
|
||||
<el-form :rules="rules" :model="dialogForm" label-position="right" label-width="120px" ref="dialogForm">
|
||||
<el-row :gutter="24">
|
||||
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
||||
<el-form-item label="抵用金额" prop="sort">
|
||||
<el-input placeholder="请输入抵用金额" v-model.number="dialogForm.coupon" style="width: 180px" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
||||
|
||||
<el-form-item label="奖品图片">
|
||||
<UploadImg @changeImgUrl="changeAvatarUrl" :img="dialogForm.cover"> </UploadImg>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
||||
<el-form-item label="折扣券类型" prop="couponsType">
|
||||
<el-select placeholder="请选择折折扣券类型" v-model="dialogForm.couponsType" style="width:160px">
|
||||
<el-option v-for="item in couponsTypeList" :label="item.name" :value="item.id" :key='item.id' />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
||||
<el-form-item label="折扣卡" prop="couponsId">
|
||||
<el-select placeholder="请选择折扣卡" v-model="dialogForm.couponsId" style="width:160px">
|
||||
<el-option v-for="item in discountcardList" :label="item.name" :value="item.id" :key='item.id' />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :lg="12" :md="12" :sm="12" :xl="12" :xs="24">
|
||||
<el-form-item label="过期时间">
|
||||
<el-date-picker v-model="dialogForm.expireTime" type="datetime" placeholder="结束时间" style="width: 163px" value-format="yyyy-MM-ddTHH:mm:ss+08:00">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
||||
<el-form-item label="用户ID" prop="sort">
|
||||
<el-input placeholder="请输入用户ID" v-model.number="dialogForm.userId" style="width: 180px" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
||||
<el-form-item label="门槛" prop="sort">
|
||||
<el-input placeholder="请输入门槛" v-model.number="dialogForm.threshold" style="width: 180px" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</el-form>
|
||||
<div class="dialog-footer" slot="footer">
|
||||
<el-button @click="Visible = false">取 消</el-button>
|
||||
<el-button @click="submitForm('dialogForm')" type="primary">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { addUserDiscountcard, upadteUserDiscountcard } from '@/api/commodity/userDiscountcard'
|
||||
import { changeMoneyFen, changeMoneyYuan } from '@/filters'
|
||||
import UploadImg from '@/components/UploadImg/index'
|
||||
export default {
|
||||
name: 'AddOrEdit',
|
||||
props: ['data', 'discountcardList'],
|
||||
components:{
|
||||
UploadImg
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: '',
|
||||
Visible: true,
|
||||
// 表单数据
|
||||
dialogForm: {
|
||||
userId: undefined,
|
||||
couponsId: undefined,
|
||||
cover:undefined,
|
||||
couponsType:undefined,
|
||||
},
|
||||
couponsTypeList:[
|
||||
{id:1,name:'抵用券'},
|
||||
{id:2,name:'折扣券'},
|
||||
],
|
||||
|
||||
rules: {
|
||||
discount: [{ required: true, message: '必填', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '必填', trigger: 'blur' }]
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.title = this.data.title
|
||||
if (this.title === '编辑') {
|
||||
this.dialogForm = { ...this.data.data }
|
||||
this.dialogForm.coupon = changeMoneyYuan(this.dialogForm.coupon)
|
||||
this.dialogForm.threshold = changeMoneyYuan(this.dialogForm.threshold)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
changeAvatarUrl(data){
|
||||
this.dialogForm.cover = data
|
||||
},
|
||||
// TODO:编辑卡片管理数据
|
||||
update(data) {
|
||||
upadteUserDiscountcard(data).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$message.success('编辑成功')
|
||||
this.Visible = false
|
||||
} else {
|
||||
this.$message.error('编辑失败')
|
||||
}
|
||||
})
|
||||
},
|
||||
// TODO:新增卡片管理数据
|
||||
add(data) {
|
||||
addUserDiscountcard(data).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.$message.success('新增成功')
|
||||
this.Visible = false
|
||||
} else {
|
||||
this.$message.error('新增失败')
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
close() {
|
||||
this.$emit('close')
|
||||
},
|
||||
|
||||
// 提交按钮
|
||||
submitForm(formName) {
|
||||
this.$refs[formName].validate(valid => {
|
||||
if (valid) {
|
||||
const data = JSON.parse(JSON.stringify(this.dialogForm))
|
||||
data.coupon = changeMoneyFen(data.coupon)
|
||||
data.threshold = changeMoneyFen(data.threshold)
|
||||
if (this.title === '编辑') {
|
||||
this.update(data)
|
||||
} else {
|
||||
this.add(data)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,244 @@
|
||||
<template>
|
||||
<div class="pf-warpper">
|
||||
<el-row class="table-form">
|
||||
<!-- 查询条件 -->
|
||||
<el-form :inline="true" :model="searchData" class="form-inline" label-width="80px" size="mini">
|
||||
<el-form-item>
|
||||
<el-select placeholder="请选择折扣卡" v-model="searchData.couponsId" style="width:160px" @clear="onClear('couponsId')">
|
||||
<el-option v-for="item in discountcardList" :label="item.name" :value="item.id" :key='item.id' />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-input placeholder="请输入id" clearable v-model="searchData.id" @clear="onClear('id')" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-form-item>
|
||||
<el-input placeholder="请输入用户id" clearable v-model.number="searchData.userId" @clear="onClear('userId')" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-input placeholder="请输入订单号" clearable v-model="searchData.tradeNo" @clear="onClear('tradeNo')" />
|
||||
</el-form-item>
|
||||
<el-select placeholder="请选择上架状态" clearable v-model="searchData.status" @clear="onClear('status')">
|
||||
<el-option :key="item.value" :label="item.label" :value="item.value" v-for="item in vipCardStatus" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="onSearch" icon="el-icon-search" plain type="primary">搜索</el-button>
|
||||
<el-button @click="handleAdd()" icon="el-icon-circle-plus-outline" plain type="success">新增商品</el-button>
|
||||
<el-button @click="getData" icon="el-icon-refresh" plain type="info">刷新</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col>
|
||||
<!-- 展示列表 -->
|
||||
<el-table :data="tableData" border height="750" highlight-current-row style="width: 100%" :row-style="{ height: '70px' }">
|
||||
<el-table-column align="center" label="奖品ID" width="80">
|
||||
<template slot-scope="scope">{{ scope.row.id }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="折扣" width="80">
|
||||
<template slot-scope="scope">{{ scope.row.discount }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="用户ID" width="80">
|
||||
<template slot-scope="scope">{{ scope.row.userId }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="折扣卡" width="80">
|
||||
<template slot-scope="scope">{{ scope.row.couponsId | changeDiscountCardList(discountcardList) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="抵用金额" width="80">
|
||||
<template slot-scope="scope">{{ scope.row.coupon/100 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="门槛" width="80">
|
||||
<template slot-scope="scope">{{ scope.row.threshold/100 }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="图片">
|
||||
<template slot-scope="scope">
|
||||
<ShowImg style="width: 40px; height: 40px; margin: 0 auto; line-height: 40px" :urls="scope.row.cover"></ShowImg>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="折扣券类型" width="80">
|
||||
<template slot-scope="scope">{{ scope.row.couponsType===1?'抵用券':'折扣券' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="状态">
|
||||
<template slot-scope="scope">
|
||||
<el-button :type="scope.row.state ? 'danger' : 'success'" plain size="mini">{{ scope.row.state===1 ? '未使用' :scope.row.state===2 ? '已使用':'已过期' }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="过期时间" width="160">
|
||||
<template slot-scope="scope">{{
|
||||
scope.row.expireTime | BeiJingTime
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="创建时间" width="160">
|
||||
<template slot-scope="scope">{{
|
||||
scope.row.createdAt | BeiJingTime
|
||||
}}</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" fixed="right" label="操作" width="160">
|
||||
<template slot-scope="scope">
|
||||
<el-button @click="handleEdit(scope.$index, scope.row)" size="mini" type="primary">编辑</el-button>
|
||||
<el-button @click="handleDelete(scope.$index, scope.row)" size="mini" type="danger">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<!-- 分页 -->
|
||||
<div class="table-pagination">
|
||||
<el-pagination
|
||||
:current-page="searchData.pageNum"
|
||||
:page-sizes="[10, 20, 30, 50, 100]"
|
||||
:total="total"
|
||||
@current-change="handleCurrentChange"
|
||||
@size-change="handleSizeChange"
|
||||
layout="total, sizes, prev, pager, next, jumper"/>
|
||||
</div>
|
||||
<!-- 新增/编辑弹出框 -->
|
||||
<Edit :discountcardList="discountcardList" :data="editData" v-if="dialogFormVisible" @close="closeEdit"></Edit>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { getUserDiscountcard, delUserDiscountcard } from '@/api/commodity/userDiscountcard'
|
||||
import { getDiscountcard } from '@/api/commodity/discountcard'
|
||||
import ShowImg from '@/components/ShowImg/index.vue'
|
||||
|
||||
import Edit from './components/AddOrEdit'
|
||||
|
||||
export default {
|
||||
name: 'Vipcard',
|
||||
components: {
|
||||
Edit,
|
||||
ShowImg
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
vipCardStatus: [
|
||||
{ label: '启用', value: true },
|
||||
{ label: '禁用', value: false }
|
||||
],
|
||||
// 请求列表筛选参数
|
||||
searchData: {
|
||||
status: undefined, // 激活状态
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
couponsId: undefined,
|
||||
tradeNo: undefined,
|
||||
id: undefined,
|
||||
userId: undefined
|
||||
},
|
||||
tableData: [],
|
||||
total: 0,
|
||||
dialogFormVisible: false,
|
||||
editData: {},
|
||||
discountcardList: []
|
||||
}
|
||||
},
|
||||
filters: {
|
||||
changeDiscountCardList(v, l) {
|
||||
if (l && l.length > 0) {
|
||||
let name = ''
|
||||
l.find(item => {
|
||||
if (item.id === v) {
|
||||
name = item.name
|
||||
}
|
||||
})
|
||||
return name
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getDiscountcardList()
|
||||
this.getData()
|
||||
},
|
||||
methods: {
|
||||
// TODO:请求卡片管理数据
|
||||
getDiscountcardList() {
|
||||
getDiscountcard({ pageNum: 1, pageSize: 1000 }).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.discountcardList = res.data.list
|
||||
} else {
|
||||
this.discountcardList = []
|
||||
}
|
||||
})
|
||||
},
|
||||
// TODO:请求卡片管理数据
|
||||
getData() {
|
||||
getUserDiscountcard(this.searchData).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.tableData = res.data.list
|
||||
this.total = res.data.count
|
||||
} else {
|
||||
this.tableData = []
|
||||
this.total = 0
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// TODO:删除卡片管理数据
|
||||
handleDelete(index, row) {
|
||||
this.$confirm('确定删除?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
delUserDiscountcard({ cardId: row.id }).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.getData({ pageNum: 1 }) // 刷新商品列表
|
||||
this.$message.success('删除成功')
|
||||
} else {
|
||||
this.$message.error('删除失败')
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
onSearch() {
|
||||
this.searchData.pageNum = 1
|
||||
this.searchData.pageSize = 10
|
||||
this.getData()
|
||||
},
|
||||
|
||||
// 切换每页显示的条数触发
|
||||
handleSizeChange(val) {
|
||||
this.searchData.pageSize = val
|
||||
this.getData()
|
||||
},
|
||||
|
||||
// 切换页码时触发
|
||||
handleCurrentChange(val) {
|
||||
this.searchData.pageNum = val
|
||||
this.getData()
|
||||
},
|
||||
|
||||
// 列表编辑按钮点击事件
|
||||
handleAdd() {
|
||||
this.editData = {
|
||||
title: '新增',
|
||||
data: {}
|
||||
}
|
||||
this.dialogFormVisible = true
|
||||
},
|
||||
// 列表编辑按钮点击事件
|
||||
handleEdit(index, row) {
|
||||
this.editData = {
|
||||
title: '编辑',
|
||||
data: row
|
||||
}
|
||||
this.dialogFormVisible = true
|
||||
},
|
||||
closeEdit() {
|
||||
this.editData = {
|
||||
title: '新增',
|
||||
data: {}
|
||||
}
|
||||
this.dialogFormVisible = false
|
||||
this.getData()
|
||||
},
|
||||
onClear(key) {
|
||||
this.searchData[key] = undefined
|
||||
this.getData()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user