Commit a35b518c by cwq0219

直播间

1 parent 186e751c
...@@ -27,4 +27,27 @@ ...@@ -27,4 +27,27 @@
color: #333333; color: #333333;
margin: 0 0 30px 0; margin: 0 0 30px 0;
padding-left: 8px; padding-left: 8px;
}
table {
width: 98%;
color: #666666;
border: 1px solid #e5e6e7;
border-width: 1px 0 0 1px;
}
table tr {
height: 30px;
line-height: 30px;
}
table th,
table td {
font-size: 12px;
font-weight: normal;
padding: 0px 10px;
border: 1px solid #e5e6e7;
border-width: 0px 1px 1px 0px;
border-spacing: 0;
text-align: center;
} }
\ No newline at end of file \ No newline at end of file
// 新值,旧值,整数部分位数,小数部分位数,最小值,最大值,规则
export function limitPrice(newValue, oldValue, intergerDigit, pointDigit, minValue, maxValue, regRule) {
var reg = {
priceReg: /^\d[\d\.]*$/,
numReg: /^[1-9]\d*$/
}
regRule = regRule || 'priceReg'
if (newValue && ((minValue && (newValue < minValue)) || (maxValue && (newValue > maxValue)))) {
return oldValue || ''
}
if (newValue && reg[regRule].test(newValue + '')) {
if ((/\./).test(newValue)) {
newValue = newValue + ''
var interger = newValue.split('.')[0]
var point = newValue.split('.')[1]
var intergerNum = interger.length > intergerDigit ? oldValue.split('.')[0] : interger
var pointNum = point.length > pointDigit ? point.slice(0, pointDigit) : point
newValue = pointDigit ? intergerNum + '.' + pointNum : newValue.split('.')[0]
} else {
newValue = newValue.length > intergerDigit ? oldValue.slice(0, intergerDigit) : newValue
}
return newValue
} else {
return newValue ? oldValue : ''
}
}
\ No newline at end of file \ No newline at end of file
...@@ -3,7 +3,13 @@ ...@@ -3,7 +3,13 @@
<div class="glsx-combi-form"> <div class="glsx-combi-form">
<el-form :ref="formRef" :inline="true" :model="formObj" :label-width="labelWidth" :rules="formRules" size="mini" class="glsx-combi-form-block"> <el-form :ref="formRef" :inline="true" :model="formObj" :label-width="labelWidth" :rules="formRules" size="mini" class="glsx-combi-form-block">
<template v-for="(item, index) in formData"> <template v-for="(item, index) in formData">
<el-form-item v-if="!item.isHide" :key="index" :class="{ 'no-label': !item.label, isBlock: isBlock, tips: item.tips }" :label="item.label ? item.label + ':' : ''" :prop="item.name"> <el-form-item v-if="!item.isHide" :key="index" :class="{ 'no-label': !item.label, isBlock: isBlock }" :label="item.label ? item.label + ':' : ''" :prop="item.name">
<span v-if="!item.isHide && item.tips" class="tips-block" slot="label">
<span class="tips-label">{{ item.label }}</span>
<el-tooltip popper-class="tooltip-class" effect="dark" :content="item.tips" :placement="item.placement || 'top'">
<span class="tips-icon"></span>
</el-tooltip>{{ item.label ? ':' : '' }}
</span>
<slot v-if="item.addHtml" :name="item.addHtml" :scope="item"></slot> <slot v-if="item.addHtml" :name="item.addHtml" :scope="item"></slot>
<el-input v-else-if="item.type === 'input'" :placeholder="item.placeholder || '请输入' + item.label" v-model.trim="formObj[item.name]" :disabled="item.isDisabled" :maxlength="item.maxlength" :clearable="item.isClear || false" :type="item.inputType || 'text'" :style="{ width: item.width || 'auto' }" :show-word-limit="item.showLimit || false" @keydown.native="e => handleInputDown(e, item)"></el-input> <el-input v-else-if="item.type === 'input'" :placeholder="item.placeholder || '请输入' + item.label" v-model.trim="formObj[item.name]" :disabled="item.isDisabled" :maxlength="item.maxlength" :clearable="item.isClear || false" :type="item.inputType || 'text'" :style="{ width: item.width || 'auto' }" :show-word-limit="item.showLimit || false" @keydown.native="e => handleInputDown(e, item)"></el-input>
<!-- 选择-输入框 --> <!-- 选择-输入框 -->
...@@ -196,7 +202,35 @@ export default { ...@@ -196,7 +202,35 @@ export default {
.glsx-combi-form .input-with-select .el-input-group__prepend { .glsx-combi-form .input-with-select .el-input-group__prepend {
background-color: #fff; background-color: #fff;
} }
.glsx-combi-form .tips { /* 提示图标 */
margin: 0; .glsx-combi-form .tips-block {
position: relative;
}
.glsx-combi-form .tips-label {
margin-right: 20px;
}
.glsx-combi-form .tips-icon {
position: absolute;
display: inline-block;
width: 12px;
height: 12px;
top: 3px;
right: 14px;
margin-right: 4px;
cursor: pointer;
border: 1px solid #7f7f7f;
border-radius: 50%;
} }
.glsx-combi-form .tips-icon::before{
content: '?';
position: absolute;
width: 8px;
height: 8px;
top: -9px;
left: 1px;
font-size: 10px;
}
/* .glsx-combi-form .tips {
margin: 0;
} */
</style> </style>
import Vue from 'vue' import Vue from 'vue'
import { Message, Button, ButtonGroup, Form, FormItem, Input, Radio, RadioGroup, Checkbox, CheckboxGroup, Switch, Select, Option, TimePicker, Col, DatePicker, Tree, Card, Table, TableColumn, Pagination, Loading, Dialog, MessageBox, Upload, Container } from 'element-ui' import { Message, Button, ButtonGroup, Form, FormItem, Input, Radio, RadioGroup, Checkbox, CheckboxGroup, Switch, Select, Option, TimePicker, Col, DatePicker, Tree, Card, Table, TableColumn, Pagination, Loading, Dialog, MessageBox, Upload, Tooltip, Container } from 'element-ui'
Vue.use(Button) Vue.use(Button)
Vue.use(ButtonGroup) Vue.use(ButtonGroup)
Vue.use(Form) Vue.use(Form)
...@@ -23,5 +23,6 @@ Vue.use(Pagination) ...@@ -23,5 +23,6 @@ Vue.use(Pagination)
Vue.use(Loading) Vue.use(Loading)
Vue.use(Dialog) Vue.use(Dialog)
Vue.use(Upload) Vue.use(Upload)
Vue.use(Tooltip)
export const message = Message export const message = Message
export const messageBox = MessageBox export const messageBox = MessageBox
...@@ -12,6 +12,18 @@ const staticRoutes = Object.freeze([ ...@@ -12,6 +12,18 @@ const staticRoutes = Object.freeze([
meta: {} meta: {}
}, },
{ {
name: 'editProduct',
path: '/cmmodityLibrary/editProduct',
component: resolve => require([`@/views/cmmodityLibrary/editProduct.vue`], resolve),
meta: {}
},
{
name: 'editProductGroup',
path: '/cmmodityLibrary/editProductGroup',
component: resolve => require([`@/views/cmmodityLibrary/editProductGroup.vue`], resolve),
meta: {}
},
{
name: 'liveRoom', name: 'liveRoom',
path: '/liveRoom/liveRoomList', path: '/liveRoom/liveRoomList',
component: resolve => require([`@/views/liveRoom/liveRoomList.vue`], resolve), component: resolve => require([`@/views/liveRoom/liveRoomList.vue`], resolve),
......
<!-- 添加商品 -->
<template>
<div class="edit-pro">
<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 type="text" @click="handleSinglePro(item)">请选择</el-button>
<table v-show="Object.keys(editForm.selectedProInfo).length" cellpadding='0' cellspacing='0' class="table-block">
<tr>
<td>商品图片</td>
<td>商品名称</td>
<td>商品价格</td>
<td>来源门店</td>
</tr>
<tr>
<td><img :src="editForm.selectedProInfo.goodsImage" /></td>
<td>{{editForm.selectedProInfo.goodsName}}</td>
<td>{{editForm.selectedProInfo.goodsCode}}</td>
<td>{{editForm.selectedProInfo.goodsCode}}</td>
</tr>
</table>
</div>
<div slot="footer">
<el-button type="primary" @click="handleConfirm">确定</el-button>
<el-button type="default" @click="handleCancel">取消</el-button>
</div>
</glsx-combi-form>
<select-single-pro-dialog :isSingleSelectVisible="isSingleSelectVisible" :selectedProInfo="selectedProInfo" @handleSingleSelectConfirm="handleSingleSelectConfirm" @handleSingleSelectClose="handleSingleSelectClose"></select-single-pro-dialog>
</div>
</template>
<script>
import _ from 'lodash'
import '@/assets/css/public.scss'
import glsxCombiForm from '@/components/glsx-combi-form'
import selectSingleProDialog from './selectSingleProDialog'
export default {
name: 'editProduct',
data() {
return {
title: '添加商品',
isBlock: true,
editChildRef: 'editChildRef',
editForm: {
selectedProInfo: {},
thumbUrl: []
},
editRule: {
title: [{ required: true, message: '请输入商品名称', trigger: 'change' }],
price: [{ required: true, message: '请输入直播价', trigger: 'change' }]
},
// 商品选择
isSingleSelectVisible: false,
selectedProInfo: {},
editFormData: [
{
label: '商品缩略图',
name: 'thumbUrl',
type: 'upload',
limitSize: 1,
tips: '建议尺寸:300像素 * 300像素,图片大小不得超过1M',
handleUpload: (file, fileList, targetItem) => {
this.editForm[targetItem.name] = fileList
// this.editForm[targetItem.name].pop()
}
},
{
label: '商品名称',
name: 'title',
width: '480px',
type: 'input',
maxlength: 20
},
{
label: '商品选择',
name: '',
addHtml: 'selectSinglePro'
},
{
label: '设置直播价',
name: 'price',
width: '480px',
type: 'input',
tips: '直播价表示直播开始时,用户购买的实际支付价格,直播结束时恢复原价'
}
]
}
},
components: {
glsxCombiForm,
selectSingleProDialog
},
computed: {},
mounted() { },
methods: {
handleSinglePro(targetItem) {
this.isSingleSelectVisible = !this.isSingleSelectVisible
},
handleSingleSelectConfirm(selectedProInfo) {
console.log(selectedProInfo)
this.selectedProInfo = selectedProInfo
this.editForm.selectedProInfo = selectedProInfo
this.handleSinglePro()
},
handleSingleSelectClose() {
this.handleSinglePro()
},
handleConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
console.log('-----------')
}
})
},
handleCancel() {}
}
}
</script>
<style>
.edit-pro .select-pro{
width: 480px;
}
.edit-pro .select-pro img {
width: 100px;
height: 100px;
}
</style>
<!-- 添加商品组 -->
<template>
<div class="edit-pro">
<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="selectMutiPro" slot-scope="item" class="select-pro">
<el-button type="text" @click="handleMutiPro(item)">请选择</el-button>
<table v-show="Object.keys(editForm.selectedProInfo).length" cellpadding='0' cellspacing='0' class="table-block">
<tr>
<td>商品图片</td>
<td>商品名称</td>
<td>商品价格</td>
<td>直播价格</td>
<td>来源门店</td>
</tr>
<tr v-for="item in editForm.selectedProInfo" :key="item.id">
<td><img :src="item.goodsImage" /></td>
<td>{{item.name}}</td>
<td>{{item.goodsCode}}</td>
<td><el-input :class="{ 'border-red': !item.price }" v-model="item.price"></el-input></td>
<td>{{item.goodsCode}}</td>
</tr>
</table>
</div>
<div slot="footer">
<el-button type="primary" @click="handleConfirm">确定</el-button>
<el-button type="default" @click="handleCancel">取消</el-button>
</div>
</glsx-combi-form>
<select-muti-pro-dialog :isMutiSelectVisible="isMutiSelectVisible" @handleMutiSelectConfirm="handleMutiSelectConfirm" @handleMutiSelectClose="handleMutiSelectClose"></select-muti-pro-dialog>
</div>
</template>
<script>
import _ from 'lodash'
import '@/assets/css/public.scss'
import glsxCombiForm from '@/components/glsx-combi-form'
import selectMutiProDialog from './selectMutiProDialog'
export default {
name: 'editProductGroup',
data() {
return {
title: '添加商品组',
isBlock: true,
editChildRef: 'editChildRef',
editForm: {
selectedProInfo: {},
thumbUrl: []
},
editRule: {
title: [{ required: true, message: '请输入商品名称', trigger: 'change' }]
},
// 商品选择
isMutiSelectVisible: false,
selectedProInfo: {},
editFormData: [
{
label: '商品组缩略图',
name: 'thumbUrl',
type: 'upload',
limitSize: 1,
tips: '建议尺寸:300像素 * 300像素,图片大小不得超过1M',
handleUpload: (file, fileList, targetItem) => {
this.editForm[targetItem.name] = fileList
// this.editForm[targetItem.name].pop()
}
},
{
label: '商品组名称',
name: 'title',
width: '480px',
type: 'input',
maxlength: 20
},
{
label: '商品选择',
name: '',
addHtml: 'selectMutiPro'
}
]
}
},
components: {
glsxCombiForm,
selectMutiProDialog
},
computed: {},
mounted() { },
methods: {
handleMutiPro(targetItem) {
this.isMutiSelectVisible = !this.isMutiSelectVisible
},
handleMutiSelectConfirm(selectedProInfo) {
console.log(selectedProInfo)
this.selectedProInfo = selectedProInfo
this.editForm.selectedProInfo = selectedProInfo
this.handleMutiPro()
},
handleMutiSelectClose() {
this.handleMutiPro()
},
handleConfirm() {
this.$refs.editFormRef.$refs[this.editChildRef].validate(valid => {
if (valid) {
console.log('-----------')
}
})
},
handleCancel() {}
}
}
</script>
<style>
.edit-pro .select-pro{
width: 480px;
}
.edit-pro .select-pro img {
width: 100px;
height: 100px;
}
.edit-pro .border-red {
border: 1px solid red;
}
</style>
<!-- 选择商品弹窗 -->
<template>
<glsx-dialog
class="muti-pro"
title="选择商品"
:isVisible.sync="isMutiSelectVisible"
width="70%"
@confirmDialog="handleMutiSelectConfirm"
@closeDialog="handleMutiSelectClose"
>
<glsx-table
ref="mutiProRef"
:tableParams="tableParams"
:tableData="tableData"
:pageConf="pageConf"
:beforeSearchFn="beforeSearchFn"
></glsx-table>
</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>
<!-- 选择商品 - 单选 -->
<template>
<glsx-dialog
class="single-pro"
title="选择商品"
:isVisible.sync="isSingleSelectVisible"
width="70%"
@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 class="ellipsis">{{item.goodsName}}</p>
<p>销量:{{item.goodsCode}}</p>
<p>库存:{{item.goodsCode}}</p>
<p>零售价:{{item.goodsCode}}</p>
</div>
</el-radio>
</el-radio-group>
</glsx-dialog>
</template>
<script>
import glsxDialog from '@/components/glsx-dialog'
export default {
name: 'selectSingleProDialog',
data() {
return {
infoId: '',
productList: [{
id: '1',
goodsName: '商品名称11111111111111',
goodsImage: 'https://img0.baidu.com/it/u=4276914015,335466661&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
goodsCode: '111'
}, {
id: '2',
goodsName: '商品名称2',
goodsImage: 'https://img0.baidu.com/it/u=4276914015,335466661&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
goodsCode: '111'
}, {
id: '3',
goodsName: '商品名称3',
goodsImage: 'https://img0.baidu.com/it/u=4276914015,335466661&fm=253&fmt=auto&app=120&f=JPEG?w=500&h=500',
goodsCode: '111'
}]
}
},
props: {
isSingleSelectVisible: {
type: Boolean,
default: false
},
selectedProInfo: {
type: Object,
default: () => { }
}
},
components: {
glsxDialog
},
computed: {},
mounted() {
this.infoId = this.selectedProInfo.id
},
methods: {
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: 150px;
border: 1px solid #cccccc;
margin-right: 10px;
}
.single-pro p {
margin: 0 0 8px 0;
}
.single-pro .pro-box img {
width: 150px;
height: 150px;
}
.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>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!