|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<view class="container">
|
|
|
- <uni-forms ref="baseForm" :modelValue="formData" :label-width="100">
|
|
|
- <uni-forms-item v-for="item in fileds" :label="item.title" :name="item.name" :key="item.name">
|
|
|
+ <uni-forms ref="baseForm" :modelValue="formData" :rules="rules" :label-width="80">
|
|
|
+ <uni-forms-item v-for="item in fileds" :label="item.title" :name="item.name" :key="item.name" required>
|
|
|
<uni-easyinput v-if="!item.formatter && !item.type" type="text" v-model="formData[item.name]" :placeholder="`请输入${item.title}`" />
|
|
|
<uni-data-checkbox v-model="formData[item.name]" v-if="item.formatter && item.type == 'checkbox'" :multiple="item.multiple || false" :localdata="item.dict" />
|
|
|
<uni-data-select v-model="formData[item.name]" v-if="item.formatter && item.type == 'select'" :localdata="item.dict"></uni-data-select>
|
|
@@ -11,7 +11,7 @@
|
|
|
<video controls v-if="item.type == 'video' && formData[item.name]" class="uploadVideo" :src="filesUrl + formData[item.name]"></video>
|
|
|
</uni-forms-item>
|
|
|
</uni-forms>
|
|
|
- <button :disabled="btnText == '已报道'" class="btn" type="primary" @click="submitForm">{{ btnText }}</button>
|
|
|
+ <button :disabled="btnText == '已报到'" class="btn" type="primary" @click="submitForm">{{ btnText }}</button>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
@@ -30,19 +30,48 @@
|
|
|
{ name: 'sex', title: '性别', formatter: 'dict:user_sex_type', type: 'checkbox' },
|
|
|
{ name: 'phone', title: '联系电话' },
|
|
|
{ name: 'workUnit', title: '工作单位' },
|
|
|
- { name: 'reportLocation', title: '报道位置' },
|
|
|
- { name: 'reportType', title: '报道类别', formatter: 'dict:baodao_type', type: 'select' },
|
|
|
+ { name: 'reportLocation', title: '报到位置' },
|
|
|
+ { name: 'reportType', title: '报到类别', formatter: 'dict:baodao_type', type: 'select' },
|
|
|
{ name: 'residence', title: '居住地' },
|
|
|
- { name: 'content', title: '报道内容' },
|
|
|
- { name: 'videoPath', title: '影片', type: 'video' },
|
|
|
- ]
|
|
|
+ { name: 'content', title: '报到内容' },
|
|
|
+ // { name: 'videoPath', title: '影片', type: 'video' },
|
|
|
+ ],
|
|
|
+ rules: {
|
|
|
+ name: {
|
|
|
+ rules:[{ required: true, errorMessage: '请填写姓名' }]
|
|
|
+ },
|
|
|
+ sex: {
|
|
|
+ rules:[{ required: true, errorMessage: '请选择性别' }]
|
|
|
+ },
|
|
|
+ phone: {
|
|
|
+ rules:[{ required: true, errorMessage: '请填写联系电话' }]
|
|
|
+ },
|
|
|
+ workUnit: {
|
|
|
+ rules:[{ required: true, errorMessage: '请填写工作单位' }]
|
|
|
+ },
|
|
|
+ reportLocation: {
|
|
|
+ rules:[{ required: true, errorMessage: '请填写报到位置' }]
|
|
|
+ },
|
|
|
+ reportType: {
|
|
|
+ rules:[{ required: true, errorMessage: '请选择报到类别' }]
|
|
|
+ },
|
|
|
+ residence: {
|
|
|
+ rules:[{ required: true, errorMessage: '请填写居住地' }]
|
|
|
+ },
|
|
|
+ content: {
|
|
|
+ rules:[{ required: true, errorMessage: '请填写报到内容' }]
|
|
|
+ },
|
|
|
+ // videoPath: {
|
|
|
+ // rules:[{ required: true, errorMessage: '请上传影片' }]
|
|
|
+ // }
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
async mounted() {
|
|
|
const res = await request.getDyStatus();
|
|
|
if (res.data) {
|
|
|
this.formData = { ...res.data, sex: String(res.data.sex), reportType: String(res.data.reportType) };;
|
|
|
- this.btnText = '已报道';
|
|
|
+ this.btnText = '已报到';
|
|
|
}
|
|
|
await this.setDict();
|
|
|
},
|
|
@@ -72,7 +101,7 @@
|
|
|
let tempFilePath=res.tempFiles[0].tempFilePath
|
|
|
// 上传视频
|
|
|
uni.uploadFile({
|
|
|
- url: _this.baseUrl + '/api/activity/photo',
|
|
|
+ url: _this.baseUrl + '/activity/photo',
|
|
|
name: 'file',
|
|
|
header: {
|
|
|
'Authorization': `Bearer ${token}`
|
|
@@ -94,18 +123,22 @@
|
|
|
},
|
|
|
})
|
|
|
},
|
|
|
- async submitForm() {
|
|
|
- const res = await request.submitdy(this.formData);
|
|
|
- if (res.code == 200) {
|
|
|
- uni.showToast({
|
|
|
- title: '提交成功',
|
|
|
- icon: 'success',
|
|
|
- duration: 2000,
|
|
|
- });
|
|
|
- setTimeout(() => {
|
|
|
- uni.navigateBack();
|
|
|
- }, 1000)
|
|
|
- }
|
|
|
+ submitForm() {
|
|
|
+ this.$refs.baseForm.validate().then(async valid=>{
|
|
|
+ const res = await request.submitdy(this.formData);
|
|
|
+ if (res.code == 200) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '提交成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 2000,
|
|
|
+ });
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.navigateBack();
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
+ }).catch(err =>{
|
|
|
+ console.log('表单错误信息:', err);
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
// 页面生命周期中onReachBottom(页面滚动到底部的事件)
|