Files
dvcp_v2_wxcp_app/src/apps/AppAskForm/AppForm.vue

82 lines
1.9 KiB
Vue
Raw Normal View History

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-12-07 20:38:13 +08:00
<ai-result v-else :tips="errMsg" :status="errStatus"/>
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-12-13 10:41:11 +08:00
import FormDetail from "./components/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 {
2021-12-02 17:57:45 +08:00
access: false,
err: ""
2021-11-29 11:56:32 +08:00
}
},
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-12-07 20:38:13 +08:00
this.access && (this.err = "表单不存在")
return this.err || "数据读取中..."
},
errStatus() {
return !!this.err ? "error" : "loading"
2021-11-29 11:56:32 +08:00
},
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() {
2021-12-02 17:57:45 +08:00
let {corpId, code, suiteId, id} = this.$route.query
2021-11-29 11:56:32 +08:00
if (this.isPreview) {
this.access = true
} else if (!!this.token) {
2021-12-02 17:57:45 +08:00
this.$http.post("/app/appquestionnairetemplate/commitCheck", null, {
params: {id}
}).then(res => {
if (res?.code == 0) {
this.access = true
}
}).catch(err => {
this.err = err
})
2021-11-29 11:56:32 +08:00
} 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})
})
2021-12-09 19:08:56 +08:00
} else this.getCode()
2021-11-29 11:56:32 +08:00
},
},
created() {
this.checkAccess()
2021-12-07 20:38:13 +08:00
document.title = "问卷调查"
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>