Browse Source

Merge branch 'dev_ljj' of http://git.elinkit.com.cn:7070/r/tduck-front into dev_ljj

old
13176889840 4 years ago
parent
commit
6bb0a39fbd
  1. 6
      src/components/parser/Parser.vue
  2. 941
      src/views/form/setting/index.vue
  3. 538
      src/views/form/write/index.vue

6
src/components/parser/Parser.vue

@ -260,14 +260,12 @@ function setValueLabel (event, config, scheme) {
console.log(scheme) console.log(scheme)
// input // input
let tagOptionKey = processType[config.tag] let tagOptionKey = processType[config.tag]
debugger
if (tagOptionKey) { if (tagOptionKey) {
if (event instanceof Array) { if (event instanceof Array) {
//
//
if (!event.includes(0) && config.tag != 'el-cascader') { if (!event.includes(0) && config.tag != 'el-cascader') {
// other // other
this.$set(this[this.formConf.labelFormModel], `${scheme.__vModel__}other`, '') this.$set(this[this.formConf.labelFormModel], `${scheme.__vModel__}other`, '')

941
src/views/form/setting/index.vue

File diff suppressed because it is too large

538
src/views/form/write/index.vue

@ -1,48 +1,50 @@
<template> <template>
<div class="write-container"> <div class="write-container">
<h1 id="inActiveTime" style="display: none;" /> <h1 id="inActiveTime"
<div v-if="writeStatus==0" class="title-icon-view"> style="display: none;" />
<div class="icon-view"> <div v-if="writeStatus==0"
<i class="el-icon-check success-icon" /> class="title-icon-view">
</div> <div class="icon-view">
<p v-if="writeNotStartPrompt" style="text-align: center;"> <i class="el-icon-check success-icon" />
<span v-if="writeNotStartPrompt">{{ writeNotStartPrompt }}</span> </div>
</p> <p v-if="writeNotStartPrompt"
</div> style="text-align: center;">
<div v-if="writeStatus==1"> <span v-if="writeNotStartPrompt">{{ writeNotStartPrompt }}</span>
<project-form </p>
v-if="projectConfig.projectKey"
:project-config="projectConfig"
@submit="submitForm"
/>
</div>
<div v-if="writeStatus==2" class="title-icon-view">
<div class="icon-view">
<i class="el-icon-check success-icon" />
</div>
<p style="text-align: center;">
<span v-if="userProjectSetting.submitPromptText">{{ userProjectSetting.submitPromptText }}</span>
<span v-else>{{ globalDefaultValue.projectSubmitPromptText }}</span>
</p>
<div>
<el-image
v-if="userProjectSetting.submitPromptImg"
:src="userProjectSetting.submitPromptImg"
fit="cover"
/>
</div>
<el-button v-if="userProjectSetting.publicResult" type="primary" @click="openPublicResultHandle">
查看数据
</el-button>
</div>
</div> </div>
<div v-if="writeStatus==1">
<project-form v-if="projectConfig.projectKey"
:project-config="projectConfig"
@submit="submitForm" />
</div>
<div v-if="writeStatus==2"
class="title-icon-view">
<div class="icon-view">
<i class="el-icon-check success-icon" />
</div>
<p style="text-align: center;">
<span v-if="userProjectSetting.submitPromptText">{{ userProjectSetting.submitPromptText }}</span>
<span v-else>{{ globalDefaultValue.projectSubmitPromptText }}</span>
</p>
<div>
<el-image v-if="userProjectSetting.submitPromptImg"
:src="userProjectSetting.submitPromptImg"
fit="cover" />
</div>
<el-button v-if="userProjectSetting.publicResult"
type="primary"
@click="openPublicResultHandle">
查看数据
</el-button>
</div>
</div>
</template> </template>
<script> <script>
import ProjectForm from '../preview/ProjectForm' import ProjectForm from '../preview/ProjectForm'
import loadWXJs from '@/utils/loadWxSdk' import loadWXJs from '@/utils/loadWxSdk'
import defaultValue from '@/utils/defaultValue' import defaultValue from '@/utils/defaultValue'
import {getQueryString} from '@/utils' import { getQueryString } from '@/utils'
import constants from '@/utils/constants' import constants from '@/utils/constants'
const uaParser = require('ua-parser-js') const uaParser = require('ua-parser-js')
@ -50,240 +52,258 @@ const ua = uaParser(navigator.userAgent)
require('@/utils/ut') require('@/utils/ut')
export default { export default {
name: 'WriteView', name: 'WriteView',
components: { components: {
ProjectForm ProjectForm
},
props: {},
data () {
return {
inActiveTime: 0,
projectConfig: {
projectKey: '',
preview: false,
showBtns: true
},
writeStatus: 1,
writeNotStartPrompt: '',
userProjectSetting: {
submitPromptText: ''
},
globalDefaultValue: defaultValue,
//
wxAuthorizationUrl: '',
wxAuthorizationCode: '',
wxUserInfo: {},
wxSignature: {},
//
clientType: '',//:gov:resi:oper
orgId: '',//Id(agencyId;deptId;gridId)
orgName: '',//---
orgType: '',//(:agency;:dept;:grid)
realName: '',//
}
},
metaInfo: {
meta: [
{
name: 'viewport',
content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no'
}
]
},
async created () {
this.clientType = this.$route.query.clientType
this.orgId = this.$route.query.orgId
this.orgName = this.$route.query.orgName
this.orgType = this.$route.query.orgType
this.realName = this.$route.query.realName
let key = this.$route.query.key || this.$route.params.key
this.projectConfig.projectKey = key
let wxCode = getQueryString('code')
if (wxCode) {
this.wxAuthorizationCode = wxCode
await this.getWxAuthorizationUserInfo()
}
this.getWxAuthorizationUrl()
this.queryProjectSettingStatus()
this.queryProjectSetting()
if (constants.enableWx) {
//
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/wx/jsapi/signature`, { params: { url: window.location.href } }).then(res => {
this.wxSignature = res.data
this.setWxConfig()
})
}
},
mounted () {
this.viewProjectHandle()
}, methods: {
viewProjectHandle () {
//
this.$api.post(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/view/${this.projectConfig.projectKey}`, { params: { projectKey: this.projectConfig.projectKey } }).then(() => {
})
}, },
props: {}, queryProjectSettingStatus () {
data() { //
return { this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/setting-status`, {
inActiveTime: 0, params: {
projectConfig: { projectKey: this.projectConfig.projectKey,
projectKey: '', wxOpenId: this.wxUserInfo ? this.wxUserInfo.openid : ''
preview: false,
showBtns: true
},
writeStatus: 1,
writeNotStartPrompt: '',
userProjectSetting: {
submitPromptText: ''
},
globalDefaultValue: defaultValue,
//
wxAuthorizationUrl: '',
wxAuthorizationCode: '',
wxUserInfo: {},
wxSignature: {}
} }
}).then(res => {
if (res.msg) {
this.writeNotStartPrompt = res.msg
this.writeStatus = 0
}
})
}, },
metaInfo: { getWxAuthorizationUserInfo () {
meta: [ let wxAuthorizationCode = this.wxAuthorizationCode
{ // code
name: 'viewport', this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/wx/jsapi/authorization/user/info`, {
content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' params: {
} code: wxAuthorizationCode
]
},
async created() {
let key = this.$route.query.key || this.$route.params.key
this.projectConfig.projectKey = key
let wxCode = getQueryString('code')
if (wxCode) {
this.wxAuthorizationCode = wxCode
await this.getWxAuthorizationUserInfo()
} }
this.getWxAuthorizationUrl() }).then(res => {
this.queryProjectSettingStatus() if (res.data) {
this.queryProjectSetting() this.wxUserInfo = res.data
if (constants.enableWx) {
//
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/wx/jsapi/signature`, {params: {url: window.location.href}}).then(res => {
this.wxSignature = res.data
this.setWxConfig()
})
} }
})
}, },
mounted() { getWxAuthorizationUrl () {
this.viewProjectHandle() // url
}, methods: { this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/wx/jsapi/authorization/url`, { params: { url: window.location.href } }).then(res => {
viewProjectHandle() { if (res.data) {
// this.wxAuthorizationUrl = res.data
this.$api.post(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/view/${this.projectConfig.projectKey}`, {params: {projectKey: this.projectConfig.projectKey}}).then(() => { }
})
}) },
}, setWxConfig () {
queryProjectSettingStatus() { let that = this
// let signature = this.wxSignature
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/setting-status`, { loadWXJs(wx => {
params: { wx.config({
projectKey: this.projectConfig.projectKey, debug: false, // ,apialertpclogpc
wxOpenId: this.wxUserInfo ? this.wxUserInfo.openid : '' appId: signature.appId, //
} timestamp: signature.timestamp, //
}).then(res => { nonceStr: signature.nonceStr, //
if (res.msg) { signature: signature.signature, //
this.writeNotStartPrompt = res.msg jsApiList: [
this.writeStatus = 0 'updateAppMessageShareData',
} 'updateTimelineShareData',
}) 'onMenuShareAppMessage',
}, 'onMenuShareTimeline',
getWxAuthorizationUserInfo() { 'showMenuItems',
let wxAuthorizationCode = this.wxAuthorizationCode 'hideMenuItems',
// code 'chooseWXPay'
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/wx/jsapi/authorization/user/info`, { ] // 使JS
params: { })
code: wxAuthorizationCode // sdk
} wx.ready(function () {
}).then(res => { //
if (res.data) { console.log('ready')
this.wxUserInfo = res.data that.setWxProjectShare(wx)
} })
}) })
},
}, /**
getWxAuthorizationUrl() { * 微信分享
// url */
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/wx/jsapi/authorization/url`, {params: {url: window.location.href}}).then(res => { setWxProjectShare (wx) {
if (res.data) { let { shareImg, shareTitle, shareDesc } = this.userProjectSetting
this.wxAuthorizationUrl = res.data wx.updateAppMessageShareData({
} title: shareTitle || defaultValue.projectShareTitle, //
}) desc: shareDesc || defaultValue.projectShareDesc, //
}, link: window.location.href, // JS
setWxConfig() { imgUrl: shareImg || defaultValue.projectShareImg, //
let that = this success: function () {
let signature = this.wxSignature //
loadWXJs(wx => { console.log('succcess')
wx.config({
debug: false, // ,apialertpclogpc
appId: signature.appId, //
timestamp: signature.timestamp, //
nonceStr: signature.nonceStr, //
signature: signature.signature, //
jsApiList: [
'updateAppMessageShareData',
'updateTimelineShareData',
'onMenuShareAppMessage',
'onMenuShareTimeline',
'showMenuItems',
'hideMenuItems',
'chooseWXPay'
] // 使JS
})
// sdk
wx.ready(function() {
//
console.log('ready')
that.setWxProjectShare(wx)
})
})
},
/**
* 微信分享
*/
setWxProjectShare(wx) {
let {shareImg, shareTitle, shareDesc} = this.userProjectSetting
wx.updateAppMessageShareData({
title: shareTitle || defaultValue.projectShareTitle, //
desc: shareDesc || defaultValue.projectShareDesc, //
link: window.location.href, // JS
imgUrl: shareImg || defaultValue.projectShareImg, //
success: function() {
//
console.log('succcess')
},
fail: function() {
console.log('fail')
}
})
wx.updateTimelineShareData({
title: shareTitle || defaultValue.projectShareTitle, //
desc: shareDesc || defaultValue.projectShareDesc, //
link: window.location.href, // JS
imgUrl: shareImg || defaultValue.projectShareImg, //
success: function() {
//
console.log('succcess')
},
fail: function() {
console.log('fail')
}
})
wx.onMenuShareTimeline({
title: shareTitle || defaultValue.projectShareTitle, //
desc: shareDesc || defaultValue.projectShareDesc, //
link: window.location.href, // JS
imgUrl: shareImg || defaultValue.projectShareImg, //
success: function() {
//
console.log('succcess')
}
})
wx.onMenuShareAppMessage({
title: shareTitle || defaultValue.projectShareTitle, //
desc: shareDesc || defaultValue.projectShareDesc, //
link: window.location.href, // JS
imgUrl: shareImg || defaultValue.projectShareImg, //
success: function() {
//
console.log('succcess')
}
})
}, },
queryProjectSetting() { fail: function () {
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/setting/${this.projectConfig.projectKey}`).then(res => { console.log('fail')
if (res.data) { }
this.userProjectSetting = res.data })
// wx.updateTimelineShareData({
if (res.data && res.data.wxWrite) { title: shareTitle || defaultValue.projectShareTitle, //
// desc: shareDesc || defaultValue.projectShareDesc, //
if (res.data.recordWxUser && !this.wxAuthorizationCode) { link: window.location.href, // JS
location.href = this.wxAuthorizationUrl imgUrl: shareImg || defaultValue.projectShareImg, //
} else { success: function () {
this.onlyWxOpenHandle() //
} console.log('succcess')
}
}
})
}, },
/** fail: function () {
* 仅在微信打开 console.log('fail')
*/ }
onlyWxOpenHandle() { })
let wxUa = navigator.userAgent.toLowerCase() wx.onMenuShareTimeline({
let isWeixin = wxUa.indexOf('micromessenger') != -1 title: shareTitle || defaultValue.projectShareTitle, //
if (!isWeixin) { desc: shareDesc || defaultValue.projectShareDesc, //
document.head.innerHTML = '<title>抱歉,出错了</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"><link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css">' link: window.location.href, // JS
document.body.innerHTML = '<div class="weui_msg"><div class="weui_icon_area"><i class="weui_icon_info weui_icon_msg"></i></div><div class="weui_text_area"><h4 class="weui_msg_title">请在微信客户端打开链接</h4></div></div>' imgUrl: shareImg || defaultValue.projectShareImg, //
success: function () {
//
console.log('succcess')
}
})
wx.onMenuShareAppMessage({
title: shareTitle || defaultValue.projectShareTitle, //
desc: shareDesc || defaultValue.projectShareDesc, //
link: window.location.href, // JS
imgUrl: shareImg || defaultValue.projectShareImg, //
success: function () {
//
console.log('succcess')
}
})
},
queryProjectSetting () {
this.$api.get(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/setting/${this.projectConfig.projectKey}`).then(res => {
if (res.data) {
this.userProjectSetting = res.data
//
if (res.data && res.data.wxWrite) {
//
if (res.data.recordWxUser && !this.wxAuthorizationCode) {
location.href = this.wxAuthorizationUrl
} else {
this.onlyWxOpenHandle()
} }
}, }
openPublicResultHandle() { }
let projectKey = this.projectConfig.projectKey })
this.$router.replace({path: '/project/public/result', query: {projectKey}}) },
}, /**
submitForm(data) { * 仅在微信打开
// */
let inActiveTime = document.getElementById('inActiveTime').innerText onlyWxOpenHandle () {
this.$api.post(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/create`, { let wxUa = navigator.userAgent.toLowerCase()
'completeTime': inActiveTime, let isWeixin = wxUa.indexOf('micromessenger') != -1
'projectKey': this.projectConfig.projectKey, if (!isWeixin) {
'submitOs': ua.os.name, document.head.innerHTML = '<title>抱歉,出错了</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"><link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css">'
'submitBrowser': ua.browser.name, document.body.innerHTML = '<div class="weui_msg"><div class="weui_icon_area"><i class="weui_icon_info weui_icon_msg"></i></div><div class="weui_text_area"><h4 class="weui_msg_title">请在微信客户端打开链接</h4></div></div>'
'submitUa': ua, }
'wxUserInfo': this.wxUserInfo, },
'wxOpenId': this.wxUserInfo ? this.wxUserInfo.openid : '', openPublicResultHandle () {
'originalData': data.formModel, let projectKey = this.projectConfig.projectKey
'processData': data.labelFormModel this.$router.replace({ path: '/project/public/result', query: { projectKey } })
}).then(() => { },
this.writeStatus = 2 submitForm (data) {
if (this.userProjectSetting.submitJumpUrl) { //
setTimeout(() => { let inActiveTime = document.getElementById('inActiveTime').innerText
window.location.replace(this.userProjectSetting.submitJumpUrl) this.$api.post(`${process.env.VUE_APP_API_ROOT_TDUCK}/user/project/result/create`, {
}, 1000) 'completeTime': inActiveTime,
} 'projectKey': this.projectConfig.projectKey,
'submitOs': ua.os.name,
}) 'submitBrowser': ua.browser.name,
'submitUa': ua,
'wxUserInfo': this.wxUserInfo,
'wxOpenId': this.wxUserInfo ? this.wxUserInfo.openid : '',
'originalData': data.formModel,
'processData': data.labelFormModel,
'clientType': this.clientType,//:gov:resi:oper
'orgId': this.orgId,//Id(agencyId;deptId;gridId)
'orgName': this.orgName,//---
'orgType': this.orgType,//(:agency;:dept;:grid)
'realName': this.realName,//
}).then(() => {
this.writeStatus = 2
if (this.userProjectSetting.submitJumpUrl) {
setTimeout(() => {
window.location.replace(this.userProjectSetting.submitJumpUrl)
}, 1000)
} }
})
} }
}
} }
</script> </script>

Loading…
Cancel
Save