Commit a962023f by 李伟康

接龙需求

1 parent d3a43214
......@@ -22,7 +22,7 @@ export default {
getRedEnvelopeMerchantList (params) {
params.method = 'scrm.api.carlife.merchant.listWithPageByCurMerchant'
params.pageSize = 50
params.pageSize = params.pageSize || 50
return http({
url: '/rop-scrm-carlife/router',
data: params
......
......@@ -2,9 +2,7 @@
<div class="box">
<div class="content">
<div class="title">{{title}}</div>
<el-scrollbar
class="form-box"
>
<el-scrollbar class="form-box">
<glsx-combi-form
class="from"
ref="formRef"
......@@ -15,7 +13,7 @@
:formRules="rule"
>
<div
slot="posterImg"
slot="cardCover"
class="edit-tips"
>图片大小10M</div>
<template #endTimeType>
......@@ -34,7 +32,7 @@
</el-date-picker>
</div>
</template>
<template #showTime>
<template #winningTime>
<el-date-picker
v-model="configForm.winningTime"
type="datetime"
......@@ -56,7 +54,7 @@
multiple
placeholder="请选择"
filterable
multiple-limit="5"
multiple-limit="10"
class="options"
collapse-tags
>
......@@ -70,6 +68,14 @@
</el-select>
</div>
</template>
<template #prizeId>
<prize-box
:value.sync="configForm.prizeType"
:form="configForm"
@choose="choose"
ref="prizeRef"
/>
</template>
</glsx-combi-form>
</el-scrollbar>
</div>
......@@ -89,34 +95,41 @@
<script type='text/ecmascript-6'>
import { formData, rule, afterRangePickerOptions } from './addJS/add.js'
import PrizeBox from './components/PrizeBox.vue'
export default {
components: { PrizeBox },
name: '',
data () {
return {
afterRangePickerOptions,
title: this.$route.query.$title,
configForm: {
filtration: 1,
activityDetail: '',
type: 1,
description: '',
merchantId: '',
posterImg: '',
// 44212575
cardTitle: '',
cardCover: '',
maxNumber: 9,
winningNumber: 0,
endTimeType: 0,
endTime: '',
winningTime: '',
groupType: 0,
groupList: []
groupList: [],
prizeId: ''
},
rule,
formData,
rule: rule(this),
formData: formData(this),
groupList: [],
}
},
watch: {
'configForm.merchantId' (n) {
this.$refs.prizeRef.reset()
},
'configForm.maxNumber' (n) {
this.configForm.winningNumber = 0
this.formData.find(e => e.name == 'winningNumber').optionList.map(i => {
......@@ -131,14 +144,46 @@ export default {
}
},
mounted () {
},
methods: {
handleConfirm () {
},
showError (message) {
this.$message.error(message || '请先选择所属渠道!')
},
async getMerchantList (merchantName = '') {
this.$loading()
try {
const { list } = await this.$apis.redenvelope.getRedEnvelopeMerchantList({
currentPage: 1,
merchantName,
pageSize: 100
}),
data = []
list && list.map(e => {
data.push({
confId: e.merchantNo,
confName: e.merchantName,
})
})
this.formData.find(e => e.name == 'merchantId').optionList = data
this.$loading().close()
} catch (error) {
console.log(error)
this.$loading().close()
}
},
choose (e) {
this.configForm.prizeId = e
this.configForm.prizeType = this.$refs.prizeRef.prizeType
this.FromRef().clearValidate('prizeId')
},
handleConfirm () {
this.FromRef().validate(valid => {
console.log(valid)
})
},
FromRef(){
return this.$refs.formRef.$refs.formRef
}
}
}
......
......@@ -3,143 +3,180 @@ const generateOptionsArray = function (count = 9) {
optionId: Number(index + 1),
optionLabel: Number(index + 1)
}))
}
export const formData = [
{
label: '群接龙种类',
type: 'radio',
name: 'filtration',
optionList: [
{
text: '猜数字',
id: 1
},
required = true,
trigger = 'change'
export const formData = that => {
return [
{
label: '所属渠道',
name: 'merchantId',
type: 'select',
width: '432px',
attrs: {
'filter-method': (e) => {
that.getMerchantList(e)
},
remote: true
},
],
optionId: 'id',
optionLabel: 'text',
},
{
label: '群接龙说明',
name: 'activityDetail',
type: 'textBox',
excludeMenus: ['video', 'code', 'table'],
boxHeight: 240
},
{
label: '所属渠道',
name: 'merchantId',
type: 'select',
width: '432px',
// multiple: true,
// attrs: {
// multipleLimit: 10
// },
noFilter: false,
optionList: [],
optionId: 'confId',
optionLabel: 'confName'
},
{
label: '卡片标题',
name: 'name',
type: 'input',
maxlength: 100
},
{
label: '海报图片',
name: 'posterImg',
type: 'upload',
width: '320px',
limitSize: 10,
maxPhotoNum: 1,
suffixSlot: 'posterImg',
beforeLoading: true,
handleUpload: async (e, file, targetItem, config, _this) => {
try {
const { result: imgFile } = e.target,
arrBase64 = imgFile.split(',')[1],
str = file.name.split('.'),
base64 = str.at(-1) + '@' + arrBase64,
res = await _this.$apis.common.pictureUpload({ file: base64, fileType: 'image' })
_this.$loading().close()
if (res) {
config[targetItem.name] = res
_this.formRef().validateField(targetItem.name)
} else throw '上传失败'
} catch (error) {
_this.$loading().close()
_this.$message(error)
noFilter: false,
optionList: [],
optionId: 'confId',
optionLabel: 'confName'
},
{
label: '群接龙种类',
type: 'radio',
name: 'type',
optionList: [
{
text: '猜数字',
id: 1
},
],
optionId: 'id',
optionLabel: 'text',
},
{
label: '群接龙说明',
name: 'description',
type: 'textBox',
excludeMenus: ['video', 'code', 'table', 'splitLine'],
boxHeight: 240
},
{
label: '卡片标题',
name: 'cardTitle',
type: 'input',
maxlength: 20
},
{
label: '卡片封面',
name: 'cardCover',
type: 'upload',
width: '320px',
limitSize: 10,
maxPhotoNum: 1,
suffixSlot: 'cardCover',
beforeLoading: true,
handleUpload: async (e, file, targetItem, config) => {
try {
const { result: imgFile } = e.target,
arrBase64 = imgFile.split(',')[1],
str = file.name.split('.'),
base64 = str.at(-1) + '@' + arrBase64,
res = await that.$apis.common.pictureUpload({ file: base64, fileType: 'image' })
that.$loading().close()
if (res) {
config[targetItem.name] = res
that.formRef().validateField(targetItem.name)
} else throw '上传失败'
} catch (error) {
that.$loading().close()
that.$message(error)
}
}
},
{
label: '数字上限',
name: 'maxNumber',
type: 'select',
optionList: generateOptionsArray(),
optionId: 'optionId',
optionLabel: 'optionLabel',
},
{
label: '中奖数字',
name: 'winningNumber',
type: 'select',
optionList: [
{
optionId: 0,
optionLabel: '随机'
},
...generateOptionsArray()
],
optionId: 'optionId',
optionLabel: 'optionLabel',
},
{
label: '接龙结束时间',
type: 'radio',
name: 'endTimeType',
optionList: [
{
text: '无限制',
id: 0
},
{
text: '选择时间',
id: 1
},
],
optionId: 'id',
optionLabel: 'text',
suffixSlot: 'endTimeType',
},
{
label: '接龙开奖时间',
name: 'winningTime',
addHtml: 'winningTime'
},
{
label: '转发群限制',
type: 'radio',
name: 'groupType',
optionList: [
{
text: '无限制',
id: 0
},
{
text: '限制群',
id: 1
},
],
optionId: 'id',
optionLabel: 'text',
suffixSlot: 'groupType',
},
{
label: '关联奖品',
name: 'prizeId',
addHtml: 'prizeId'
}
},
{
label: '数字上限',
name: 'maxNumber',
type: 'select',
optionList: generateOptionsArray(),
optionId: 'optionId',
optionLabel: 'optionLabel',
},
{
label: '中奖数字',
name: 'winningNumber',
type: 'select',
optionList: [
{
optionId: 0,
optionLabel: '随机'
},
...generateOptionsArray()
],
optionId: 'optionId',
optionLabel: 'optionLabel',
},
{
label: '接龙结束时间',
type: 'radio',
name: 'endTimeType',
optionList: [
{
text: '无限制',
id: 0
},
{
text: '选择时间',
id: 1
},
],
optionId: 'id',
optionLabel: 'text',
suffixSlot: 'endTimeType',
},
{
label: '接龙开奖时间',
addHtml: 'showTime'
},
{
label: '转发群限制',
type: 'radio',
name: 'groupType',
optionList: [
{
text: '无限制',
id: 0
]
}
export const rule = that => {
return {
type: [{ required, message: '请选择接龙种类', trigger }],
merchantId: [{ required, message: '请选择所属渠道', trigger }],
description: [{ required, message: '请输入群接龙说明', trigger }],
cardTitle: [{ required, message: '请输入卡片标题', trigger }],
cardCover: [{ required, message: '请上传卡片封面', trigger }],
maxNumber: [{ required }],
winningNumber: [{ required }],
endTimeType: [{
required,
validator: (rule, value, callback) => {
if (value == 1 && !that.configForm.endTime) {
callback(new Error('请选择接龙结束时间'))
}
callback()
},
{
text: '限制群',
id: 1
}],
winningTime: [{ required, message: '请选择接龙开奖时间', trigger }],
groupType: [{
required,
validator: (rule, value, callback) => {
if (value == 1 && !that.configForm.groupList.length) {
callback(new Error('请选择群'))
}
callback()
},
],
optionId: 'id',
optionLabel: 'text',
suffixSlot: 'groupType',
},
]
export const rule = {
name: [{ required: true, message: '请输入问卷名称', trigger: 'change' }],
merchantId: [{ required: true, message: '请选择所属渠道', trigger: 'change' }],
cardTitle: [{ required: true, message: '请输入卡片标题', trigger: 'change' }],
cardCover: [{ required: true, message: '请上传卡片封面', trigger: 'change' }],
}],
prizeId: [{ required, message: '请选择关联奖品', trigger }]
}
}
export const afterRangePickerOptions = {
......
<template>
<div
@click="chooseRed(data.id)"
:class="['item',{'disabled':disabled},{'active':configForm.prizeId == data.id}]"
>
<div class="radio">
<img src="@/assets/red-radio.png" />
</div>
<div class="icon">
<img src="@/assets/activity-2.png" />
</div>
<div class="icon"></div>
<div class="title">{{ data.couponName }}</div>
<template v-if="[2,3,6].includes(data.effectiveType)">
<div class="type">有效期:
<template v-if="data.effectiveType == 2">
{{ data.effectiveStartTime ? data.effectiveStartTime.split(' ')[0] : '' }}~{{ data.effectiveEndTime ? data.effectiveEndTime.split(' ')[0] : '' }}
</template>
<template v-if="data.effectiveType == 3">
无限制
</template>
<template v-if="data.effectiveType == 6">
{{ data.effectiveDays }}天
</template>
</div>
</template>
<div class="time">使用途径: {{ data.useChannel == 1 ? '线上商品' : '到店核销' }}</div>
<div class="status flex">数量:{{ data.residueAmount || 0 }}</div>
</div>
</template>
<script type='text/ecmascript-6'>
import * as dayjs from 'dayjs'
export default {
name: '',
props: {
data: {
type: Object,
default: () => { }
},
configForm: {
type: Object,
default: () => { }
},
disabled: Boolean
},
data () {
return {
dayjs,
}
},
mounted () {
},
methods: {
chooseRed (id) {
const { prizeId } = this.configForm,
{ disabled } = this
if (disabled) return
if (prizeId && prizeId == id) id = ''
this.$emit('choose', id)
}
}
}
</script>
<style scoped lang='scss'>
.item {
width: 100%;
height: 96px;
background: #fff;
border-radius: 4px;
box-sizing: border-box;
cursor: pointer;
padding: 0 16px;
font-size: 12px;
color: #999999;
line-height: 17px;
position: relative;
user-select: none;
.icon {
position: absolute;
right: 0;
bottom: 0;
width: 28px;
height: 28px;
}
.radio {
display: none;
}
.title {
font-weight: 500;
font-size: 14px;
color: #333333;
padding: 10px 0 7px;
}
&:hover {
opacity: 0.95;
}
}
.active {
border-color: #5850ff;
.radio {
display: block;
position: absolute;
right: 0;
top: 0;
width: 16px;
height: 16px;
background-color: #5850ff;
border-radius: 0 0 0 4px;
overflow: hidden;
}
&::after{
content:'';
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
border: 1px solid #5850ff;
box-sizing: border-box;
}
}
.disabled {
cursor: not-allowed;
}
</style>
\ No newline at end of file
<template>
<div
@click="chooseRed(data.equityClassId)"
:class="['item',{'disabled':disabled},{'active':configForm.prizeId == data.equityClassId}]"
>
<div class="radio">
<img src="@/assets/red-radio.png" />
</div>
<div class="icon">
<img src="@/assets/activity-3.png" />
</div>
<div class="title">品牌:{{ data.equityName }}</div>
<div class="time">商品名称:{{data.orderCode}}</div>
<div class="status flex">券面额:{{data.freeDay }}天</div>
</div>
</template>
<script type='text/ecmascript-6'>
import * as dayjs from 'dayjs'
export default {
name: '',
props: {
data: {
type: Object,
default: () => { }
},
configForm: {
type: Object,
default: () => { }
},
disabled: Boolean
},
data () {
return {
dayjs,
}
},
mounted () {
},
methods: {
chooseRed (id) {
const { prizeId } = this.configForm,
{ disabled } = this
if (disabled) return
if (prizeId && prizeId == id) id = ''
this.$emit('choose', id)
}
}
}
</script>
<style scoped lang='scss'>
.item {
width: 100%;
height: 75px;
background: #fff;
border-radius: 4px;
box-sizing: border-box;
cursor: pointer;
padding: 0 16px;
font-size: 12px;
color: #999999;
line-height: 17px;
position: relative;
user-select: none;
.icon {
position: absolute;
right: 0;
bottom: 0;
width: 28px;
height: 28px;
}
.radio {
display: none;
}
.title {
padding-top: 12px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
&:hover {
opacity: 0.95;
}
}
.active {
.radio {
display: block;
position: absolute;
right: 0;
top: 0;
width: 16px;
height: 16px;
background-color: #5850ff;
border-radius: 0 0 0 4px;
overflow: hidden;
}
&::after{
content:'';
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
border: 1px solid #5850ff;
box-sizing: border-box;
}
}
.disabled {
cursor: not-allowed;
}
</style>
\ No newline at end of file
<template>
<div class="tab-box">
<el-tabs
ref="tabs"
v-model="prizeType"
@tab-click="handleClick"
>
<template v-for="(i,index) in prizeList">
<el-tab-pane
:key="index"
:label="i.label"
:name="i.name"
>
<template v-if="dataList[i.name].list.length">
<div class="content-box">
<template v-for="(item,ind) in dataList[i.name].list">
<template>
<component
:key="ind"
:is="{
3: 'EquityItem',
2: 'CouponItem',
1: 'RedEnvelopeItem'
}[prizeType]"
:configForm="form"
:data="item"
@choose="choose"
></component>
</template>
</template>
</div>
<el-pagination
background
@current-change="handleCurrentChange"
:page-size="15"
layout="total, prev, pager, next"
:total="dataList[i.name].total"
>
</el-pagination>
</template>
<template v-else>
<div class="nothing">
<img :src="url">
暂无数据
</div>
</template>
</el-tab-pane>
</template>
</el-tabs>
</div>
</template>
<script type='text/ecmascript-6'>
import url from '@/assets/empty.png'
import EquityItem from './EquityItem.vue'
import CouponItem from './CouponItem.vue'
import RedEnvelopeItem from './RedEnvelopeItem.vue'
export default {
name: 'prize-box',
components: { RedEnvelopeItem, EquityItem, CouponItem },
props: {
value: [String, Number],
form: {
type: Object,
default: () => { }
}
},
data () {
return {
url,
prizeType: 1,
prizeList: [
{ label: '红包活动', name: 1 },
{ label: '商城券', name: 2 },
{ label: '权益卡券', name: 3 },
],
dataList: {
1: {
list: [],
total: 0,
pageNum: 1
},
2: {
list: [],
total: 0,
pageNum: 1
},
3: {
list: [],
total: 0,
pageNum: 1
}
}
}
},
mounted () {
this.init()
},
methods: {
reset () {
this.dataList = this.$options.data.call(this).dataList
this.handleClick()
},
init () {
const { prizeType } = this
this.$nextTick(() => {
this.$refs.tabs.$emit('tab-click', { name: prizeType })
})
},
handleClick () {
this.resetActivePosition(this.$refs.tabs.$el)
this.getActivityList()
},
resetActivePosition ($el) { // tabs的样式修改
this.$nextTick(() => {
const activeEl = $el.querySelector('.el-tabs__item.is-active'),
lineEl = $el.querySelector('.el-tabs__active-bar'),
style = getComputedStyle(activeEl),
pl = style.paddingLeft.match(/\d+/)[0] * 1,
pr = style.paddingRight.match(/\d+/)[0] * 1,
w = style.width.match(/\d+/)[0] * 1
lineEl.style.transform = 'translateX(' + (activeEl.offsetLeft + pl) + 'px)'
lineEl.style.width = (w - pl - pr) + 'px'
})
},
handleCurrentChange (e) {
console.log(e)
},
async getActivityList () {
const { prizeType: index } = this,
{ merchantId } = this.form,
{ pageNum } = this.dataList[index],
targetApi = {
3: 'getEquityActivityList',
2: 'getMerchantCouponList',
1: 'getActivityRedEnvelopeList'
}[index],
params = {
merchantId,
pageNum,
pageSize: 15
}
if (!merchantId) return
try {
this.$loading()
// this.activityObj.loading = true
const res = await this.$apis.questionnaire[targetApi](params)
let data = res
this.dataList[index].list = index == 2 ? data.list : data
// if (index == 2) {
// data = [...this.activityObj.data, ...res.list]
// this.activityObj.total = res.total
// }
this.$loading().close()
} catch (error) {
console.log(error)
this.$loading().close()
}
},
choose (e) {
this.$emit('choose', e)
}
}
}
</script>
<style scoped lang='scss'>
.tab-box {
width: 824px;
padding: 0 20px 20px;
background: #f9f9f9;
/deep/.el-tabs--top {
line-height: 56px;
}
/deep/.el-tabs__item.is-active {
font-weight: 700;
}
/deep/.el-pager {
line-height: 28px;
}
.content-box {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
margin-top: 5px;
}
.nothing {
display: flex;
flex-direction: column;
padding: 4px 0;
justify-content: center;
align-items: center;
color: #909399;
font-size: 14px;
img {
margin-bottom: 12px;
width: 64px;
height: 40px;
}
}
}
</style>
\ No newline at end of file
<template>
<div
@click="chooseRed(data.id)"
:class="['item',{'disabled':disabled},{'active':configForm.prizeId == data.id}]"
>
<div class="radio">
<img src="@/assets/red-radio.png" />
</div>
<div class="icon">
<img src="@/assets/activity-1.png" />
</div>
<div class="title">{{ data.activityName }}</div>
<div class="type">活动形式:{{ {0: '随机红包', 1: '九宫格', 2: '翻牌', 3: '大转盘' }[data.activityType] }}</div>
<div class="time">活动时间:{{dayjs(data.activityStartTime).format('YYYY/MM/DD')}}-{{dayjs(data.activityEndTime).format('YYYY/MM/DD')}}</div>
<div class="status">状态:{{ {0: '活动待进行', 1: '活动进行中', 2: '红包已用完', 3: '活动已结束' }[data.activityStatus] }}</div>
</div>
</template>
<script type='text/ecmascript-6'>
import * as dayjs from 'dayjs'
export default {
name: '',
props: {
data: {
type: Object,
default: () => { }
},
configForm: {
type: Object,
default: () => { }
},
disabled: Boolean
},
data () {
return {
dayjs,
}
},
mounted () {
},
methods: {
chooseRed (id) {
const { prizeId } = this.configForm,
{ disabled } = this
if (disabled) return
if (prizeId && prizeId == id) id = ''
this.$emit('choose', id)
}
}
}
</script>
<style scoped lang='scss'>
.item {
width: 100%;
height: 96px;
background: #fff;
border-radius: 4px;
box-sizing: border-box;
cursor: pointer;
padding: 0 16px;
font-size: 12px;
color: #999999;
line-height: 17px;
position: relative;
user-select: none;
.radio {
display: none;
}
.icon {
position: absolute;
right: 0;
bottom: 0;
width: 28px;
height: 28px;
}
.title {
font-weight: 500;
font-size: 14px;
color: #333333;
padding: 10px 0 7px;
}
&:hover {
opacity: 0.95;
}
}
.active {
border-color: #5850ff;
.radio {
display: block;
position: absolute;
right: 0;
top: 0;
width: 16px;
height: 16px;
background-color: #5850ff;
border-radius: 0 0 0 4px;
overflow: hidden;
}
&::after {
content: '';
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
border: 1px solid #5850ff;
box-sizing: border-box;
}
}
.disabled {
cursor: not-allowed;
}
</style>
\ No newline at end of file
......@@ -4,6 +4,7 @@
type="primary"
size="small"
@click="editForm"
icon="el-icon-plus"
>新建接龙</el-button>
<div class="container">
<div class="sticky">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!