中心调研二维码和链接的时间有效性
continuous-integration/drone/push Build is passing Details

has
wangxiaoshuang 2026-06-18 13:31:20 +08:00
parent 0631af4d9b
commit 97411b7eaf
3 changed files with 362 additions and 85 deletions

View File

@ -4483,3 +4483,35 @@ export function getDoctorUserTrialReadingStat(data) {
data, data,
}) })
} }
// 设置项目链接过期时间
export function setTrialLinkExpirationTime(data) {
return request({
url: `/TrialConfig/setTrialLinkExpirationTime`,
method: 'post',
data,
})
}
// 获取项目链接过期时间
export function getTrialLinkExpirationTime(data) {
return request({
url: `/TrialConfig/getTrialLinkExpirationTime`,
method: 'post',
data,
})
}
// 获取项目链接时间是否过期
export function getLinkLinkExpirationTime(data) {
return request({
url: `/TrialConfig/getLinkLinkExpirationTime`,
method: 'post',
data,
})
}
// 获取项目链接code是否有效
export function getLinkVerificationCodeIsEffective(data) {
return request({
url: `/TrialConfig/getLinkVerificationCodeIsEffective`,
method: 'post',
data,
})
}

View File

@ -1,6 +1,7 @@
<template> <template>
<div class="question-login-wrapper"> <div class="question-login-wrapper">
<div class="box-wrapper"> <div v-if="verify"></div>
<div class="box-wrapper" v-else>
<h2 style="text-align:center;"> <h2 style="text-align:center;">
<!-- 中心调研表 --> <!-- 中心调研表 -->
{{ $t('trials:researchForm:title:question') }} {{ $t('trials:researchForm:title:question') }}
@ -91,7 +92,10 @@ import { getUserMenuTree, getUserPermissions } from '@/api/user'
import store from '@/store' import store from '@/store'
import TopLang from './topLang' import TopLang from './topLang'
import { mapGetters, mapMutations } from 'vuex' import { mapGetters, mapMutations } from 'vuex'
import {
getLinkLinkExpirationTime,
getLinkVerificationCodeIsEffective
} from '@/api/trials'
export default { export default {
components: { TopLang }, components: { TopLang },
data() { data() {
@ -146,6 +150,7 @@ export default {
} }
return { return {
trialId: '', trialId: '',
verify: true,
form: { form: {
Sponsor: null, // Sponsor: null, //
ResearchProgramNo: null, // ResearchProgramNo: null, //
@ -202,31 +207,112 @@ export default {
]) ])
}, },
mounted() { mounted() {
this.$i18n.locale = this.$route.query.lang let lang = this.$route.query.lang
this.setLanguage(this.$route.query.lang) if (!lang) {
const language = navigator.language
lang = 'zh'
if (language === 'en-US') {
lang = 'en'
}
}
this.$i18n.locale = lang
this.setLanguage(lang)
this.$updateDictionary() this.$updateDictionary()
if (this.$route.query.trialId) { this.getLinkTimeIsExpired()
this.trialId = this.$route.query.trialId
this.initPage()
}
if (this.$route.query.isUpload) {
this.isUpload = true
this.form.IsUpdate = true
let { email, oldEMail, trialSiteId } = this.$route.query
if (trialSiteId) this.form.TrialSiteId = trialSiteId
if (oldEMail) this.form.ReplaceUserEmailOrPhone = oldEMail
if (email && email !== 'null') {
this.form.EmailOrPhone = email
} else {
this.form.EmailOrPhone = oldEMail
}
if ((email && email !== 'null') || (oldEMail && oldEMail !== 'null')) {
this.isNeedUpload = false
}
}
}, },
methods: { methods: {
...mapMutations({ setLanguage: 'lang/setLanguage' }), ...mapMutations({ setLanguage: 'lang/setLanguage' }),
async getLinkTimeIsExpired() {
try {
let data = {
TrialId: this.$route.query.trialId,
}
let res = await getLinkLinkExpirationTime(data)
if (res.IsSuccess) {
if (res.Result.IsIsExpired) return this.$confirm(this.$t("trials:researchForm:confirm:linkIsExpired"), '', {
type: 'warning'
})
this.customPrompt()
}
} catch (err) {
console.log(err)
}
},
async getLinkVerificationCodeIsEffective(value) {
try {
let data = {
TrialId: this.$route.query.trialId,
LinkVerificationCode: value
}
let res = await getLinkVerificationCodeIsEffective(data)
if (res.IsSuccess) {
if (!res.Result.IsEffective) {
return false
}
this.verify = false
if (this.$route.query.trialId) {
this.trialId = this.$route.query.trialId
this.initPage()
}
if (this.$route.query.isUpload) {
this.isUpload = true
this.form.IsUpdate = true
let { email, oldEMail, trialSiteId } = this.$route.query
if (trialSiteId) this.form.TrialSiteId = trialSiteId
if (oldEMail) this.form.ReplaceUserEmailOrPhone = oldEMail
if (email && email !== 'null') {
this.form.EmailOrPhone = email
} else {
this.form.EmailOrPhone = oldEMail
}
if ((email && email !== 'null') || (oldEMail && oldEMail !== 'null')) {
this.isNeedUpload = false
}
}
}
return true
} catch (err) {
return false
console.log(err)
}
},
async customPrompt(name) {
try {
const that = this
//
let message = this.$t('trials:researchForm:message:LinkVerificationCode')
const { value } = await this.$prompt(message, '', {
showClose: false,
cancelButtonText: this.$t('common:button:cancel'),
confirmButtonText: this.$t('trials:researchForm:button:saveLinkCode'),
showCancelButton: false,
closeOnClickModal: false,
closeOnPressEscape: false,
inputValue: name,
beforeClose: async (action, instance, done) => {
if (action === 'confirm') {
const value = instance.inputValue
if (!value) {
that.$message.error(this.$t('trials:researchForm:error:noValue'))
} else {
let flag = await this.getLinkVerificationCodeIsEffective(value)
if (!flag) {
that.$message.error(this.$t('trials:researchForm:confirm:isEffective'))
} else {
done()
}
}
} else {
done()
}
}
})
this.getLinkVerificationCodeIsEffective(value)
} catch (err) {
console.log(err)
return null
}
},
// //
async initPage() { async initPage() {
this.loading = true this.loading = true

View File

@ -184,44 +184,75 @@
</el-dialog> </el-dialog>
<!-- 调查表链接 --> <!-- 调查表链接 -->
<base-model :config="share_model"> <base-model :config="share_model">
<template slot="dialog-body"> <template slot="dialog-body" v-loading="shareLoading">
<el-button size="small" type="primary" style="margin-bottom: 10px;" @click.stop="openImageManual">{{ <el-button size="small" type="primary" style="margin-bottom: 10px;" @click.stop="openImageManual">{{
$t('trials:researchRecord:label:edit') $t('trials:researchRecord:label:edit')
}}</el-button> }}</el-button>
<div style="width: 100%; display: flex"> <div style="width: 100%; display: flex">
<div class="shareLink"> <div class="date">
<!-- <div> <el-form :model="shareForm" :rules="rules" ref="shareForm" label-width="100px">
<i style="color: #428bca" class="el-icon-success" /> <el-form-item :label="$t('trials:researchRecord:label:ExpirationDays')" prop="ExpirationDays">
<span>{{ <el-radio-group v-model="shareForm.ExpirationDays" @input="shareForm.OtherExpirationDays = null">
$t('trials:researchRecord:message:createLinkSuccessfully') <el-radio :label="1">{{ $t('trials:researchRecord:label:day1') }}</el-radio>
}}</span> <el-radio :label="7">{{ $t('trials:researchRecord:label:day7') }}</el-radio>
</div> --> <el-radio :label="15">{{ $t('trials:researchRecord:label:day15') }}</el-radio>
<div style="margin: 10px 0"> <el-radio :label="`default`">{{ $t('trials:researchRecord:label:default') }}
<!-- 链接 --> <el-input placeholder="" type="number" @input="handleInput" v-model="shareForm.OtherExpirationDays"
{{ $t('trials:researchRecord:label:link') }} clearable size="mini" style="width: 60px;" class="dayInput" />
<span style="margin-left: 10px;">{{ $t('trials:researchRecord:label:day') }}</span>
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item :label="$t('trials:researchRecord:label:LinkVerificationCode')" prop="LinkVerificationCode">
<el-radio-group v-model="shareForm.LinkVerificationCode"
@input="shareForm.OtherLinkVerificationCode = null">
<el-radio label="researchProgramNo">{{ $t('trials:researchRecord:label:researchProgramNo')
}}</el-radio>
<el-radio label="default">{{ $t('trials:researchRecord:label:default') }}
<el-input placeholder="" type="number" v-model="shareForm.OtherLinkVerificationCode" clearable
size="mini" style="width: 100px;" />
</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<el-button type="primary" round @click="setLink" style="float: right;">
{{ $t('trials:researchRecord:button:setLink') }}
</el-button>
</div>
<div class="share">
<div class="shareLink">
<h3>{{ $t('trials:researchRecord:label:link') }}</h3>
<el-input ref="shareLink" v-model="shareLink" readonly type="textarea" autosize /> <el-input ref="shareLink" v-model="shareLink" readonly type="textarea" autosize />
</div> <div class="dateBox">
<div> <span>{{ $t('trials:researchRecord:label:ValidityPeriod') }}</span>
<!-- 复制链接 --> <span>{{ validityPeriod }}</span>
<el-button type="primary" round @click="copyLink" class="shareLinkBtn"> <span style="color: red;" v-if="isExpired">({{ $t('trials:researchRecord:label:Expired') }})</span>
</div>
<el-button type="primary" round @click="copyLink" class="shareLinkBtn"
:disabled="!validityPeriod || isExpired">
{{ $t('trials:researchRecord:button:copyLink') }} {{ $t('trials:researchRecord:button:copyLink') }}
</el-button> </el-button>
</div> </div>
</div> <div class="shareCode">
<div class="shareCode"> <h3>{{ $t('trials:researchRecord:label:shareCode') }}</h3>
<div class="qrCode"> <div style="display: flex;align-items: center;justify-content: space-between;">
<div id="qrcode" ref="qrcode"></div> <div class="qrCodeBox">
</div> <div id="qrcode" ref="qrcode"></div>
<div class="codeBtnBox"> </div>
<el-button @click="handleCopyImg" type="primary" round>{{ <div class="codeBtnBox">
$t('trials:researchRecord:button:copyCode') <el-button @click="handleCopyImg" type="primary" round :disabled="!validityPeriod || isExpired">{{
}}</el-button> $t('trials:researchRecord:button:copyCode')
<el-button @click="savePic" round>{{ }}</el-button>
$t('trials:researchRecord:button:savePic') <el-button @click="savePic" round :disabled="!validityPeriod || isExpired">{{
}}</el-button> $t('trials:researchRecord:button:savePic')
}}</el-button>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
</base-model> </base-model>
</BaseContainer> </BaseContainer>
@ -231,6 +262,9 @@ import {
getTrialSiteSurveyList, getTrialSiteSurveyList,
getTrialSiteSelect, getTrialSiteSelect,
abandonSiteSurvey, abandonSiteSurvey,
setTrialLinkExpirationTime,
getTrialLinkExpirationTime,
getLinkLinkExpirationTime,
} from '@/api/trials' } from '@/api/trials'
import { changeURLStatic } from '@/utils/history.js' import { changeURLStatic } from '@/utils/history.js'
import BaseContainer from '@/components/BaseContainer' import BaseContainer from '@/components/BaseContainer'
@ -272,14 +306,50 @@ export default {
share_model: { share_model: {
visible: false, visible: false,
title: this.$t('trials:researchRecord:title:shark'), title: this.$t('trials:researchRecord:title:shark'),
width: '800px', width: '1000px',
}, },
shareLink: '', shareLink: '',
researchState: this.$d.ResearchRecord, researchState: this.$d.ResearchRecord,
qrcode: null, qrcode: null,
validityPeriod: null,
isExpired: false,
shareLoading: false,
shareForm: {
ExpirationDays: null,
OtherExpirationDays: null,
LinkVerificationCode: null,
OtherLinkVerificationCode: null,
},
rules: {
ExpirationDays: [
{ required: true, message: this.$t("common:ruleMessage:select"), trigger: 'blur' },
{
validator: (rule, value, callback) => {
if (value === 'default' && !this.shareForm.OtherExpirationDays) {
callback(new Error(this.$t("common:ruleMessage:specify")));
} else {
callback()
}
}, trigger: 'blur'
}
],
LinkVerificationCode: [
{ required: true, message: this.$t("common:ruleMessage:select"), trigger: 'blur' },
{
validator: (rule, value, callback) => {
if (value === 'default' && !this.shareForm.OtherLinkVerificationCode) {
callback(new Error(this.$t("common:ruleMessage:specify")));
} else {
callback()
}
}, trigger: 'blur'
}
],
},
ImageManualVisible: false, ImageManualVisible: false,
trialSiteSurveyId: null trialSiteSurveyId: null,
} }
}, },
mounted() { mounted() {
@ -287,6 +357,77 @@ export default {
this.getSite() this.getSite()
}, },
methods: { methods: {
async getLinkTimeIsExpired() {
try {
let data = {
TrialId: this.$route.query.trialId,
}
this.shareLoading = true
let res = await getLinkLinkExpirationTime(data)
this.shareLoading = false
if (res.IsSuccess) {
this.isExpired = res.Result.IsIsExpired
}
} catch (err) {
this.shareLoading = false
console.log(err)
}
},
async getLinkTime() {
try {
let data = {
TrialId: this.$route.query.trialId,
}
this.shareLoading = true
let res = await getTrialLinkExpirationTime(data)
this.shareLoading = false
if (res.IsSuccess) {
this.validityPeriod = res.Result.LinkExpirationTime
if (!this.validityPeriod) return false
this.getLinkTimeIsExpired()
this.shareLink = `${location.protocol}//${location.host}/researchLogin?trialId=${this.$route.query.trialId}`
this.$nextTick(() => {
this.creatQrCode()
})
}
} catch (err) {
this.shareLoading = false
console.log(err)
}
},
async setLink() {
try {
let validate = await this.$refs.shareForm.validate()
if (!validate) return false
let data = {
TrialId: this.$route.query.trialId,
ExpirationDays: this.shareForm.ExpirationDays,
LinkVerificationCode: this.shareForm.LinkVerificationCode
}
if (this.shareForm.LinkVerificationCode === 'researchProgramNo') {
data.LinkVerificationCode = null
}
if (this.shareForm.LinkVerificationCode === 'default') {
data.LinkVerificationCode = this.shareForm.OtherLinkVerificationCode
}
if (this.shareForm.ExpirationDays === 'default') {
data.ExpirationDays = this.shareForm.OtherExpirationDays
}
this.shareLoading = true
let res = await setTrialLinkExpirationTime(data)
this.shareLoading = false
if (res.IsSuccess) {
this.getLinkTime()
}
} catch (err) {
this.shareLoading = false
console.log(err)
}
},
handleInput(val) {
//
this.shareForm.OtherExpirationDays = val.replace(/[^\d]/g, '').replace(/^0+/, '')
},
openImageManual() { openImageManual() {
// if (!this.trialSiteSurveyId) return false // if (!this.trialSiteSurveyId) return false
this.ImageManualVisible = true this.ImageManualVisible = true
@ -344,7 +485,7 @@ export default {
// //
this.$copyText( this.$copyText(
`${this.$t('trials:researchRecord:message:researchFormLink')}: ${this.shareLink `${this.$t('trials:researchRecord:message:researchFormLink')}: ${this.shareLink
}` }\n${this.$t('trials:researchRecord:label:ValidityPeriod')}:${this.validityPeriod}`
) )
.then((res) => { .then((res) => {
// //
@ -415,13 +556,18 @@ export default {
}, },
// //
showResearchLink() { showResearchLink() {
const trialId = this.trialId this.shareForm = {
this.shareLink = `${location.protocol}//${location.host}/researchLogin?trialId=${trialId}&lang=${this.$i18n.locale}` ExpirationDays: null,
OtherExpirationDays: null,
LinkVerificationCode: null,
OtherLinkVerificationCode: null,
}
this.validityPeriod = null
this.isExpired = false
this.share_model.visible = true this.share_model.visible = true
this.getLinkTime()
// &lang=${this.$i18n.locale}
// this.trialSiteSurveyId = this.list[0].Id // this.trialSiteSurveyId = this.list[0].Id
this.$nextTick(() => {
this.creatQrCode()
})
}, },
// //
handleReset() { handleReset() {
@ -462,41 +608,54 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.shareLink { .date,
padding-right: 20px; .share {
width: 50%; width: 55%;
position: relative; height: 100%;
}
.shareLinkBtn { .dayInput {
position: absolute; ::v-deep .el-input__inner {
bottom: 0px; padding-left: 5px;
left: 0px;
} }
} }
.shareCode {
width: 50%; .date {
border-left: 1px solid #eee; padding-right: 10px;
}
.share {
width: 45%;
padding-left: 5%;
border-left: 1px solid #000;
box-sizing: border-box;
}
.shareLinkBtn {
float: right;
}
.qrCodeBox {
width: 220px;
height: 220px;
display: flex; display: flex;
border: 1px solid #c0c4cc;
border-radius: 5px;
box-shadow: 1px 1px 5px #c0c4cc;
align-items: center;
justify-content: center; justify-content: center;
flex-wrap: wrap; }
.qrCode { .dateBox {
width: 220px; margin: 10px;
height: 220px; }
display: flex;
border: 1px solid #c0c4cc;
border-radius: 5px;
box-shadow: 1px 1px 5px #c0c4cc;
align-items: center;
justify-content: center;
}
.codeBtnBox { .codeBtnBox {
margin-top: 20px;
width: 100%; ::v-deep .el-button {
display: flex; display: block;
justify-content: space-around; margin: 10px auto;
} }
} }
</style> </style>