Commit 48f98cb9 by 李伟康

提交问卷需求

1 parent e84b6249
......@@ -34,6 +34,24 @@ export default {
data: params
})
},
/**
*导出调查问卷列表
*/
exportQuestionnaireList (params) {
params.method = 'marketing.api.activityQuestionnaireForm.export'
return http({
url,
data: params
})
},
/**导出用户调查问卷 */
exportUserQuestionnaireList(params) {
params.method = 'marketing.api.activityQuestionnaireUserForm.export'
return http({
url,
data: params
})
},
/**新增调查问卷 */
addQuestionnaire (params) {
params.method = 'marketing.api.activityQuestionnaireForm.add'
......@@ -52,6 +70,16 @@ export default {
data: params
})
},
/**
*
*/
getQuestionnaireDetail (params = {}) {
params.method = 'marketing.api.activityQuestionnaireForm.detail'
return http({
url,
data: params
})
},
/**权益卡试用 */
getEquityActivityList (params) {
params.method = 'scrm.api.equity.open.card.price.list.by.merchantid'
......
......@@ -11,6 +11,8 @@ export default {
}
}
},
mounted () {
},
methods: {
selectFocus () {
const { configForm } = this
......@@ -61,7 +63,7 @@ export default {
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
const condition = (this.scrollHeight - this.scrollTop) <= this.clientHeight
if (condition) binding.value()
})
}
......
......@@ -6,12 +6,17 @@
:before-close="handleClose"
:visible.sync="dataObj.show"
>
<el-button
type="default"
@click="handleExport"
>导出</el-button>
<GLTable
:tableData="tableData"
:noDataImg="url"
:tableParams="tableParams"
:tableTotal="tableTotal"
:pageConf="pageConf"
ref="listRef"
>
</GLTable>
</GLDialog>
......@@ -19,6 +24,7 @@
<script type='text/ecmascript-6'>
import url from '@/assets/empty.png'
import { exportFn } from '@/common/constant'
export default {
name: '',
props: {
......@@ -34,7 +40,26 @@ export default {
tableParams: {
listName: 'data',
tableOption: false,
tableColumns: [
tableColumns: []
},
tableData: [],
tableTotal: 0
}
},
mounted () {
},
watch: {
'dataObj' (n) {
if (n.id) {
this.setTableColumns(n.id)
this.refreshTable()
}
}
},
methods: {
async setTableColumns (id) {
const data = await this.$apis.questionnaire.getQuestionnaireDetail({ id }),
tableColumns = [
{
label: '手机号码',
prop: 'phone',
......@@ -51,20 +76,16 @@ export default {
minWidth: 100
},
]
},
tableData: [],
tableTotal: 0
}
},
mounted () {
},
watch: {
'dataObj' (n) {
if (n.id) this.refreshTable()
}
},
methods: {
data.questions.map(e => {
tableColumns.push({
label: e.text,
prop: `${e.num}_prop`,
minWidth: 180
})
})
this.tableParams.tableColumns = tableColumns
console.log(data)
},
async refreshTable (pageCon) {
pageCon && (this.pageConfig = pageCon)
const { id } = this.dataObj,
......@@ -75,20 +96,30 @@ export default {
...this.pageConfig
}
const { data, count } = await this.$apis.questionnaire.getQuestionnaireDetailPage(params)
data.map(e => {
e.questions.map(i => {
e[`${i.num}_prop`] = i.answer
})
})
this.tableData = data || []
this.tableTotal = count || 0
},
handleClose () {
this.$emit('update:dataObj', {})
},
handleExport () {
const { id } = this.dataObj
this.$apis.questionnaire.exportUserQuestionnaireList({ formId: id, ...this.$refs.listRef.page }).then(res => {
exportFn(res)
})
}
}
}
</script>
<style scoped lang='scss'>
.link {
/deep/.el-form-item--small {
width: fit-content;
}
.el-button {
display: flex;
margin: 0 0 8px auto;
}
</style>
\ No newline at end of file
......@@ -190,13 +190,13 @@ export default {
}
},
mounted () {
this.onReachBottom(this)
this.onActivityReachBottom(this)
},
methods: {
formRef () {
return this.$refs.formRef.$refs.formRef
},
onReachBottom (_this) {
onActivityReachBottom (_this) {
this.$refs.stepBox.wrap.addEventListener('scroll', function () {
const condition = this.scrollHeight - this.scrollTop - 20 <= this.clientHeight,
{ index } = _this.tabsObj,
......@@ -214,7 +214,7 @@ export default {
changeActivity (index) {
const { merchantId } = this.configForm
if (this.tabsObj.index == index) return
if (!merchantId) return this.$message.error('请先选择所属渠道')
if (!merchantId) return this.$message.error('请选择所属渠道')
this.tabsObj.index = index
this.configForm.activityId = ''
this.configForm.activityType = ''
......
......@@ -257,11 +257,16 @@ export default {
close () {
this.configForm = this.$options.data.call(this).configForm
this.$refs.configRef.resetFields()
this.errorList = []
this.$emit('update:show', false)
},
handleFileUpload (event) {
const [file] = event.target.files
if (file) {
if (this.configForm.cascaderValue.length) {
this.$refs.file.value = ''
return this.$message.error('已有数据,不能批量导入!')
}
const reader = new FileReader()
reader.onload = e => {
try {
......@@ -272,27 +277,41 @@ export default {
[firstSheetName] = workbook.SheetNames,
worksheet = workbook.Sheets[firstSheetName],
parsedData = XLSX.utils.sheet_to_json(worksheet, { header: 1 }),
errorList = []
let str = ''
parsedData.map((i, rowNum) => {
let [row] = i
formattedData = []
parsedData.map(i => {
const [row] = i
if (row) {
const [one, two, three] = row.split('/')
if (!one || !two) errorList.push(`第${rowNum + 1}行第${one ? '2' : '1'}列数据异常,请重新输入`)
str += `${one || ''}/${two || ''}/${three || ''}${rowNum == parsedData.length - 1 ? '' : '\n'}`
const [one, two, three] = String(row).split('/')
formattedData.push(`${one || ''}/${two || ''}${three ? `/${three}` : ''}`)
}
})
this.configForm.cascaderValue = str
this.errorList = errorList
this.configForm.cascaderValue = formattedData.join('\n')
this.$refs.configRef.clearValidate('value')
} else throw '数据不能为空'
} catch (error) {
console.log(error)
this.$message.error(error || '读取文件时出错')
}
}
reader.readAsArrayBuffer(file)
}
},
checkData (data) {
const errorList = [],
list = data.split('\n'),
[, , hasThree] = list[0].split('/')
list.forEach((row, rowNum) => {
if (rowNum != 0) {
const [one, two] = String(row).split('/')
if (hasThree) {
if (!one || !two) errorList.push(`第${rowNum + 1}行第${(one ? '2' : '1')}列数据异常,请重新输入`)
}
else if (!one) errorList.push(`第${rowNum + 1}行第1列数据异常,请重新输入`)
}
})
if (errorList.length) this.errorList = [errorList[0]]
return errorList.length
},
delError (index) {
this.errorList.splice(index, 1)
},
......@@ -313,14 +332,18 @@ export default {
{ userInfoFields } = this
this.$refs.configRef.validate(valid => {
if (valid) {
this.errorList = []
let option = this.configForm[inputKeyObject[type]],
data = type == 3 ? option : option.split('\n'),
itemValue = ''
if (type == 2 || type == 5) itemValue = []
if (type == 5) {
data.splice(0, 1)
if (data.length < 2) return this.$message.error('数据不能为空')
const [, two, three] = data[0].split('/')
option = data.join('\n')
data = this.transformData(data)
if (this.checkData(option)) return
data.splice(0, 1)
data = this.transformData(data, three ? 3 : two ? 2 : 1)
userInfoField = userInfoFields.join('/')
}
this.$emit('addQuestions', {
......@@ -336,25 +359,24 @@ export default {
}
})
},
transformData (data) {
transformData (data, childrenDepth) {
const result = []
data.forEach((item, index) => {
data.forEach(item => {
const levels = item.split('/')
let currentLevel = result
for (let i = 0; i < levels.length; i++) {
for (let i = 0; i < childrenDepth; i++) {
const label = levels[i],
value = label,
existingOption = currentLevel.find((option) => option.label === label)
if (existingOption) {
if (i === levels.length - 1) {
if (i === childrenDepth - 1) {
continue
}
currentLevel = existingOption.children
} else {
const newOption = { label, value, children: [] }
currentLevel.push(newOption)
if (i === levels.length - 1) {
if (label && value) currentLevel.push(newOption)
if (i === childrenDepth - 1) {
delete newOption.children
}
currentLevel = newOption.children
......
......@@ -18,6 +18,10 @@
path: '/questionnaire/add'
})"
>新建问卷</el-button>
<el-button
type="default"
@click="handleExport"
>导出</el-button>
</div>
</div>
</div>
......@@ -86,13 +90,14 @@
<script type='text/ecmascript-6'>
import url from '@/assets/empty.png'
import DataTable from './components/DataTable/index.vue'
import { exportFn } from '@/common/constant'
export default {
name: 'RedEnvelopeConfig',
name: 'Questionnaire',
components: { DataTable },
data () {
return {
url,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' },
searchForm: {
merchantName: '',
name: '',
......@@ -200,6 +205,11 @@ export default {
this.handleSearch()
} else this.$message.error('操作失败,请重试。')
},
handleExport () {
this.$apis.questionnaire.exportQuestionnaireList({ ...this.searchForm, ...this.$refs.listRef.page }).then(res => {
exportFn(res)
})
}
}
}
</script>
......
......@@ -211,8 +211,11 @@ export default {
id: e.id || ''
}
},
handleExport (row) {
this.$apis.redenvelope.exportActivityRedEnvelope(this.getParams()).then(res => {
handleExport () {
this.$apis.redenvelope.exportActivityRedEnvelope({
...this.getParams(),
...this.$refs.listRef.page
}).then(res => {
exportFn(res)
})
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!