Commit 4d99bc14 authored by gengchunlei's avatar gengchunlei

居民端小程序 v1.2 表单校验

parent 6132a8a2
...@@ -55,7 +55,7 @@ export default { ...@@ -55,7 +55,7 @@ export default {
if (!token) { if (!token) {
token = sessionStorage.getItem('token') token = sessionStorage.getItem('token')
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
token = '9156ef22-32c5-4216-afea-11b42684d76b' token = '3c295432-bbfe-4cc2-8570-89becac57b49'
} }
} }
if (token) { if (token) {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
label='药品名称:' label='药品名称:'
placeholder='请选择' placeholder='请选择'
class='input-back mt-2 form-input w-full' class='input-back mt-2 form-input w-full'
:rules="[{required: true, message:'请选择'}]"
@click='showDrug= true' @click='showDrug= true'
/> />
<van-popup v-model:show='showDrug' position='bottom'> <van-popup v-model:show='showDrug' position='bottom'>
......
...@@ -515,17 +515,25 @@ export default { ...@@ -515,17 +515,25 @@ export default {
if (this.checkGroupsArrays && this.checkGroupsArrays.length) { if (this.checkGroupsArrays && this.checkGroupsArrays.length) {
this.form.groupsArrays = this.checkGroupsArrays.join() this.form.groupsArrays = this.checkGroupsArrays.join()
this.form.groupsArraysName = res.join() this.form.groupsArraysName = res.join()
} else {
this.form.groupsArrays = ''
this.form.groupsArraysName = ''
} }
this.showGroupsArrays = false this.showGroupsArrays = false
}, },
//随访方式 //随访方式
visitWayConfirm() { visitWayConfirm() {
if (this.checkVisitWay) {
this.store.getDict('CP00179').forEach(item => { this.store.getDict('CP00179').forEach(item => {
if (item.value == this.checkVisitWay) { if (item.value == this.checkVisitWay) {
this.form.visitWay = item.value this.form.visitWay = item.value
this.form.visitWayName = item.name this.form.visitWayName = item.name
} }
}) })
} else {
this.form.visitWay = ''
this.form.visitWayName = ''
}
this.showVisitWay = false this.showVisitWay = false
}, },
//随访类型 //随访类型
...@@ -540,6 +548,9 @@ export default { ...@@ -540,6 +548,9 @@ export default {
if (this.checkVisitWayRules && this.checkVisitWayRules.length) { if (this.checkVisitWayRules && this.checkVisitWayRules.length) {
this.form.visitWayRules = this.checkVisitWayRules.join() this.form.visitWayRules = this.checkVisitWayRules.join()
this.form.visitWayRulesName = res.join() this.form.visitWayRulesName = res.join()
} else {
this.form.visitWayRules = ''
this.form.visitWayRulesName = ''
} }
this.showVisitWayRules = false this.showVisitWayRules = false
}, },
...@@ -665,10 +676,10 @@ export default { ...@@ -665,10 +676,10 @@ export default {
overflow: visible; overflow: visible;
} }
:deep(.van-field__error-message) { /*:deep(.van-field__error-message) {
position: absolute; position: absolute;
margin-top: 3px; margin-top: 3px;
} }*/
:deep(.van-cell:after) { :deep(.van-cell:after) {
border-bottom: 0px; border-bottom: 0px;
......
...@@ -406,10 +406,10 @@ export default { ...@@ -406,10 +406,10 @@ export default {
overflow: visible; overflow: visible;
} }
:deep(.van-field__error-message) { /*:deep(.van-field__error-message) {
position: absolute; position: absolute;
margin-top: 3px; margin-top: 3px;
} }*/
:deep(.van-cell:after) { :deep(.van-cell:after) {
border-bottom: 0px; border-bottom: 0px;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<div class='label-title'>随访内容</div> <div class='label-title'>随访内容</div>
<van-field <van-field
v-model='form.visitContent' v-model='form.visitContent'
name='visitContent'
placeholder='随访内容' placeholder='随访内容'
class='input-back mt-2 form-input' class='input-back mt-2 form-input'
rows='2' rows='2'
...@@ -64,7 +65,9 @@ ...@@ -64,7 +65,9 @@
<van-popup v-model:show='showPublicizeType' position='bottom'> <van-popup v-model:show='showPublicizeType' position='bottom'>
<div class='p-4'> <div class='p-4'>
<div class='flex justify-between mb-4 items-center pop-title'> <div class='flex justify-between mb-4 items-center pop-title'>
<div class='greyColor' @click='showPublicizeType = false' style='font-weight: 400'>取消</div> <div class='greyColor' @click='showPublicizeType = false' style='font-weight: 400'>
取消
</div>
<div>健康宣教(可多选)</div> <div>健康宣教(可多选)</div>
<div class='blueColor' @click='publicizeTypeConfirm'>确定</div> <div class='blueColor' @click='publicizeTypeConfirm'>确定</div>
</div> </div>
...@@ -153,7 +156,6 @@ ...@@ -153,7 +156,6 @@
/> />
</div> </div>
<div> <div>
<div class='label-title mt-5'>下次随访日期</div> <div class='label-title mt-5'>下次随访日期</div>
<van-field <van-field
...@@ -376,7 +378,7 @@ export default { ...@@ -376,7 +378,7 @@ export default {
obj.drugsList = data.drugsList obj.drugsList = data.drugsList
} }
if (selectType.includes(2)) {//是否返回音频选中 if (selectType.includes(2)) {//是否返回音频选中
obj.annexList = [...obj.annexList ,...mp3List] obj.annexList = [...obj.annexList, ...mp3List]
} }
if (selectType.includes(3)) {//是否返回视频选中 if (selectType.includes(3)) {//是否返回视频选中
obj.annexList = [...obj.annexList, ...mp4List] obj.annexList = [...obj.annexList, ...mp4List]
...@@ -402,6 +404,9 @@ export default { ...@@ -402,6 +404,9 @@ export default {
if (this.checkPublicizeType && this.checkPublicizeType.length) { if (this.checkPublicizeType && this.checkPublicizeType.length) {
this.form.publicizeType = this.checkPublicizeType.join() this.form.publicizeType = this.checkPublicizeType.join()
this.form.publicizeTypeName = res.join() this.form.publicizeTypeName = res.join()
} else {
this.form.publicizeType = ''
this.form.publicizeTypeName = ''
} }
this.showPublicizeType = false this.showPublicizeType = false
}, },
...@@ -623,17 +628,36 @@ export default { ...@@ -623,17 +628,36 @@ export default {
resObj.annexList = uniqueArr(resObj.annexList, 'relativeUrl') resObj.annexList = uniqueArr(resObj.annexList, 'relativeUrl')
this.form.publicize = resObj this.form.publicize = resObj
}, },
onSubmit() { async onSubmit() {
try {
if (this.showTwo) {
await this.$refs.guideRef.submit()
}
if (this.showThree) {
//文本
if (this.form?.publicizeType?.includes(1)) {
await this.$refs.contentOne.submit()
}
//音频
if (this.form?.publicizeType?.includes(2)) {
await this.$refs.contentTwo.submit()
}
//视频
if (this.form?.publicizeType?.includes(3)) {
await this.$refs.contentThree.submit()
}
}
}catch (e) {}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.$refs.form.validate().then(async () => { this.$refs.form.validate().then(async () => {
let time = dayjs(this.form.screenTime).format('YYYY-MM-DD HH:00:00') let time = dayjs(this.form.screenTime).format('YYYY-MM-DD HH:00:00')
let content = `${this.modeEnumList?.urgeResidentShow ? `${this.firstForm?.residentsRecord?.residentName}先生/女士,` : `您好,`}请您于${time}${this.authInfo.unitName}进行专病高危筛查/慢病复查,祝早日恢复健康!` let content = `${this.modeEnumList?.urgeResidentShow ? `${this.firstForm?.residentsRecord?.residentName}先生/女士,` : `您好,`}请您于${time}${this.authInfo.unitName}进行专病高危筛查/慢病复查,祝早日恢复健康!`
const {publicizeType, ...others} = this.form const { publicizeType, ...others } = this.form
let publicizeTypeInfo = '' let publicizeTypeInfo = ''
if (publicizeType && publicizeType instanceof Array) { if (publicizeType && publicizeType instanceof Array) {
publicizeTypeInfo = publicizeType.join() publicizeTypeInfo = publicizeType.join()
} }
if (publicizeType && typeof publicizeType === "string") { if (publicizeType && typeof publicizeType === 'string') {
publicizeTypeInfo = publicizeType publicizeTypeInfo = publicizeType
} }
let res = { let res = {
...@@ -841,10 +865,10 @@ export default { ...@@ -841,10 +865,10 @@ export default {
overflow: visible; overflow: visible;
} }
:deep(.van-field__error-message) { //:deep(.van-field__error-message) {
position: absolute; // position: absolute;
margin-top: 3px; // margin-top: 3px;
} //}
:deep(.van-cell:after) { :deep(.van-cell:after) {
border-bottom: 0px; border-bottom: 0px;
...@@ -871,6 +895,7 @@ export default { ...@@ -871,6 +895,7 @@ export default {
line-height: 24px; line-height: 24px;
font-weight: bold; font-weight: bold;
} }
:deep(.van-popup) { :deep(.van-popup) {
min-height: 30% !important; min-height: 30% !important;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
type='textarea' type='textarea'
placeholder='请输入' placeholder='请输入'
class='input-back mt-2 form-input' class='input-back mt-2 form-input'
:rules='rules.templateContent'
/> />
</div> </div>
<!-- 更多选项--> <!-- 更多选项-->
...@@ -24,6 +25,7 @@ ...@@ -24,6 +25,7 @@
is-link is-link
placeholder='请选择' placeholder='请选择'
class='input-back mt-2 form-input' class='input-back mt-2 form-input'
name='contentSelectName'
:rules='rules.contentSelectName' :rules='rules.contentSelectName'
@click='showContentSelect= true' @click='showContentSelect= true'
> >
...@@ -35,8 +37,9 @@ ...@@ -35,8 +37,9 @@
<van-popup v-model:show='showContentSelect' position='bottom'> <van-popup v-model:show='showContentSelect' position='bottom'>
<div class='p-4'> <div class='p-4'>
<div class='flex justify-between mb-4 items-center pop-title'> <div class='flex justify-between mb-4 items-center pop-title'>
<div class='greyColor' @click='showContentSelect = false' style='font-weight: 400'>取消</div> <div class='greyColor' @click='showContentSelect = false' style='font-weight: 400'>取消
<div>{{contentTitle}}(可多选)</div> </div>
<div>{{ contentTitle }}(可多选)</div>
<div class='blueColor' @click='contentSelectConfirm'>确定</div> <div class='blueColor' @click='contentSelectConfirm'>确定</div>
</div> </div>
<CheckBtn multiple column-2 :options='contentArray' v-model:value='checkContentSelect' <CheckBtn multiple column-2 :options='contentArray' v-model:value='checkContentSelect'
...@@ -53,7 +56,8 @@ ...@@ -53,7 +56,8 @@
<div class='text-driver' v-if='index'></div> <div class='text-driver' v-if='index'></div>
<DocDrug v-model:value='item.drugsCode' placeholder='拼音码查询药品' <DocDrug v-model:value='item.drugsCode' placeholder='拼音码查询药品'
:valueName="selectData.drugsList ? selectData.drugsList[index]?.helpCode : ''" :valueName="selectData.drugsList ? selectData.drugsList[index]?.helpCode : ''"
@change='drugChange($event, item)' /> @change='drugChange($event, item)'
/>
<div class='flex items-center justify-between w-full mt-2'> <div class='flex items-center justify-between w-full mt-2'>
<van-field <van-field
v-model='item.dose' v-model='item.dose'
...@@ -62,6 +66,7 @@ ...@@ -62,6 +66,7 @@
type='digit' type='digit'
class='input-back form-input' class='input-back form-input'
style='flex: 1' style='flex: 1'
:rules='rules.dose'
/> />
<van-field <van-field
v-model='item.doseUnitName' v-model='item.doseUnitName'
...@@ -70,6 +75,7 @@ ...@@ -70,6 +75,7 @@
class='input-back ml-2 form-input' class='input-back ml-2 form-input'
style='width: .8rem' style='width: .8rem'
@click='showDoseUnit= true' @click='showDoseUnit= true'
:rules='rules.doseUnitName'
/> />
</div> </div>
<van-popup v-model:show='showDoseUnit' position='bottom'> <van-popup v-model:show='showDoseUnit' position='bottom'>
...@@ -90,6 +96,7 @@ ...@@ -90,6 +96,7 @@
placeholder='请选择' placeholder='请选择'
class='input-back mt-2 form-input' class='input-back mt-2 form-input'
@click='showFrequency= true' @click='showFrequency= true'
:rules='rules.frequencyName'
/> />
<van-popup v-model:show='showFrequency' position='bottom'> <van-popup v-model:show='showFrequency' position='bottom'>
<div class='p-4'> <div class='p-4'>
...@@ -109,6 +116,7 @@ ...@@ -109,6 +116,7 @@
placeholder='请选择' placeholder='请选择'
class='input-back mt-2 form-input' class='input-back mt-2 form-input'
@click='showUsageMethod= true' @click='showUsageMethod= true'
:rules='rules.usageMethodName'
/> />
<van-popup v-model:show='showUsageMethod' position='bottom'> <van-popup v-model:show='showUsageMethod' position='bottom'>
<div class='p-4'> <div class='p-4'>
...@@ -141,6 +149,8 @@ ...@@ -141,6 +149,8 @@
autosize autosize
type='textarea' type='textarea'
placeholder='请输入' placeholder='请输入'
:name='item.templateContent'
:rules='rules.templateContent'
class='input-back mt-2 form-input' class='input-back mt-2 form-input'
/> />
</div> </div>
...@@ -216,7 +226,13 @@ export default { ...@@ -216,7 +226,13 @@ export default {
form: {}, form: {},
selectData: {}, selectData: {},
activeMediaUrl: '', activeMediaUrl: '',
rules: {} rules: {
templateContent: [{ required: true, message: '请输入' }],
dose: [{ required: true, message: '请输入' }],
doseUnitName: [{ required: true, message: '请选择' }],
frequencyName: [{ required: true, message: '请选择' }],
usageMethodName: [{ required: true, message: '请选择' }]
}
} }
}, },
computed: { computed: {
...@@ -277,7 +293,7 @@ export default { ...@@ -277,7 +293,7 @@ export default {
handler() { handler() {
this.contentSelectChange() this.contentSelectChange()
} }
}, }
}, },
methods: { methods: {
//指导和宣教赋值 //指导和宣教赋值
...@@ -295,7 +311,7 @@ export default { ...@@ -295,7 +311,7 @@ export default {
//判断父组件的数据里是否存在 无 的选项 //判断父组件的数据里是否存在 无 的选项
let resList = infoC.filter(item => item.templateMode == 1) let resList = infoC.filter(item => item.templateMode == 1)
if (!resList.length) { //不存在无选项 if (!resList.length) { //不存在无选项
contentList = [ ...initC, ...infoC] contentList = [...initC, ...infoC]
} else { } else {
contentList = [...infoC] contentList = [...infoC]
} }
...@@ -314,7 +330,7 @@ export default { ...@@ -314,7 +330,7 @@ export default {
let contentSelectNameList = [] let contentSelectNameList = []
this.checkContentSelect = [] this.checkContentSelect = []
contentList.forEach(item => { contentList.forEach(item => {
if (item.templateMode !=1) { if (item.templateMode != 1) {
this.checkContentSelect.push(item.templateMode) this.checkContentSelect.push(item.templateMode)
contentSelectNameList.push(item.templateModeTrans) contentSelectNameList.push(item.templateModeTrans)
} }
...@@ -339,15 +355,21 @@ export default { ...@@ -339,15 +355,21 @@ export default {
_video: JSON.parse(JSON.stringify(info._video || [])), _video: JSON.parse(JSON.stringify(info._video || [])),
_audio: JSON.parse(JSON.stringify(info._audio || [])), _audio: JSON.parse(JSON.stringify(info._audio || [])),
drugSelect: 1, drugSelect: 1,
contentSelectName: contentSelectName, contentSelectName: contentSelectName
} }
return form return form
}, },
// 选择的模板内容变化 // 选择的模板内容变化
contentSelectChange() { contentSelectChange() {
debugger
const cont = this.form.contentList || [] const cont = this.form.contentList || []
let val = this.checkContentSelect let val = this.checkContentSelect
const delValue = cont.filter(i => !val.includes(i.templateMode)).map(e => e.templateMode) let delValue = []
cont.forEach(i => {
if (!val.includes(i.templateMode) && i.templateMode != 1) {
delValue.push(i.templateMode)
}
})
if (delValue.length) { if (delValue.length) {
this.form.contentList = this.form.contentList.filter(e => !delValue.includes(e.templateMode)) this.form.contentList = this.form.contentList.filter(e => !delValue.includes(e.templateMode))
// 药物指导处理 // 药物指导处理
...@@ -409,6 +431,7 @@ export default { ...@@ -409,6 +431,7 @@ export default {
return this.$refs.form return this.$refs.form
}, },
contentSelectConfirm() { contentSelectConfirm() {
debugger
let res = [] let res = []
this.contentArray.forEach(item => { this.contentArray.forEach(item => {
let selected = this.checkContentSelect.filter(i => i == item.value) let selected = this.checkContentSelect.filter(i => i == item.value)
...@@ -419,6 +442,9 @@ export default { ...@@ -419,6 +442,9 @@ export default {
if (this.checkContentSelect && this.checkContentSelect.length) { if (this.checkContentSelect && this.checkContentSelect.length) {
this.form.contentSelect = this.checkContentSelect.join() this.form.contentSelect = this.checkContentSelect.join()
this.form.contentSelectName = res.join() this.form.contentSelectName = res.join()
} else {
this.form.contentSelect = ''
this.form.contentSelectName = ''
} }
this.showContentSelect = false this.showContentSelect = false
}, },
...@@ -455,6 +481,8 @@ export default { ...@@ -455,6 +481,8 @@ export default {
}, },
submit() { submit() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
debugger
console.log(this.$refs.form)
this.$refs.form.validate().then(valid => { this.$refs.form.validate().then(valid => {
/* if (this.form.fileType.includes(3) && !this.form._video.length) { /* if (this.form.fileType.includes(3) && !this.form._video.length) {
this.$message.info('请上传视频') this.$message.info('请上传视频')
...@@ -539,6 +567,8 @@ export default { ...@@ -539,6 +567,8 @@ export default {
item.templateContent = str item.templateContent = str
} }
resolve(query) resolve(query)
}).catch(e => {
console.log( 'GuideTextVideo',e)
}) })
} }
} }
...@@ -618,4 +648,7 @@ export default { ...@@ -618,4 +648,7 @@ export default {
line-height: 24px; line-height: 24px;
font-weight: bold; font-weight: bold;
} }
//:deep(.van-field__error-message) {
// position: relative!important;
//}
</style> </style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment