直播添商品相关
This commit is contained in:
@ -24,4 +24,10 @@ export function edit(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del }
|
||||
export function sync() {
|
||||
return request({
|
||||
url: 'api/yxWechatLive/synchro',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
export default { add, edit, del, sync }
|
||||
|
27
src/api/yxWechatLiveGoods.js
Normal file
27
src/api/yxWechatLiveGoods.js
Normal file
@ -0,0 +1,27 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function add(data) {
|
||||
return request({
|
||||
url: 'api/yxWechatLiveGoods',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function del(ids) {
|
||||
return request({
|
||||
url: 'api/yxWechatLiveGoods/',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
export function edit(data) {
|
||||
return request({
|
||||
url: 'api/yxWechatLiveGoods',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { add, edit, del }
|
144
src/views/components/good/index.vue
Normal file
144
src/views/components/good/index.vue
Normal file
@ -0,0 +1,144 @@
|
||||
<template>
|
||||
<div>
|
||||
<div v-if="value.productId">
|
||||
<ul class="el-upload-list el-upload-list--picture-card">
|
||||
<li tabindex="0" class="el-upload-list__item is-ready">
|
||||
<div>
|
||||
<img :src="value.image" alt="" class="el-upload-list__item-thumbnail">
|
||||
<span class="el-upload-list__item-actions">
|
||||
<span class="el-upload-list__item-delete" @click="deleteGood">
|
||||
<i class="el-icon-delete" />
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-else tabindex="0" class="el-upload el-upload--picture-card" @click="toSelete">
|
||||
<i class="el-icon-plus" />
|
||||
</div>
|
||||
<el-dialog :visible.sync="dialog" append-to-body width="60%" title="商品列表">
|
||||
<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>
|
||||
<!--表单组件-->
|
||||
|
||||
<!--表格渲染-->
|
||||
<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="storeCategory.cateName" label="分类名称" />
|
||||
<el-table-column prop="price" label="商品价格" />
|
||||
<el-table-column label="操作" width="185" align="center" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="primary"
|
||||
icon="el-icon-edit"
|
||||
@click="doSelect(scope.row)"
|
||||
>选择</el-button>
|
||||
</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>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import checkPermission from '@/utils/permission'
|
||||
import initData from '@/mixins/crud'
|
||||
export default {
|
||||
components: { },
|
||||
mixins: [initData],
|
||||
props: {
|
||||
value: {
|
||||
type: Object
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
delLoading: false,
|
||||
dialog: 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
|
||||
},
|
||||
deleteGood() {
|
||||
const that = this
|
||||
this.$confirm('是否确认删除?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function() {
|
||||
that.$set(that.value,"productId", null)
|
||||
that.$set(that.value,"storeName", null)
|
||||
that.$set(that.value,"image", null)
|
||||
})
|
||||
},
|
||||
doSelect(data) {
|
||||
this.$set(this.value,"productId", data.id)
|
||||
this.$set(this.value,"storeName", data.storeName)
|
||||
this.$set(this.value,"image", data.image)
|
||||
this.dialog = false
|
||||
},
|
||||
toSelete() {
|
||||
this.dialog = true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.avatar-uploader-icon {
|
||||
font-size: 28px;
|
||||
color: #8c939d;
|
||||
width: 178px;
|
||||
height: 178px;
|
||||
line-height: 178px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
210
src/views/wechat/goods/index.vue
Normal file
210
src/views/wechat/goods/index.vue
Normal file
@ -0,0 +1,210 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<div v-if="crud.props.searchToggle">
|
||||
<!-- 搜索 -->
|
||||
<el-input v-model="query.value" clearable placeholder="输入搜索内容" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.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>
|
||||
<rrOperation :crud="crud" />
|
||||
</div>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission" />
|
||||
<!--表单组件-->
|
||||
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="800px">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="200px">
|
||||
<el-form-item label="选择商品" prop="coverImgeUrl" label-width="80px">
|
||||
<cgood v-model="form.good" ></cgood>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品小程序路径" prop="url" label-width="80px">
|
||||
<el-input v-model="form.url" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<!-- 1:一口价(只需要传入price,price2不传)-->
|
||||
<!-- 2:价格区间(price字段为左边界,price2字段为右边界,price和price2必传)-->
|
||||
<!-- 3:显示折扣价(price字段为原价,price2字段为现价, price和price2必传)-->
|
||||
|
||||
<el-form-item label="商品名称" prop="name" label-width="80px">
|
||||
<el-input v-model="form.name" style="width: 370px;" />
|
||||
</el-form-item>
|
||||
<el-form-item label="价格类型" prop="priceType" label-width="80px">
|
||||
<el-radio-group v-model="form.priceType" >
|
||||
<el-radio :label="1" class="radio">一口价</el-radio>
|
||||
<el-radio :label="2">价格区间</el-radio>
|
||||
<el-radio :label="3">显示折扣价</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-col v-if="form.priceType===1" v-bind="grid">
|
||||
<el-form-item label="一口价" prop="price" label-width="80px">
|
||||
<el-input v-model="form.price" style="width: 200px;" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-if="form.priceType===2" v-bind="grid">
|
||||
<el-form-item label="最低价格" prop="price" label-width="80px">
|
||||
<el-input v-model="form.price" style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-if="form.priceType===2" v-bind="grid">
|
||||
<el-form-item label="最高价格" prop="price2" label-width="80px" >
|
||||
<el-input v-model="form.price2" style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-if="form.priceType===3" v-bind="grid">
|
||||
<el-form-item label="市场价" prop="price" label-width="80px">
|
||||
<el-input v-model="form.price" style="width: 200px;" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-if="form.priceType===3" v-bind="grid">
|
||||
<el-form-item label="现价" prop="price2" label-width="80px">
|
||||
<el-input v-model="form.price2" style="width: 200px;"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="text" @click="crud.cancelCU">取消</el-button>
|
||||
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<!--表格渲染-->
|
||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column v-if="columns.visible('goodsId')" prop="goodsId" label="直播商品id" />
|
||||
<el-table-column v-if="columns.visible('name')" prop="name" label="商品名称" />
|
||||
<el-table-column v-if="columns.visible('productId')" prop="productId" label="关联商品id" />
|
||||
<el-table-column v-if="columns.visible('coverImgUrl')" prop="coverImgUrl" label="商品" />
|
||||
<el-table-column v-if="columns.visible('url')" prop="url" label="商品小程序路径" />
|
||||
<el-table-column v-if="columns.visible('priceType')" prop="priceType" label="价格类型" >
|
||||
<template slot-scope="scope">
|
||||
<div>
|
||||
<el-tag v-if="scope.row.type === 1" :type="''">一口价</el-tag>
|
||||
<el-tag v-else-if="scope.row.type === 2" :type="''">价格区间</el-tag>
|
||||
<el-tag v-else-if="scope.row.type === 3" :type="''">显示折扣价</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="columns.visible('price')" prop="price" label="price" />
|
||||
<el-table-column v-if="columns.visible('price2')" prop="price2" label="price2" />
|
||||
<el-table-column v-if="columns.visible('auditStatus')" prop="auditStatus" label="审核状态" >
|
||||
<template slot-scope="scope">
|
||||
<div>
|
||||
<el-tag v-if="scope.row.auditStatus === 1" :type="''">推流</el-tag>
|
||||
<el-tag v-else :type="''">手机直播</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="columns.visible('thirdPartyTag')" prop="thirdPartyTag" label="1, 2:表示是为api添加商品,否则是直播控制台添加的商品" />
|
||||
<el-table-column v-permission="['admin','yxWechatLiveGoods:edit','yxWechatLiveGoods:del']" label="操作" width="150px" align="center">
|
||||
<template slot-scope="scope">
|
||||
<udOperation
|
||||
:data="scope.row"
|
||||
:permission="permission"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!--分页组件-->
|
||||
<pagination />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import crudYxWechatLiveGoods from '@/api/yxWechatLiveGoods'
|
||||
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import MaterialList from "@/components/material";
|
||||
import cgood from '@/views/components/good'
|
||||
|
||||
// crud交由presenter持有
|
||||
const defaultCrud = CRUD({ title: 'yxWechatLiveGoods', url: 'api/yxWechatLiveGoods', sort: 'goodsId,desc', crudMethod: { ...crudYxWechatLiveGoods }})
|
||||
const defaultForm = { good: {productId: null,storeName: null,image: null}, goodsId: null, productId: null, coverImgeUrl: null, url: null, priceType: null, price: null, price2: null, name: null, thirdPartyTag: null, auditId: null, auditStatus: null }
|
||||
export default {
|
||||
name: 'YxWechatLiveGoods',
|
||||
components: { pagination, crudOperation, rrOperation, udOperation ,MaterialList,cgood},
|
||||
mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
|
||||
data() {
|
||||
return {
|
||||
grid: {
|
||||
xl: 8,
|
||||
lg: 12,
|
||||
md: 12,
|
||||
sm: 24,
|
||||
xs: 24
|
||||
},
|
||||
permission: {
|
||||
add: ['admin', 'yxWechatLiveGoods:add'],
|
||||
edit: ['admin', 'yxWechatLiveGoods:edit'],
|
||||
del: ['admin', 'yxWechatLiveGoods:del']
|
||||
},
|
||||
rules: {
|
||||
// coverImgUrl: [
|
||||
// { required: true, message: '商品图片不能为空', trigger: 'blur' }
|
||||
// ],
|
||||
// url: [
|
||||
// { required: true, message: '商品小程序路径不能为空', trigger: 'blur' }
|
||||
// ],
|
||||
// priceType: [
|
||||
// { required: true, message: '价格类型不能为空', trigger: 'blur' }
|
||||
// ],
|
||||
// price: [
|
||||
// { required: true, message: '不能为空', trigger: 'blur' }
|
||||
// ],
|
||||
// name: [
|
||||
// { required: true, message: '商品名称不能为空', trigger: 'blur' }
|
||||
// ]
|
||||
},
|
||||
queryTypeOptions: [
|
||||
{ key: 'name', display_name: '商品名称' }
|
||||
]
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
methods: {
|
||||
// 获取数据前设置好接口地址
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
const query = this.query
|
||||
if (query.type && query.value) {
|
||||
this.crud.params[query.type] = query.value
|
||||
}else{
|
||||
delete this.crud.params.name
|
||||
}
|
||||
return true
|
||||
}, // 新增与编辑前做的操作
|
||||
[CRUD.HOOK.beforeToCU](crud, form) {
|
||||
this.form.good.productId = form.productId
|
||||
this.form.good.storeName = form.name
|
||||
this.form.good.image = form.coverImgeUrl
|
||||
},
|
||||
[CRUD.HOOK.beforeSubmit]() {
|
||||
console.log(this.form)
|
||||
this.form.productId = this.form.good.productId
|
||||
this.form.name = this.form.good.storeName
|
||||
this.form.coverImgeUrl = this.form.good.image
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.table-img {
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
background: #ccc;
|
||||
color: #fff;
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
vertical-align: middle;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
}
|
||||
</style>
|
@ -3,7 +3,19 @@
|
||||
<!--工具栏-->
|
||||
<div class="head-container">
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation :permission="permission" />
|
||||
<crudOperation :permission="permission">
|
||||
<el-tooltip slot="right" class="item" effect="dark" content="数据库中表字段变动时使用该功能" placement="top-start">
|
||||
<el-button
|
||||
class="filter-item"
|
||||
size="mini"
|
||||
type="success"
|
||||
icon="el-icon-refresh"
|
||||
:loading="syncLoading"
|
||||
:disabled="crud.selections.length === 0"
|
||||
@click="sync"
|
||||
>同步</el-button>
|
||||
</el-tooltip>
|
||||
</crudOperation>
|
||||
<!--表单组件-->
|
||||
<el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="800px">
|
||||
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
|
||||
@ -82,7 +94,20 @@
|
||||
<a :href="scope.row.shareImge" style="color: #42b983" target="_blank"><img :src="scope.row.shareImge" alt="点击打开" class="el-avatar"></a>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="columns.visible('liveStatus')" prop="liveStatus" label="直播间状态" />
|
||||
<!-- 101:直播中,102:未开始,103 已结束,104 禁播,105:暂停,106:异常,107:已过期-->
|
||||
<el-table-column v-if="columns.visible('liveStatus')" prop="liveStatus" label="直播间状态" >
|
||||
<template slot-scope="scope">
|
||||
<div>
|
||||
<el-tag v-if="scope.row.liveStatus === 101" :type="''">直播中</el-tag>
|
||||
<el-tag v-if="scope.row.liveStatus === 102" :type="''">未开始</el-tag>
|
||||
<el-tag v-if="scope.row.liveStatus === 103" :type="''">已结束</el-tag>
|
||||
<el-tag v-if="scope.row.liveStatus === 104" :type="''">禁播</el-tag>
|
||||
<el-tag v-if="scope.row.liveStatus === 105" :type="''">暂停</el-tag>
|
||||
<el-tag v-if="scope.row.liveStatus === 106" :type="''">异常</el-tag>
|
||||
<el-tag v-if="scope.row.liveStatus === 107" :type="''">已过期</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="columns.visible('startTime')" prop="startTime" label="开始时间" />
|
||||
<el-table-column v-if="columns.visible('endTime')" prop="endTime" label="预计结束时间" />
|
||||
<el-table-column v-if="columns.visible('anchorName')" prop="anchorName" label="主播昵称" />
|
||||
@ -96,7 +121,7 @@
|
||||
<template slot-scope="scope">
|
||||
<div>
|
||||
<el-tag v-if="scope.row.type === 1" :type="''">推流</el-tag>
|
||||
<el-tag v-else :type=" 'info' ">手机直播</el-tag>
|
||||
<el-tag v-else :type="''">手机直播</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -104,7 +129,7 @@
|
||||
<template slot-scope="scope">
|
||||
<div>
|
||||
<el-tag v-if="scope.row.screenType === 1" :type="''">横屏</el-tag>
|
||||
<el-tag v-else :type=" 'info' ">竖屏</el-tag>
|
||||
<el-tag v-else :type="''">竖屏</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -112,7 +137,7 @@
|
||||
<template slot-scope="scope">
|
||||
<div>
|
||||
<el-tag v-if="scope.row.closeLike === 1" :type="''">关闭</el-tag>
|
||||
<el-tag v-else :type=" 'info' ">开启</el-tag>
|
||||
<el-tag v-else :type="''">开启</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -120,7 +145,7 @@
|
||||
<template slot-scope="scope">
|
||||
<div>
|
||||
<el-tag v-if="scope.row.closeGoods === 1" :type="''">关闭</el-tag>
|
||||
<el-tag v-else :type=" 'info' ">开启</el-tag>
|
||||
<el-tag v-else :type=" '' ">开启</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -128,7 +153,7 @@
|
||||
<template slot-scope="scope">
|
||||
<div>
|
||||
<el-tag v-if="scope.row.closeComment === 1" :type="''">关闭</el-tag>
|
||||
<el-tag v-else :type=" 'info' ">开启</el-tag>
|
||||
<el-tag v-else :type=" '' ">开启</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -148,6 +173,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { sync } from '@/api/yxWechatLive'
|
||||
import crudYxWechatLive from '@/api/yxWechatLive'
|
||||
import CRUD, { presenter, header, form, crud } from '@crud/crud'
|
||||
import rrOperation from '@crud/RR.operation'
|
||||
@ -165,7 +191,7 @@ export default {
|
||||
mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
|
||||
data() {
|
||||
return {
|
||||
|
||||
syncLoading: false,
|
||||
permission: {
|
||||
add: ['admin', 'yxWechatLive:add'],
|
||||
edit: ['admin', 'yxWechatLive:edit'],
|
||||
@ -210,6 +236,18 @@ export default {
|
||||
watch: {
|
||||
},
|
||||
methods: {
|
||||
sync() {
|
||||
this.crud.selections.forEach(val => {
|
||||
})
|
||||
this.syncLoading = true
|
||||
sync().then(() => {
|
||||
this.crud.refresh()
|
||||
this.crud.notify('同步成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
this.syncLoading = false
|
||||
}).then(() => {
|
||||
this.syncLoading = false
|
||||
})
|
||||
},
|
||||
// 获取数据前设置好接口地址
|
||||
[CRUD.HOOK.beforeRefresh]() {
|
||||
return true
|
||||
|
Reference in New Issue
Block a user