|
|
@@ -10,35 +10,61 @@
|
|
|
<input v-model="phone" placeholder="请输入手机号" placeholder-class="p-placeholder"/>
|
|
|
</view>
|
|
|
<view v-for='item,index in parmas' class="p-form-item">
|
|
|
- <view class="p-label">{{item.label}}</view>
|
|
|
+ <view class="p-label">{{item.chineseName}}</view>
|
|
|
<!-- 输入框 -->
|
|
|
<view v-if="item.type==1" class="p-input">
|
|
|
- <input v-model="item.value" :placeholder="'请输入'+item.label" placeholder-class="p-placeholder"/>
|
|
|
+ <input v-model="item.value" :placeholder="'请输入'+item.chineseName" placeholder-class="p-placeholder"/>
|
|
|
</view>
|
|
|
<!-- 单选 -->
|
|
|
<view v-if="item.type==2" class="p-select">
|
|
|
<view class="ddflex">
|
|
|
- <view class="ddflex p-select-item" v-for="it in item.data" @click="pSelect(item,it)">
|
|
|
- <image v-if="item.value===it.value" src="/static/images/select_h.png"></image>
|
|
|
+ <view class="ddflex p-select-item" v-for="it in item.selectValues" @click="pSelect(item,it)">
|
|
|
+ <image v-if="item.value===it.name" src="/static/images/select_h.png"></image>
|
|
|
<image v-else src="/static/images/select.png"></image>
|
|
|
- <view>{{it.label}}</view>
|
|
|
+ <view>{{it.name}}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 多选 -->
|
|
|
<view v-if="item.type==3" class="p-select-group">
|
|
|
<view class="ddflex">
|
|
|
- <view :class="'ddflex p-select-group-item '+(item.value.indexOf(it.value)!=-1?'p-select-group-item-active':'')" v-for="it in item.data" @click="pSelectGroup(item,it)">
|
|
|
- <view>{{it.label}}</view>
|
|
|
+ <view :class="'ddflex p-select-group-item '+(item.value&&item.value.split(',').indexOf(it.name)!=-1?'p-select-group-item-active':'')" v-for="it in item.selectValues" @click="pSelectGroup(item,it)">
|
|
|
+ <view>{{it.name}}</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <!-- 图片 -->
|
|
|
+ <view v-if="item.type==4">
|
|
|
+ <view class="ddflex" style="margin-top: 30rpx;">
|
|
|
+ <view class="upload-photo-image" v-if="item.value" @click="uploadImage(item)">
|
|
|
+ <image :src="item.value" mode="aspectFill"></image>
|
|
|
+ <image class="upload-photo-close" src="/static/pages/images/close3.png"
|
|
|
+ @click.stop="deleteImage(item)"></image>
|
|
|
+ </view>
|
|
|
+ <view class="upload-photo ddflex" @click="uploadImage(item)" v-else>
|
|
|
+ <image src="../static/images/photo.png"></image>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <!-- 多图片 -->
|
|
|
+ <view v-if="item.type==5">
|
|
|
+ <view class="ddflex" style="margin-top: 30rpx;">
|
|
|
+ <view class="upload-photo-image" v-for="it,idx in item.value?item.value.split(','):[]" @click="uploadImage(item)">
|
|
|
+ <image :src="it" mode="aspectFill"></image>
|
|
|
+ <image class="upload-photo-close" src="/static/pages/images/close3.png"
|
|
|
+ @click.stop="deleteImage(item,idx)"></image>
|
|
|
+ </view>
|
|
|
+ <view class="upload-photo ddflex" @click="uploadImage(item)">
|
|
|
+ <image src="../static/images/photo.png"></image>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 文本域 -->
|
|
|
- <view v-if="item.type==4" class="p-input">
|
|
|
+ <!-- <view v-if="item.type==4" class="p-input">
|
|
|
<view class="ddflex">
|
|
|
- <textarea v-model="item.value" :placeholder="'请输入'+item.label" placeholder-class="p-placeholder"></textarea>
|
|
|
+ <textarea v-model="item.value" :placeholder="'请输入'+item.chineseName" placeholder-class="p-placeholder"></textarea>
|
|
|
</view>
|
|
|
- </view>
|
|
|
+ </view> -->
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
@@ -64,6 +90,7 @@ import util from "../../utils/util.js";
|
|
|
name:'',
|
|
|
phone:'',
|
|
|
parmas:[],
|
|
|
+ // type 1 输入框 2单择框 3多选框 4单图片 5多图片
|
|
|
// parmas:[{
|
|
|
// label:'姓名',
|
|
|
// name:'name',
|
|
|
@@ -97,10 +124,13 @@ import util from "../../utils/util.js";
|
|
|
// value:'',
|
|
|
// type:4,//文本域
|
|
|
// }],
|
|
|
- index:null
|
|
|
+ index:null,
|
|
|
+ id:null
|
|
|
}
|
|
|
},
|
|
|
- onLoad(options) {
|
|
|
+ async onLoad(options) {
|
|
|
+ this.id = options.id
|
|
|
+ await this.getExtForm()
|
|
|
if(options.index){
|
|
|
this.index = options.index
|
|
|
if(req.getStorage('personList')){
|
|
|
@@ -110,7 +140,7 @@ import util from "../../utils/util.js";
|
|
|
this.parmas.map(item=>{
|
|
|
parmas.extend.map(it=>{
|
|
|
if(item.type == it.type&&item.name == it.name){
|
|
|
- item.value = it.value
|
|
|
+ item.value = it.value
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
@@ -121,26 +151,52 @@ import util from "../../utils/util.js";
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
+ getExtForm(){
|
|
|
+ return new Promise((r,j)=>{
|
|
|
+ req.getRequest('/api/match/detail',{id:this.id},res=>{
|
|
|
+ this.parmas = res.extForm?JSON.parse(res.extForm):[]
|
|
|
+ if(this.parmas.length>0){
|
|
|
+ this.parmas.map(item=>{
|
|
|
+ item.value = ''
|
|
|
+ })
|
|
|
+ }
|
|
|
+ r()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
pSelect(item,it){
|
|
|
- if(item.value === it.value){
|
|
|
+ console.log('cc')
|
|
|
+ if(item.value === it.name){
|
|
|
item.value=''
|
|
|
- }else if(item.value != it.value){
|
|
|
- item.value=it.value
|
|
|
+ }else if(item.value != it.name){
|
|
|
+ item.value=it.name
|
|
|
}
|
|
|
+ this.parmas = JSON.parse(JSON.stringify(this.parmas))
|
|
|
},
|
|
|
pSelectGroup(item,it){
|
|
|
if(item.value=='') item.value=[]
|
|
|
- let index = item.value.indexOf(it.value)
|
|
|
+ else item.value = item.value.split(',')
|
|
|
+ let index = item.value.indexOf(it.name)
|
|
|
if(index!=-1){
|
|
|
item.value.splice(index,1)
|
|
|
}else {
|
|
|
- item.value.push(it.value)
|
|
|
+ item.value.push(it.name)
|
|
|
}
|
|
|
+ item.value = item.value.join(',')
|
|
|
+ this.parmas = JSON.parse(JSON.stringify(this.parmas))
|
|
|
},
|
|
|
submit(){
|
|
|
if(!this.name) return req.msg('请填写报名人员姓名');
|
|
|
if(!this.phone) return req.msg('请填写报名人员手机号码');
|
|
|
if(!util.isMobile(this.phone)) return req.msg('请填写正确的手机号码')
|
|
|
+
|
|
|
+ // 数据校验
|
|
|
+ for(let i=0;i<this.parmas.length;i++){
|
|
|
+ let item = this.parmas[i]
|
|
|
+ if(item.required==1){
|
|
|
+ if(!item.value) return req.msg("请完善"+item.chineseName)
|
|
|
+ }
|
|
|
+ }
|
|
|
if(this.index){
|
|
|
console.log('parmas',JSON.stringify(this.parmas))
|
|
|
let personList = []
|
|
|
@@ -172,7 +228,54 @@ import util from "../../utils/util.js";
|
|
|
req.setStorage('personList',personList)
|
|
|
uni.navigateBack()
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ uploadImage(item) {
|
|
|
+ let that = this;
|
|
|
+ let count = 1
|
|
|
+ if(item.type==5) {
|
|
|
+ count = 9
|
|
|
+ item.value = item.value?item.value.split(','):[]
|
|
|
+ }
|
|
|
+ uni.chooseImage({
|
|
|
+ count: count,
|
|
|
+ sizeType: ['original', 'compressed'],
|
|
|
+ sourceType: ['album', 'camera'],
|
|
|
+ success: function({
|
|
|
+ tempFilePaths
|
|
|
+ }) {
|
|
|
+ var promise = Promise.all(
|
|
|
+ tempFilePaths.map(tempFilePath => {
|
|
|
+ return new Promise(function(resolve, reject) {
|
|
|
+ req.uploadFile('/api/nocheck/upload', tempFilePath,
|
|
|
+ res => {
|
|
|
+ if(item.type==5) {
|
|
|
+ console.log('item.type')
|
|
|
+ item.value = item.value.concat(res.src)
|
|
|
+ }
|
|
|
+ else item.value = res.src
|
|
|
+ resolve()
|
|
|
+ });
|
|
|
+ });
|
|
|
+ })
|
|
|
+ );
|
|
|
+ promise
|
|
|
+ .then(function(results) {
|
|
|
+ item.value = item.value.join(',')
|
|
|
+ that.parmas = JSON.parse(JSON.stringify(that.parmas))
|
|
|
+ console.log(results);
|
|
|
+ })
|
|
|
+ .catch(function(err) {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ deleteImage(item,index) {
|
|
|
+ if(item.type==5) {
|
|
|
+ item.value.splice(index, 1)
|
|
|
+ }
|
|
|
+ else item.value = ''
|
|
|
+ },
|
|
|
},
|
|
|
mounted() {
|
|
|
const systemInfo = uni.getSystemInfoSync();
|