Commit cbb2953c by cwq0219

晒单;去模块

1 parent 7dc45923
import { http } from '@/main'
const defaultPath = 'scrm.api.live.'
const getWarehousListApi = params => {
params.method = `${defaultPath}goods.list`
return http({
url: 'rop-scrm-live/router',
method: 'GET',
data: params,
sign: true
})
}
const auditGoodApi = params => {
params.method = `${defaultPath}audit.goods`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
const getGoodInfoApi = params => {
params.method = `${defaultPath}get.good.by.id`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true
})
}
const getGoodGroupInfoApi = params => {
params.method = `${defaultPath}get.good.group.by.id`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true
})
}
const insertGoodApi = params => {
params.method = `${defaultPath}insert.good`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
const insertGoodGroupApi = params => {
params.method = `${defaultPath}insert.good.group`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
const deleteGoodApi = params => {
params.method = `${defaultPath}delete.goods`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
export { getWarehousListApi, auditGoodApi, getGoodInfoApi, getGoodGroupInfoApi, insertGoodApi, insertGoodGroupApi, deleteGoodApi }
import { http } from '@/main'
const defaultPath = 'scrm.api.live.'
const getLiveRoomListApi = params => {
params.method = `${defaultPath}live.room.list`
return http({
url: 'rop-scrm-live/router',
method: 'GET',
data: params,
sign: true
})
}
const getLiveShareApi = params => {
params.method = `${defaultPath}get.shared.code`
return http({
url: 'rop-scrm-live/router',
method: 'GET',
data: params,
sign: true
})
}
const insertLiveRoomApi = params => {
params.method = `${defaultPath}insert.live.room`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
const deleteLiveRoomApi = params => {
params.method = `${defaultPath}delete.live.room`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
const getLiveRoomInfoApi = params => {
params.method = `${defaultPath}get.live.room.by.id`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true
})
}
const getControlInfoApi = params => {
params.method = `${defaultPath}get.control`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true
})
}
const getControlImportListApi = params => {
params.method = `${defaultPath}get.import.goods`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true
})
}
const getWaitImportListApi = params => {
params.method = `${defaultPath}get.wait.import.goods`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true
})
}
const importGoodsApi = params => {
params.method = `${defaultPath}import.goods`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
const updateCommentApi = params => {
params.method = `${defaultPath}update.comment`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
const updateReplayApi = params => {
params.method = `${defaultPath}update.replay`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
const controlUpOrDownApi = params => {
params.method = `${defaultPath}toggle.status`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
const controlDeleteApi = params => {
params.method = `${defaultPath}delete.room.goods`
return http({
url: 'rop-scrm-live/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
export { getLiveRoomListApi, getLiveShareApi, insertLiveRoomApi, deleteLiveRoomApi, getLiveRoomInfoApi, getControlInfoApi, getControlImportListApi, getWaitImportListApi, importGoodsApi, updateCommentApi, updateReplayApi, controlUpOrDownApi, controlDeleteApi }
......@@ -12,6 +12,16 @@ const getListApi = params => {
})
}
const getShareRecordInfoApi = params => {
params.method = `${defaultPath}orderShareRecord.detail`
return http({
url: 'rop-scrm-shopmall/router',
method: 'GET',
data: params,
sign: true
})
}
const deleteShareRecordApi = params => {
params.method = `${defaultPath}orderShareRecord.remove`
return http({
......@@ -34,4 +44,26 @@ const revokeShareRecordApi = params => {
})
}
export default { getListApi, deleteShareRecordApi, revokeShareRecordApi }
const addShareRecordApi = params => {
params.method = `${defaultPath}orderShareRecord.add`
return http({
url: 'rop-scrm-shopmall/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
const updateShareRecordApi = params => {
params.method = `${defaultPath}orderShareRecord.update`
return http({
url: 'rop-scrm-shopmall/router',
method: 'POST',
data: params,
sign: true,
returnAll: true
})
}
export default { getListApi, getShareRecordInfoApi, deleteShareRecordApi, revokeShareRecordApi, addShareRecordApi, updateShareRecordApi }
......@@ -57,6 +57,10 @@
height: 100px;
}
.marketing .m-t-10 {
margin-top: 10px;
}
.marketing .footer {
position: fixed;
bottom: 0;
......
<!-- 商品库 -->
<template>
<div class="live-room">
<div class="container">
<el-tabs v-model="activeName" type="card" @tab-click="handleTabClick">
<el-tab-pane label="未入库" name="noWarehous">
<warehous-list></warehous-list>
</el-tab-pane>
<el-tab-pane label="已入库" name="warehousing">
<warehousing-list></warehousing-list>
</el-tab-pane>
</el-tabs>
</div>
</div>
</template>
<script>
import warehousingList from './warehousingList'
import warehousList from './warehousList'
export default {
name: 'commodityList',
data() {
return {
activeName: 'noWarehous'
}
},
components: {
warehousingList,
warehousList
},
computed: {},
mounted() {},
methods: {
handleTabClick() {}
}
}
</script>
<style scoped></style>
<!-- 添加商品 -->
<template>
<div class="edit-pro live-room">
<div class="container edit-container">
<p class="edit-title">{{ title }}</p>
<glsx-combi-form ref="editFormRef" labelWidth="140px" :isBlock="isBlock" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule">
<div slot="selectSinglePro" slot-scope="item" class="select-pro">
<el-button v-show="routeInfo.addOrEdit != 3" type="text" @click="handleSinglePro(item)">{{ selectedProInfo.id ? '更换' : '请选择' }}</el-button>
</div>
<div slot="proTable" class="select-pro">
<GLTable v-show="selectedProInfoList.length" ref="warehousListRef" :hasPage="hasPage" :searchForm="searchForm" :tableParams="tableParams" :tableData="selectedProInfoList">
<span slot="goodsImage" slot-scope="scope">
<img class="m-t-10 img-60" :src="scope.scope.goodsImage" />
</span>
<span slot="price">
<el-input :disabled="routeInfo.addOrEdit == 3" placeholder="请输入" v-model="editForm.price"><template slot="append">元</template></el-input>
</span>
<span slot="auth-button">
<el-button type="text" @click="handleProDelete()">删除</el-button>
</span>
</GLTable>
</div>
</glsx-combi-form>
<p>直播价表示直播开始时,用户购买的实际支付价格,直播结束时恢复原价</p>
<select-single-pro-dialog v-if="isSingleSelectVisible" :isSingleSelectVisible="isSingleSelectVisible" :selectedProInfo="selectedProInfo" @handleSingleSelectConfirm="handleSingleSelectConfirm" @handleSingleSelectClose="handleSingleSelectClose"></select-single-pro-dialog>
</div>
<div class="footer">
<el-button v-show="routeInfo.addOrEdit != 3" type="primary" @click="handleConfirm">确定</el-button>
<el-button type="default" @click="handleCancel">取消</el-button>
</div>
</div>
</template>
<script>
import _ from 'lodash'
import glsxCombiForm from '@/components/glsx-combi-form'
import selectSingleProDialog from './selectSingleProDialog'
import { uploadImg } from '@/api/modules/common'
import { getGoodInfoApi, insertGoodApi } from '@/api/modules/cmmodityLibrary'
export default {
name: 'editProduct',
data() {
return {
title: '添加商品',
titleObj: {
1: '新增商品',
2: '编辑商品',
3: '查看商品'
},
isBlock: true,
editChildRef: 'editChildRef',
routeInfo: {
// 1-新增;2-编辑;3-查看
addOrEdit: 1,
id: ''
},
editForm: {
name: '',
price: '',
coverImgUrl: ''
},
selectedProInfoList: [],
editRule: {
coverImgUrl: [{ required: true, message: '请上传商品缩略图', trigger: 'change' }],
name: [{ required: true, message: '请输入商品名称', trigger: 'change' }]
// price: [{ required: true, message: '请输入直播价', trigger: 'change' }]
},
// 商品选择
isSingleSelectVisible: false,
selectedProInfo: {},
editFormData: [
{
label: '商品缩略图',
name: 'coverImgUrl',
type: 'upload',
// limitSize: 1,
isDisabled: false,
maxPhotoNum: 1,
tips: '建议尺寸:300像素 * 300像素,图片大小不得超过1M',
handleUpload: (e, file, targetItem) => {
const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
uploadImg({ file: base64, fileType: 'image' }).then(res => {
this.editForm[targetItem.name] = res
this.$refs.editFormRef.$refs[this.editChildRef].validateField(targetItem.name)
})
}
},
{
label: '商品名称',
name: 'name',
width: '480px',
type: 'input',
isDisabled: false,
maxlength: 20
},
{
label: '商品选择',
name: '',
addHtml: 'selectSinglePro'
},
{
// label: '商品选择',
name: '',
addHtml: 'proTable'
}
// {
// label: '设置直播价',
// name: 'price',
// width: '480px',
// type: 'input',
// tips: '直播价表示直播开始时,用户购买的实际支付价格,直播结束时恢复原价'
// }
],
// 表格
hasPage: false,
tableParams: {
tableOption: true,
tableColumns: [
{
label: '商品图片',
prop: 'goodsImage',
addHtml: 'goodsImage'
},
{
label: '商品名称',
prop: 'goodsName'
},
{
label: '商品价格',
prop: 'retailPrice'
},
{
label: '设置直播价格(元)',
prop: '',
width: '180px',
addHtml: 'price'
},
{
label: '来源门店',
prop: 'merchantName'
}
]
}
}
},
components: {
glsxCombiForm,
selectSingleProDialog
},
computed: {},
mounted() {
this.routeInfo = this.$route.params
this.title = this.titleObj[this.routeInfo.addOrEdit]
this.routeInfo.addOrEdit != 1 ? this.getInfo() : ''
this.editFormData[0].isDisabled = this.routeInfo.addOrEdit == 3
this.editFormData[1].isDisabled = this.routeInfo.addOrEdit == 3
this.tableParams.tableOption = this.routeInfo.addOrEdit != 3
},
methods: {
getInfo() {
getGoodInfoApi({ id: this.routeInfo.id }).then(res => {
console.log(res)
this.editForm = res
this.editForm.price = res.price ? (res.price / 100).toFixed(2) : ''
if (res.goodsInfo) {
this.selectedProInfo = {
id: res.goodsInfo.goodsId,
retailPrice: res.goodsInfo.price2 && res.goodsInfo.price1 != res.goodsInfo.price2 ? (res.goodsInfo.price1 / 100).toFixed(2) + '-' + (res.goodsInfo.price2 / 100).toFixed(2) : (res.goodsInfo.price1 / 100).toFixed(2),
goodsName: res.goodsInfo.name,
merchantId: res.goodsInfo.merchantId,
merchantName: res.goodsInfo.merchantName,
goodsImage: res.goodsInfo.selfGoodsImageUrl
}
this.selectedProInfoList = [this.selectedProInfo]
}
})
},
handleProDelete() {
this.$messageBox.confirm('是否删除该商品?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
callback: action => {
if (action == 'confirm') {
this.selectedProInfo = {}
this.selectedProInfoList = []
}
}
})
},
handleSinglePro(targetItem) {
this.isSingleSelectVisible = !this.isSingleSelectVisible
},
handleSingleSelectConfirm(selectedProInfo) {
this.selectedProInfo = selectedProInfo
this.selectedProInfoList = [selectedProInfo]
this.handleSinglePro()
},
handleSingleSelectClose() {
this.handleSinglePro()
},
handleConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
var params = JSON.parse(JSON.stringify(this.editForm))
params.price = this.editForm.price * 100
params.shopMallGoodsInfo = {
goodsId: this.selectedProInfo.id,
// name: this.selectedProInfo.goodsName,
merchantId: this.selectedProInfo.merchantId,
merchantName: this.selectedProInfo.merchantName
// selfGoodsImageUrl: this.selectedProInfo.goodsImage
}
insertGoodApi(params).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : '操作失败',
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.$router.push({
path: '/cmmodityLibrary/commodityList'
})
}
})
}
})
},
handleCancel() {
this.$router.push({
path: '/cmmodityLibrary/commodityList'
})
}
}
}
</script>
<style>
.edit-pro .select-pro {
/* width: calc(98% - 140px); */
width: 98%;
}
.edit-pro .m-t-10 {
margin-top: 10px;
}
</style>
<!-- 添加商品组 -->
<template>
<div class="edit-pro-group live-room">
<div class="container edit-container">
<p class="edit-title">{{ title }}</p>
<glsx-combi-form ref="editFormRef" labelWidth="150px" :isBlock="isBlock" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule">
<div slot="selectMutiPro" slot-scope="item" class="select-pro">
<el-button v-show="routeInfo.addOrEdit != 3" type="text" @click="handleMutiPro(item)">{{ editForm.shopMallGoodsInfoList.length ? '更换' : '请选择' }}</el-button>
</div>
<div slot="proTable" class="select-pro">
<GLTable v-show="editForm.shopMallGoodsInfoList.length" ref="warehousListRef" :hasPage="hasPage" :searchForm="searchForm" :tableParams="tableParams" :tableData="editForm.shopMallGoodsInfoList">
<span slot="goodsImage" slot-scope="scope">
<img class="m-t-10 img-60" :src="scope.scope.goodsImage" />
</span>
<span slot="price" slot-scope="scope">
<el-input :disabled="routeInfo.addOrEdit == 3" placeholder="请输入" v-model="scope.scope.livePrice"><template slot="append">元</template></el-input>
</span>
<span slot="auth-button" slot-scope="scope">
<el-button type="text" @click="handleProDelete(scope.scope)">删除</el-button>
</span>
</GLTable>
</div>
</glsx-combi-form>
<select-muti-pro-dialog v-if="isMutiSelectVisible" :isMutiSelectVisible="isMutiSelectVisible" :selectedProList="editForm.shopMallGoodsInfoList" @handleMutiSelectConfirm="handleMutiSelectConfirm" @handleMutiSelectClose="handleMutiSelectClose"></select-muti-pro-dialog>
</div>
<div class="footer">
<el-button v-show="routeInfo.addOrEdit != 3" type="primary" @click="handleConfirm">确定</el-button>
<el-button type="default" @click="handleCancel">取消</el-button>
</div>
</div>
</template>
<script>
import _ from 'lodash'
import '@/assets/css/public.scss'
import glsxCombiForm from '@/components/glsx-combi-form'
import { uploadImg } from '@/api/modules/common'
import { getGoodInfoApi, getGoodGroupInfoApi, insertGoodGroupApi } from '@/api/modules/cmmodityLibrary'
import selectMutiProDialog from './selectMutiProDialog'
export default {
name: 'editProductGroup',
data() {
return {
title: '添加商品组',
titleObj: {
1: '新增商品组',
2: '编辑商品组',
3: '查看商品组'
},
isBlock: true,
editChildRef: 'editChildRef',
routeInfo: {
// 1-新增;2-编辑
addOrEdit: 1,
id: ''
},
editForm: {
coverImgUrl: '',
shopMallGoodsInfoList: []
},
editRule: {
coverImgUrl: [{ required: true, message: '请上传商品缩略图', trigger: 'change' }],
name: [{ required: true, message: '请输入商品名称', trigger: 'change' }]
},
// 商品选择
isMutiSelectVisible: false,
editFormData: [
{
label: '商品组缩略图',
name: 'coverImgUrl',
type: 'upload',
isDisabled: false,
maxPhotoNum: 1,
tips: '建议尺寸:300像素 * 300像素,图片大小不得超过1M',
handleUpload: (e, file, targetItem) => {
const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
uploadImg({ file: base64, fileType: 'image' }).then(res => {
this.editForm[targetItem.name] = res
this.$refs.editFormRef.$refs[this.editChildRef].validateField(targetItem.name)
})
}
},
{
label: '商品组名称',
name: 'name',
width: '480px',
type: 'input',
isDisabled: false,
maxlength: 20
},
{
label: '商品选择',
name: '',
addHtml: 'selectMutiPro'
},
{
name: '',
addHtml: 'proTable'
}
],
// 表格
hasPage: false,
tableParams: {
tableOption: true,
tableColumns: [
{
label: '商品图片',
prop: 'goodsImage',
addHtml: 'goodsImage'
},
{
label: '商品名称',
prop: 'goodsName'
},
{
label: '商品价格',
prop: 'retailPrice'
},
{
label: '设置直播价格(元)',
prop: '',
width: '180px',
addHtml: 'price'
},
{
label: '来源门店',
prop: 'merchantName'
}
]
}
}
},
components: {
glsxCombiForm,
selectMutiProDialog
},
computed: {},
mounted() {
this.routeInfo = this.$route.params
this.title = this.titleObj[this.routeInfo.addOrEdit]
this.routeInfo.addOrEdit != 1 ? this.getInfo() : ''
this.editFormData[0].isDisabled = this.routeInfo.addOrEdit == 3
this.editFormData[1].isDisabled = this.routeInfo.addOrEdit == 3
this.tableParams.tableOption = this.routeInfo.addOrEdit != 3
},
methods: {
getInfo() {
getGoodGroupInfoApi({ id: this.routeInfo.id }).then(res => {
console.log(res)
this.editForm = res
this.editForm.shopMallGoodsInfoList = []
if (res.goodsInfoList.length) {
res.goodsInfoList.forEach(item => {
this.editForm.shopMallGoodsInfoList.push({
id: item.goodsId,
retailPrice: item.price2 && item.price1 != item.price2 ? (item.price1 / 100).toFixed(2) + '-' + (item.price2 / 100).toFixed(2) : (item.price1 / 100).toFixed(2),
livePrice: (item.livePrice / 100).toFixed(2),
goodsName: item.name,
merchantId: item.merchantId,
merchantName: item.merchantName,
goodsImage: item.selfGoodsImageUrl
})
})
}
delete this.editForm.goodsInfoList
})
},
handleMutiPro(targetItem) {
this.isMutiSelectVisible = !this.isMutiSelectVisible
},
handleProDelete(obj) {
this.$messageBox.confirm('是否删除该商品?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
callback: action => {
if (action == 'confirm') {
var idx = this.editForm.shopMallGoodsInfoList.findIndex(item => item.id == obj.id)
this.editForm.shopMallGoodsInfoList.splice(idx, 1)
}
}
})
},
handleMutiSelectConfirm(selectedProInfo) {
console.log(selectedProInfo)
var idExitList = this.editForm.shopMallGoodsInfoList.map(item => item.id)
var tempList = []
selectedProInfo.forEach(item => {
if (idExitList.includes(item.id)) {
tempList.push(this.editForm.shopMallGoodsInfoList.find(k => k.id == item.id))
} else {
tempList.push({
...item,
livePrice: ''
})
}
})
this.editForm.shopMallGoodsInfoList = tempList
this.handleMutiPro()
},
handleMutiSelectClose() {
this.handleMutiPro()
},
handleConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
var params = JSON.parse(JSON.stringify(this.editForm))
params.shopMallGoodsInfoList = []
this.editForm.shopMallGoodsInfoList.forEach(item => {
params.shopMallGoodsInfoList.push({
goodsId: item.id,
merchantId: item.merchantId,
merchantName: item.merchantName,
livePrice: (item.livePrice * 100).toFixed(0)
})
})
console.log(params)
insertGoodGroupApi(params).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : '操作失败',
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.$router.push({
path: '/cmmodityLibrary/commodityList'
})
}
})
}
})
},
handleCancel() {
this.$router.push({
path: '/cmmodityLibrary/commodityList'
})
}
}
}
</script>
<style>
.edit-pro-group .select-pro {
width: 98%;
}
.edit-pro-group .m-t-10 {
margin-top: 10px;
}
.edit-pro-group .border-red {
border: 1px solid red;
}
</style>
<!-- 选择商品弹窗 -->
<template>
<glsx-dialog class="muti-pro" title="选择商品" :isVisible.sync="isMutiSelectVisible" width="70%" @confirmDialog="handleMutiSelectConfirm" @closeDialog="handleMutiSelectClose">
<GLTable ref="mutiProRef" :tableData="productList" :tableParams="tableParams" @refreshTable="getList">
<span slot="goodsImage" slot-scope="scope">
<img class="m-t-10 img-60" :src="scope.scope.goodsImage" />
</span>
</GLTable>
</glsx-dialog>
</template>
<script>
import { getGoodsList } from '@/api/modules/common'
import glsxDialog from '@/components/glsx-dialog'
export default {
name: 'selectMutiProDialog',
data() {
return {
// 表格组件
getListApi: getGoodsList,
productList: [],
// pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
// 表格参数
tableParams: {
listName: 'list',
// 行数据的key
mutiSelectUniqueKey: 'id',
// 多选ref的名称
mutiSelectName: 'list',
tableColumns: [
{
label: '商品名称',
prop: 'goodsName'
},
{
label: '缩略图',
prop: 'goodsImage',
addHtml: 'goodsImage'
},
{
label: '价格(元)',
prop: 'retailPrice'
},
{
label: '来源门店',
prop: 'merchantName'
}
]
}
}
},
props: {
isMutiSelectVisible: {
type: Boolean,
default: false
},
selectedProList: {
type: Array,
default: () => []
}
},
components: {
glsxDialog
},
mounted() {
this.getList(true)
},
methods: {
getList(isMounted = false) {
var params = {
goodsStatus: 1,
goodsSource: 1,
pageNum: isMounted ? 1 : this.$refs.mutiProRef.page.pageNum,
pageSize: isMounted ? 10 : this.$refs.mutiProRef.page.pageSize
}
var that = this
getGoodsList(params).then(res => {
// console.log(res)
this.productList = res.list
this.$refs.mutiProRef.tableTotal = res.total
this.productList.forEach(function(item) {
item.saleAmount = item.goodsStatistics.saleAmount
if (item.specificationDetailList.length > 1) {
let retailPriceList = item.specificationDetailList.sort(function(a, b) {
return a.retailPrice - b.retailPrice
})
let stockeList = item.specificationDetailList.sort(function(a, b) {
return a.stock - b.stock
})
let minRatilPrice = retailPriceList[0].retailPrice / 100
let maxRatilPrice = retailPriceList[retailPriceList.length - 1].retailPrice / 100
let minStock = stockeList[0].stock
let maxStock = stockeList[stockeList.length - 1].stock
item.retailPrice = minRatilPrice == maxRatilPrice ? minRatilPrice.toFixed(2) : minRatilPrice.toFixed(2) + '-' + maxRatilPrice.toFixed(2)
item.minRatilPrice = minRatilPrice.toFixed(2)
item.goodsStock = minStock == maxStock ? minStock : minStock + '-' + maxStock
} else if (item.specificationDetailList.length == 1) {
item.retailPrice = (item.specificationDetailList[0].retailPrice / 100).toFixed(2)
item.minRatilPrice = item.retailPrice
item.goodsStock = item.specificationDetailList[0].stock
} else {
item.retailPrice = (item.retailPrice / 100).toFixed(2)
item.minRatilPrice = item.retailPrice
}
})
this.recoverySelected()
})
},
recoverySelected() {
if (this.selectedProList.length) {
this.selectedProList.forEach(row => {
this.$refs.mutiProRef.$refs[this.tableParams.mutiSelectName + 'MutiTable'].toggleRowSelection(row)
})
}
},
handleMutiSelectConfirm() {
var selectedData = this.$refs.mutiProRef.mutiSelectArr[this.tableParams.mutiSelectName]
console.log(selectedData)
this.$emit('handleMutiSelectConfirm', selectedData)
},
handleMutiSelectClose() {
this.$emit('handleMutiSelectClose')
}
}
}
</script>
<style>
.muti-pro .m-t-10 {
margin-top: 10px;
}
</style>
<!-- 选择商品 - 单选 -->
<template>
<glsx-dialog class="single-pro" title="选择商品" :isVisible.sync="isSingleSelectVisible" width="900px" @confirmDialog="handleSingleSelectConfirm" @closeDialog="handleSingleSelectClose">
<el-radio-group v-model="infoId">
<el-radio class="pro-box" v-for="item in productList" :key="item.id" :label="item.id">
<img :src="item.goodsImage" />
<div class="txt-box">
<p :title="item.goodsName" class="ellipsis">{{ item.goodsName }}</p>
<p class="f-s-12">销量:{{ item.saleAmount }}</p>
<p class="f-s-12">库存:{{ item.goodsStock }}</p>
<p class="f-s-12">零售价:{{ item.retailPrice }}</p>
<p :title="item.merchantName" class="ellipsis f-s-12">门店名称:{{ item.merchantName }}</p>
</div>
</el-radio>
</el-radio-group>
</glsx-dialog>
</template>
<script>
import { getGoodsList } from '@/api/modules/common'
import glsxDialog from '@/components/glsx-dialog'
export default {
name: 'selectSingleProDialog',
data() {
return {
infoId: '',
minRatilPrice: '',
productList: []
}
},
props: {
isSingleSelectVisible: {
type: Boolean,
default: false
},
selectedProInfo: {
type: Object,
default: () => {}
}
},
components: {
glsxDialog
},
computed: {},
mounted() {
this.infoId = this.selectedProInfo.id
this.getList()
},
methods: {
getList() {
var params = {
goodsStatus: 1,
goodsSource: 1,
pageNum: 1,
pageSize: 100000
}
var that = this
getGoodsList(params).then(res => {
// console.log(res)
this.productList = res.list
this.productList.forEach(function(item) {
item.saleAmount = item.goodsStatistics.saleAmount
if (item.specificationDetailList.length > 1) {
let retailPriceList = item.specificationDetailList.sort(function(a, b) {
return a.retailPrice - b.retailPrice
})
let stockeList = item.specificationDetailList.sort(function(a, b) {
return a.stock - b.stock
})
let minRatilPrice = retailPriceList[0].retailPrice / 100
let maxRatilPrice = retailPriceList[retailPriceList.length - 1].retailPrice / 100
let minStock = stockeList[0].stock
let maxStock = stockeList[stockeList.length - 1].stock
item.retailPrice = minRatilPrice == maxRatilPrice ? minRatilPrice.toFixed(2) : minRatilPrice.toFixed(2) + '-' + maxRatilPrice.toFixed(2)
item.minRatilPrice = minRatilPrice.toFixed(2)
item.goodsStock = minStock == maxStock ? minStock : minStock + '-' + maxStock
} else if (item.specificationDetailList.length == 1) {
item.retailPrice = (item.specificationDetailList[0].retailPrice / 100).toFixed(2)
item.minRatilPrice = item.retailPrice
item.goodsStock = item.specificationDetailList[0].stock
} else {
item.retailPrice = (item.retailPrice / 100).toFixed(2)
item.minRatilPrice = item.retailPrice
}
})
})
},
handleSingleSelectConfirm() {
if (!this.infoId) {
this.$message.error('请选择商品')
return true
}
var selectInfo = this.productList.find(item => item.id === this.infoId)
this.$emit('handleSingleSelectConfirm', selectInfo)
},
handleSingleSelectClose() {
this.$emit('handleSingleSelectClose')
}
}
}
</script>
<style>
.single-pro .pro-box {
width: 202px;
border: 1px solid #cccccc;
margin: 0 10px 10px 0;
}
.single-pro p {
margin: 0 0 8px 0;
}
.single-pro .f-s-12 {
font-size: 12px;
}
.single-pro .pro-box img {
width: 202px;
height: 202px;
}
.single-pro .el-radio__input {
position: absolute;
top: 8px;
left: 8px;
}
.single-pro .el-radio__label {
padding: 0;
}
.single-pro .txt-box {
padding: 10px 10px 0;
color: #666666;
}
.single-pro .ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
<!-- 未入库 -->
<template>
<div class="warehous-list">
<div class="flex">
<el-form>
<el-form-item>
<el-button :size="size" type="primary" class="el-icon-plus" @click="handleEdit(1)">添加商品</el-button>
<el-button :size="size" type="primary" class="el-icon-plus" @click="handleEditGroup(1)">添加商品组</el-button>
</el-form-item>
</el-form>
<el-form :inline="true" :model="searchForm">
<el-form-item label="商品搜索:">
<el-input :size="size" v-model="searchForm.name" placeholder="请输入商品名称" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button :size="size" type="primary" @click="handleSearch">查询</el-button>
<el-button :size="size" @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
</div>
<GLTable ref="warehousListRef" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
<span slot="coverImgUrl" slot-scope="scope">
<img class="img-60" :src="scope.scope.coverImgUrl" />
</span>
<span class="table-btns" slot="auth-button" slot-scope="scope" :data="scope.scope">
<span v-show="scope.scope.auditStatus != 1" >
<el-button type="text" @click="handleExamine(scope.scope)">提交审核</el-button>
<el-button type="text" @click="scope.scope.goodsGroupFlag == 'N' ? handleEdit(2, scope.scope) : handleEditGroup(2, scope.scope)">编辑</el-button>
<el-button type="text" @click="handleDelete(scope.scope)">删除</el-button>
</span>
<el-button v-show="scope.scope.auditStatus == 1" type="text" @click="scope.scope.goodsGroupFlag == 'N' ? handleEdit(3, scope.scope) : handleEditGroup(3, scope.scope)">查看</el-button>
</span>
</GLTable>
</div>
</template>
<script>
import { getWarehousListApi, auditGoodApi, deleteGoodApi } from '@/api/modules/cmmodityLibrary'
import { auditStatusList } from '@/common/constant'
export default {
name: 'warehousList',
data() {
return {
size: 'small',
searchForm: {
name: '',
status: '-1'
},
// 表格组件
getListApi: getWarehousListApi,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
// 表格参数
tableParams: {
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '商品标题',
prop: 'name',
line: 2
},
{
label: '直播间图片',
prop: 'coverImgUrl',
addHtml: 'coverImgUrl'
},
{
label: '价格(元)',
prop: 'price',
line: 1,
formatter: cellValue => {
return cellValue.price2 && cellValue.price1 != cellValue.price2 ? (cellValue.price1 / 100).toFixed(2) + '-' + (cellValue.price2 / 100).toFixed(2) : (cellValue.price1 / 100).toFixed(2)
}
},
{
label: '审核状态',
prop: 'auditStatus',
width: '80',
formatter: cellValue => {
return this.baseDataList.auditStatusList.find(item => item.confId == cellValue.auditStatus).confName
}
},
{
label: '来源门店',
prop: 'merchantName',
line: 2
}
]
},
baseDataList: {
auditStatusList: auditStatusList
}
}
},
components: {},
computed: {},
mounted() {},
methods: {
beforeSearchFn() {
return new Promise(resolve => {
resolve()
})
},
// 1-新增;2-编辑;3-查看
handleEdit(addOrEdit, row) {
this.$router.push({
// name: 'editProduct',
// path: '/cmmodityLibrary/editProduct',
name: 'ServicesCmmodityLibraryEditProduct',
params: {
addOrEdit: addOrEdit,
id: row ? row.id : -1
}
})
},
// 1-新增;2-编辑;3-查看;4-修改价格
handleEditGroup(addOrEdit, row) {
this.$router.push({
// name: 'editProductGroup',
// path: '/cmmodityLibrary/editProductGroup',
name: 'ServicesCmmodityLibraryEditProductGroup',
params: {
addOrEdit: addOrEdit,
id: row ? row.id : -1
}
})
},
handleExamine(row) {
this.$messageBox.confirm('审核大概需要1-7天', '提交审核', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
auditGoodApi({ id: row.id }).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleSearch()
}
})
}
}
})
},
handleDelete(row) {
this.$messageBox.confirm('是否删除该商品?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
callback: action => {
if (action == 'confirm') {
deleteGoodApi({ id: row.id }).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleSearch()
}
})
}
}
})
},
handleReset() {
this.searchForm = {
name: '',
status: '-1'
}
this.handleSearch()
},
handleSearch() {
this.$refs.warehousListRef.refreshTable()
}
}
}
</script>
<style scoped></style>
<template>
<div>
<div class="flex">
<el-form :inline="true" :model="searchForm">
<el-form-item label="商品搜索:">
<el-input :size="size" v-model="searchForm.name" placeholder="请输入商品名称" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button :size="size" type="primary" @click="handleSearch">查询</el-button>
<el-button :size="size" @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
</div>
<!-- 表格区域 开始 -->
<GLTable ref="wareRef" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi" :pageConf="pageConf">
<span slot="coverImgUrl" slot-scope="scope">
<img class="img-60" :src="scope.scope.coverImgUrl" />
</span>
<span class="table-btns" slot="auth-button" slot-scope="scope" :data="scope.scope">
<el-button type="text" @click="handleEdit(scope.scope)">修改价格</el-button>
<el-button type="text" @click="handleDelete(scope.scope)">删除</el-button>
</span>
</GLTable>
<!-- 表格区域 end -->
<!-- 修改价格弹框 开始 -->
<!-- <glsx-dialog title="修改价格" width="620px" :isVisible="showPriceDialog" @closeDialog="closePriceDialog" @confirmDialog="closePriceDialog">
<el-form ref="priceForm" :rules="formRules" :model="form" label-width="120px">
<el-form-item label="商品价格:" prop="price">
<el-input v-model="form.price" maxlength="8" style="width:400px" />
</el-form-item>
</el-form>
<div slot="footer">
<el-button type="primary" @click="resetPrice()">提交</el-button>
<el-button @click="showPriceDialog = false">取消</el-button>
</div>
</glsx-dialog> -->
<!-- 修改价格弹框 end -->
</div>
</template>
<script>
import { getWarehousListApi, deleteGoodApi } from '@/api/modules/cmmodityLibrary'
// import glsxDialog from '@/components/glsx-dialog'
export default {
// components: {
// glsxDialog
// },
data() {
return {
size: 'small',
searchForm: {
name: '',
status: '2'
},
// 表格组件
getListApi: getWarehousListApi,
tableParams: {
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '商品标题',
prop: 'name',
line: 2
},
{
label: '直播间图片',
prop: 'coverImgUrl',
addHtml: 'coverImgUrl'
},
{
label: '价格(元)',
prop: 'price',
line: 1,
formatter: cellValue => {
return cellValue.price2 && cellValue.price1 != cellValue.price2 ? (cellValue.price1 / 100).toFixed(2) + '-' + (cellValue.price2 / 100).toFixed(2) : (cellValue.price1 / 100).toFixed(2)
}
},
{
label: '来源门店',
prop: 'merchantName',
line: 2
}
]
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
// tableData: [
// {
// id: 1,
// pic: 'https://t7.baidu.com/it/u=4162611394,4275913936&fm=193&f=GIF',
// title: '商品标题',
// price: 999,
// merchant: 'xxx'
// }
// ],
// pageTotal: 0,
// userInfo: {},
// currentPage: 1,
// pageSizes: [10, 20, 30, 40],
// pageSize: 10,
// tdWidth: 170,
// DATEFORMATE: (str, type) => {
// return this.$Util.dateFormate(str, type)
// }
// showPriceDialog: false,
// form: {},
// formRules: {
// price: [{ required: true, message: '请输入价格', trigger: 'blur' }]
// }
}
},
created() {},
mounted: function() {},
methods: {
handleReset() {
this.searchForm = {
name: '',
status: '2'
}
this.handleSearch()
},
handleSearch() {
this.$refs.wareRef.refreshTable()
},
handleDelete(row) {
this.$messageBox.confirm('是否删除该商品?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
callback: action => {
if (action == 'confirm') {
deleteGoodApi({ id: row.id }).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleSearch()
}
})
}
}
})
},
// 1-新增;2-编辑;3-查看;4-修改价格
handleEdit: function(row) {
// this.showPriceDialog = true
this.$router.push({
// name: 'editProductGroup',
// path: '/cmmodityLibrary/editProductGroup',
name: 'ServicesCmmodityLibraryEditProductGroup',
params: {
addOrEdit: 4,
id: row ? row.id : -1
}
})
},
// closePriceDialog: function() {
// this.showPriceDialog = false
// }
}
}
</script>
<style lang="scss">
.table_box {
margin: 20px 0;
}
</style>
<!-- 编辑直播间 -->
<template>
<div class="live-room">
<div class="container edit-container">
<p class="edit-title">{{ title }}</p>
<!-- <p class="edit-sub-title" style="margin-top: 10px;">关联门店信息</p> -->
<glsx-combi-form ref="editFormRef" labelWidth="160px" :isBlock="isBlock" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule">
<div slot="merchantList">
<el-button type="primary" size="mini" class="el-icon-plus" @click="handleRelateStoreClose">直播间配置</el-button>
</div>
<div slot="storeTable" class="select-store">
<GLTable v-show="storeSelectedList.length" ref="warehousListRef" :hasPage="hasPage" :tableParams="tableParams" :tableData="storeSelectedList">
<span slot="auth-button" slot-scope="item">
<el-button type="text" @click="handleProDelete(item)">删除</el-button>
</span>
</GLTable>
</div>
</glsx-combi-form>
<relate-store-dialog v-if="relateStoreVisible" ref="relateStore" :relateStoreVisible="relateStoreVisible" :storeApi="storeApi" :storeSearchForm="storeSearchForm" :storeSelected="storeSelectedList" @handleRelateStoreConfirm="handleRelateStoreConfirm" @handleRelateStoreClose="handleRelateStoreClose">
<!-- <el-row>
<el-form
:model="storeSearchForm"
:rules="rules"
ref="relate"
:inline="true"
>
<el-form-item label="园区店:">
<el-input
v-model.trim="storeSearchForm.yqMerchantName"
placeholder="园区店名称"
@keydown.native="handleStoreInput"
clearable
></el-input>
</el-form-item>
<el-form-item label="4S店:">
<el-input
v-model.trim="storeSearchForm.merchantName"
placeholder="4S店名称"
@keydown.native="handleStoreInput"
clearable
></el-input>
</el-form-item>
<el-button
type="primary"
@click="handleSearchStore"
>搜索</el-button>
</el-form>
</el-row> -->
</relate-store-dialog>
</div>
<div class="footer">
<el-button type="primary" @click="handleConfirm">确定</el-button>
<el-button type="default" @click="handleCancel">取消</el-button>
</div>
</div>
</template>
<script>
// import '@/assets/css/public.scss'
import _ from 'lodash'
import { uploadImg, getMerchantList, getZoneListApi } from '@/api/modules/common'
import { insertLiveRoomApi, getLiveRoomInfoApi } from '@/api/modules/liveRoom'
import glsxCombiForm from '@/components/glsx-combi-form'
// import glsxDialog from '@/components/glsx-dialog'
import relateStoreDialog from './relateStoreDialog'
export default {
name: 'editLiveRoom',
data() {
return {
title: '新建直播间',
titleObj: {
1: '新建直播间',
2: '编辑直播间',
3: '查看直播间'
},
editChildRef: 'editChildRef',
routeInfo: {
// 1-新增;2-编辑;3-查看
addOrEdit: 1,
id: ''
},
editForm: {
name: '',
openTime: '',
anchorName: '',
anchorWechat: '',
subAnchorWechat: '',
shareImgUrl: '',
feedsImgUrl: '',
coverImgUrl: ''
},
editRule: {
name: [{ required: true, message: '请输入直播间标题', trigger: 'change' }],
openTime: [{ required: true, message: '请选择开播时间', trigger: 'blur' }],
anchorName: [{ required: true, message: '请输入主播昵称', trigger: 'change' }],
anchorWechat: [{ required: true, message: '请输入主播微信账号', trigger: 'change' }],
shareImgUrl: [{ required: true, message: '请上传分享卡片样式配置', trigger: 'change' }],
feedsImgUrl: [{ required: true, message: '请上传官方收录样式', trigger: 'change' }],
coverImgUrl: [{ required: true, message: '请上传主播间背景墙', trigger: 'change' }],
zoneId: [{ required: true, message: '请选择发现频道', trigger: 'blur' }]
},
isBlock: true,
editFormData: [
{
label: '直播间标题',
name: 'name',
width: '480px',
type: 'input',
maxlength: 20
},
{
label: '开播时间',
name: 'openTime',
type: 'datePicker',
dateType: 'datetimerange',
isClear: true,
pickerOptions: 'afterRangePickerOptions'
},
{
label: '主播昵称',
name: 'anchorName',
width: '480px',
type: 'input',
maxlength: 30
},
{
label: '主播微信账号',
name: 'anchorWechat',
width: '480px',
type: 'input',
maxlength: 64
},
{
label: '主播副号',
name: 'subAnchorWechat',
width: '480px',
type: 'input',
maxlength: 64
},
{
label: '分享卡片样式配置',
name: 'shareImgUrl',
type: 'upload',
maxPhotoNum: 1,
wdithLt: 800,
heightLt: 640,
handleUpload: (e, file, targetItem) => {
const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
uploadImg({ file: base64, fileType: 'image' }).then(res => {
this.editForm[targetItem.name] = res
this.$refs.editFormRef.$refs[this.editChildRef].validateField(targetItem.name)
})
}
},
{
label: '官方收录样式',
name: 'feedsImgUrl',
type: 'upload',
limitSize: 0.09,
maxPhotoNum: 1,
wdithLt: 800,
heightLt: 800,
handleUpload: (e, file, targetItem) => {
const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
uploadImg({ file: base64, fileType: 'image' }).then(res => {
this.editForm[targetItem.name] = res
this.$refs.editFormRef.$refs[this.editChildRef].validateField(targetItem.name)
})
}
},
{
label: '主播间背景墙',
name: 'coverImgUrl',
type: 'upload',
limitSize: 2,
maxPhotoNum: 1,
wdithLt: 1080,
heightLt: 1920,
handleUpload: (e, file, targetItem) => {
const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
uploadImg({ file: base64, fileType: 'image' }).then(res => {
this.editForm[targetItem.name] = res
this.$refs.editFormRef.$refs[this.editChildRef].validateField(targetItem.name)
})
}
},
{
label: '关联发现频道',
name: 'zoneId',
type: 'select',
// isDisabled: false,
width: '480px',
optionList: [],
optionId: 'id',
optionLabel: 'zoneName',
optionsName: 'zoneList'
},
{
label: '',
name: '',
addHtml: 'merchantList'
},
{
label: '',
name: '',
addHtml: 'storeTable'
}
],
// 表格
hasPage: false,
tableParams: {
tableOption: true,
tableColumns: [
{
label: '门店名称',
prop: 'merchantName'
}
]
},
// 直播配置
relateStoreVisible: false,
storeApi: getMerchantList,
storeSearchForm: {},
storeSelectedList: [],
baseData: {
zoneList: []
}
}
},
components: {
glsxCombiForm,
// glsxDialog,
relateStoreDialog
},
mounted() {
this.getZoneList()
this.routeInfo = this.$route.params
this.title = this.titleObj[this.routeInfo.addOrEdit]
this.routeInfo.addOrEdit != 1 ? this.getInfo() : ''
// this.eventBus.$on('editRoom', val => {
// this.routeInfo = val
// this.title = this.titleObj[this.routeInfo.addOrEdit]
// this.routeInfo.addOrEdit != 1 ? this.getInfo() : ''
// this.eventBus.$off('editRoom')
// })
// this.getOptionsList('editFormData', false)
},
methods: {
getInfo() {
getLiveRoomInfoApi({ id: this.routeInfo.id }).then(res => {
this.editForm = res
this.editForm.openTime = [new Date(this.editForm.startTime), new Date(this.editForm.endTime)]
this.editForm.merchantInfoDTOList.forEach(item => {
this.storeSelectedList.push({
merchantNo: item.merchantId,
merchantName: item.merchantName,
merchantAccountLevel: item.merchantAccountLevel
})
})
})
},
getZoneList() {
getZoneListApi({}).then(res => {
this.baseData.zoneList = res.list
this.getOptionsList('editFormData', false)
})
},
getOptionsList(formName, hasAll = true) {
this[formName].forEach((item, index) => {
if (item.type === 'select' && this.baseData[item.optionsName].length) {
this.$set(this[formName][index], 'optionList', _.cloneDeep(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[this[formName][index].optionId] = ''
temp[this[formName][index].optionLabel] = '全部'
this[formName][index].optionList.unshift(temp)
}
}
})
},
relateCloseReset() {
// this.storeSelectedList = []
},
handleRelateStoreClose() {
this.relateStoreVisible = !this.relateStoreVisible
this.relateCloseReset()
},
handleRelateStoreConfirm(selectedData) {
// if (!selectedData.length) {
// this.$message({
// message: '请选择关联门店',
// type: 'warning',
// showClose: true
// })
// return true
// }
// this.couponsForm.merchantCouponDTOList = selectedData
// this.couponsNumList = new Array(selectedData.length).fill(999)
// this.couponsForm.merchantCouponDTOList.forEach((item, idx) => {
// if (!item.hasOwnProperty('amount')) {
// item['amount'] = 999
// } else {
// this.couponsNumList[idx] = item.amount
// }
// })
this.storeSelectedList = selectedData
this.handleRelateStoreClose()
// this.$refs.couponAddForm.clearValidate('merchantCouponDTOList')
},
handleProDelete(obj) {
this.$messageBox.confirm('是否删除该门店?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
callback: action => {
if (action == 'confirm') {
var idx = this.storeSelectedList.findIndex(item => item.merchantNo == obj.scope.merchantNo)
this.storeSelectedList.splice(idx, 1)
}
}
})
},
dateFormate(date) {
var hours = date.getHours() <= 9 ? '0' + date.getHours() : date.getHours()
var minutes = date.getMinutes() <= 9 ? '0' + date.getMinutes() : date.getMinutes()
var seconds = date.getSeconds() <= 9 ? '0' + date.getSeconds() : date.getSeconds()
return date.toLocaleDateString().replace(/\//g, '-') + ' ' + hours + ':' + minutes + ':' + seconds
},
handleConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
// console.log(this.editForm)
var params = JSON.parse(JSON.stringify(this.editForm))
params.startTime = this.dateFormate(new Date(this.editForm.openTime[0]))
params.endTime = this.dateFormate(new Date(this.editForm.openTime[1]))
delete params.openTime
params.merchantList = []
this.storeSelectedList.forEach(item => {
params.merchantList.push({
merchantId: item.merchantNo,
merchantName: item.merchantName,
merchantAccountLevel: item.merchantAccountLevel
})
})
insertLiveRoomApi(params).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleCancel()
}
})
}
})
},
handleCancel() {
this.$router.push({
path: '/liveRoom/liveRoomList'
})
}
}
}
</script>
<style scoped>
.live-room .select-store {
/* width: calc(98% - 140px); */
width: 98%;
}
</style>
<!-- 控制台 -->
<template>
<div class="live-room live-control">
<div class="container">
<div class="box">
<p class="edit-title">直播控制台</p>
<div class="head-box flex-start">
<img class="head-img" :src="editForm.shareImgUrl" />
<div>
<p class="head-title m-b-18">{{ editForm.name }}</p>
<p class="txt m-b-18">开播时间:{{ editForm.startTime + '-' + editForm.endTime }}</p>
<p class="txt m-b-18">房间号:{{ editForm.id }}</p>
<p class="txt m-b-18">
<span class="m-r-20">主播:{{ editForm.anchorName }}</span>
<span>微信号:{{ editForm.anchorWechat }}</span>
</p>
<p class="count-down" v-if="countDown">倒计时{{ countDown }}</p>
</div>
</div>
</div>
</div>
<div class="container">
<div class="box">
<div class="content">
<p class="edit-title no-border">直播数据</p>
<GLTable :tableParams="liveTableParams" :tableData="liveDataTable" :hasPage="false">
<span slot="coverImgUrl" slot-scope="scope">
<img class="img-60" :src="scope.scope.coverImgUrl" />
</span>
</GLTable>
</div>
</div>
</div>
<div class="container">
<div class="box">
<div class="content">
<p class="edit-title">商品数据</p>
<div class="flex pro-data">
<div class="w-25">
<p>直播成交总金额</p>
<p class="price">¥{{ editForm.saleAmtTotal || '0' }}</p>
</div>
<div class="w-25">
<p>累计推送次数</p>
<p class="price">{{ editForm.pushNum }}</p>
</div>
<div class="w-25">
<p>商品点击人数</p>
<p class="price">{{ editForm.clickUserNum }}</p>
</div>
<div class="w-25">
<p>商品点击次数</p>
<p class="price">{{ editForm.clickNum }}</p>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="box">
<div class="content">
<p class="edit-title no-border">商品配置</p>
<div class="flex">
<el-form :inline="true" :model="searchConfigForm">
<el-form-item label="商品名称:">
<el-input :size="size" v-model="searchConfigForm.name" placeholder="请输入商品名称" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button :size="size" type="primary" @click="handleConfigSearch">查询</el-button>
<el-button :size="size" @click="handleConfigReset">重置</el-button>
</el-form-item>
</el-form>
<el-form>
<el-form-item>
<el-button v-if="![103, 107].includes(editForm.liveStatus)" type="primary" size="mini" @click="handleConfigImport">导入商品</el-button>
</el-form-item>
</el-form>
</div>
<GLTable ref="controlConfigRef" :searchForm="searchConfigForm" :tableParams="tableParams" :getListApi="getControlImportListApi" :pageConf="pageConf" :beforeSearchFn="beforeConfigSearchFn">
<span slot="coverImgUrl" slot-scope="scope">
<img class="img-60" :src="scope.scope.coverImgUrl" />
</span>
<span class="table-btns" slot="auth-button" slot-scope="scope" :data="scope.scope">
<el-button v-if="editForm.liveStatus == '101'" type="text" @click="handlePush(scope.scope.id)">{{ targetId === scope.scope.id ? '已推送' + pushCountDown + 's' : '推送' }}</el-button>
<!-- <el-button type="text" @click="handlePush(scope.scope.id)">{{ targetId === scope.scope.id ? '已推送' + pushCountDown + 's' : '推送' }}</el-button> -->
<el-button v-show="!targetId" type="text" @click="handleUpOrDown(scope.scope)">{{ scope.scope.onSale == '1' ? '下架' : '上架' }}</el-button>
<el-button v-show="!targetId" type="text" @click="handleDelete(scope.scope)">删除</el-button>
</span>
</GLTable>
</div>
</div>
</div>
<div class="container edit-container">
<div class="box">
<div class="content">
<p class="edit-title">直播设置</p>
<div class="flex">
<div>
<p class="edit-title no-border">直播间禁言</p>
<p class="txt">
开启后,所有观众无法在直播间发表评论。
<el-switch :disabled="editForm.liveStatus != '102'" :size="size" v-model="editForm.closeComment" active-value="1" inactive-value="0" @change="handleChangeComment"></el-switch>
<!-- <el-switch :size="size" v-model="editForm.closeComment" active-value="1" inactive-value="0" @change="handleChangeComment"></el-switch> -->
</p>
</div>
<div>
<p class="edit-title no-border">直播回放</p>
<p class="txt">
开启后,观众可在直播结束页面查看本场直播。
<el-switch :disabled="[103, 107].includes(editForm.liveStatus)" :size="size" v-model="editForm.closeReplay" active-value="1" inactive-value="0" @change="handleChangeReplay"></el-switch>
<!-- <el-switch :size="size" v-model="editForm.closeReplay" active-value="1" inactive-value="0" @change="handleChangeReplay"></el-switch> -->
</p>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<el-button type="primary" @click="handleBack">返回</el-button>
</div>
<select-muti-pro-dialog v-if="isMutiSelectVisible" :isMutiSelectVisible="isMutiSelectVisible" :searchForm="searchWaitForm" :getListApi="getWaitImportListApi" :selectedProList="selectedProList" @handleMutiSelectConfirm="handleMutiSelectConfirm" @handleMutiSelectClose="handleMutiSelectClose">
<!-- <template slot="search">
<div class="flex">
<el-form :inline="true" :model="searchWaitForm">
<el-form-item label="商品名称:">
<el-input :size="size" v-model="searchWaitForm.name" placeholder="请输入商品名称" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button :size="size" type="primary" @click="handleConfigSearch">查询</el-button>
<el-button :size="size" @click="handleConfigReset">重置</el-button>
</el-form-item>
</el-form>
</div>
</template> -->
</select-muti-pro-dialog>
</div>
</template>
<script>
import { getControlInfoApi, getControlImportListApi, getWaitImportListApi, importGoodsApi, updateCommentApi, updateReplayApi, controlUpOrDownApi, controlDeleteApi } from '@/api/modules/liveRoom'
// import selectMutiProDialog from './selectMutiProDialog'
import { liveStatusList } from '@/common/constant'
import selectMutiProDialog from '@/components/select-muti-pro'
export default {
name: 'liveControl',
data() {
return {
size: 'small',
countDown: 0,
timer: null,
isFirst: true,
editForm: {},
// 直播数据 - 表格
liveDataTable: [],
liveTableParams: {
tableColumns: [
{
label: '商品名称',
prop: 'goodsName',
line: 2
},
{
label: '商品图片',
prop: 'coverImgUrl',
addHtml: 'coverImgUrl'
},
{
label: '成交单量',
prop: 'saleNum',
line: 1
},
{
label: '成交金额',
prop: 'saleAmt',
line: 1
},
{
label: '来源门店',
prop: 'merchantName',
line: 2
}
]
},
// 导入商品
isMutiSelectVisible: false,
searchWaitForm: {},
selectedProList: [],
getWaitImportListApi: getWaitImportListApi,
// 商品配置 - 表格
getControlImportListApi: getControlImportListApi,
searchConfigForm: {},
pushTimer: null,
pushCountDown: 0,
targetId: '',
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
tableParams: {
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '商品图片',
prop: 'coverImgUrl',
addHtml: 'coverImgUrl'
},
{
label: '商品标题',
prop: 'name',
line: 2
},
{
label: '商品价格',
prop: 'price',
line: 1,
formatter: cellValue => {
return cellValue.price2 && cellValue.price1 != cellValue.price2 ? (cellValue.price1 / 100).toFixed(2) + '-' + (cellValue.price2 / 100).toFixed(2) : (cellValue.price1 / 100).toFixed(2)
}
},
{
label: '状态',
prop: 'onSale',
width: '80',
formatter: cellValue => {
return {
0: '下架',
1: '上架'
}[cellValue.onSale]
}
},
{
label: '点击次数',
prop: 'clickNumber',
line: 1
},
{
label: '点击人数',
prop: 'clickUserNumber',
line: 1
},
{
label: '来源门店',
prop: 'merchantName',
line: 2
}
]
},
baseDataList: {
liveStatusList: liveStatusList
}
}
},
components: {
selectMutiProDialog
},
computed: {},
mounted() {
this.routeInfo = this.$route.params
this.searchWaitForm = {
id: this.routeInfo.id
}
this.getInfo()
},
beforeDestroy() {
this.timer && clearInterval(this.timer)
this.pushTimer && clearInterval(this.pushTimer)
},
methods: {
getInfo(fn, noChangeList = []) {
getControlInfoApi({ id: this.routeInfo.id }).then(res => {
// liveStatus 直播间状态101:直播中,102:未开始,103已结束,104禁播,105:暂停,106:异常,107:已过期
this.editForm = res
this.liveDataTable = res.liveStatisticsDTOList
this.editForm.closeComment = res.closeComment + ''
this.editForm.closeReplay = res.closeReplay + ''
this.isFirst = true
console.log(this.editForm)
this.countDownTime()
fn && fn()
})
},
beforeConfigSearchFn() {
return new Promise(resolve => {
this.searchConfigForm.id = this.$route.params.id
resolve()
})
},
handleConfigSearch() {
this.$refs.controlConfigRef.refreshTable()
},
handleConfigReset() {
this.searchConfigForm.name = ''
this.handleConfigSearch()
},
countDownTime() {
this.isFirst ? (this.isFirst = false) : (this.editForm.systemTimestamp = this.editForm.systemTimestamp + 1)
clearInterval(this.timer)
if (new Date() < new Date(this.editForm.startTime)) {
this.timer = setInterval(() => {
var leftTime = new Date(this.editForm.startTime) - new Date()
//计算剩余的天数
var days = parseInt(leftTime / 1000 / 60 / 60 / 24, 10)
//计算剩余的小时
var hours = parseInt((leftTime / 1000 / 60 / 60) % 24, 10)
//计算剩余的分钟
var minutes = parseInt((leftTime / 1000 / 60) % 60, 10)
//计算剩余的秒数
var seconds = parseInt((leftTime / 1000) % 60, 10)
// days = this.checkTime(days)
// hours = this.checkTime(hours)
// minutes = this.checkTime(minutes)
// seconds = this.checkTime(seconds)
this.countDown = (days ? days + '天' : '') + hours + '小时' + minutes + '分' + seconds + '秒'
this.countDownTime()
}, 1000)
}
},
//将0-9的数字前面加上0,例1变为01
// checkTime(i) {
// if (i < 10) {
// i = '0' + i
// }
// return i
// },
handlePush(id) {
if (!this.targetId) {
this.targetId = id
this.pushTimeDown()
}
},
pushTimeDown() {
clearInterval(this.pushTimer)
if (this.pushCountDown != 60) {
this.pushTimer = setInterval(() => {
this.pushCountDown++
this.pushTimeDown()
}, 1000)
} else {
this.targetId = ''
this.pushCountDown = 0
}
},
handleUpOrDown(row) {
var upOrDownTxt = row.onSale == '1' ? '下架' : '上架'
this.$messageBox.confirm('是否'+upOrDownTxt+'该商品?', upOrDownTxt, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
callback: action => {
if (action == 'confirm') {
controlUpOrDownApi({ roomId: this.editForm.roomId, goodsId: row.id }).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleConfigSearch()
}
})
}
}
})
},
handleDelete(row) {
this.$messageBox.confirm('是否删除该商品?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
callback: action => {
if (action == 'confirm') {
controlDeleteApi({ roomId: this.editForm.roomId, goodsId: row.id }).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleConfigSearch()
}
})
}
}
})
},
handleConfigImport() {
var that = this
this.getInfo(() => {
if ([103, 107].includes(this.editForm.liveStatus)) {
this.$message({
message: '直播' + that.baseDataList.liveStatusList.find(item => item.confId == this.editForm.liveStatus).confName + ',不能导入商品',
type: 'info'
})
return true
}
this.isMutiSelectVisible = !this.isMutiSelectVisible
})
},
handleMutiSelectConfirm(selectedProInfo) {
var params = {
roomId: this.routeInfo.id,
goodsIds: selectedProInfo.map(item => item.id)
}
console.log(params)
importGoodsApi(params).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : '操作失败',
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleConfigReset()
}
})
},
handleMutiSelectClose() {
this.handleConfigImport()
},
// liveStatus 直播间状态101:直播中,102:未开始,103已结束,104禁播,105:暂停,106:异常,107:已过期
handleChangeComment(val) {
this.getInfo(() => {
if (this.editForm.liveStatus != 102) {
// this.$message({
// message: '当前直播间不处于未开始状态,不能开启禁言',
// type: 'info'
// })
return true
}
var params = {
id: this.routeInfo.id,
banComment: val
}
updateCommentApi(params).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : '操作失败',
type: res.code == '0' ? 'success' : 'error'
})
if (res.code != '0') {
this.editForm.closeComment = val ? '0' : '1'
} else {
this.editForm.closeComment = val
}
})
})
},
handleChangeReplay(val) {
this.getInfo(() => {
if ([103, 107].includes(this.editForm.liveStatus)) {
// this.$message({
// message: '不能改变回播状态',
// type: 'info'
// })
return true
}
var params = {
id: this.routeInfo.id,
closeReplay: val
}
updateReplayApi(params).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : '操作失败',
type: res.code == '0' ? 'success' : 'error'
})
if (res.code != '0') {
this.editForm.closeReplay = val ? '0' : '1'
} else {
this.editForm.closeReplay = val
}
})
})
},
handleBack() {
this.$router.push({
path: '/liveRoom/liveRoomList'
})
}
}
}
</script>
<style>
/* .live-control {
padding: 20px;
} */
/* .live-control p {
margin: 0 0 10px 0;
color: #666666;
} */
/* .live-control .box {
padding: 10px;
border: 1px solid #cccccc;
} */
.live-control {
font-size: 16px;
color: #333333;
}
.live-control .flex-start {
display: flex;
justify-content: flex-start;
}
.live-control .no-border{
border: 0;
}
.live-control .m-b-18 {
margin-bottom: 18px;
}
.live-control .m-r-20 {
margin-right: 20px;
}
.live-control .head-box {
position: relative;
padding: 32px 10px 17px;
}
.live-control .head-box .head-title {
line-height: 20px;
font-weight: bold;
}
.live-control .txt {
font-size: 14px;
line-height: 20px;
color: #666666;
}
.live-control .head-box .count-down {
position: absolute;
right: 20px;
top: 100px;
font-size: 20px;
color: #5850FF;
}
.live-control .head-box .head-img {
width: 170px;
height: 136px;
padding-right: 20px;
}
.live-control .pro-data {
padding: 40px 20px;
}
.pro-data .w-25 {
width: 25%;
text-align: center;
}
.live-control .pro-data .price {
font-size: 30px;
margin-top: 20px;
}
</style>
<!-- 直播间列表 -->
<template>
<div class="live-room">
<div class="container live-room">
<div class="flex">
<el-form>
<el-form-item>
<el-button :size="size" type="primary" class="el-icon-plus" @click="handleEdit(1)">新增直播</el-button>
</el-form-item>
</el-form>
<el-form :inline="true" :model="searchForm">
<el-form-item label="直播间搜索:">
<el-input :size="size" v-model="searchForm.name" placeholder="请输入直播间名" clearable></el-input>
</el-form-item>
<el-form-item>
<el-button :size="size" type="primary" @click="handleSearch">查询</el-button>
<el-button :size="size" @click="handleReset">重置</el-button>
</el-form-item>
</el-form>
</div>
<GLTable ref="liveRoomRef" :searchForm="searchForm" :tableParams="tableParams" :getListApi="getListApi" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
<span slot="shareImgUrl" slot-scope="scope">
<img class="img-60" :src="scope.scope.shareImgUrl" />
</span>
<span class="table-btns" slot="auth-button" slot-scope="scope" :data="scope.scope">
<el-button type="text" @click="handleDetail(scope.scope)">控制台</el-button>
<el-button type="text" @click="handleShare(scope.scope)">分享</el-button>
<el-button v-if="scope.scope.liveStatus == '102'" type="text" @click="handleEdit(2, scope.scope)">编辑</el-button>
<el-button v-if="scope.scope.liveStatus != '101'" type="text" @click="handleDelete(scope.scope)">删除</el-button>
</span>
</GLTable>
<glsx-dialog title="分享" width="730px" :isVisible="isShareVisible" :noCancel="noCancel" @closeDialog="handleShareClose" @confirmDialog="handleShareClose">
<div class="share-dialog">
<div class="flex">
<div class="flex box poster">
<div>
<p class="share-txt">海报</p>
<!-- <p>小程序码不带参数</p> -->
<el-button :size="size" type="primary">保存图片</el-button>
</div>
<img :src="shareForm.posterUrl" />
</div>
<div class="flex box poster">
<div>
<p class="share-txt">小程序码</p>
<!-- <p>小程序码不带参数</p> -->
<el-button :size="size" type="primary">保存图片</el-button>
</div>
<img :src="shareForm.cdnUrl" />
</div>
</div>
<div class="box page-route">
<div>
<p class="route-txt">短链</p>
<div class="flex">
<p style="width: 426px;">{{shareForm.pagePath}}</p>
<el-button :size="size" type="primary" @click="handleSaveTxt(shareForm.pagePath)">复制链接</el-button>
<!-- <p>链接是直播间原始页面路径,如需加入参数,详见使用方法</p> -->
</div>
</div>
</div>
</div>
</glsx-dialog>
</div>
</div>
</template>
<script>
import glsxDialog from '@/components/glsx-dialog'
// import glsxTable from '@/components/glsx-table'
import { getLiveRoomListApi, getLiveShareApi, deleteLiveRoomApi } from '@/api/modules/liveRoom'
import { liveStatusList } from '@/common/constant'
export default {
name: 'liveRoom',
data() {
return {
size: 'small',
searchForm: {
name: ''
},
// 分享 - 弹窗
shareForm: {},
isShareVisible: false,
noCancel: true,
// 表格组件
getListApi: getLiveRoomListApi,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
// 表格参数
tableParams: {
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '最近开播',
prop: 'time',
width: '180',
formatter: cellValue => {
return cellValue.startTime + '-' + cellValue.endTime
}
},
{
label: '直播间名称',
prop: 'name',
line: 1
},
{
label: '房间号',
prop: 'roomId'
},
{
label: '主播',
prop: 'anchorName',
line: 1
},
{
label: '直播间图片',
prop: 'shareImgUrl',
line: 1,
addHtml: 'shareImgUrl'
},
{
label: '直播状态',
prop: 'liveStatus',
width: '80',
formatter: cellValue => {
return this.baseDataList.liveStatusList.find(item => item.confId == cellValue.liveStatus).confName
}
}
]
},
baseDataList: {
liveStatusList: liveStatusList
}
}
},
components: {
glsxDialog
// glsxTable
},
mounted() {
console.log(this.$common.utils)
},
methods: {
beforeSearchFn() {
return new Promise(resolve => {
resolve()
})
},
handleShare(row) {
getLiveShareApi({ id: row.id }).then(res => {
console.log(res)
this.isShareVisible = !this.isShareVisible
this.shareForm = res
})
},
handleShareClose() {
// this.handleShare()
this.isShareVisible = !this.isShareVisible
},
handleSaveTxt(txt) {
const input = document.createElement('input')
document.body.appendChild(input)
input.setAttribute('value', txt)
input.select()
document.execCommand('Copy')
document.body.removeChild(input)
this.$message({
message: '复制成功',
type: 'success'
})
},
handleDetail(row) {
this.$router.push({
// name: 'liveControl',
// path: '/liveRoom/liveControl',
name: 'ServicesLiveRoomLiveControl',
params: {
id: row.id
}
})
},
handleDelete(row) {
this.$messageBox.confirm('是否删除该直播间?', '删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'error',
callback: action => {
if (action == 'confirm') {
deleteLiveRoomApi({ id: row.id }).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleSearch()
}
})
}
}
})
},
// 1-新增;2-编辑
handleEdit(addOrEdit, row) {
// console.log(row)
// this.$history.push('services/liveRoom/editLiveRoom', { addOrEdit: addOrEdit, row: row || {} })
// this.eventBus.$emit('editRoom', {
// addOrEdit: addOrEdit,
// id: row ? row.id : ''
// })
this.$router.push({
name: 'ServicesLiveRoomEditLiveRoom',
params: {
addOrEdit: addOrEdit,
id: row ? row.id : '-1'
}
// name: 'editLiveRoom',
// path: '/liveRoom/editLiveRoom'
})
},
handleSearch() {
this.$refs.liveRoomRef.refreshTable()
}
}
}
</script>
<style>
.live-room .flex {
display: flex;
justify-content: space-between;
}
.live-room .share-dialog .box {
background: #f7f7f7;
border-radius: 6px;
padding: 30px;
}
.live-room .share-dialog .poster img {
width: 150px;
height: 240px;
margin-left: 45px;
}
.live-room .share-dialog .page-route {
margin-top: 16px;
}
.live-room .share-dialog .page-route .route-txt {
font-weight: bold;
padding-bottom: 10px;
}
.live-room .share-dialog .share-txt {
font-weight: bold;
margin-bottom: 50px;
}
</style>
<!-- 关联门店弹窗 -->
<template>
<glsx-dialog title="关联门店" :isVisible.sync="relateStoreVisible" width="70%" btnOkLabel="关联" @confirmDialog="handleRelateStoreConfirm" @closeDialog="handleRelateStoreClose" class="relateStore">
<slot></slot>
<el-row>
<el-col :span="12">
<el-table ref="seletingTable" :data="selectingData" height="464px" class="table" border @select="handleChange" @select-all="handleAll">
<el-table-column type="selection" width="55" align="center" :selectable="selectable"></el-table-column>
<el-table-column prop="merchantName" label="商户名称" align="center">
<!-- <template slot-scope="scope">
<span :class="{ red: !scope.row.isSetUpgradeSettleRule && needTip.includes(sourcePage) }">{{ scope.row.yqMerchantName }}</span>
</template> -->
</el-table-column>
<!-- <el-table-column prop="merchantName" label="4S店名称" align="center">
<template slot-scope="scope">
<span :class="{ red: !scope.row.isSetUpgradeSettleRule && needTip.includes(sourcePage) }">{{ scope.row.merchantName }}</span>
<el-tooltip v-if="!scope.row.isSetUpgradeSettleRule" popper-class="tooltip-class" effect="dark" content="该门店无配置财务分润规则,无法关联!" placement="top">
<span v-if="!scope.row.isSetUpgradeSettleRule && needTip.includes(sourcePage)" class="tip-icon">?</span>
</el-tooltip>
</template>
</el-table-column> -->
</el-table>
<el-pagination small background @current-change="handleCurrentChange" :current-page.sync="pageNum" :page-size="pageSize" layout="total, prev, pager, next" :total="total"></el-pagination>
</el-col>
<el-col :span="12">
<el-table :data="selectedData" class="table" border height="464px">
<el-table-column prop="merchantName" label="商户名称" align="center"></el-table-column>
<!-- <el-table-column prop="merchantName" label="4S店名称" align="center"></el-table-column> -->
<el-table-column label="删除" align="center" width="50">
<template slot-scope="scope">
<el-button style="padding: 0;" class="el-icon-delete" @click="handleDelete(scope.row)" type="text"></el-button>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
</glsx-dialog>
</template>
<script>
import glsxDialog from '@/components/glsx-dialog'
export default {
name: 'relateStoreDialog',
data() {
return {
selectedData: [],
selectingData: [],
// needTip: ['editProduct'],
// 分页
total: 0,
pageNum: 1,
pageSize: 20
}
},
props: {
relateStoreVisible: {
type: Boolean,
default: false
},
// 页面来源
// sourcePage: {
// type: String,
// default: ''
// },
storeApi: {
type: Function,
default: () => {}
},
storeSelected: {
type: Array,
default: () => []
},
storeSearchForm: {
type: Object,
default: () => {}
}
// 去掉表格中某些字段
// noTableField: {
// type: Array,
// default: () => []
// }
},
components: {
glsxDialog
},
mounted() {
this.selectedData = this.storeSelected
this.getSelectingList()
},
methods: {
selectable(row, index) {
var isSelect = row.hasOwnProperty('beServed') ? !row.beServed : true
// if (this.sourcePage === 'editProduct') {
// isSelect = row.isSetUpgradeSettleRule
// }
return isSelect
},
recoverySelection() {
var exitIds = this.selectedData.map(item => item.merchantNo + '')
this.selectingData.forEach(item => {
if (exitIds.includes(item.merchantNo)) {
this.$refs.seletingTable.toggleRowSelection(item, true)
}
})
},
getSelectingList() {
this.storeApi({
...this.storeSearchForm,
pageNum: this.pageNum,
pageSize: this.pageSize
}).then(res => {
this.selectingData = res.list
this.total = res.total
this.$nextTick(() => {
this.recoverySelection()
})
})
},
handleChange(selection, row) {
var addOrDelete = !!selection.find(item => item.merchantNo === row.merchantNo)
addOrDelete ? this.selectedData.push(row) : (this.selectedData = this.selectedData.filter(item => item.merchantNo !== row.merchantNo))
},
handleAll(selection) {
this.selectingData.forEach(item => {
var isExit = this.selectedData.findIndex(subItem => subItem.merchantNo === item.merchantNo)
var isServed = item.hasOwnProperty('beServed') ? item.beServed : false
if (selection.length && isExit === -1 && !isServed) {
this.selectedData.push(item)
} else if (!selection.length && isExit !== -1) {
this.selectedData.splice(isExit, 1)
}
})
},
handleDelete(row) {
this.selectedData = this.selectedData.filter(item => item.merchantNo !== row.merchantNo)
this.$refs.seletingTable.toggleRowSelection(row)
},
handleCurrentChange(val) {
this.pageNum = val
this.getSelectingList()
},
handleRelateStoreConfirm() {
if (!this.selectedData.length) {
this.$message({
message: '请选择关联门店',
type: 'warning',
showClose: true
})
return true
}
this.$emit('handleRelateStoreConfirm', this.selectedData)
},
handleRelateStoreClose() {
this.$emit('handleRelateStoreClose')
}
}
}
</script>
<style>
.relateStore .table {
margin: 0 auto 20px !important;
width: 98%;
}
/* .service-store .relateStore .el-table .cell,
.d2-form .relateStore .el-table .cell {
line-height: 26px !important;
} */
.service-store .relateStore .el-table--medium td,
.d2-form .relateStore .el-table--medium td {
padding: 6px 8px !important;
}
.relateStore .red {
color: red;
}
.relateStore .tip-icon {
position: absolute;
display: inline-block;
height: 10px;
width: 10px;
line-height: 10px;
color: #ffffff;
background-color: red;
border: 1px solid red;
border-radius: 50%;
cursor: pointer;
font-size: 6px;
margin-left: 2px;
}
</style>
<!-- 选择商品弹窗 -->
<template>
<glsx-dialog class="muti-pro" title="选择商品" :isVisible.sync="isMutiSelectVisible" width="70%" @confirmDialog="handleMutiSelectConfirm" @closeDialog="handleMutiSelectClose">
<GLTable ref="mutiProRef" :searchForm="searchForm" :tableParams="tableParams" :tableData="tableData" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn"></GLTable>
</glsx-dialog>
</template>
<script>
import glsxDialog from '@/components/glsx-dialog'
export default {
name: 'selectMutiProDialog',
data() {
return {
// 表格组件
getListApi: '',
tableData: [
{
id: 1,
name: '商品名称1'
},
{
id: 2,
name: '商品名称2'
}
],
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
// 表格参数
tableParams: {
listName: 'list',
// 行数据的key
mutiSelectUniqueKey: 'id',
// 多选ref的名称
mutiSelectName: 'list',
tableOption: true,
tableColumns: [
{
label: '商品名称',
prop: 'name'
},
{
label: '缩略图',
prop: 'title'
},
{
label: '价格(元)',
prop: 'status'
},
{
label: '来源门店',
prop: ''
}
]
}
}
},
props: {
isMutiSelectVisible: {
type: Boolean,
default: false
}
},
components: {
glsxDialog
},
mounted() {},
methods: {
handleMutiSelectConfirm() {
var selectedData = this.$refs.mutiProRef.mutiSelectArr[this.tableParams.mutiSelectName]
console.log(selectedData)
this.$emit('handleMutiSelectConfirm', selectedData)
},
handleMutiSelectClose() {
this.$emit('handleMutiSelectClose')
}
}
}
</script>
<style></style>
......@@ -3,12 +3,21 @@
<div class="edit-share marketing">
<div class="container edit-container">
<p class="edit-title">{{ title }}</p>
<glsx-combi-form class="edit-form-container" ref="editFormRef" labelWidth="140px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule"></glsx-combi-form>
<glsx-combi-form class="edit-form-container" ref="editFormRef" labelWidth="140px" :isBlock="true" :formRef="editChildRef" :formObj="editForm" :formData="editFormData" :formRules="editRule">
<template slot="selectPro" slot-scope="scope">
<el-button type="primary" @click="handleRelateProClose(scope)">{{ editForm.goodsId ? '更换' : '请选择' }}</el-button>
<div class="m-t-10" v-show="editForm.goodsId">
<img style="margin-right: 10px;" class="img-60" :src="editForm.goodsImage" />
<span>{{ editForm.goodsName }}</span>
</div>
</template>
</glsx-combi-form>
</div>
<div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
<el-button type="primary" @click="handleConfirm">确定</el-button>
<el-button type="default" @click="handleCancel">取消</el-button>
</div>
<select-single-pro-dialog v-if="isSingleSelectVisible" :isSingleSelectVisible="isSingleSelectVisible" :selectedProInfo="selectedProInfo" @handleSingleSelectConfirm="handleSingleSelectConfirm" @handleSingleSelectClose="handleSingleSelectClose"></select-single-pro-dialog>
</div>
</template>
......@@ -31,15 +40,22 @@ export default {
addOrEdit: 1,
id: ''
},
// 商品选择
isSingleSelectVisible: false,
selectedProInfo: {},
editForm: {
videoUrl: '',
imgUrls: [],
shareContent: ''
shareContent: '',
relatePro: 1,
goodsId: ''
},
editRule: {
shareContent: [{ required: true, message: '请输入专区名称', trigger: 'change' }],
zoneId: [{ required: true, message: '请选择发现频道', trigger: 'change' }],
imgUrls: [{ required: true, message: '请上传照片', trigger: 'change' }]
imgUrls: [{ required: true, message: '请上传照片', trigger: 'change' }],
relatePro: [{ required: true, message: '请选择关联商品', trigger: 'change' }],
goodsId: [{ required: false, message: '请选择关联的商品', trigger: 'change' }]
},
editFormData: [
{
......@@ -93,6 +109,29 @@ export default {
rows: 5,
// showLimit: true,
maxlength: 200
},
{
label: '关联商品',
name: 'relatePro',
type: 'radio',
optionId: 'confId',
optionLabel: 'confName',
optionList: [{
confId: 1,
confName: '不关联'
}, {
confId: 2,
confName: '关联'
}],
handleRadioChange: val => {
this.handleRelateProChange(val)
}
},
{
label: '商品',
name: 'goodsId',
addHtml: 'selectPro',
isHide: true
}
],
baseData: {
......@@ -118,14 +157,31 @@ export default {
this.getOptionsList('editFormData', false, 'zoneId')
})
},
handleRelateProChange(val) {
this.editRule.goodsId[0].required = val == 2
var idx = this.editFormData.findIndex(item => item.name == 'goodsId')
this.editFormData[idx].isHide = val != 2
},
handleRelateProClose(targetItem) {
this.selectedProInfo = this.editForm.goodsId ? { id: this.editForm.goodsId } : {}
this.handleSingleSelectClose()
},
handleSingleSelectConfirm(selectedProInfo) {
this.editForm.goodsId = selectedProInfo.id
this.editForm.goodsName = selectedProInfo.goodsName
this.editForm.goodsImage = selectedProInfo.goodsImage
this.handleSingleSelectClose()
},
handleSingleSelectClose() {
this.isSingleSelectVisible = !this.isSingleSelectVisible
},
getInfo() {
this.$apis.zoneList.getZoneInfoApi({ id: this.routeInfo.id }).then(res => {
// this.editForm.zoneName = res.zoneName
// this.editForm.zoneImg = res.zoneImg
// this.editForm.merchantList = res.merchantRefList
// this.editForm.merchantList.forEach(item => {
// item.merchantNo = item.merchantId
// })
this.$apis.orderShare.getShareRecordInfoApi({ id: this.routeInfo.id }).then(res => {
this.editForm = {
...res,
relatePro: res.goodsId ? 2 : 1
}
this.handleRelateProChange(this.editForm.relatePro)
})
},
......@@ -158,19 +214,21 @@ export default {
handleConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
var apiName = this.routeInfo.addOrEdit == 1 ? 'addShareRecordApi' : 'updateShareRecordApi'
var params = this.$common.utils.deepClone(this.editForm)
if (this.routeInfo.addOrEdit == 2) {
params.id = this.routeInfo.id
}
// this.$apis.zoneList.insertZoneApi(params).then(res => {
// this.$message({
// message: res.code == '0' ? '操作成功' : '操作失败',
// type: res.code == '0' ? 'success' : 'error'
// })
// if (res.code == '0') {
// this.handleCancel()
// }
// })
params.goodsId = this.editForm.relatePro == 1 ? '' : params.goodsId
this.$apis.orderShare[apiName](params).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : '操作失败',
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleCancel()
}
})
}
})
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!