1.2.3 后台操作按钮调整及其新增开启拼团功能

This commit is contained in:
hupeng
2019-11-19 13:44:19 +08:00
commit 4faa83dc0c
307 changed files with 23684 additions and 0 deletions

View File

@ -0,0 +1,447 @@
<template>
<el-dialog :append-to-body="true" :close-on-click-modal="false" :before-close="cancel" :visible.sync="dialog" :title="title" width="900px">
<el-form ref="form" :model="form" :inline="true" :rules="rules" label-width="80px" v-show="hidden == false">
<el-form-item label="规则名称" >
<el-row :gutter="10">
<el-col :span="10"><el-button type="primary" @click="hiddenBool" >添加新规则</el-button></el-col>
</el-row>
</el-form-item>
</el-form>
<el-form ref="form" :model="form" :rules="rules" label-width="80px" v-show="hidden == true">
<el-form-item label="规则名称" >
<el-row :gutter="10">
<el-col :span="5" style="position: relative;margin-right: 6px"
v-for="(item, index) in items"
:key="index">
<el-input v-model="item.value" style="width: 150px;" placeholder="设置名称" />
<el-button type="text" style="position: absolute;top:-6px;right:17px;margin-top:1px;border: none;font-size: 14px;font-weight:bold;line-height: 1.8" @click="handleRemove(index)" icon="el-icon-close" v-show="item.attrHidden == true" />
<el-button type="text" style="position: absolute;top:-6px;right:17px;margin-top:1px;border: none;font-size: 14px;font-weight:bold;line-height: 1.8" @click="attrHiddenBool(item)" icon="el-icon-check" v-show="item.attrHidden == false" />
</el-col>
<el-col :span="5"><el-button type="primary" @click="handleAdd" >添加新规则</el-button></el-col>
</el-row>
</el-form-item>
<el-form-item v-show="item.attrHidden == true"
v-for="(item, index) in items"
:key="index"
:label="''+item.value+':'" >
<el-row :gutter="13">
<el-col :span="3"
v-for="(attr,k) in item.detail"
:key="attr"
:name="attr">
<el-tag @on-close="attrRemove(item,k)" closable>{{ attr }}</el-tag>
</el-col>
<el-col :span="5">
<el-input v-model="item.detailValue" style="width: 150px;" placeholder="设置属性" />
</el-col>
<el-col :span="5">
<el-button type="primary" @click="attrAdd(item)" >添加</el-button>
</el-col>
</el-row>
</el-form-item>
<el-form-item v-show="hidden == true" >
<el-row :gutter="24">
<el-col :span="24"><el-button :loading="loading" type="primary" @click="addGoods(true)">生成</el-button></el-col>
</el-row>
</el-form-item>
<template v-if="items[0].value!='' && items[0].detail.length>0 && attrs.length">
<template v-for="(attr,index) in attrs">
<el-form-item>
<el-row :gutter="24">
<template v-for="(item,index) in attr.detail">
<el-col :span="3" style="margin-right: 2px">
{{index}}:{{item}}
</el-col>
</template>
<el-col :span="4">
<span :class="attr.check ? 'check':''">金额:</span>&nbsp;
<el-input placeholder="金额" v-model="attr.price" style="width: 60%" :number="true" />
</el-col>
<el-col :span="4">
<span :class="attr.check ? 'check':''">库存:</span>&nbsp;
<el-input placeholder="库存" v-model="attr.sales" style="width: 60%" :number="true" />
</el-col>
<el-col :span="5">
<span :class="attr.check ? 'check':''">成本价:</span>&nbsp;
<el-input placeholder="成本价" v-model="attr.cost" style="width: 60%" :number="true" />
</el-col>
<el-col :span="3" style="margin-right: 2px">
<div class="demo-upload">
<!--<img :src="attr.pic">-->
<pic-upload-two v-model="attr.pic" />
</div>
</el-col>
<el-col :span="2" style="margin-right: 3px">
<el-button type="primary" @click="removeGoods(index)" >删除</el-button>
</el-col>
</el-row>
</el-form-item>
</template>
<el-form-item>
<el-row :gutter="24">
<el-col :span="2" >
<el-button type="primary" :loading="loading" @click="submit">提交</el-button>
</el-col>
<el-col :span="2" >
<el-button type="error" @click="clear">清空所有属性</el-button>
</el-col>
</el-row>
</el-form-item>
</template>
</el-form>
</el-dialog>
</template>
<script>
import { getCates } from '@/api/yxStoreCategory'
import { add, edit, isFormatAttr, setAttr, clearAttr, getAttr } from '@/api/yxStoreProduct'
import editor from '../../components/Editor'
import picUploadTwo from '@/components/pic-upload-two'
import mulpicUpload from '@/components/mul-pic-upload'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { Message } from 'element-ui'
export default {
components: { editor, picUploadTwo, mulpicUpload, Treeselect },
props: {
isAttr: {
type: Boolean,
required: true
}
},
data() {
return {
loading: false, dialog: false, cates: [], title: "规则属性",
form: {
id: '',
merId: '',
image: '',
sliderImage: '',
storeName: '',
storeInfo: '',
keyword: '',
barCode: '',
cateId: 1,
price: '',
vipPrice: '',
otPrice: '',
postage: '',
unitName: '',
sort: '',
sales: '',
stock: '',
isShow: '',
isHot: '',
isBenefit: '',
isBest: '',
isNew: '',
description: '',
addTime: '',
isPostage: '',
isDel: '',
merUse: '',
giveIntegral: '',
cost: '',
isSeckill: '',
isBargain: '',
isGood: '',
ficti: '',
browse: '',
codePath: '',
soureLink: ''
},
rules: {
},
items: [{
value: '',
detailValue:'',
attrHidden:false,
detail:[]
}],
attrs: [],
hidden:false,
attrHidden:false,
submiting :false,
}
},
methods: {
getAttrs(id) {
getAttr(id).then(res=>{
console.log('res'+res)
//this.items = JSON.parse(res.attr)
if(res){
this.hidden = true
this.items = res.attr
this.attrs = res.value
}else{
this.hidden = false
this.items = [{
value: '',
detailValue:'',
attrHidden:false,
detail:[]
}]
this.attrs = []
}
})
},
cancel() {
this.resetForm()
},
doSubmit() {
this.loading = true
if (this.isAttr) {
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: '',
merId: '',
image: '',
sliderImage: '',
storeName: '',
storeInfo: '',
keyword: '',
barCode: '',
cateId: '',
price: '',
vipPrice: '',
otPrice: '',
postage: '',
unitName: '',
sort: '',
sales: '',
stock: '',
isShow: '',
isHot: '',
isBenefit: '',
isBest: '',
isNew: '',
description: '',
addTime: '',
isPostage: '',
isDel: '',
merUse: '',
giveIntegral: '',
cost: '',
isSeckill: '',
isBargain: '',
isGood: '',
ficti: '',
browse: '',
codePath: '',
soureLink: ''
}
},
setAttrPic(index,pic){
this.$set(this.attrs[index],'pic',pic);
},
attrHiddenBool(item){
if(item.value == ''){
Message({message: '请填写规则名称',type: 'error'})
}else{
item.attrHidden = true;
}
},
hiddenBool(){
this.hidden = true;
},
handleAdd () {
if(!this.checkAttr())return ;
this.items.push({
value: '',
detailValue:'',
attrHidden:false,
detail:[]
});
},
checkAttr(){
var bool = true;
this.items.map(function(item){
if(!bool) return;
if(!item.value){
Message({message: '请填写规则名称',type: 'error'})
bool = false;
}else if(!item.detail.length){
Message({message: '请设置规则属性',type: 'error'})
bool = false;
}
});
return bool;
},
attrAdd (item) {
if(!item.detailValue) return false;
item.detail.push(item.detailValue);
item.detailValue = '';
},
handleRemove (index) {
if(this.items.length > 1)
this.items.splice(index,1);
else
Message({message: '请设置至少一个规则',type: 'error'})
},
attrRemove(item,k){
if(1==item.detail.length){
Message({message: '请设置至少一个属性',type: 'error'})
return false;
}
item.detail.splice(k,1);
},
removeGoods(index){
this.attrs.splice(index,1);
},
checkGoods(){
var bool = true;
this.attrs.map(function(attr){
if(!bool) return ;
if(!Object.keys(attr.detail).length){
Message({message: '请选择至少一个属性',type: 'error'})
bool = false;
}else if(attr.price != parseFloat(attr.price) || attr.price < 0){
Message({message: '请输入正确的商品价格',type: 'error'})
bool = false;
}else if(attr.sales != parseInt(attr.sales) || attr.sales < 0){
Message({message: '请输入正确的商品库存',type: 'error'})
bool = false;
}
});
return bool;
},
addGoods(type){
if(this.attrs.length){
if(!this.checkGoods())return ;
}
var that = this;
isFormatAttr(this.form.id,{items:this.items,attrs:this.attrs}).then(res => {
this.attrs = res
}).catch(err => {
this.loading = false
console.log(err.response.data.message)
})
},
submit(){
var that = this;
that.submiting = true;
if(!this.checkAttr() || !this.checkGoods()) return ;
for(let attr in that.attrs){
that.attrs[attr].check = false;
}
//console.log({items:this.items,attrs:this.attrs})
this.loading = false
setAttr(this.form.id,{items:this.items,attrs:this.attrs}).then(res => {
this.attrs = res
Message({message: '操作成功',type: 'success'})
}).catch(err => {
this.loading = false
console.log(err.response.data.message)
})
this.dialog = false
},
clear(){
this.$confirm(`确定要清空属性数据'}]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
clearAttr(this.form.id).then(({ data }) => {
Message({message: '操作成功',type: 'success'})
//this.dialog = false
this.getAttrs(this.form.id)
})
})
.catch(() => { })
}
},
mounted (){
//console.log('items'+this.items)
//console.log('attrs'+this.attrs)
//if(this.items && this.attrs) this.hidden = true;
// window.changeIMG = (index,pic)=>{
// _vm.setAttrPic(index,pic);
// };
}
}
</script>
<style scoped>
.demo-upload{
display: block;
/*//height: 50px;*/
text-align: center;
border: 1px solid transparent;
border-radius: 4px;
overflow: hidden;
background: #fff;
position: relative;
box-shadow: 0 1px 1px rgba(0,0,0,.2);
margin-right: 4px;
}
.demo-upload img{
width: 100%;
height: 100%;
display: block;
}
.demo-upload-cover{
display: block;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0,0,0,.6);
}
.demo-upload:hover .demo-upload-cover{
display: block;
}
.demo-upload-cover i{
color: #fff;
font-size: 20px;
cursor: pointer;
margin: 0 2px;
}
</style>

View File

@ -0,0 +1,247 @@
<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" :inline="true" :rules="rules" size="small" label-width="80px">
<el-form-item style="margin-bottom: 0px;" label="商品分类">
<treeselect v-model="form.cateId" :options="cates" style="width: 370px;" placeholder="选择商品分类" />
</el-form-item>
<el-form-item label="商品名称" >
<el-input v-model="form.storeName" style="width: 500px;"/>
</el-form-item>
<el-form-item label="关键字" >
<el-input v-model="form.keyword" style="width: 500px;"/>
</el-form-item>
<el-form-item label="单位名" >
<el-input v-model="form.unitName" style="width: 320px;"/>
</el-form-item>
<el-form-item label="产品条码" >
<el-input v-model="form.barCode" style="width: 320px;"/>
</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.sliderImage" style="width: 500px;"/>
</el-form-item>
<el-form-item label="商品简介" >
<el-input v-model="form.storeInfo" style="width: 500px;" rows="5" type="textarea"/>
</el-form-item>
<el-form-item label="产品描述" >
<editor v-model="form.description" />
</el-form-item>
<el-form-item label="商品价格" >
<el-input v-model="form.price" />
</el-form-item>
<el-form-item label="会员价格" >
<el-input v-model="form.vipPrice"/>
</el-form-item>
<el-form-item label="市场价" >
<el-input v-model="form.otPrice"/>
</el-form-item>
<el-form-item label="成本价" >
<el-input v-model="form.cost" />
</el-form-item>
<el-form-item label="邮费" >
<el-input v-model="form.postage" />
</el-form-item>
<el-form-item label="排序" >
<el-input v-model="form.sort" />
</el-form-item>
<el-form-item label="销量" >
<el-input v-model="form.sales" />
</el-form-item>
<el-form-item label="库存" >
<el-input v-model="form.stock" />
</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: 200px;">否</el-radio>
</el-form-item>
<el-form-item label="促销单品" >
<el-radio v-model="form.isBenefit" :label="1">是</el-radio>
<el-radio v-model="form.isBenefit" :label="0" style="width: 200px;">否</el-radio>
</el-form-item>
<el-form-item label="精品推荐" >
<el-radio v-model="form.isBest" :label="1">是</el-radio>
<el-radio v-model="form.isBest" :label="0" style="width: 200px;">否</el-radio>
</el-form-item>
<el-form-item label="首发新品" >
<el-radio v-model="form.isNew" :label="1">是</el-radio>
<el-radio v-model="form.isNew" :label="0" style="width: 200px;">否</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: 200px;">否</el-radio>
</el-form-item>
<el-form-item label="优品推荐">
<el-radio v-model="form.isGood" :label="1"></el-radio>
<el-radio v-model="form.isGood" :label="0" style="width: 200px;"></el-radio>
</el-form-item>
<el-form-item label="获得积分" >
<el-input v-model="form.giveIntegral" />
</el-form-item>
<el-form-item label="虚拟销量" >
<el-input v-model="form.ficti" />
</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 { getCates } from '@/api/yxStoreCategory'
import { add, edit } from '@/api/yxStoreProduct'
import editor from '../../components/Editor'
import picUpload from '@/components/pic-upload'
import mulpicUpload from '@/components/mul-pic-upload'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
export default {
components: { editor, picUpload, mulpicUpload, Treeselect },
props: {
isAdd: {
type: Boolean,
required: true
}
},
data() {
return {
loading: false, dialog: false, cates: [],
form: {
id: '',
merId: 0,
image: '',
sliderImage: '',
storeName: '',
storeInfo: '',
keyword: '',
barCode: '',
cateId: 1,
price: 0,
vipPrice: 0,
otPrice: 0,
postage: 0,
unitName: '',
sort: 0,
sales: 0,
stock: 0,
isShow: 1,
isHot: 0,
isBenefit: 0,
isBest: 0,
isNew: 0,
description: '',
addTime: '',
isPostage: 0,
isDel: 0,
merUse: 0,
giveIntegral: 0,
cost: 0,
isSeckill: 0,
isBargain: 0,
isGood: 0,
ficti: 0,
browse: 0,
codePath: '',
soureLink: ''
},
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: '',
merId: '',
image: '',
sliderImage: '',
storeName: '',
storeInfo: '',
keyword: '',
barCode: '',
cateId: '',
price: '',
vipPrice: '',
otPrice: '',
postage: '',
unitName: '',
sort: '',
sales: '',
stock: '',
isShow: '',
isHot: '',
isBenefit: '',
isBest: '',
isNew: '',
description: '',
addTime: '',
isPostage: '',
isDel: '',
merUse: '',
giveIntegral: '',
cost: '',
isSeckill: '',
isBargain: '',
isGood: '',
ficti: '',
browse: '',
codePath: '',
soureLink: ''
}
},
getCates() {
getCates({ enabled: true }).then(res => {
this.cates = res.content
})
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,295 @@
<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 style="display: inline-block;margin: 0px 2px;">
<el-button
v-permission="['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_CREATE']"
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="add">新增</el-button>
</div>
</div>
<!--表单组件-->
<eForm ref="form" :is-add="isAdd"/>
<eAttr ref="form2" :is-attr="isAttr"/>
<comForm ref="form3" :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 ref="table" 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="storeName" label="商品名称"/>
<el-table-column prop="cateName" label="分类名称"/>
<el-table-column prop="price" label="商品价格"/>
<el-table-column prop="sales" label="销量"/>
<el-table-column prop="stock" label="库存"/>
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<div @click="onSale(scope.row.id,scope.row.isShow)">
<el-tag v-if="scope.row.isShow === 1" style="cursor: pointer" :type="''">已上架</el-tag>
<el-tag style="cursor: pointer" v-else :type=" 'info' ">已下架</el-tag>
</div>
</template>
</el-table-column>
<el-table-column v-if="checkPermission(['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_EDIT','YXSTOREPRODUCT_DELETE'])" label="操作" width="185px" align="center">
<template slot-scope="scope">
<el-button slot="reference" type="danger" size="mini" @click="attr(scope.row)">属性</el-button>
<el-dropdown size="mini" split-button type="primary" trigger="click">
操作
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>
<el-button v-permission="['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_EDIT']" size="mini"
type="primary" icon="el-icon-edit" @click="edit(scope.row)">编辑</el-button>
</el-dropdown-item>
<el-dropdown-item>
<el-popover
v-permission="['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_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-button>
</el-popover>
</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>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</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, onsale } from '@/api/yxStoreProduct'
import eForm from './form'
import eAttr from './attr'
import comForm from '@/views/activity/combination/form'
export default {
components: { eForm, eAttr, comForm },
mixins: [initData],
data() {
return {
delLoading: false,
visible: false,
queryTypeOptions: [
{ key: 'storeName', display_name: '商品名称' }
],
isAttr: false
}
},
created() {
this.$nextTick(() => {
this.init()
})
},
methods: {
checkPermission,
beforeInit() {
this.url = 'api/yxStoreProduct'
const sort = 'id,desc'
this.params = { page: this.page, size: this.size, sort: sort, isShow: 1, isDel: 0 }
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)
})
},
onSale(id, status) {
this.$confirm(`确定进行[${status ? '下架' : '上架'}]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
onsale(id, { status: status }).then(({ data }) => {
this.$message({
message: '操作成功',
type: 'success',
duration: 1000,
onClose: () => {
this.init()
}
})
})
})
.catch(() => { })
},
add() {
this.isAdd = true
this.$refs.form.dialog = true
this.$refs.form.getCates()
},
edit(data) {
this.isAdd = false
const _this = this.$refs.form
_this.getCates()
_this.form = {
id: data.id,
merId: data.merId,
image: data.image,
sliderImage: data.sliderImage,
storeName: data.storeName,
storeInfo: data.storeInfo,
keyword: data.keyword,
barCode: data.barCode,
cateId: data.cateId,
price: data.price,
vipPrice: data.vipPrice,
otPrice: data.otPrice,
postage: data.postage,
unitName: data.unitName,
sort: data.sort,
sales: data.sales,
stock: data.stock,
isShow: data.isShow,
isHot: data.isHot,
isBenefit: data.isBenefit,
isBest: data.isBest,
isNew: data.isNew,
description: data.description,
addTime: data.addTime,
isPostage: data.isPostage,
isDel: data.isDel,
merUse: data.merUse,
giveIntegral: data.giveIntegral,
cost: data.cost,
isSeckill: data.isSeckill,
isBargain: data.isBargain,
isGood: data.isGood,
ficti: data.ficti,
browse: data.browse,
codePath: data.codePath,
soureLink: data.soureLink
}
_this.dialog = true
},
editC(data) {
this.isAdd = false
const _this = this.$refs.form3
_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,
isHost: data.isHot,
description: data.description,
isPostage: data.isPostage,
people: 0,
price: 0,
effectiveTime: 24,
combination: 1,
cost: data.cost,
isDel: 0,
browse: 0
}
_this.dialog = true
},
attr(data) {
console.log(3333)
this.isAttr = false
const _this = this.$refs.form2
_this.form = {
id: data.id,
merId: data.merId,
image: data.image,
sliderImage: data.sliderImage,
storeName: data.storeName,
storeInfo: data.storeInfo,
keyword: data.keyword,
barCode: data.barCode,
cateId: data.cateId,
price: data.price,
vipPrice: data.vipPrice,
otPrice: data.otPrice,
postage: data.postage,
unitName: data.unitName,
sort: data.sort,
sales: data.sales,
stock: data.stock,
isShow: data.isShow,
isHot: data.isHot,
isBenefit: data.isBenefit,
isBest: data.isBest,
isNew: data.isNew,
description: data.description,
addTime: data.addTime,
isPostage: data.isPostage,
isDel: data.isDel,
merUse: data.merUse,
giveIntegral: data.giveIntegral,
cost: data.cost,
isSeckill: data.isSeckill,
isBargain: data.isBargain,
isGood: data.isGood,
ficti: data.ficti,
browse: data.browse,
codePath: data.codePath,
soureLink: data.soureLink
}
_this.dialog = true
this.$refs.form2.getAttrs(data.id)
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,201 @@
<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 style="display: inline-block;margin: 0px 2px;">
<el-button
v-permission="['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_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 ref="table" 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="storeName" label="商品名称"/>
<el-table-column prop="cateName" label="分类名称"/>
<el-table-column prop="price" label="商品价格"/>
<el-table-column prop="sales" label="销量"/>
<el-table-column prop="stock" label="库存"/>
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<div @click="onSale(scope.row.id,scope.row.isShow)">
<el-tag v-if="scope.row.isShow === 1" style="cursor: pointer" :type="''">已上架</el-tag>
<el-tag style="cursor: pointer" v-else :type=" 'info' ">已下架</el-tag>
</div>
</template>
</el-table-column>
<el-table-column v-if="checkPermission(['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_EDIT','YXSTOREPRODUCT_DELETE'])" label="操作" width="150px" align="center">
<template slot-scope="scope">
<el-button v-permission="['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_EDIT']" size="mini" type="primary" icon="el-icon-edit" @click="edit(scope.row)"/>
<el-popover
v-permission="['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_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, onsale } from '@/api/yxStoreProduct'
import eForm from './form'
export default {
components: { eForm },
mixins: [initData],
data() {
return {
delLoading: false,
visible: false,
queryTypeOptions: [
{ key: 'storeName', display_name: '商品名称' }
]
}
},
created() {
this.$nextTick(() => {
this.init()
})
},
methods: {
checkPermission,
beforeInit() {
this.url = 'api/yxStoreProduct'
const sort = 'id,desc'
this.params = { page: this.page, size: this.size, sort: sort, isShow: 0 }
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)
})
},
onSale(id, status) {
this.$confirm(`确定进行[${status ? '下架' : '上架'}]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
onsale(id, { status: status }).then(({ data }) => {
this.$message({
message: '操作成功',
type: 'success',
duration: 1000,
onClose: () => {
this.init()
}
})
})
})
.catch(() => { })
},
add() {
this.isAdd = true
this.$refs.form.dialog = true
this.$refs.form.getCates()
},
edit(data) {
this.isAdd = false
const _this = this.$refs.form
_this.getCates()
_this.form = {
id: data.id,
merId: data.merId,
image: data.image,
sliderImage: data.sliderImage,
storeName: data.storeName,
storeInfo: data.storeInfo,
keyword: data.keyword,
barCode: data.barCode,
cateId: data.cateId,
price: data.price,
vipPrice: data.vipPrice,
otPrice: data.otPrice,
postage: data.postage,
unitName: data.unitName,
sort: data.sort,
sales: data.sales,
stock: data.stock,
isShow: data.isShow,
isHot: data.isHot,
isBenefit: data.isBenefit,
isBest: data.isBest,
isNew: data.isNew,
description: data.description,
addTime: data.addTime,
isPostage: data.isPostage,
isDel: data.isDel,
merUse: data.merUse,
giveIntegral: data.giveIntegral,
cost: data.cost,
isSeckill: data.isSeckill,
isBargain: data.isBargain,
isGood: data.isGood,
ficti: data.ficti,
browse: data.browse,
codePath: data.codePath,
soureLink: data.soureLink
}
_this.dialog = true
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,193 @@
<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 style="display: inline-block;margin: 0px 2px;">
<el-button
v-permission="['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_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 ref="table" 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="storeName" label="商品名称"/>
<el-table-column prop="cateName" label="分类名称"/>
<el-table-column prop="price" label="商品价格"/>
<el-table-column prop="sales" label="销量"/>
<el-table-column prop="stock" label="库存"/>
<el-table-column v-if="checkPermission(['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_EDIT','YXSTOREPRODUCT_DELETE'])" label="操作" width="150px" align="center">
<template slot-scope="scope">
<el-button v-permission="['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_EDIT']" size="mini" type="primary" icon="el-icon-edit" @click="edit(scope.row)"/>
<el-popover
v-permission="['ADMIN','YXSTOREPRODUCT_ALL','YXSTOREPRODUCT_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-button>
</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 { recovery, onsale } from '@/api/yxStoreProduct'
import eForm from './form'
export default {
components: { eForm },
mixins: [initData],
data() {
return {
delLoading: false,
visible: false,
queryTypeOptions: [
{ key: 'storeName', display_name: '商品名称' }
]
}
},
created() {
this.$nextTick(() => {
this.init()
})
},
methods: {
checkPermission,
beforeInit() {
this.url = 'api/yxStoreProduct'
const sort = 'id,desc'
this.params = { page: this.page, size: this.size, sort: sort, isDel: 1 }
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
recovery(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)
})
},
onSale(id, status) {
this.$confirm(`确定进行[${status ? '下架' : '上架'}]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
onsale(id, { status: status }).then(({ data }) => {
this.$message({
message: '操作成功',
type: 'success',
duration: 1000,
onClose: () => {
this.init()
}
})
})
})
.catch(() => { })
},
add() {
this.isAdd = true
this.$refs.form.dialog = true
this.$refs.form.getCates()
},
edit(data) {
this.isAdd = false
const _this = this.$refs.form
_this.getCates()
_this.form = {
id: data.id,
merId: data.merId,
image: data.image,
sliderImage: data.sliderImage,
storeName: data.storeName,
storeInfo: data.storeInfo,
keyword: data.keyword,
barCode: data.barCode,
cateId: data.cateId,
price: data.price,
vipPrice: data.vipPrice,
otPrice: data.otPrice,
postage: data.postage,
unitName: data.unitName,
sort: data.sort,
sales: data.sales,
stock: data.stock,
isShow: data.isShow,
isHot: data.isHot,
isBenefit: data.isBenefit,
isBest: data.isBest,
isNew: data.isNew,
description: data.description,
addTime: data.addTime,
isPostage: data.isPostage,
isDel: data.isDel,
merUse: data.merUse,
giveIntegral: data.giveIntegral,
cost: data.cost,
isSeckill: data.isSeckill,
isBargain: data.isBargain,
isGood: data.isGood,
ficti: data.ficti,
browse: data.browse,
codePath: data.codePath,
soureLink: data.soureLink
}
_this.dialog = true
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,43 @@
<template>
<el-tabs v-model="activeName" style="padding-left: 8px;" @tab-click="tabClick">
<el-tab-pane label="出售中产品" name="first">
<onSale ref="onSale"/>
</el-tab-pane>
<el-tab-pane label="待上架产品" name="second">
<unonSale ref="unonSale"/>
</el-tab-pane>
<el-tab-pane label="产品回收站" name="thrid">
<recycle ref="recycle"/>
</el-tab-pane>
</el-tabs>
</template>
<script>
import onSale from '@/views/shop/goods/index'
import unonSale from '@/views/shop/goods/index2'
import recycle from '@/views/shop/goods/index3'
import '@/styles/description.scss'
export default {
name: 'Tab',
components: { onSale, unonSale, recycle },
data() {
return {
activeName: 'first'
}
},
methods: {
tabClick(name) {
if (this.activeName === 'first') {
this.$refs.onSale.init()
} else if (this.activeName === 'second') {
this.$refs.unonSale.init()
}else{
this.$refs.recycle.init()
}
}
}
}
</script>
<style scoped>
</style>