Commit 842c5b83 by 李伟康

调查问卷需求

1 parent 9d9aac99
...@@ -7,6 +7,11 @@ html { ...@@ -7,6 +7,11 @@ html {
overflow: hidden; overflow: hidden;
background-color: #f4f5fa; background-color: #f4f5fa;
} }
img{
width: 100%;
height: 100%;
vertical-align: top;
}
.el-message { .el-message {
z-index: 3000 !important; z-index: 3000 !important;
} }
......
export default {
data () {
return {
merchantObj: {
nothing: false,
data: [],
currentPage: 1,
name: '',
loading: false,
total: 0
}
}
},
methods: {
selectFocus () {
const { configForm } = this
if (!configForm.merchantId) {
this.merchantObj.data = []
this.merchantObj.name = ''
this.merchantObj.currentPage = 1
this.getMerchantList()
}
},
onReachBottom () {
const { total, currentPage } = this.merchantObj
if (Math.ceil(total / 50) > currentPage) {
this.merchantObj.currentPage += 1
this.getMerchantList()
} else this.merchantObj.nothing = true
},
remoteMethod (val) {
this.merchantObj.name = val
if (val) {
this.merchantObj.loading = true
this.configForm.merchantId = ''
this.merchantObj.nothing = false
this.merchantObj.data = []
this.merchantObj.currentPage = 1
this.getMerchantList(val)
}
},
async getMerchantList () {
const { currentPage, data, name } = this.merchantObj,
{ list, total } = await this.$apis.redenvelope.getRedEnvelopeMerchantList({
currentPage,
merchantName: name
})
this.merchantObj.total = total
list && list.map(e => {
data.push({
confId: e.merchantNo,
confName: e.merchantName,
})
})
this.merchantObj.data = data
this.merchantObj.loading = false
},
},
directives: {
'reachbottom': {
inserted (el, binding) {
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
SELECTWRAP_DOM.addEventListener('scroll', function () {
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight
if (condition) binding.value()
})
}
}
},
}
\ No newline at end of file \ No newline at end of file
import getMerchantListMixin from './getMerchantListMixin'
export {
getMerchantListMixin
}
\ No newline at end of file \ No newline at end of file
<template> <template>
<div> <div class="layout">
<input <div class="tabs flex">
type="file" <template v-for="(i,index) in tabs">
@change="handleFileUpload" <template>
accept=".xlsx" <div
/>
<table v-if="parsedData.length > 0">
<!-- <thead>
<tr>
<th
v-for="(header, index) in parsedData[0]"
:key="index" :key="index"
>{{ header }}</th> :class="['tab flex',{'active':step == index + 1}]"
</tr>
</thead> -->
<tbody>
<tr
v-for="(row, rowIndex) in parsedData"
:key="rowIndex"
> >
<td <template v-if="index != 0">
v-for="(cell, cellIndex) in row" <div class="line"></div>
:key="cellIndex" </template>
>{{ cell }}</td> <template v-if="step == 2 && index == 0">
</tr> <div class="icon finish">
</tbody> <span class="el-icon-check"></span>
</table> </div>
</template>
<template v-else>
<div class="icon">{{index + 1}}</div>
</template>
{{i}}
</div>
</template>
</template>
</div>
<div class="content">
<step-one
v-show="step == 1"
ref="stepOne"
/>
<step-two
v-show="step == 2"
ref="stepTwo"
/>
</div>
<GLFooter class="footer">
<el-button
@click="handleCancel"
size="medium"
>{{step == 1?'取消':'上一步'}}</el-button>
<el-button
type="primary"
@click="handleConfirm"
size="medium"
>{{step == 1?'下一步':'提交'}}</el-button>
</GLFooter>
</div> </div>
</template> </template>
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import * as XLSX from 'xlsx' import StepOne from './components/StepOne.vue'
import StepTwo from './components/StepTwo.vue'
export default { export default {
components: { StepOne, StepTwo },
name: '', name: '',
data () { data () {
return { return {
parsedData: [], parsedData: [],
step: 1,
tabs: ['基本信息', '配置内容']
} }
}, },
mounted () { mounted () {
}, },
methods: { methods: {
handleFileUpload (event) { handleCancel () {
const [file] = event.target.files const { step } = this
if (file) { step == 1 ? this.$router.go(-1) : this.step = 1
const reader = new FileReader() },
reader.onload = (e) => { handleConfirm () {
try { const { step, $refs: {
const data = e.target.result stepOne,
if (data) { stepTwo
const workbook = XLSX.read(data, { type: 'array' }), } } = this
firstSheetName = workbook.SheetNames[0], if (step == 1) {
worksheet = workbook.Sheets[firstSheetName] stepOne.formRef().validate(valid => {
this.parsedData = XLSX.utils.sheet_to_json(worksheet, { header: 1 }) if (valid) this.step = 2
console.log(this.parsedData) })
} else throw 'File data is empty.' } else {
} catch (error) { console.log(stepTwo)
this.$message.error(error || 'Error reading the file')
}
} }
reader.readAsArrayBuffer(file)
} }
},
} }
} }
</script> </script>
<style scoped lang='scss'> <style scoped lang='scss'>
.layout {
position: absolute;
width: 100%;
height: calc(100vh - 48px);
top: 0;
left: 0;
.tabs {
height: 64px;
justify-content: center;
.tab {
font-size: 16px;
color: #000000a6;
line-height: 24px;
.icon {
width: 32px;
height: 32px;
border-radius: 100%;
border: 1px solid #c6c6c6;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
margin-right: 8px;
font-size: 14px;
color: #c6c6c6;
}
.finish {
border-color: #5850ff !important;
border-width: 2px;
}
.line {
width: 160px;
height: 1px;
background: #e5e5e5;
margin: 0 8px;
}
}
.active {
font-weight: 500;
color: #000000d9;
.icon {
background: #5850ff;
border-color: #5850ff;
color: #fff;
}
}
.el-icon-check {
color: #5850ff;
font-size: 18px;
font-weight: 700;
}
}
.content {
height: calc(100% - 136px);
background-color: #fff;
margin: 0 24px;
border-radius: 0 4px 4px 4px;
}
.footer {
padding: 16px 0;
}
}
</style> </style>
\ No newline at end of file \ No newline at end of file
<template>
<el-scrollbar class="step-box">
<div class="step-content">
<glsx-combi-form
ref="formRef"
:isEdit="true"
:isBlock="true"
:formObj="form"
:formData="formData"
:formRules="rule"
>
<template #merchantId>
<el-select
v-model="form.merchantId"
placeholder="请选择"
filterable
remote
:remote-method="remoteMethod"
v-reachbottom="onReachBottom"
@focus="selectFocus"
:loading="loading"
>
<el-option
v-for="item in merchantObj.data"
:key="item.confId"
:label="item.confName"
:value="item.confId"
></el-option>
<template v-if="nothing">
<div class="nothing">到底了!</div>
</template>
</el-select>
</template>
<template #activity>
<div class="tabs flex">
<template v-for="(i,index) in tabs">
<template>
<div
@click="changeActivity(index)"
:class="['tab',{active:index == tabIndex}]"
:key="index"
>{{i}}</div>
</template>
</template>
</div>
<div
class="activity-box"
:key="activityKey"
>
<template v-for="(i,index) in activityList">
<template>
<div
@click="chooseRed(i.id)"
:key="index"
:class="['item',{'active': form.activityId == i.id}]"
>
<div class="icon">
<img src="@/assets/red-radio.png" />
</div>
<div class="title">{{ i.activityName }}</div>
<div class="type">活动形式:{{ {
0: '随机红包', 1: '九宫格', 2: '翻牌', 3: '大转盘'
}[i.activityType] }}</div>
<div class="time">活动时间:{{dayjs(i.activityStartTime).format('YYYY/MM/DD')}} - {{dayjs(i.activityEndTime).format('YYYY/MM/DD')}}</div>
<div class="status">状态:{{ {
0: '活动待进行', 1: '活动进行中', 2: '红包已用完', 3: '活动已结束'
}[i.activityStatus] }}</div>
</div>
</template>
</template>
</div>
</template>
</glsx-combi-form>
</div>
</el-scrollbar>
</template>
<script type='text/ecmascript-6'>
import * as dayjs from 'dayjs'
import { getMerchantListMixin } from '@/mixins'
export default {
name: 'StepOne',
mixins:[getMerchantListMixin],
data () {
return {
dayjs,
configForm: {
merchantId: '',
activityImg: ''
},
rule: {
activityName: [{ required: true, message: '请输入问卷名称', trigger: 'change' }],
merchantId: [{ required: true, message: '请选择所属渠道', trigger: 'change' }],
activityTime: [{ required: true, message: '请输入卡片标题', trigger: 'change' }],
activityImg: [{ required: true, message: '请上传卡片封面', trigger: 'change' }],
},
formData: [
{
label: '问卷名称',
name: 'activityName',
type: 'input',
maxlength: 50,
},
{
label: '所属渠道',
type: 'select',
name: 'merchantId',
addHtml: 'merchantId'
},
{
label: '卡片标题',
name: 'activityTime',
type: 'input',
maxlength: 20,
},
{
label: '卡片封面',
name: 'activityImg',
type: 'upload',
width: '320px',
// limitSize: 10,
maxPhotoNum: 1,
suffixSlot: 'activityImg',
handleUpload: (e, file, targetItem) => {
const imgFile = e.target.result,
base64 = file.name.split('.')[file.name.split('.').length - 1] + '@' + imgFile.split(',')[1]
this.$apis.common.pictureUpload({ file: base64, fileType: 'image' }).then(res => {
this.configForm[targetItem.name] = res
this.formRef().validateField(targetItem.name)
})
}
},
{
label: '关联活动',
addHtml: 'activity'
}
],
tabs: ['权益卡试用', '商城券', '红包活动'],
tabIndex: 0,
activityList: new Array(20).fill({}),
activityKey: Date.now(),
merchantObj: {
nothing: false,
data: [],
currentPage: 1,
name: '',
loading: false,
total: 0
}
}
},
mounted () {
},
methods: {
formRef () {
return this.$refs.formRef.$refs.formRef
},
changeActivity (index) {
this.tabIndex = index
}
},
}
</script>
<style scoped lang='scss'>
.step-box {
width: 100%;
height: 100%;
box-sizing: border-box;
/deep/.el-scrollbar__wrap {
&::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
}
}
.step-content {
padding-top: 32px;
}
/deep/.el-form-item__content {
width: fit-content;
max-width: calc(100% - 154px);
}
/deep/.activity-img,
/deep/.muti-imgs {
width: 104px;
height: 104px;
background: #0000000a;
border: 1px dashed #00000026;
border-radius: 4px;
input {
margin-top: 0;
}
.img-w-h,
.img-btns {
width: 100%;
height: 100%;
}
}
.tabs {
height: 36px;
background: #f8f8f8;
border-radius: 4px;
padding: 0 2px;
width: fit-content;
.tab {
height: 32px;
font-size: 14px;
color: #666666;
padding: 0 16px;
cursor: pointer;
transition: all 0.25s;
&:hover {
opacity: 0.85;
}
}
.active {
background: #ffffff;
border-radius: 3px;
font-weight: 500;
color: #5850ff;
}
}
.activity-box {
display: flex;
gap: 16px;
flex-wrap: wrap;
margin-top: 16px;
.item {
width: 282px;
height: 132px;
background: #f9f9f9;
border-radius: 4px;
border: 2px solid #f9f9f9;
box-sizing: border-box;
cursor: pointer;
padding: 0 16px;
font-size: 14px;
color: #666666;
line-height: 20px;
position: relative;
.icon {
display: none;
}
div {
margin-top: 8px;
}
.title {
font-weight: 500;
font-size: 14px;
color: #333333;
padding-top: 4px;
}
&:hover {
opacity: 0.95;
}
}
.active {
border-color: #5850ff;
.icon {
display: block;
position: absolute;
right: 0;
bottom: 0;
width: 16px;
height: 16px;
background-color: #5850ff;
}
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<div class="step-box">
2
<!-- <input
type="file"
@change="handleFileUpload"
accept=".xlsx"
/> -->
</div>
</template>
<script type='text/ecmascript-6'>
import * as XLSX from 'xlsx'
export default {
name: 'StepTwo',
data () {
return {
}
},
mounted () {
},
methods: {
handleFileUpload (event) {
const [file] = event.target.files
if (file) {
const reader = new FileReader()
reader.onload = e => {
try {
const data = e.target.result
if (data) {
const workbook = XLSX.read(data, { type: 'array' }),
[firstSheetName] = workbook.SheetNames,
worksheet = workbook.Sheets[firstSheetName]
this.parsedData = XLSX.utils.sheet_to_json(worksheet, { header: 1 })
console.table(this.parsedData)
} else throw '数据不能为空'
} catch (error) {
this.$message.error(error || '读取文件时出错')
}
}
reader.readAsArrayBuffer(file)
}
},
}
}
</script>
<style scoped lang='scss'>
</style>
\ No newline at end of file \ No newline at end of file
...@@ -48,12 +48,12 @@ ...@@ -48,12 +48,12 @@
:loading="loading" :loading="loading"
> >
<el-option <el-option
v-for="item in merchantList" v-for="item in merchantObj.data"
:key="item.confId" :key="item.confId"
:label="item.confName" :label="item.confName"
:value="item.confId" :value="item.confId"
></el-option> ></el-option>
<template v-if="nothing"> <template v-if="merchantObj.nothing">
<div class="nothing">到底了!</div> <div class="nothing">到底了!</div>
</template> </template>
</el-select> </el-select>
...@@ -148,8 +148,10 @@ export const afterRangePickerOptions = { ...@@ -148,8 +148,10 @@ export const afterRangePickerOptions = {
} }
import commonFun from '../common/fun.js' import commonFun from '../common/fun.js'
import * as dayjs from 'dayjs' import * as dayjs from 'dayjs'
import { getMerchantListMixin } from '@/mixins'
export default { export default {
mixins:[getMerchantListMixin],
name: '', name: '',
props: { props: {
editObj: { editObj: {
...@@ -204,14 +206,8 @@ export default { ...@@ -204,14 +206,8 @@ export default {
} }
], ],
}, },
merchantList: [],
fileName: '', fileName: '',
fileError: '', fileError: '',
loading: false,
currentPage: 1,
total: 0,
nothing: false,
merchantName: ''
} }
}, },
mounted () { mounted () {
...@@ -223,46 +219,7 @@ export default { ...@@ -223,46 +219,7 @@ export default {
if (n.id) this.getRedEnvelopeActivityDetail(n.id) if (n.id) this.getRedEnvelopeActivityDetail(n.id)
} }
}, },
directives: {
'reachbottom': {
inserted (el, binding) {
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
SELECTWRAP_DOM.addEventListener('scroll', function () {
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight
if (condition) binding.value()
})
}
}
},
methods: { methods: {
selectFocus () {
const { configForm } = this
if (!configForm.merchantId) {
this.merchantList = []
this.merchantName = ''
this.currentPage = 1
this.getMerchantList()
}
},
onReachBottom () {
const { total, currentPage } = this
if (Math.ceil(total / 50) > currentPage) {
this.currentPage += 1
this.getMerchantList()
} else this.nothing = true
},
remoteMethod (val) {
this.merchantName = val
if (val) {
this.loading = true
this.configForm.merchantId = ''
this.nothing = false
this.merchantList = []
this.currentPage = 1
this.getMerchantList(val)
}
},
async getRedEnvelopeActivityDetail (id) { async getRedEnvelopeActivityDetail (id) {
try { try {
const { configForm } = this, const { configForm } = this,
...@@ -287,22 +244,6 @@ export default { ...@@ -287,22 +244,6 @@ export default {
this.$message.error(error) this.$message.error(error)
} }
}, },
async getMerchantList () {
const { currentPage, merchantList, merchantName } = this,
{ list, total } = await this.$apis.redenvelope.getRedEnvelopeMerchantList({
currentPage,
merchantName
})
this.total = total
list && list.map(e => {
merchantList.push({
confId: e.merchantNo,
confName: e.merchantName,
})
})
this.merchantList = merchantList
this.loading = false
},
handleClose () { handleClose () {
this.configForm = this.$options.data.call(this).configForm this.configForm = this.$options.data.call(this).configForm
this.disabled = false this.disabled = false
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!