|
|
@@ -1,6 +1,20 @@
|
|
|
import * as api from '@/api'
|
|
|
-import Custom from './custom'
|
|
|
+import Custom from '../js/custom'
|
|
|
+import Layout1 from '../Layout1'
|
|
|
+import Layout2 from '../Layout2'
|
|
|
export default {
|
|
|
+ props: {
|
|
|
+ edata: {
|
|
|
+ type: Object
|
|
|
+ },
|
|
|
+ edataItem: {
|
|
|
+ type: Object
|
|
|
+ }
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ Layout1,
|
|
|
+ Layout2,
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
TITLE: '问卷调查',
|
|
|
@@ -8,6 +22,11 @@ export default {
|
|
|
result: [],
|
|
|
topic: {}
|
|
|
},
|
|
|
+ layoutCurrent: '',
|
|
|
+ layoutType: {
|
|
|
+ '1': 'Layout1',
|
|
|
+ '2': 'Layout2'
|
|
|
+ },
|
|
|
loading: {
|
|
|
data: false,
|
|
|
empty: false,
|
|
|
@@ -29,6 +48,9 @@ export default {
|
|
|
if (from.name === 'FormVolume') {
|
|
|
clearInterval(this.codeMess.t)
|
|
|
}
|
|
|
+ },
|
|
|
+ edata () {
|
|
|
+ this.inData()
|
|
|
}
|
|
|
},
|
|
|
destroyed() {
|
|
|
@@ -84,30 +106,22 @@ export default {
|
|
|
this.loading.data = true
|
|
|
this.loading.empty = false
|
|
|
try {
|
|
|
- let { result_id } = this.$route.query
|
|
|
- let pm = result_id
|
|
|
- ? api.apiGetVolumeResult({ result_id })
|
|
|
- : api.apiGetVolumeInfo(this.$route.query)
|
|
|
- let res = await pm
|
|
|
- let data = res.data
|
|
|
- let configType = {
|
|
|
- 'radio': '单选',
|
|
|
- 'checkbox': '多选'
|
|
|
- }
|
|
|
- data.result.forEach(item => {
|
|
|
- item.layout_align = item.layout_align || data.topic.layout_align || 'left'
|
|
|
- item.layout_inline = item.layout_inline || data.topic.layout_inline || 1
|
|
|
- item.type_name = configType[item.type] || ''
|
|
|
-
|
|
|
- // 自定义组件处理
|
|
|
- Custom(item)
|
|
|
- })
|
|
|
- if (data.topic.memo) {
|
|
|
- data.topic.memo = data.topic.memo.replace(/\n/g, '<br />')
|
|
|
- }
|
|
|
- if (this.layoutType) {
|
|
|
- this.layoutCurrent = this.layoutType[data.topic.layout_type] || 'van-empty'
|
|
|
+ let data = null
|
|
|
+ if (this.edata) {
|
|
|
+ data = this.edata
|
|
|
+ } else {
|
|
|
+ let { result_id } = this.$route.query
|
|
|
+ let pm = result_id
|
|
|
+ ? api.apiGetVolumeResult({ result_id })
|
|
|
+ : api.apiGetVolumeInfo(this.$route.query)
|
|
|
+ let res = await pm
|
|
|
+ data = res.data
|
|
|
}
|
|
|
+
|
|
|
+ this.inTopicLayout(data)
|
|
|
+ this.inTopicAttr(data)
|
|
|
+ this.inTopicComponent(data)
|
|
|
+
|
|
|
this.$set(this, 'data', data)
|
|
|
} catch (error) {
|
|
|
this.loading.empty = true
|
|
|
@@ -115,6 +129,36 @@ export default {
|
|
|
}
|
|
|
this.loading.data = false
|
|
|
},
|
|
|
+ // 问卷属性初始化
|
|
|
+ inTopicAttr (data) {
|
|
|
+ data = data || this.data
|
|
|
+ if (data.topic.memo) {
|
|
|
+ data.topic.memo = data.topic.memo.replace(/\n/g, '<br />')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 问卷组件初始化
|
|
|
+ inTopicComponent (data) {
|
|
|
+ data = data || this.data
|
|
|
+ let configType = {
|
|
|
+ 'radio': '单选',
|
|
|
+ 'checkbox': '多选'
|
|
|
+ }
|
|
|
+ data.result.forEach(item => {
|
|
|
+ item.layout_align = item.layout_align || data.topic.layout_align || 'left'
|
|
|
+ item.layout_inline = item.layout_inline || data.topic.layout_inline || 1
|
|
|
+ item.type_name = configType[item.type] || ''
|
|
|
+
|
|
|
+ // 自定义组件处理
|
|
|
+ Custom(item)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 问卷主题UI初始化
|
|
|
+ inTopicLayout (data) {
|
|
|
+ data = data || this.data
|
|
|
+ if (this.layoutType) {
|
|
|
+ this.layoutCurrent = this.layoutType[data.topic.layout_type] || 'van-empty'
|
|
|
+ }
|
|
|
+ },
|
|
|
btnOpenSuccess(callback) {
|
|
|
this.show.submit = true
|
|
|
this.loopCode(this.codeMess.num, async () => {
|