hupeng
5 years ago
11 changed files with 663 additions and 9 deletions
@ -0,0 +1,24 @@
|
||||
import request from '@/utils/request' |
||||
|
||||
export function add(data) { |
||||
return request({ |
||||
url: 'api/yxStoreSeckill', |
||||
method: 'post', |
||||
data |
||||
}) |
||||
} |
||||
|
||||
export function del(id) { |
||||
return request({ |
||||
url: 'api/yxStoreSeckill/' + id, |
||||
method: 'delete' |
||||
}) |
||||
} |
||||
|
||||
export function edit(data) { |
||||
return request({ |
||||
url: 'api/yxStoreSeckill', |
||||
method: 'put', |
||||
data |
||||
}) |
||||
} |
@ -0,0 +1,206 @@
|
||||
<template> |
||||
<el-dialog :append-to-body="true" :close-on-click-modal="false" :before-close="cancel" :visible.sync="dialog" :title="isAdd ? '新增' : '开启秒杀'" width="900px"> |
||||
<el-form ref="form" :model="form" :rules="rules" :inline="true" size="small" label-width="140px"> |
||||
<el-form-item label="秒杀名称" > |
||||
<el-input v-model="form.title" style="width: 500px;"/> |
||||
</el-form-item> |
||||
<el-form-item label="秒杀简介" > |
||||
<el-input v-model="form.info" style="width: 500px;"/> |
||||
</el-form-item> |
||||
<el-form-item label="单位" > |
||||
<el-input v-model="form.unitName" style="width: 500px;"/> |
||||
</el-form-item> |
||||
<el-form-item label="秒杀开始时间" > |
||||
<template> |
||||
<el-date-picker |
||||
v-model="form.startTimeDate" |
||||
type="datetime" |
||||
placeholder="选择日期时间"> |
||||
</el-date-picker> |
||||
</template> |
||||
</el-form-item> |
||||
<el-form-item label="秒杀结束时间" > |
||||
<template> |
||||
<el-date-picker |
||||
v-model="form.endTimeDate" |
||||
type="datetime" |
||||
placeholder="选择日期时间"> |
||||
</el-date-picker> |
||||
</template> |
||||
</el-form-item> |
||||
<el-form-item label="产品主图片" > |
||||
<pic-upload v-model="form.image" style="width: 500px;"/> |
||||
</el-form-item> |
||||
<el-form-item label="产品轮播图" > |
||||
<mulpic-upload v-model="form.images" style="width: 500px;"/> |
||||
</el-form-item> |
||||
<el-form-item label="秒杀价" > |
||||
<el-input-number v-model="form.price"/> |
||||
</el-form-item> |
||||
<el-form-item label="成本" > |
||||
<el-input-number v-model="form.cost" /> |
||||
</el-form-item> |
||||
<el-form-item label="原价" > |
||||
<el-input-number v-model="form.otPrice"/> |
||||
</el-form-item> |
||||
<el-form-item label="库存" > |
||||
<el-input-number v-model="form.stock" /> |
||||
</el-form-item> |
||||
<el-form-item label="虚拟销量" > |
||||
<el-input-number v-model="form.sales" /> |
||||
</el-form-item> |
||||
<el-form-item label="排序" > |
||||
<el-input-number v-model="form.sort"/> |
||||
</el-form-item> |
||||
<el-form-item label="限购" > |
||||
<el-input-number v-model="form.num" /> |
||||
</el-form-item> |
||||
<el-form-item label="邮费" > |
||||
<el-input-number v-model="form.postage"/> |
||||
</el-form-item> |
||||
<el-form-item label="是否包邮" > |
||||
<el-radio v-model="form.isPostage" :label="1">是</el-radio> |
||||
<el-radio v-model="form.isPostage" :label="0" style="width: 110px;">否</el-radio> |
||||
</el-form-item> |
||||
<el-form-item label="活动状态" > |
||||
<el-radio v-model="form.status" :label="1">开启</el-radio> |
||||
<el-radio v-model="form.status" :label="0" style="width: 200px;">关闭</el-radio> |
||||
</el-form-item> |
||||
<el-form-item label="详情" > |
||||
<editor v-model="form.description" /> |
||||
</el-form-item> |
||||
</el-form> |
||||
<div slot="footer" class="dialog-footer"> |
||||
<el-button type="text" @click="cancel">取消</el-button> |
||||
<el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button> |
||||
</div> |
||||
</el-dialog> |
||||
</template> |
||||
|
||||
<script> |
||||
import { add, edit } from '@/api/yxStoreSeckill' |
||||
import editor from '../../components/Editor' |
||||
import picUpload from '@/components/pic-upload' |
||||
import mulpicUpload from '@/components/mul-pic-upload' |
||||
export default { |
||||
components: { editor, picUpload, mulpicUpload }, |
||||
props: { |
||||
isAdd: { |
||||
type: Boolean, |
||||
required: true |
||||
} |
||||
}, |
||||
data() { |
||||
return { |
||||
loading: false, dialog: false, |
||||
form: { |
||||
id: '', |
||||
productId: '', |
||||
image: '', |
||||
images: '', |
||||
title: '', |
||||
info: '', |
||||
price: '', |
||||
cost: '', |
||||
otPrice: '', |
||||
giveIntegral: '', |
||||
sort: '', |
||||
stock: '', |
||||
sales: '', |
||||
unitName: '', |
||||
postage: '', |
||||
description: '', |
||||
startTime: '', |
||||
stopTime: '', |
||||
addTime: '', |
||||
status: 1, |
||||
isPostage: 1, |
||||
isHot: '', |
||||
isDel: 0, |
||||
num: '', |
||||
isShow: '', |
||||
startTimeDate: '', |
||||
endTimeDate: '' |
||||
}, |
||||
rules: { |
||||
} |
||||
} |
||||
}, |
||||
methods: { |
||||
cancel() { |
||||
this.resetForm() |
||||
}, |
||||
doSubmit() { |
||||
this.loading = true |
||||
if (this.isAdd) { |
||||
this.doAdd() |
||||
} else this.doEdit() |
||||
}, |
||||
doAdd() { |
||||
add(this.form).then(res => { |
||||
this.resetForm() |
||||
this.$notify({ |
||||
title: '添加成功', |
||||
type: 'success', |
||||
duration: 2500 |
||||
}) |
||||
this.loading = false |
||||
this.$parent.init() |
||||
}).catch(err => { |
||||
this.loading = false |
||||
console.log(err.response.data.message) |
||||
}) |
||||
}, |
||||
doEdit() { |
||||
edit(this.form).then(res => { |
||||
this.resetForm() |
||||
this.$notify({ |
||||
title: '修改成功', |
||||
type: 'success', |
||||
duration: 2500 |
||||
}) |
||||
this.loading = false |
||||
this.$parent.init() |
||||
}).catch(err => { |
||||
this.loading = false |
||||
console.log(err.response.data.message) |
||||
}) |
||||
}, |
||||
resetForm() { |
||||
this.dialog = false |
||||
this.$refs['form'].resetFields() |
||||
this.form = { |
||||
id: '', |
||||
productId: '', |
||||
image: '', |
||||
images: '', |
||||
title: '', |
||||
info: '', |
||||
price: '', |
||||
cost: '', |
||||
otPrice: '', |
||||
giveIntegral: '', |
||||
sort: '', |
||||
stock: '', |
||||
sales: '', |
||||
unitName: '', |
||||
postage: '', |
||||
description: '', |
||||
startTime: '', |
||||
stopTime: '', |
||||
addTime: '', |
||||
status: '', |
||||
isPostage: '', |
||||
isHot: '', |
||||
isDel: '', |
||||
num: '', |
||||
isShow: '' |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
@ -0,0 +1,165 @@
|
||||
<template> |
||||
<div class="app-container"> |
||||
<!--工具栏--> |
||||
<div class="head-container"> |
||||
<!-- 搜索 --> |
||||
<el-input v-model="query.value" clearable placeholder="输入搜索内容" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/> |
||||
<el-select v-model="query.type" clearable placeholder="类型" class="filter-item" style="width: 130px"> |
||||
<el-option v-for="item in queryTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/> |
||||
</el-select> |
||||
<el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button> |
||||
<!-- 新增 --> |
||||
</div> |
||||
<!--表单组件--> |
||||
<eForm ref="form" :is-add="isAdd"/> |
||||
<!--表格渲染--> |
||||
<el-table v-loading="loading" :data="data" size="small" style="width: 100%;"> |
||||
<el-table-column prop="id" label="id"/> |
||||
<el-table-column prop="image" label="产品主图"> |
||||
<template slot-scope="scope"> |
||||
<a :href="scope.row.image" style="color: #42b983" target="_blank"><img :src="scope.row.image" alt="点击打开" class="el-avatar"></a> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column prop="title" label="产品标题"/> |
||||
<el-table-column prop="price" label="秒杀价"/> |
||||
<el-table-column prop="otPrice" label="原价"/> |
||||
<el-table-column prop="stock" label="库存"/> |
||||
<el-table-column prop="sales" label="销量"/> |
||||
<el-table-column prop="num" label="限购"/> |
||||
<el-table-column prop="statusStr" label="秒杀状态"/> |
||||
<el-table-column prop="stopTime" label="开始时间"> |
||||
<template slot-scope="scope"> |
||||
<span>{{ formatTimeTwo(scope.row.startTime) }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column prop="stopTime" label="结束时间"> |
||||
<template slot-scope="scope"> |
||||
<span>{{ formatTimeTwo(scope.row.stopTime) }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column v-if="checkPermission(['ADMIN','YXSTORESECKILL_ALL','YXSTORESECKILL_EDIT','YXSTORESECKILL_DELETE'])" label="操作" width="150px" align="center"> |
||||
<template slot-scope="scope"> |
||||
<el-button v-permission="['ADMIN','YXSTORESECKILL_ALL','YXSTORESECKILL_EDIT']" size="mini" type="primary" icon="el-icon-edit" @click="edit(scope.row)"/> |
||||
<el-popover |
||||
v-permission="['ADMIN','YXSTORESECKILL_ALL','YXSTORESECKILL_DELETE']" |
||||
:ref="scope.row.id" |
||||
placement="top" |
||||
width="180"> |
||||
<p>确定删除本条数据吗?</p> |
||||
<div style="text-align: right; margin: 0"> |
||||
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button> |
||||
<el-button :loading="delLoading" type="primary" size="mini" @click="subDelete(scope.row.id)">确定</el-button> |
||||
</div> |
||||
<el-button slot="reference" type="danger" icon="el-icon-delete" size="mini"/> |
||||
</el-popover> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
<!--分页组件--> |
||||
<el-pagination |
||||
:total="total" |
||||
:current-page="page + 1" |
||||
style="margin-top: 8px;" |
||||
layout="total, prev, pager, next, sizes" |
||||
@size-change="sizeChange" |
||||
@current-change="pageChange"/> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import checkPermission from '@/utils/permission' |
||||
import initData from '@/mixins/initData' |
||||
import { del } from '@/api/yxStoreSeckill' |
||||
import eForm from './form' |
||||
import { formatTimeTwo, parseTime } from '@/utils/index' |
||||
export default { |
||||
components: { eForm }, |
||||
mixins: [initData], |
||||
data() { |
||||
return { |
||||
delLoading: false, |
||||
queryTypeOptions: [ |
||||
{ key: 'title', display_name: '产品标题' } |
||||
] |
||||
} |
||||
}, |
||||
created() { |
||||
this.$nextTick(() => { |
||||
this.init() |
||||
}) |
||||
}, |
||||
methods: { |
||||
parseTime, |
||||
formatTimeTwo, |
||||
checkPermission, |
||||
beforeInit() { |
||||
this.url = 'api/yxStoreSeckill' |
||||
const sort = 'id,desc' |
||||
this.params = { page: this.page, size: this.size, sort: sort } |
||||
const query = this.query |
||||
const type = query.type |
||||
const value = query.value |
||||
if (type && value) { this.params[type] = value } |
||||
return true |
||||
}, |
||||
subDelete(id) { |
||||
this.delLoading = true |
||||
del(id).then(res => { |
||||
this.delLoading = false |
||||
this.$refs[id].doClose() |
||||
this.dleChangePage() |
||||
this.init() |
||||
this.$notify({ |
||||
title: '删除成功', |
||||
type: 'success', |
||||
duration: 2500 |
||||
}) |
||||
}).catch(err => { |
||||
this.delLoading = false |
||||
this.$refs[id].doClose() |
||||
console.log(err.response.data.message) |
||||
}) |
||||
}, |
||||
add() { |
||||
this.isAdd = true |
||||
this.$refs.form.dialog = true |
||||
}, |
||||
edit(data) { |
||||
this.isAdd = false |
||||
const _this = this.$refs.form |
||||
_this.form = { |
||||
id: data.id, |
||||
productId: data.productId, |
||||
image: data.image, |
||||
images: data.images, |
||||
title: data.title, |
||||
info: data.info, |
||||
price: data.price, |
||||
cost: data.cost, |
||||
otPrice: data.otPrice, |
||||
giveIntegral: data.giveIntegral, |
||||
sort: data.sort, |
||||
stock: data.stock, |
||||
sales: data.sales, |
||||
unitName: data.unitName, |
||||
postage: data.postage, |
||||
description: data.description, |
||||
startTimeDate: new Date(data.startTimeDate), |
||||
endTimeDate: new Date(data.endTimeDate), |
||||
addTime: data.addTime, |
||||
status: data.status, |
||||
isPostage: data.isPostage, |
||||
isHot: data.isHot, |
||||
isDel: data.isDel, |
||||
num: data.num, |
||||
isShow: data.isShow |
||||
} |
||||
_this.dialog = true |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
@ -0,0 +1,118 @@
|
||||
<template> |
||||
<div class="app-container"> |
||||
<!--工具栏--> |
||||
<div class="head-container"> |
||||
<!-- 新增 --> |
||||
<div style="display: inline-block;margin: 0px 2px;"> |
||||
<el-button |
||||
v-permission="['ADMIN','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_CREATE']" |
||||
class="filter-item" |
||||
size="mini" |
||||
type="primary" |
||||
icon="el-icon-plus" |
||||
@click="add">新增</el-button> |
||||
</div> |
||||
</div> |
||||
<!--表单组件--> |
||||
<eForm ref="form" :is-add="isAdd"/> |
||||
<!--表格渲染--> |
||||
<el-table v-loading="loading" :data="data" size="small" style="width: 100%;"> |
||||
<el-table-column prop="id" label="ID"/> |
||||
<el-table-column prop="map.time" label="开启时间(整数小时)"/> |
||||
<el-table-column prop="map.continued" label="持续时间(整数小时)"/> |
||||
<el-table-column v-if="checkPermission(['ADMIN','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_EDIT','YXSYSTEMGROUPDATA_DELETE'])" label="操作" width="150px" align="center"> |
||||
<template slot-scope="scope"> |
||||
<el-button v-permission="['ADMIN','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_EDIT']" size="mini" type="primary" icon="el-icon-edit" @click="edit(scope.row)"/> |
||||
<el-popover |
||||
v-permission="['ADMIN','YXSYSTEMGROUPDATA_ALL','YXSYSTEMGROUPDATA_DELETE']" |
||||
:ref="scope.row.id" |
||||
placement="top" |
||||
width="180"> |
||||
<p>确定删除本条数据吗?</p> |
||||
<div style="text-align: right; margin: 0"> |
||||
<el-button size="mini" type="text" @click="$refs[scope.row.id].doClose()">取消</el-button> |
||||
<el-button :loading="delLoading" type="primary" size="mini" @click="subDelete(scope.row.id)">确定</el-button> |
||||
</div> |
||||
<el-button slot="reference" type="danger" icon="el-icon-delete" size="mini"/> |
||||
</el-popover> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
<!--分页组件--> |
||||
<el-pagination |
||||
:total="total" |
||||
:current-page="page + 1" |
||||
style="margin-top: 8px;" |
||||
layout="total, prev, pager, next, sizes" |
||||
@size-change="sizeChange" |
||||
@current-change="pageChange"/> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import checkPermission from '@/utils/permission' |
||||
import initData from '@/mixins/initData' |
||||
import { del } from '@/api/yxSystemGroupData' |
||||
import eForm from './seckillform' |
||||
export default { |
||||
components: { eForm }, |
||||
mixins: [initData], |
||||
data() { |
||||
return { |
||||
delLoading: false, |
||||
} |
||||
}, |
||||
created() { |
||||
this.$nextTick(() => { |
||||
this.init() |
||||
|
||||
}) |
||||
}, |
||||
methods: { |
||||
checkPermission, |
||||
beforeInit() { |
||||
this.url = 'api/yxSystemGroupData' |
||||
const sort = 'id,desc' |
||||
this.params = { page: this.page, size: this.size, sort: sort, groupName: 'routine_seckill_time' } |
||||
return true |
||||
}, |
||||
subDelete(id) { |
||||
this.delLoading = true |
||||
del(id).then(res => { |
||||
this.delLoading = false |
||||
this.$refs[id].doClose() |
||||
this.dleChangePage() |
||||
this.init() |
||||
this.$notify({ |
||||
title: '删除成功', |
||||
type: 'success', |
||||
duration: 2500 |
||||
}) |
||||
}).catch(err => { |
||||
this.delLoading = false |
||||
this.$refs[id].doClose() |
||||
console.log(err.response.data.message) |
||||
}) |
||||
}, |
||||
add() { |
||||
this.isAdd = true |
||||
this.$refs.form.dialog = true |
||||
}, |
||||
edit(data) { |
||||
this.isAdd = false |
||||
const _this = this.$refs.form |
||||
_this.form = { |
||||
id: data.id, |
||||
groupName: data.groupName, |
||||
time: data.map.time, |
||||
continued: data.map.continued |
||||
} |
||||
_this.dialog = true |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
@ -0,0 +1,101 @@
|
||||
<template> |
||||
<el-dialog :append-to-body="true" :close-on-click-modal="false" :before-close="cancel" :visible.sync="dialog" :title="isAdd ? '新增' : '编辑'" width="500px"> |
||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="150px"> |
||||
<el-form-item label="开启时间(整数小时)" > |
||||
<el-input v-model="form.time" style="width: 270px;"/> |
||||
</el-form-item> |
||||
<el-form-item label="持续时间(整数小时)" > |
||||
<el-input v-model="form.continued" style="width: 270px;"/> |
||||
</el-form-item> |
||||
</el-form> |
||||
<div slot="footer" class="dialog-footer"> |
||||
<!--<el-input v-model="form.groupName" />--> |
||||
<el-button type="text" @click="cancel">取消</el-button> |
||||
<el-button :loading="loading" type="primary" @click="doSubmit">确认</el-button> |
||||
</div> |
||||
</el-dialog> |
||||
</template> |
||||
|
||||
<script> |
||||
import { add, edit } from '@/api/yxSystemGroupData' |
||||
import picUpload from '@/components/pic-upload' |
||||
export default { |
||||
components: { picUpload }, |
||||
props: { |
||||
isAdd: { |
||||
type: Boolean, |
||||
required: true |
||||
} |
||||
}, |
||||
data() { |
||||
return { |
||||
loading: false, dialog: false, |
||||
form: { |
||||
id: '', |
||||
groupName: 'routine_seckill_time', |
||||
time: 5, |
||||
continued: 2 |
||||
}, |
||||
rules: { |
||||
} |
||||
} |
||||
}, |
||||
methods: { |
||||
cancel() { |
||||
this.resetForm() |
||||
}, |
||||
doSubmit() { |
||||
this.loading = true |
||||
if (this.isAdd) { |
||||
this.doAdd() |
||||
} else this.doEdit() |
||||
}, |
||||
doAdd() { |
||||
add(this.form).then(res => { |
||||
this.resetForm() |
||||
this.$notify({ |
||||
title: '添加成功', |
||||
type: 'success', |
||||
duration: 2500 |
||||
}) |
||||
this.loading = false |
||||
this.$parent.init() |
||||
}).catch(err => { |
||||
this.loading = false |
||||
console.log(err.response.data.message) |
||||
}) |
||||
}, |
||||
doEdit() { |
||||
edit(this.form).then(res => { |
||||
this.resetForm() |
||||
this.$notify({ |
||||
title: '修改成功', |
||||
type: 'success', |
||||
duration: 2500 |
||||
}) |
||||
this.loading = false |
||||
this.$parent.init() |
||||
}).catch(err => { |
||||
this.loading = false |
||||
console.log(err.response.data.message) |
||||
}) |
||||
}, |
||||
resetForm() { |
||||
this.dialog = false |
||||
this.$refs['form'].resetFields() |
||||
this.form = { |
||||
id: '', |
||||
groupName: 'routine_seckill_time', |
||||
value: '', |
||||
addTime: '', |
||||
sort: '', |
||||
status: '' |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
Loading…
Reference in new issue