1
This commit is contained in:
304
src/views/modules/coupon/coupon-add-or-update.vue
Normal file
304
src/views/modules/coupon/coupon-add-or-update.vue
Normal file
@@ -0,0 +1,304 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="!dataForm.id ? '新增' : '修改'"
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="visible">
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
|
||||
<el-form-item label="优惠卷类型:" prop="type">
|
||||
<!-- <el-input v-model="dataForm.type" placeholder="优惠卷类型"></el-input> -->
|
||||
<el-select v-model="dataForm.type" placeholder="请选择" >
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠券名称" prop="name">
|
||||
<el-input v-model="dataForm.name" placeholder="名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="使用平台">
|
||||
<!-- <el-input v-model="dataForm.platform" placeholder="使用平台"></el-input> -->
|
||||
<el-select v-model="dataForm.platform" placeholder="请选择" >
|
||||
<el-option
|
||||
v-for="item in options1"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="总发行量" prop="publishCount">
|
||||
<el-input v-model="dataForm.publishCount" placeholder="发行数量"></el-input>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="数量" prop="count">
|
||||
<el-input v-model="dataForm.count" placeholder="数量"></el-input>
|
||||
</el-form-item> -->
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="面额:" prop="amount">
|
||||
<el-input v-model="dataForm.amount" placeholder="面额">
|
||||
<template slot="append">元</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="每人限领:" prop="perLimit">
|
||||
<el-input v-model="dataForm.perLimit" placeholder="">
|
||||
<template slot="append">张</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="使用门槛" prop="minPoint">
|
||||
<el-input v-model="dataForm.minPoint" placeholder="">
|
||||
<template slot="prepend">满</template>
|
||||
<template slot="append">元可用</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="有效期" prop="startTime">
|
||||
<el-date-picker
|
||||
v-model="startTime"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="结束使用时间" prop="endTime">
|
||||
<el-input v-model="dataForm.endTime" placeholder="结束使用时间"></el-input>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="使用类型" prop="useType">
|
||||
<!-- <el-input v-model="dataForm.useType" placeholder="使用类型"></el-input> -->
|
||||
<el-radio-group v-model="dataForm.useType">
|
||||
<el-radio-button label="0">全场通用</el-radio-button>
|
||||
<el-radio-button label="1">指定分类</el-radio-button>
|
||||
<el-radio-button label="2">指定商品</el-radio-button>
|
||||
<!-- <el-radio-button label="深圳"></el-radio-button> -->
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="note">
|
||||
<el-input v-model="dataForm.note" placeholder="备注"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
<!-- <el-form-item label="已使用数量" prop="useCount">
|
||||
<el-input v-model="dataForm.useCount" placeholder="已使用数量"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="领取数量" prop="receiveCount">
|
||||
<el-input v-model="dataForm.receiveCount" placeholder="领取数量"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="可以领取的日期" prop="enableTime">
|
||||
<el-input v-model="dataForm.enableTime" placeholder="可以领取的日期"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠码" prop="code">
|
||||
<el-input v-model="dataForm.code" placeholder="优惠码"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="可领取的会员类型" prop="memberLevel">
|
||||
<el-input v-model="dataForm.memberLevel" placeholder="可领取的会员类型"></el-input>
|
||||
</el-form-item> -->
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
visible: false,
|
||||
options: [{
|
||||
value: 0,
|
||||
label: '全场赠券'
|
||||
}, {
|
||||
value: 1,
|
||||
label: '会员赠券'
|
||||
}, {
|
||||
value: 2,
|
||||
label: '购物赠券'
|
||||
}, {
|
||||
value: 3,
|
||||
label: '注册赠券'
|
||||
}],
|
||||
options1: [{
|
||||
value: 0,
|
||||
label: '全部'
|
||||
}, {
|
||||
value: 1,
|
||||
label: '移动'
|
||||
}, {
|
||||
value: 2,
|
||||
label: 'PC'
|
||||
}],
|
||||
startTime:[],
|
||||
dataForm: {
|
||||
id: 0,
|
||||
type: '',
|
||||
name: '',
|
||||
platform: '',
|
||||
count: '',
|
||||
amount: '',
|
||||
perLimit: '',
|
||||
minPoint: '',
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
useType: '',
|
||||
note: '',
|
||||
publishCount: '',
|
||||
useCount: '1',
|
||||
receiveCount: '',
|
||||
enableTime: '',
|
||||
code: '',
|
||||
memberLevel: ''
|
||||
},
|
||||
dataRule: {
|
||||
type: [
|
||||
{ required: true, message: '优惠卷类型;0->全场赠券;1->会员赠券;2->购物赠券;3->注册赠券不能为空', trigger: 'blur' }
|
||||
],
|
||||
name: [
|
||||
{ required: true, message: '名称不能为空', trigger: 'blur' }
|
||||
],
|
||||
platform: [
|
||||
{ required: true, message: '使用平台:0->全部;1->移动;2->PC不能为空', trigger: 'blur' }
|
||||
],
|
||||
count: [
|
||||
{ required: true, message: '数量不能为空', trigger: 'blur' }
|
||||
],
|
||||
amount: [
|
||||
{ required: true, message: '金额不能为空', trigger: 'blur' }
|
||||
],
|
||||
perLimit: [
|
||||
{ required: true, message: '每人限领张数不能为空', trigger: 'blur' }
|
||||
],
|
||||
minPoint: [
|
||||
{ required: true, message: '使用门槛;0表示无门槛不能为空', trigger: 'blur' }
|
||||
],
|
||||
startTime: [
|
||||
{ required: true, message: '开始使用时间不能为空', trigger: 'blur' }
|
||||
],
|
||||
endTime: [
|
||||
{ required: true, message: '结束使用时间不能为空', trigger: 'blur' }
|
||||
],
|
||||
useType: [
|
||||
{ required: true, message: '使用类型:0->全场通用;1->指定分类;2->指定商品不能为空', trigger: 'blur' }
|
||||
],
|
||||
note: [
|
||||
{ required: true, message: '备注不能为空', trigger: 'blur' }
|
||||
],
|
||||
publishCount: [
|
||||
{ required: true, message: '发行数量不能为空', trigger: 'blur' }
|
||||
],
|
||||
useCount: [
|
||||
{ required: true, message: '已使用数量不能为空', trigger: 'blur' }
|
||||
],
|
||||
receiveCount: [
|
||||
{ required: true, message: '领取数量不能为空', trigger: 'blur' }
|
||||
],
|
||||
enableTime: [
|
||||
{ required: true, message: '可以领取的日期不能为空', trigger: 'blur' }
|
||||
],
|
||||
code: [
|
||||
{ required: true, message: '优惠码不能为空', trigger: 'blur' }
|
||||
],
|
||||
memberLevel: [
|
||||
{ required: true, message: '可领取的会员类型:0->无限制不能为空', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init (id) {
|
||||
this.dataForm.id = id || 0
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (this.dataForm.id) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/book/coupon/info/${this.dataForm.id}`),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams()
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataForm.type = data.coupon.type
|
||||
this.dataForm.name = data.coupon.name
|
||||
this.dataForm.platform = data.coupon.platform
|
||||
this.dataForm.count = data.coupon.count
|
||||
this.dataForm.amount = data.coupon.amount
|
||||
this.dataForm.perLimit = data.coupon.perLimit
|
||||
this.dataForm.minPoint = data.coupon.minPoint
|
||||
this.dataForm.startTime = data.coupon.startTime
|
||||
this.dataForm.endTime = data.coupon.endTime
|
||||
this.dataForm.useType = data.coupon.useType
|
||||
this.dataForm.note = data.coupon.note
|
||||
this.dataForm.publishCount = data.coupon.publishCount
|
||||
this.dataForm.useCount = data.coupon.useCount
|
||||
this.dataForm.receiveCount = data.coupon.receiveCount
|
||||
this.dataForm.enableTime = data.coupon.enableTime
|
||||
this.dataForm.code = data.coupon.code
|
||||
this.dataForm.memberLevel = data.coupon.memberLevel
|
||||
|
||||
this.startTime = [this.dataForm.startTime,this.dataForm.endTime]
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit () {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/book/coupon/${!this.dataForm.id ? 'save' : 'update'}`),
|
||||
method: 'post',
|
||||
data: this.$http.adornData({
|
||||
'id': this.dataForm.id || undefined,
|
||||
'type': this.dataForm.type,
|
||||
'name': this.dataForm.name,
|
||||
'platform': this.dataForm.platform,
|
||||
'count': this.dataForm.count,
|
||||
'amount': this.dataForm.amount,
|
||||
'perLimit': this.dataForm.perLimit,
|
||||
'minPoint': this.dataForm.minPoint,
|
||||
'startTime': this.startTime[0],
|
||||
'endTime': this.startTime[1],
|
||||
'useType': this.dataForm.useType,
|
||||
'note': this.dataForm.note,
|
||||
'publishCount': this.dataForm.publishCount,
|
||||
'useCount': this.dataForm.useCount,
|
||||
'receiveCount': this.dataForm.receiveCount,
|
||||
'enableTime': this.dataForm.enableTime,
|
||||
'code': this.dataForm.code,
|
||||
'memberLevel': this.dataForm.memberLevel
|
||||
})
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.error(data.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
259
src/views/modules/coupon/coupon.vue
Normal file
259
src/views/modules/coupon/coupon.vue
Normal file
@@ -0,0 +1,259 @@
|
||||
<template>
|
||||
<div class="mod-config">
|
||||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
||||
<el-form-item>
|
||||
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="getDataList()">查询</el-button>
|
||||
<el-button v-if="isAuth('book:coupon:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
|
||||
<el-button v-if="isAuth('book:coupon:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table
|
||||
:data="dataList"
|
||||
border
|
||||
v-loading="dataListLoading"
|
||||
@selection-change="selectionChangeHandle"
|
||||
style="width: 100%;">
|
||||
<el-table-column
|
||||
type="selection"
|
||||
header-align="center"
|
||||
align="center"
|
||||
width="50">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="id"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="序号">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="name"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="优惠券名称">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="type"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="优惠卷类型">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="platform"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="使用平台">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="count"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="数量">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="amount"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="金额">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="perLimit"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="每人限领张数">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="minPoint"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="使用门槛">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="startTime"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="开始使用时间">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="endTime"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="结束使用时间">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="useType"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="使用类型">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="note"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="备注">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="publishCount"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="发行数量">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="useCount"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="已使用数量">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="receiveCount"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="领取数量">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="enableTime"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="可以领取的日期">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="code"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="优惠码">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="memberLevel"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="可领取的会员类型">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
header-align="center"
|
||||
align="center"
|
||||
width="150"
|
||||
label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
|
||||
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
:current-page="pageIndex"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:page-size="pageSize"
|
||||
:total="totalPage"
|
||||
layout="total, sizes, prev, pager, next, jumper">
|
||||
</el-pagination>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AddOrUpdate from './coupon-add-or-update'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
dataForm: {
|
||||
key: ''
|
||||
},
|
||||
dataList: [],
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
totalPage: 0,
|
||||
dataListLoading: false,
|
||||
dataListSelections: [],
|
||||
addOrUpdateVisible: false
|
||||
}
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate
|
||||
},
|
||||
activated () {
|
||||
this.getDataList()
|
||||
},
|
||||
methods: {
|
||||
// 获取数据列表
|
||||
getDataList () {
|
||||
this.dataListLoading = true
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/book/coupon/list'),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams({
|
||||
'page': this.pageIndex,
|
||||
'limit': this.pageSize,
|
||||
'key': this.dataForm.key
|
||||
})
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataList = data.page.list
|
||||
this.totalPage = data.page.totalCount
|
||||
} else {
|
||||
this.dataList = []
|
||||
this.totalPage = 0
|
||||
}
|
||||
this.dataListLoading = false
|
||||
})
|
||||
},
|
||||
// 每页数
|
||||
sizeChangeHandle (val) {
|
||||
this.pageSize = val
|
||||
this.pageIndex = 1
|
||||
this.getDataList()
|
||||
},
|
||||
// 当前页
|
||||
currentChangeHandle (val) {
|
||||
this.pageIndex = val
|
||||
this.getDataList()
|
||||
},
|
||||
// 多选
|
||||
selectionChangeHandle (val) {
|
||||
this.dataListSelections = val
|
||||
},
|
||||
// 新增 / 修改
|
||||
addOrUpdateHandle (id) {
|
||||
this.addOrUpdateVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id)
|
||||
})
|
||||
},
|
||||
// 删除
|
||||
deleteHandle (id) {
|
||||
var ids = id ? [id] : this.dataListSelections.map(item => {
|
||||
return item.id
|
||||
})
|
||||
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/book/coupon/delete'),
|
||||
method: 'post',
|
||||
data: this.$http.adornData(ids, false)
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getDataList()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.error(data.msg)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
165
src/views/modules/coupon/couponhistory-add-or-update.vue
Normal file
165
src/views/modules/coupon/couponhistory-add-or-update.vue
Normal file
@@ -0,0 +1,165 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="!dataForm.id ? '新增' : '修改'"
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="visible">
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
|
||||
<el-form-item label="优惠券id" prop="couponId">
|
||||
<el-input v-model="dataForm.couponId" placeholder="优惠券id"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="会员id" prop="memberId">
|
||||
<el-input v-model="dataForm.memberId" placeholder="会员id"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="订单id" prop="orderId">
|
||||
<el-input v-model="dataForm.orderId" placeholder="订单id"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="优惠券码" prop="couponCode">
|
||||
<el-input v-model="dataForm.couponCode" placeholder="优惠券码"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="领取人昵称" prop="memberNickname">
|
||||
<el-input v-model="dataForm.memberNickname" placeholder="领取人昵称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="获取类型" prop="getType">
|
||||
<el-input v-model="dataForm.getType" placeholder="获取类型"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-input v-model="dataForm.createTime" placeholder="创建时间"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="使用状态" prop="useStatus">
|
||||
<el-input v-model="dataForm.useStatus" placeholder="使用状态"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="使用时间" prop="useTime">
|
||||
<el-input v-model="dataForm.useTime" placeholder="使用时间"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="订单号码" prop="orderSn">
|
||||
<el-input v-model="dataForm.orderSn" placeholder="订单号码"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
visible: false,
|
||||
dataForm: {
|
||||
id: 0,
|
||||
couponId: '',
|
||||
memberId: '',
|
||||
orderId: '',
|
||||
couponCode: '',
|
||||
memberNickname: '',
|
||||
getType: '',
|
||||
createTime: '',
|
||||
useStatus: '',
|
||||
useTime: '',
|
||||
orderSn: ''
|
||||
},
|
||||
dataRule: {
|
||||
couponId: [
|
||||
{ required: true, message: '优惠券id不能为空', trigger: 'blur' }
|
||||
],
|
||||
memberId: [
|
||||
{ required: true, message: '会员id不能为空', trigger: 'blur' }
|
||||
],
|
||||
orderId: [
|
||||
{ required: true, message: '订单id不能为空', trigger: 'blur' }
|
||||
],
|
||||
couponCode: [
|
||||
{ required: true, message: '优惠券码不能为空', trigger: 'blur' }
|
||||
],
|
||||
memberNickname: [
|
||||
{ required: true, message: '领取人昵称不能为空', trigger: 'blur' }
|
||||
],
|
||||
getType: [
|
||||
{ required: true, message: '获取类型:0->后台赠送;1->主动获取不能为空', trigger: 'blur' }
|
||||
],
|
||||
createTime: [
|
||||
{ required: true, message: '创建时间不能为空', trigger: 'blur' }
|
||||
],
|
||||
useStatus: [
|
||||
{ required: true, message: '使用状态:0->未使用;1->已使用;2->已过期不能为空', trigger: 'blur' }
|
||||
],
|
||||
useTime: [
|
||||
{ required: true, message: '使用时间不能为空', trigger: 'blur' }
|
||||
],
|
||||
orderSn: [
|
||||
{ required: true, message: '订单号码不能为空', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init (id) {
|
||||
this.dataForm.id = id || 0
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (this.dataForm.id) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/book/couponhistory/info/${this.dataForm.id}`),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams()
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataForm.couponId = data.couponHistory.couponId
|
||||
this.dataForm.memberId = data.couponHistory.memberId
|
||||
this.dataForm.orderId = data.couponHistory.orderId
|
||||
this.dataForm.couponCode = data.couponHistory.couponCode
|
||||
this.dataForm.memberNickname = data.couponHistory.memberNickname
|
||||
this.dataForm.getType = data.couponHistory.getType
|
||||
this.dataForm.createTime = data.couponHistory.createTime
|
||||
this.dataForm.useStatus = data.couponHistory.useStatus
|
||||
this.dataForm.useTime = data.couponHistory.useTime
|
||||
this.dataForm.orderSn = data.couponHistory.orderSn
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit () {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/book/couponhistory/${!this.dataForm.id ? 'save' : 'update'}`),
|
||||
method: 'post',
|
||||
data: this.$http.adornData({
|
||||
'id': this.dataForm.id || undefined,
|
||||
'couponId': this.dataForm.couponId,
|
||||
'memberId': this.dataForm.memberId,
|
||||
'orderId': this.dataForm.orderId,
|
||||
'couponCode': this.dataForm.couponCode,
|
||||
'memberNickname': this.dataForm.memberNickname,
|
||||
'getType': this.dataForm.getType,
|
||||
'createTime': this.dataForm.createTime,
|
||||
'useStatus': this.dataForm.useStatus,
|
||||
'useTime': this.dataForm.useTime,
|
||||
'orderSn': this.dataForm.orderSn
|
||||
})
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.error(data.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
217
src/views/modules/coupon/couponhistory.vue
Normal file
217
src/views/modules/coupon/couponhistory.vue
Normal file
@@ -0,0 +1,217 @@
|
||||
<template>
|
||||
<div class="mod-config">
|
||||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
||||
<el-form-item>
|
||||
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="getDataList()">查询</el-button>
|
||||
<el-button v-if="isAuth('book:couponhistory:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
|
||||
<el-button v-if="isAuth('book:couponhistory:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table
|
||||
:data="dataList"
|
||||
border
|
||||
v-loading="dataListLoading"
|
||||
@selection-change="selectionChangeHandle"
|
||||
style="width: 100%;">
|
||||
<el-table-column
|
||||
type="selection"
|
||||
header-align="center"
|
||||
align="center"
|
||||
width="50">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="id"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="couponId"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="优惠券id">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="memberId"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="会员id">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="orderId"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="订单id">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="couponCode"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="优惠券码">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="memberNickname"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="领取人昵称">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="getType"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="获取类型:0->后台赠送;1->主动获取">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="createTime"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="创建时间">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="useStatus"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="使用状态:0->未使用;1->已使用;2->已过期">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="useTime"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="使用时间">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="orderSn"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="订单号码">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
header-align="center"
|
||||
align="center"
|
||||
width="150"
|
||||
label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
|
||||
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
:current-page="pageIndex"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:page-size="pageSize"
|
||||
:total="totalPage"
|
||||
layout="total, sizes, prev, pager, next, jumper">
|
||||
</el-pagination>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AddOrUpdate from './couponhistory-add-or-update'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
dataForm: {
|
||||
key: ''
|
||||
},
|
||||
dataList: [],
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
totalPage: 0,
|
||||
dataListLoading: false,
|
||||
dataListSelections: [],
|
||||
addOrUpdateVisible: false
|
||||
}
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate
|
||||
},
|
||||
activated () {
|
||||
this.getDataList()
|
||||
},
|
||||
methods: {
|
||||
// 获取数据列表
|
||||
getDataList () {
|
||||
this.dataListLoading = true
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/book/couponhistory/list'),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams({
|
||||
'page': this.pageIndex,
|
||||
'limit': this.pageSize,
|
||||
'key': this.dataForm.key
|
||||
})
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataList = data.page.list
|
||||
this.totalPage = data.page.totalCount
|
||||
} else {
|
||||
this.dataList = []
|
||||
this.totalPage = 0
|
||||
}
|
||||
this.dataListLoading = false
|
||||
})
|
||||
},
|
||||
// 每页数
|
||||
sizeChangeHandle (val) {
|
||||
this.pageSize = val
|
||||
this.pageIndex = 1
|
||||
this.getDataList()
|
||||
},
|
||||
// 当前页
|
||||
currentChangeHandle (val) {
|
||||
this.pageIndex = val
|
||||
this.getDataList()
|
||||
},
|
||||
// 多选
|
||||
selectionChangeHandle (val) {
|
||||
this.dataListSelections = val
|
||||
},
|
||||
// 新增 / 修改
|
||||
addOrUpdateHandle (id) {
|
||||
this.addOrUpdateVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id)
|
||||
})
|
||||
},
|
||||
// 删除
|
||||
deleteHandle (id) {
|
||||
var ids = id ? [id] : this.dataListSelections.map(item => {
|
||||
return item.id
|
||||
})
|
||||
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/book/couponhistory/delete'),
|
||||
method: 'post',
|
||||
data: this.$http.adornData(ids, false)
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getDataList()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.error(data.msg)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,111 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="!dataForm.id ? '新增' : '修改'"
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="visible">
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
|
||||
<el-form-item label="优惠券id" prop="couponId">
|
||||
<el-input v-model="dataForm.couponId" placeholder="优惠券id"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类id" prop="productCategoryId">
|
||||
<el-input v-model="dataForm.productCategoryId" placeholder="商品分类id"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类名称" prop="productCategoryName">
|
||||
<el-input v-model="dataForm.productCategoryName" placeholder="商品分类名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="父分类名称" prop="parentCategoryName">
|
||||
<el-input v-model="dataForm.parentCategoryName" placeholder="父分类名称"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
visible: false,
|
||||
dataForm: {
|
||||
id: 0,
|
||||
couponId: '',
|
||||
productCategoryId: '',
|
||||
productCategoryName: '',
|
||||
parentCategoryName: ''
|
||||
},
|
||||
dataRule: {
|
||||
couponId: [
|
||||
{ required: true, message: '优惠券id不能为空', trigger: 'blur' }
|
||||
],
|
||||
productCategoryId: [
|
||||
{ required: true, message: '商品分类id不能为空', trigger: 'blur' }
|
||||
],
|
||||
productCategoryName: [
|
||||
{ required: true, message: '商品分类名称不能为空', trigger: 'blur' }
|
||||
],
|
||||
parentCategoryName: [
|
||||
{ required: true, message: '父分类名称不能为空', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init (id) {
|
||||
this.dataForm.id = id || 0
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (this.dataForm.id) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/book/couponproductcategoryrelation/info/${this.dataForm.id}`),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams()
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataForm.couponId = data.couponProductCategoryRelation.couponId
|
||||
this.dataForm.productCategoryId = data.couponProductCategoryRelation.productCategoryId
|
||||
this.dataForm.productCategoryName = data.couponProductCategoryRelation.productCategoryName
|
||||
this.dataForm.parentCategoryName = data.couponProductCategoryRelation.parentCategoryName
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit () {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/book/couponproductcategoryrelation/${!this.dataForm.id ? 'save' : 'update'}`),
|
||||
method: 'post',
|
||||
data: this.$http.adornData({
|
||||
'id': this.dataForm.id || undefined,
|
||||
'couponId': this.dataForm.couponId,
|
||||
'productCategoryId': this.dataForm.productCategoryId,
|
||||
'productCategoryName': this.dataForm.productCategoryName,
|
||||
'parentCategoryName': this.dataForm.parentCategoryName
|
||||
})
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.error(data.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
181
src/views/modules/coupon/couponproductcategoryrelation.vue
Normal file
181
src/views/modules/coupon/couponproductcategoryrelation.vue
Normal file
@@ -0,0 +1,181 @@
|
||||
<template>
|
||||
<div class="mod-config">
|
||||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
||||
<el-form-item>
|
||||
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="getDataList()">查询</el-button>
|
||||
<el-button v-if="isAuth('book:couponproductcategoryrelation:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
|
||||
<el-button v-if="isAuth('book:couponproductcategoryrelation:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table
|
||||
:data="dataList"
|
||||
border
|
||||
v-loading="dataListLoading"
|
||||
@selection-change="selectionChangeHandle"
|
||||
style="width: 100%;">
|
||||
<el-table-column
|
||||
type="selection"
|
||||
header-align="center"
|
||||
align="center"
|
||||
width="50">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="id"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="couponId"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="优惠券id">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="productCategoryId"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="商品分类id">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="productCategoryName"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="商品分类名称">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="parentCategoryName"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="父分类名称">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
header-align="center"
|
||||
align="center"
|
||||
width="150"
|
||||
label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
|
||||
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
:current-page="pageIndex"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:page-size="pageSize"
|
||||
:total="totalPage"
|
||||
layout="total, sizes, prev, pager, next, jumper">
|
||||
</el-pagination>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AddOrUpdate from './couponproductcategoryrelation-add-or-update'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
dataForm: {
|
||||
key: ''
|
||||
},
|
||||
dataList: [],
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
totalPage: 0,
|
||||
dataListLoading: false,
|
||||
dataListSelections: [],
|
||||
addOrUpdateVisible: false
|
||||
}
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate
|
||||
},
|
||||
activated () {
|
||||
this.getDataList()
|
||||
},
|
||||
methods: {
|
||||
// 获取数据列表
|
||||
getDataList () {
|
||||
this.dataListLoading = true
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/book/couponproductcategoryrelation/list'),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams({
|
||||
'page': this.pageIndex,
|
||||
'limit': this.pageSize,
|
||||
'key': this.dataForm.key
|
||||
})
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataList = data.page.list
|
||||
this.totalPage = data.page.totalCount
|
||||
} else {
|
||||
this.dataList = []
|
||||
this.totalPage = 0
|
||||
}
|
||||
this.dataListLoading = false
|
||||
})
|
||||
},
|
||||
// 每页数
|
||||
sizeChangeHandle (val) {
|
||||
this.pageSize = val
|
||||
this.pageIndex = 1
|
||||
this.getDataList()
|
||||
},
|
||||
// 当前页
|
||||
currentChangeHandle (val) {
|
||||
this.pageIndex = val
|
||||
this.getDataList()
|
||||
},
|
||||
// 多选
|
||||
selectionChangeHandle (val) {
|
||||
this.dataListSelections = val
|
||||
},
|
||||
// 新增 / 修改
|
||||
addOrUpdateHandle (id) {
|
||||
this.addOrUpdateVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id)
|
||||
})
|
||||
},
|
||||
// 删除
|
||||
deleteHandle (id) {
|
||||
var ids = id ? [id] : this.dataListSelections.map(item => {
|
||||
return item.id
|
||||
})
|
||||
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/book/couponproductcategoryrelation/delete'),
|
||||
method: 'post',
|
||||
data: this.$http.adornData(ids, false)
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getDataList()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.error(data.msg)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
111
src/views/modules/coupon/couponproductrelation-add-or-update.vue
Normal file
111
src/views/modules/coupon/couponproductrelation-add-or-update.vue
Normal file
@@ -0,0 +1,111 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:title="!dataForm.id ? '新增' : '修改'"
|
||||
:close-on-click-modal="false"
|
||||
:visible.sync="visible">
|
||||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
|
||||
<el-form-item label="优惠券id" prop="couponId">
|
||||
<el-input v-model="dataForm.couponId" placeholder="优惠券id"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品id" prop="productId">
|
||||
<el-input v-model="dataForm.productId" placeholder="商品id"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品名称" prop="productName">
|
||||
<el-input v-model="dataForm.productName" placeholder="商品名称"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品条码" prop="productSn">
|
||||
<el-input v-model="dataForm.productSn" placeholder="商品条码"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
visible: false,
|
||||
dataForm: {
|
||||
id: 0,
|
||||
couponId: '',
|
||||
productId: '',
|
||||
productName: '',
|
||||
productSn: ''
|
||||
},
|
||||
dataRule: {
|
||||
couponId: [
|
||||
{ required: true, message: '优惠券id不能为空', trigger: 'blur' }
|
||||
],
|
||||
productId: [
|
||||
{ required: true, message: '商品id不能为空', trigger: 'blur' }
|
||||
],
|
||||
productName: [
|
||||
{ required: true, message: '商品名称不能为空', trigger: 'blur' }
|
||||
],
|
||||
productSn: [
|
||||
{ required: true, message: '商品条码不能为空', trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
init (id) {
|
||||
this.dataForm.id = id || 0
|
||||
this.visible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
if (this.dataForm.id) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/book/couponproductrelation/info/${this.dataForm.id}`),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams()
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataForm.couponId = data.couponProductRelation.couponId
|
||||
this.dataForm.productId = data.couponProductRelation.productId
|
||||
this.dataForm.productName = data.couponProductRelation.productName
|
||||
this.dataForm.productSn = data.couponProductRelation.productSn
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
// 表单提交
|
||||
dataFormSubmit () {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl(`/book/couponproductrelation/${!this.dataForm.id ? 'save' : 'update'}`),
|
||||
method: 'post',
|
||||
data: this.$http.adornData({
|
||||
'id': this.dataForm.id || undefined,
|
||||
'couponId': this.dataForm.couponId,
|
||||
'productId': this.dataForm.productId,
|
||||
'productName': this.dataForm.productName,
|
||||
'productSn': this.dataForm.productSn
|
||||
})
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.visible = false
|
||||
this.$emit('refreshDataList')
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.error(data.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
181
src/views/modules/coupon/couponproductrelation.vue
Normal file
181
src/views/modules/coupon/couponproductrelation.vue
Normal file
@@ -0,0 +1,181 @@
|
||||
<template>
|
||||
<div class="mod-config">
|
||||
<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
|
||||
<el-form-item>
|
||||
<el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="getDataList()">查询</el-button>
|
||||
<el-button v-if="isAuth('book:couponproductrelation:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
|
||||
<el-button v-if="isAuth('book:couponproductrelation:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table
|
||||
:data="dataList"
|
||||
border
|
||||
v-loading="dataListLoading"
|
||||
@selection-change="selectionChangeHandle"
|
||||
style="width: 100%;">
|
||||
<el-table-column
|
||||
type="selection"
|
||||
header-align="center"
|
||||
align="center"
|
||||
width="50">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="id"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="couponId"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="优惠券id">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="productId"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="商品id">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="productName"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="商品名称">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="productSn"
|
||||
header-align="center"
|
||||
align="center"
|
||||
label="商品条码">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
header-align="center"
|
||||
align="center"
|
||||
width="150"
|
||||
label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
|
||||
<el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
:current-page="pageIndex"
|
||||
:page-sizes="[10, 20, 50, 100]"
|
||||
:page-size="pageSize"
|
||||
:total="totalPage"
|
||||
layout="total, sizes, prev, pager, next, jumper">
|
||||
</el-pagination>
|
||||
<!-- 弹窗, 新增 / 修改 -->
|
||||
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AddOrUpdate from './couponproductrelation-add-or-update'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
dataForm: {
|
||||
key: ''
|
||||
},
|
||||
dataList: [],
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
totalPage: 0,
|
||||
dataListLoading: false,
|
||||
dataListSelections: [],
|
||||
addOrUpdateVisible: false
|
||||
}
|
||||
},
|
||||
components: {
|
||||
AddOrUpdate
|
||||
},
|
||||
activated () {
|
||||
this.getDataList()
|
||||
},
|
||||
methods: {
|
||||
// 获取数据列表
|
||||
getDataList () {
|
||||
this.dataListLoading = true
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/book/couponproductrelation/list'),
|
||||
method: 'get',
|
||||
params: this.$http.adornParams({
|
||||
'page': this.pageIndex,
|
||||
'limit': this.pageSize,
|
||||
'key': this.dataForm.key
|
||||
})
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.dataList = data.page.list
|
||||
this.totalPage = data.page.totalCount
|
||||
} else {
|
||||
this.dataList = []
|
||||
this.totalPage = 0
|
||||
}
|
||||
this.dataListLoading = false
|
||||
})
|
||||
},
|
||||
// 每页数
|
||||
sizeChangeHandle (val) {
|
||||
this.pageSize = val
|
||||
this.pageIndex = 1
|
||||
this.getDataList()
|
||||
},
|
||||
// 当前页
|
||||
currentChangeHandle (val) {
|
||||
this.pageIndex = val
|
||||
this.getDataList()
|
||||
},
|
||||
// 多选
|
||||
selectionChangeHandle (val) {
|
||||
this.dataListSelections = val
|
||||
},
|
||||
// 新增 / 修改
|
||||
addOrUpdateHandle (id) {
|
||||
this.addOrUpdateVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.addOrUpdate.init(id)
|
||||
})
|
||||
},
|
||||
// 删除
|
||||
deleteHandle (id) {
|
||||
var ids = id ? [id] : this.dataListSelections.map(item => {
|
||||
return item.id
|
||||
})
|
||||
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$http({
|
||||
url: this.$http.adornUrl('/book/couponproductrelation/delete'),
|
||||
method: 'post',
|
||||
data: this.$http.adornData(ids, false)
|
||||
}).then(({data}) => {
|
||||
if (data && data.code === 0) {
|
||||
this.$message({
|
||||
message: '操作成功',
|
||||
type: 'success',
|
||||
duration: 1500,
|
||||
onClose: () => {
|
||||
this.getDataList()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.$message.error(data.msg)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user