Browse Source

YSHOP1.6新增砍价后台管理

master
xuwenbo 5 years ago
parent
commit
d2585cdd8b
  1. 24
      src/api/yxStoreBargain.js
  2. 242
      src/views/activity/bargain/form.vue
  3. 168
      src/views/activity/bargain/index.vue
  4. 44
      src/views/shop/goods/index.vue

24
src/api/yxStoreBargain.js

@ -0,0 +1,24 @@
import request from '@/utils/request'
export function add(data) {
return request({
url: 'api/yxStoreBargain',
method: 'post',
data
})
}
export function del(id) {
return request({
url: 'api/yxStoreBargain/' + id,
method: 'delete'
})
}
export function edit(data) {
return request({
url: 'api/yxStoreBargain',
method: 'put',
data
})
}

242
src/views/activity/bargain/form.vue

@ -0,0 +1,242 @@
<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;" rows="5" type="textarea"/>
</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.stock" />
</el-form-item>
<el-form-item label="销量" >
<el-input-number v-model="form.sales" />
</el-form-item>
<!-- <el-form-item label="砍价产品名称" >-->
<!-- <el-input v-model="form.storeName" />-->
<!-- </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.minPrice" />
</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.bargainMaxPrice" />
</el-form-item>
<el-form-item label="单次砍最低价" >
<el-input-number v-model="form.bargainMinPrice" />
</el-form-item>
<el-form-item label="用户每次砍价的次数" >
<el-input-number v-model="form.bargainNum" />
</el-form-item>
<el-form-item label="反多少积分" >
<el-input-number v-model="form.giveIntegral" />
</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: 110px;">到砍价时间不自动开启</el-radio>
</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.sort" />
</el-form-item>
<el-form-item label="是否推荐" >
<el-radio v-model="form.isHot" :label="1"></el-radio>
<el-radio v-model="form.isHot" :label="0" style="width: 110px;"></el-radio>
</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="邮费" v-if="form.isPostage ===0">
<el-input-number v-model="form.postage" />
</el-form-item>
<el-form-item label="砍价规则" >
<editor v-model="form.rule" />
</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 picUpload from '@/components/pic-upload'
import mulpicUpload from '@/components/mul-pic-upload'
import { add, edit } from '@/api/yxStoreBargain'
import editor from '../../components/Editor'
export default {
components: { editor, picUpload, mulpicUpload },
props: {
isAdd: {
type: Boolean,
required: true
}
},
data() {
return {
loading: false, dialog: false,
form: {
id: '',
productId: '',
title: '',
image: '',
unitName: '',
stock: '',
sales: '',
images: '',
startTime: '',
stopTime: '',
storeName: '',
price: '',
minPrice: '',
num: '',
bargainMaxPrice: '',
bargainMinPrice: '',
bargainNum: '',
status: '',
description: '',
giveIntegral: '',
info: '',
cost: '',
sort: 0,
isHot: 0,
isDel: 0,
addTime: '',
isPostage: 1,
postage: '',
rule: '',
look: '',
share: '',
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: '',
title: '',
image: '',
unitName: '',
stock: '',
sales: '',
images: '',
startTime: '',
stopTime: '',
storeName: '',
price: '',
minPrice: '',
num: '',
bargainMaxPrice: '',
bargainMinPrice: '',
bargainNum: '',
status: '',
description: '',
giveIntegral: '',
info: '',
cost: '',
sort: '',
isHot: '',
isDel: '',
addTime: '',
isPostage: '',
postage: '',
rule: '',
look: '',
share: ''
}
}
}
}
</script>
<style scoped>
</style>

168
src/views/activity/bargain/index.vue

@ -0,0 +1,168 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<!-- 新增 -->
<div style="display: inline-block;margin: 0px 2px;">
<el-button
v-permission="['ADMIN','YXSTOREBARGAIN_ALL','YXSTOREBARGAIN_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="title" label="砍价标题"/>
<el-table-column prop="info" label="砍价简介"/>
<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="unitName" label="单位名称"/>
<el-table-column prop="stock" label="库存"/>
<el-table-column prop="sales" label="销量"/>
<el-table-column prop="startTime" 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 prop="storeName" label="砍价产品名称"/>-->
<el-table-column prop="look" label="浏览量"/>
<el-table-column prop="share" label="分享量"/>
<el-table-column v-if="checkPermission(['ADMIN','YXSTOREBARGAIN_ALL','YXSTOREBARGAIN_EDIT','YXSTOREBARGAIN_DELETE'])" label="操作" width="150px" align="center">
<template slot-scope="scope">
<el-button v-permission="['ADMIN','YXSTOREBARGAIN_ALL','YXSTOREBARGAIN_EDIT']" size="mini" type="primary" icon="el-icon-edit" @click="edit(scope.row)"/>
<el-popover
v-permission="['ADMIN','YXSTOREBARGAIN_ALL','YXSTOREBARGAIN_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/yxStoreBargain'
import eForm from './form'
import { formatTimeTwo, parseTime } from '@/utils/index'
export default {
components: { eForm },
mixins: [initData],
data() {
return {
delLoading: false,
}
},
created() {
this.$nextTick(() => {
this.init()
})
},
methods: {
parseTime,
formatTimeTwo,
checkPermission,
beforeInit() {
this.url = 'api/yxStoreBargain'
const sort = 'id,desc'
this.params = { page: this.page, size: this.size, sort: sort }
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,
title: data.title,
image: data.image,
unitName: data.unitName,
stock: data.stock,
sales: data.sales,
images: data.images,
startTime: data.startTime,
stopTime: data.stopTime,
storeName: data.storeName,
price: data.price,
minPrice: data.minPrice,
num: data.num,
bargainMaxPrice: data.bargainMaxPrice,
bargainMinPrice: data.bargainMinPrice,
bargainNum: data.bargainNum,
status: data.status,
description: data.description,
giveIntegral: data.giveIntegral,
info: data.info,
cost: data.cost,
sort: data.sort,
isHot: data.isHot,
isDel: data.isDel,
addTime: data.addTime,
isPostage: data.isPostage,
postage: data.postage,
rule: data.rule,
look: data.look,
share: data.share
}
_this.dialog = true
}
}
}
</script>
<style scoped>
</style>

44
src/views/shop/goods/index.vue

@ -24,6 +24,7 @@
<eAttr ref="form2" :is-attr="isAttr"/>
<comForm ref="form3" :is-add="isAdd"/>
<killForm ref="form4" :is-add="isAdd"/>
<bargainForm ref = "form5" :is-add="isAdd"/>
<!--表格渲染-->
<el-table v-loading="loading" :data="data" size="small" style="width: 100%;">
<el-table-column prop="id" label="商品id"/>
@ -71,12 +72,16 @@
</el-dropdown-item>
<el-dropdown-item>
<el-button v-permission="['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_EDIT']" size="mini"
type="primary" @click="editC(scope.row)">开启拼团</el-button>
type="success" @click="editC(scope.row)">开启拼团</el-button>
</el-dropdown-item>
<el-dropdown-item>
<el-button v-permission="['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_EDIT']" size="mini"
<el-button v-permission="['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_EDIT']" size="mini"
type="primary" @click="editD(scope.row)">开启秒杀</el-button>
</el-dropdown-item>
<el-dropdown-item>
<el-button v-permission="['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_EDIT']" size="mini"
type="warning" @click="editE(scope.row)">开启砍价</el-button>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
@ -101,8 +106,9 @@ import eForm from './form'
import eAttr from './attr'
import comForm from '@/views/activity/combination/form'
import killForm from '@/views/activity/seckill/form'
import bargainForm from '@/views/activity/bargain/form'
export default {
components: { eForm, eAttr, comForm, killForm },
components: { eForm, eAttr, comForm, killForm, bargainForm },
mixins: [initData],
data() {
return {
@ -279,6 +285,38 @@ export default {
}
_this.dialog = true
},
editE(data) {
this.isAdd = false
const _this = this.$refs.form5
_this.form = {
productId: data.id,
merId: data.merId,
image: data.image,
images: data.sliderImage,
title: data.storeName,
info: data.storeInfo,
postage: data.postage,
unitName: data.unitName,
sort: data.sort,
sales: data.sales,
stock: data.stock,
isShow: data.isShow,
status: 1,
isHot: data.isHot,
description: data.description,
isPostage: data.isPostage,
people: 0,
price: 0.01,
effectiveTime: 24,
otPrice: data.otPrice,
cost: data.cost,
num: 1,
giveIntegral: 0,
isDel: 0,
browse: 0
}
_this.dialog = true
},
attr(data) {
console.log(3333)
this.isAttr = false

Loading…
Cancel
Save