Commit 4d99bc14 authored by gengchunlei's avatar gengchunlei

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

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