2021-12-15 16:42:31 +08:00
|
|
|
<template>
|
|
|
|
|
<section class="AppForm">
|
|
|
|
|
<template v-if="showDetail">
|
|
|
|
|
<form-detail/>
|
|
|
|
|
</template>
|
|
|
|
|
<AiResult v-else :tips="errMsg" :status="errStatus"/>
|
|
|
|
|
</section>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import {mapActions, mapState} from "vuex";
|
|
|
|
|
import FormDetail from "./components/formDetail";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "AppForm",
|
|
|
|
|
appName: "问卷表单",
|
|
|
|
|
inject: {root: {}},
|
|
|
|
|
components: {FormDetail},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
access: false,
|
|
|
|
|
err: ""
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
2022-07-19 18:06:22 +08:00
|
|
|
...mapState(['user']),
|
2021-12-15 16:42:31 +08:00
|
|
|
showDetail() {
|
|
|
|
|
return !!this.$route.query?.id && this.access
|
|
|
|
|
},
|
|
|
|
|
errMsg() {
|
|
|
|
|
this.access && (this.err = "表单不存在")
|
|
|
|
|
return this.err || "数据读取中..."
|
|
|
|
|
},
|
|
|
|
|
errStatus() {
|
|
|
|
|
return !!this.err ? "error" : "loading"
|
|
|
|
|
},
|
|
|
|
|
isPreview() {
|
|
|
|
|
return !!this.$route.query?.preview
|
2022-10-24 18:03:11 +08:00
|
|
|
},
|
|
|
|
|
action: v => v.$route.query.action || "appquestionnairetemplate"
|
2021-12-15 16:42:31 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
...mapActions(['getCode', 'getToken']),
|
2022-07-19 18:06:22 +08:00
|
|
|
checkAccess(review) {
|
|
|
|
|
let {code, suiteId, id} = this.$route.query
|
2021-12-15 16:42:31 +08:00
|
|
|
if (this.isPreview) {
|
|
|
|
|
this.access = true
|
2022-07-19 18:06:22 +08:00
|
|
|
} else if (!!this.user.token) {
|
2022-10-24 18:03:11 +08:00
|
|
|
this.$http.post(`/app/${this.action}/commitCheck`, null, {
|
2021-12-15 16:42:31 +08:00
|
|
|
params: {id}
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res?.code == 0) {
|
|
|
|
|
this.access = true
|
2022-07-27 09:57:12 +08:00
|
|
|
} else if (res?.code == 401) {
|
|
|
|
|
this.checkAccess()
|
2021-12-15 16:42:31 +08:00
|
|
|
} else {
|
|
|
|
|
this.err = "无法获取表单"
|
|
|
|
|
}
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
this.err = err
|
|
|
|
|
})
|
|
|
|
|
} else if (code) {
|
2022-07-19 18:06:22 +08:00
|
|
|
this.getToken({code, suiteId}).then(() => this.checkAccess(true))
|
|
|
|
|
} else if (!review) this.getCode()
|
|
|
|
|
else this.err = "登录失败!"
|
|
|
|
|
|
2021-12-15 16:42:31 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.checkAccess()
|
2021-12-24 15:27:36 +08:00
|
|
|
},
|
|
|
|
|
onShow() {
|
2022-01-27 09:16:46 +08:00
|
|
|
document.title = '问卷调查'
|
2021-12-28 10:33:51 +08:00
|
|
|
wx.hideOptionMenu()
|
2021-12-24 15:27:36 +08:00
|
|
|
},
|
2021-12-15 16:42:31 +08:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.AppForm {
|
|
|
|
|
position: absolute;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
background: #fff;
|
|
|
|
|
}
|
|
|
|
|
</style>
|