This commit is contained in:
Sakura9701
2022-11-18 13:37:00 +08:00
parent c3ad633a66
commit d8b675fbe6
16 changed files with 2314 additions and 9 deletions

View File

@@ -0,0 +1,186 @@
<template>
<el-dialog
:title="!dataForm.id ? '新增' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible" append-to-body>
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
<el-form-item label="商品名称" prop="">
<el-autocomplete
v-model="state"
:fetch-suggestions="querySearchAsync"
placeholder="请输入内容"
@select="handleSelect"
></el-autocomplete>
</el-form-item>
<!-- <el-form-item label="场次id" prop="promotionSeckillId">
<el-input v-model="dataForm.promotionSeckillId" placeholder="场次id"></el-input>
</el-form-item> -->
<!-- <el-form-item label="商品id" prop="prodId">
<el-input v-model="dataForm.prodId" placeholder="商品id"></el-input>
</el-form-item> -->
<el-form-item label="秒杀价格" prop="seckillPrice">
<el-input-number v-model="dataForm.seckillPrice" :precision="2" :step="0.1" :max="999"></el-input-number>
<!-- <el-input v-model="dataForm.seckillPrice" placeholder="秒杀价格"></el-input> -->
</el-form-item>
<el-form-item label="秒杀数量" prop="seckillCount">
<el-input-number v-model="dataForm.seckillCount" label="秒杀数量"></el-input-number>
<!-- <el-input v-model="dataForm.seckillCount" placeholder="秒杀数量"></el-input> -->
</el-form-item>
<el-form-item label="限制购买" prop="seckillLimit">
<el-input-number v-model="dataForm.seckillLimit" label="限制购买"></el-input-number>
<!-- <el-input v-model="dataForm.seckillLimit" placeholder="限制购买"></el-input> -->
</el-form-item>
<!-- <el-form-item label="权重" prop="seckillSort">
<el-input v-model="dataForm.seckillSort" 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,
restaurants: [],
state: '',
id : '',
timeout: null,
dataForm: {
id: 0,
promotionId: '',
promotionSeckillId: '',
prodId: '',
seckillPrice: '',
seckillCount: '',
seckillLimit: '',
seckillSort: ''
},
dataRule: {
promotionId: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
promotionSeckillId: [
{ required: true, message: '场次id不能为空', trigger: 'blur' }
],
prodId: [
{ required: true, message: '商品id不能为空', trigger: 'blur' }
],
seckillPrice: [
{ required: true, message: '秒杀价格不能为空', trigger: 'blur' }
],
seckillCount: [
{ required: true, message: '秒杀数量不能为空', trigger: 'blur' }
],
seckillLimit: [
{ required: true, message: '限制购买不能为空', trigger: 'blur' }
],
seckillSort: [
{ required: true, message: '权重不能为空', trigger: 'blur' }
]
}
}
},
methods: {
init (id,seckillId) {
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/seckillprodrelation/info/${this.dataForm.id}`),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dataForm.promotionId = data.seckillProdRelation.promotionId
this.dataForm.promotionSeckillId = data.seckillProdRelation.promotionSeckillId
this.dataForm.prodId = data.seckillProdRelation.prodId
this.dataForm.seckillPrice = data.seckillProdRelation.seckillPrice
this.dataForm.seckillCount = data.seckillProdRelation.seckillCount
this.dataForm.seckillLimit = data.seckillProdRelation.seckillLimit
this.dataForm.seckillSort = data.seckillProdRelation.seckillSort
}
})
}
this.dataForm.promotionSeckillId = seckillId
})
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/book/seckillprodrelation/${!this.dataForm.id ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'id': this.dataForm.id || undefined,
'promotionId': this.dataForm.promotionId,
'promotionSeckillId': this.dataForm.promotionSeckillId,
'prodId': this.dataForm.prodId,
'seckillPrice': this.dataForm.seckillPrice,
'seckillCount': this.dataForm.seckillCount,
'seckillLimit': this.dataForm.seckillLimit,
'seckillSort': this.dataForm.seckillSort
})
}).then(({data}) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList',this.dataForm.promotionSeckillId)
}
})
} else {
this.$message.error(data.msg)
}
})
}
})
},
loadAll() {
this.$http({
url: this.$http.adornUrl(`/book/shopproduct/prodSearch`),
method: 'get'
}).then(({data}) => {
this.restaurants = data.list
console.log(this.restaurants)
})
},
querySearchAsync(queryString, cb) {
console.log('数据'+this.restaurants)
var restaurants = this.restaurants;
var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
cb(results);
}, 3000 * Math.random());
},
createStateFilter(queryString) {
return (state) => {
return (state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
};
},
handleSelect(item) {
console.log(item);
this.dataForm.prodId = item.productId,
this.dataForm.promotionId = item.value
}
},
mounted() {
this.loadAll();
// this.restaurants = this.loadAll();
}
}
</script>

View File

@@ -0,0 +1,204 @@
<template>
<el-dialog title="秒杀商品列表" :visible.sync="relationProdVisible" @close="handlereset">
<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:seckillprodrelation:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
<el-button v-if="isAuth('book:seckillprodrelation: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 label="序号" width="70" align="center">
<template slot-scope="scope">
{{ (pageIndex - 1) * pageSize + scope.$index + 1 }}
</template>
</el-table-column>
<el-table-column
prop="promotionId"
header-align="center"
align="center"
label="商品名称">
</el-table-column>
<!-- <el-table-column
prop="promotionSeckillId"
header-align="center"
align="center"
label="场次id">
</el-table-column>
<el-table-column
prop="prodId"
header-align="center"
align="center"
label="商品id">
</el-table-column> -->
<el-table-column
prop="seckillPrice"
header-align="center"
align="center"
label="秒杀价格">
</el-table-column>
<el-table-column
prop="seckillCount"
header-align="center"
align="center"
label="秒杀数量">
</el-table-column>
<el-table-column
prop="seckillLimit"
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>
</el-dialog>
</template>
<script>
import AddOrUpdate from './seckillprodrelation-add-or-update'
export default {
name: "dialogComponent",
data () {
return {
dataForm: {
key: ''
},
dataList: [],
seckillId:'',
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false,
relationProdVisible:false
}
},
components: {
AddOrUpdate
},
activated () {
this.getDataList()
},
methods: {
// 获取数据列表
getDataList (id) {
this.seckillId = id
this.relationProdVisible = true
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/book/seckillprodrelation/list'),
method: 'get',
params: this.$http.adornParams({
'page': this.pageIndex,
'limit': this.pageSize,
'key': this.dataForm.key,
'promotionSeckillId': id
})
}).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,this.seckillId)
})
},
// 删除
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/seckillprodrelation/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(this.seckillId)
}
})
} else {
this.$message.error(data.msg)
}
})
})
},
handlereset(){
this.relationProdVisible = false
}
}
}
</script>

View File

@@ -0,0 +1,145 @@
<template>
<el-dialog :title="!dataForm.seckillId ? '新增' : '修改'" :close-on-click-modal="false" :visible.sync="visible" @close="handlereset">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
label-width="80px">
<el-form-item label="名称" prop="nam">
<el-input v-model="dataForm.nam" placeholder="名称"></el-input>
</el-form-item>
<!-- <el-form-item label="秒杀开启时间" prop="startTime">
<el-input v-model="dataForm.startTime" placeholder="秒杀开启时间"></el-input>
</el-form-item> -->
<el-form-item label="秒杀结束" prop="endTime">
<el-date-picker v-model="value2" type="datetimerange" :picker-options="pickerOptions" range-separator="至" value-format="yyyy-MM-dd HH:mm:ss"
start-placeholder="开始日期" end-placeholder="结束日期" align="right">
</el-date-picker>
</el-form-item>
<!-- <el-form-item label="创建时间" prop="createTime">
<el-input v-model="dataForm.createTime" placeholder="创建时间"></el-input>
</el-form-item> -->
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click=handlereset>取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data () {
return {
visible: false,
pickerOptions: {
shortcuts: [{
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
}
}, {
text: '最近三个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit('pick', [start, end]);
}
}]
},
value2: '',
dataForm: {
seckillId: 0,
nam: '',
startTime: '',
endTime: '',
createTime: ''
},
dataRule: {
// nam: [
// { required: true, message: '名称不能为空', trigger: 'blur' }
// ],
// startTime: [
// { required: true, message: '秒杀开启时间不能为空', trigger: 'blur' }
// ],
// endTime: [
// { required: true, message: '秒杀结束时间不能为空', trigger: 'blur' }
// ],
// createTime: [
// { required: true, message: '创建时间不能为空', trigger: 'blur' }
// ]
}
}
},
methods: {
init (id) {
this.dataForm.seckillId = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.seckillId) {
this.$http({
url: this.$http.adornUrl(`/book/shopseckill/info/${this.dataForm.seckillId}`),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dataForm.nam = data.shopSeckill.nam
this.dataForm.startTime = data.shopSeckill.startTime
this.dataForm.endTime = data.shopSeckill.endTime
this.dataForm.createTime = data.shopSeckill.createTime
this.value2 = [this.dataForm.startTime,this.dataForm.endTime]
}
})
}
})
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/book/shopseckill/${!this.dataForm.seckillId ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'seckillId': this.dataForm.seckillId || undefined,
'nam': this.dataForm.nam,
'startTime': this.value2[0],
'endTime': this.value2[1],
'createTime': this.dataForm.createTime
})
}).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)
}
})
}
})
},
handlereset(){
this.value2 = ''
this.visible = false
}
}
}
</script>

View File

@@ -0,0 +1,193 @@
<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:shopseckill:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button>
<el-button v-if="isAuth('book:shopseckill: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 label="序号" width="70" align="center">
<template slot-scope="scope">
{{ (pageIndex - 1) * pageSize + scope.$index + 1 }}
</template>
</el-table-column>
<el-table-column
prop="nam"
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="createTime"
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="relationProdHandle(scope.row.seckillId)">关联商品</el-button>
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.seckillId)">修改</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.seckillId)">删除</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>
<dialog-component v-if="relationProdVisible" ref="dialog"></dialog-component>
</div>
</template>
<script>
import AddOrUpdate from './shopseckill-add-or-update'
import dialogComponent from './seckillprodrelation'
export default {
data () {
return {
dataForm: {
key: ''
},
dataList: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
dataListSelections: [],
addOrUpdateVisible: false,
relationProdVisible: false
}
},
components: {
AddOrUpdate,
dialogComponent
},
activated () {
this.getDataList()
},
methods: {
// 获取数据列表
getDataList () {
this.dataListLoading = true
this.relationProdVisible = false
this.$http({
url: this.$http.adornUrl('/book/shopseckill/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)
})
},
//关联商品
relationProdHandle (id) {
this.relationProdVisible = true
this.$nextTick(() => {
this.$refs.dialog.getDataList(id)
})
},
// 删除
deleteHandle (id) {
var ids = id ? [id] : this.dataListSelections.map(item => {
return item.seckillId
})
this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http({
url: this.$http.adornUrl('/book/shopseckill/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>