2021-11-22 16:39:07 +08:00
|
|
|
<template>
|
2021-11-25 17:04:43 +08:00
|
|
|
<section class="AppForm">
|
2021-11-25 16:02:53 +08:00
|
|
|
<template v-if="showDetail">
|
2021-11-22 16:39:07 +08:00
|
|
|
<form-detail/>
|
|
|
|
|
</template>
|
2021-11-25 16:11:32 +08:00
|
|
|
<ai-result v-else :tips="errMsg" status="error"/>
|
2021-11-22 16:39:07 +08:00
|
|
|
</section>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-11-29 11:56:32 +08:00
|
|
|
import {mapActions, mapState} from "vuex";
|
2021-11-22 16:39:07 +08:00
|
|
|
import FormDetail from "./formDetail";
|
2021-11-25 16:11:32 +08:00
|
|
|
import AiResult from "../../components/AiResult";
|
2021-11-22 16:39:07 +08:00
|
|
|
|
|
|
|
|
export default {
|
2021-11-25 17:04:43 +08:00
|
|
|
name: "AppForm",
|
2021-11-25 16:02:53 +08:00
|
|
|
appName: "问卷表单",
|
2021-11-29 11:56:32 +08:00
|
|
|
inject: {root: {}},
|
2021-11-25 16:11:32 +08:00
|
|
|
components: {AiResult, FormDetail},
|
2021-11-29 11:56:32 +08:00
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
access: false
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-11-22 16:39:07 +08:00
|
|
|
computed: {
|
2021-11-29 11:56:32 +08:00
|
|
|
...mapState(['user', 'token']),
|
2021-11-22 16:39:07 +08:00
|
|
|
showDetail() {
|
2021-11-29 11:56:32 +08:00
|
|
|
return !!this.$route.query?.id && this.access
|
2021-11-22 16:39:07 +08:00
|
|
|
},
|
2021-11-25 16:11:32 +08:00
|
|
|
errMsg() {
|
2021-11-29 11:56:32 +08:00
|
|
|
return this.access ? "表单不存在" : "无法获取用户信息"
|
|
|
|
|
},
|
|
|
|
|
isPreview() {
|
|
|
|
|
return !!this.$route.query?.preview
|
2021-11-22 16:39:07 +08:00
|
|
|
}
|
2021-11-29 11:56:32 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
...mapActions(['getCode', 'getToken']),
|
|
|
|
|
checkAccess() {
|
|
|
|
|
let {corpId, code, suiteId} = this.$route.query
|
|
|
|
|
if (this.isPreview) {
|
|
|
|
|
this.access = true
|
|
|
|
|
} else if (!!this.token) {
|
|
|
|
|
this.access = true
|
|
|
|
|
} else if (code) {
|
|
|
|
|
this.getToken({code, corpId, suiteId, isAppForm: true}).then(() => {
|
|
|
|
|
let {query, path, hash} = this.$route
|
|
|
|
|
delete query.code
|
|
|
|
|
this.root.goto({query, path, hash})
|
|
|
|
|
})
|
|
|
|
|
} else {
|
2021-12-02 15:10:34 +08:00
|
|
|
this.getCode({corpId, suiteId, url: location.href})
|
2021-11-29 11:56:32 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.checkAccess()
|
2021-11-22 16:39:07 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-11-25 17:04:43 +08:00
|
|
|
.AppForm {
|
2021-11-22 16:39:07 +08:00
|
|
|
position: absolute;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
background: #fff;
|
|
|
|
|
}
|
|
|
|
|
</style>
|