Browse Source

填写 统计

old
wangqing 5 years ago
parent
commit
3786a85ed5
  1. 61
      src/components/parser/Parser.vue
  2. 1
      src/views/account/login.vue
  3. 8
      src/views/form/index.vue
  4. 75
      src/views/form/statistics.vue
  5. 5
      src/views/form/write.vue

61
src/components/parser/Parser.vue

@ -17,6 +17,7 @@ const ruleTrigger = {
const processType = {
'el-select': '__slot__.options',
'el-cascader': 'options',
'el-radio-group': '__slot__.options',
'el-checkbox-group': '__slot__.options'
}
@ -135,16 +136,40 @@ function renderChildren(h, scheme) {
}
function setValue(event, config, scheme) {
debugger
this.$set(config, 'defaultValue', event)
this.$set(this[this.formConf.formModel], scheme.__vModel__, event)
if (processType[config.tag]) {
let item = _.find(_.get(scheme, processType[config.tag]), {'value': event})
this.$set(this[this.formConf.labelFormModel], scheme.__vModel__, item.label)
setValueLabel.call(this, event, config, scheme)
}
function setValueLabel(event, config, scheme) {
let tagOptionKey = processType[config.tag]
if (tagOptionKey) {
if (event instanceof Array) {
let labelStr = ''
event.forEach(item => {
let {label} = getObject(_.get(scheme, tagOptionKey), 'value', item)
labelStr += label + ','
})
this.$set(this[this.formConf.labelFormModel], scheme.__vModel__, labelStr)
} else {
let item = _.find(_.get(scheme, tagOptionKey), {'value': event})
this.$set(this[this.formConf.labelFormModel], scheme.__vModel__, item.label)
}
} else {
this.$set(this[this.formConf.labelFormModel], scheme.__vModel__, event)
}
}
function getObject(array, key, value) {
let o
array.some(function iter(a) {
if (a[key] === value) {
o = a
return true
}
return Array.isArray(a.children) && a.children.some(iter)
})
return o
}
function buildListeners(scheme) {
@ -177,7 +202,7 @@ export default {
handler(val) {
this.formConfCopy = val
this.initFormData(data.formConfCopy.fields, data[this.formConf.formModel])
this.initFormData(data.formConfCopy.fields, data[this.formConf.labelFormModel])
this.initLabelFormData(data.formConfCopy.fields, data[this.formConf.labelFormModel])
this.buildRules(data.formConfCopy.fields, data[this.formConf.formRules])
},
deep: true
@ -192,11 +217,35 @@ export default {
[this.formConf.formRules]: {}
}
this.initFormData(data.formConfCopy.fields, data[this.formConf.formModel])
this.initFormData(data.formConfCopy.fields, data[this.formConf.labelFormModel])
this.initLabelFormData(data.formConfCopy.fields, data[this.formConf.labelFormModel])
this.buildRules(data.formConfCopy.fields, data[this.formConf.formRules])
return data
},
methods: {
initLabelFormData(componentList, formData) {
//
componentList.forEach(cur => {
let temConfig = cur.__config__
if (cur.__vModel__) {
let tagOptionKey = processType[temConfig.tag]
let defaultValue = temConfig.defaultValue
let labelStr = ''
if (tagOptionKey) {
if (defaultValue instanceof Array) {
defaultValue.forEach(item => {
let {label} = getObject(_.get(cur, tagOptionKey), 'value', item)
labelStr += label + ','
})
formData[cur.__vModel__] = labelStr
} else {
let {label} = _.find(_.get(cur, tagOptionKey), {'value': defaultValue})
formData[cur.__vModel__] = label
}
}
}
if (temConfig.children) this.initLabelFormData(temConfig.children, formData)
})
},
initFormData(componentList, formData) {
//
componentList.forEach(cur => {

1
src/views/account/login.vue

@ -61,6 +61,7 @@
<el-form ref="accountLoginForm" label-position="top" size="small" :model="accountForm"
:rules="accountLoginRules"
class="account-login-form"
status-icon hide-required-asterisk @key.enter.native="loginHandle"
>
<el-form-item label="手机号/邮箱登录" prop="account">

8
src/views/form/index.vue

@ -22,6 +22,7 @@
<theme :projectKey="projectKey" v-if="activeIndex==2"/>
<setting :projectKey="projectKey" v-if="activeIndex==3"/>
<publish :projectKey="projectKey" v-if="activeIndex==4"/>
<statistics :projectKey="projectKey" v-if="activeIndex==5"/>
</div>
</template>
@ -30,17 +31,18 @@ import editor from './editor'
import theme from './theme'
import setting from './setting'
import publish from './publish'
import statistics from './statistics'
export default {
components: {
editor,
theme,
setting,
publish
publish,
statistics
},
data() {
return {
activeIndex: '4',
activeIndex: '5',
projectKey: ''
}
},

75
src/views/form/statistics.vue

@ -0,0 +1,75 @@
<template>
<div class="statistics-container">
<template>
<el-table
:data="projectResultList"
style="width: 100%">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column
prop="serialNumber"
label="提交序号"
width="180">
</el-table-column>
<el-table-column
prop="submitAddress"
label="提交地址"
width="180">
</el-table-column>
<el-table-column
prop="address"
label="地址">
</el-table-column>
</el-table>
</template>
</div>
</template>
<script>
export default {
name: 'projectStatistics',
components: {},
props: {
projectKey: '',
projectResultList: []
},
mounted() {
this.queryConditions.projectKey = this.projectKey
this.queryProjectResult()
},
data() {
return {
//
queryConditions: {
projectKey: ''
}
}
}, methods: {
queryProjectResult() {
this.$api.post(`/user/project/result/query`, this.queryConditions).then(res => {
this.projectResultList = res.data
})
}
}
}
</script>
<style lang="scss" scoped>
.statistics-container {
width: 100%;
height: 100%;
padding: 0px;
margin: 0;
background-color: #F7F7F7;
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
display: flex;
align-items: center;
justify-content: center;
}

5
src/views/form/write.vue

@ -22,7 +22,7 @@
<p style="text-align: center">
<i class="el-icon-check"/>
<span v-if="userProjectSetting.submitPromptText">{{ userProjectSetting.submitPromptText }}</span>
<span v-else>{{globalDefaultValue.projectSubmitPromptText}}</span>
<span v-else>{{ globalDefaultValue.projectSubmitPromptText }}</span>
</p>
</div>
</div>
@ -204,7 +204,8 @@ export default {
submitForm(data) {
this.$api.post('/user/project/result/create', {
'projectKey': this.projectConfig.projectKey,
'collectData': data
'originalData': data.formModel,
'processData': data.labelFormModel
}).then(res => {
this.writeStatus = 2
})

Loading…
Cancel
Save