step3.vue
4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<template>
<view>
<!-- 培训信息完善 -->
<view class="title-left-border">培训信息</view>
<uni-forms ref="baseForm" :modelValue="form" label-width="120">
<uni-forms-item label="所在单位名称" required name="unitName">
<uni-easyinput v-model="form.unitName" placeholder="请输入所在单位名称" />
</uni-forms-item>
<uni-forms-item label="现任职务" required name="unitRole">
<uni-easyinput v-model="form.unitRole" placeholder="请输入现任职务" />
</uni-forms-item>
<view v-if="activity.invoiceFlag=='1'">
<uni-forms-item label="是否需要发票" required name="invoiceFlag">
<uni-data-checkbox v-model="form.invoiceFlag" :localdata="invoiceFlag" />
</uni-forms-item>
<uni-forms-item label="发票形式" v-if="form.invoiceFlag=='1'" required name="invoiceType">
<uni-data-checkbox v-model="form.invoiceType" :localdata="invoiceType" />
</uni-forms-item>
<uni-forms-item label="开票信息" v-if="form.invoiceFlag=='1'" required name="invoiceInfo">
<uni-easyinput v-model="form.invoiceInfo" placeholder="请输入开票信息" />
</uni-forms-item>
</view>
<uni-forms-item :label="c.name" v-for="c in customInfo" :key="c.id">
<uni-easyinput v-if="c.type=='1'" v-model="form.customInfoObj[c.id]" placeholder="请输入" />
<view>
<uni-file-picker v-if="c.type == '2'" limit="1" file-mediatype="all" file-extname="doc,docx,pdf,txt"
v-model="c.value" @select="selectFile"
@delete="delSupplementFile(c,$event)" />
<text v-if="c.type == '2'" style="font-size: 24rpx;color: #999;">仅支持上传doc,docx,pdf,txt</text>
<uni-file-picker v-if="c.type == '3'" v-model="upSupplement3Value" return-type="object" limit="1"
@select="upSupplement3" @delete="delSupplementImg(c,$event)" />
</view>
<uni-data-select v-model="c.value" v-if="c.type == '4'" :localdata="c.option"></uni-data-select>
</uni-forms-item>
</uni-forms>
</view>
<view class="fixedBottom">
<button class="btn btn-red-kx" @click="prev">上一步</button>
<button class="btn btn-red" @click="next">下一步</button>
</view>
</template>
<script setup>
import {
onLoad
} from '@dcloudio/uni-app'
import {
ref,
reactive,
toRefs,
computed,
watch
} from 'vue'
import _ from 'lodash'
import * as train from '@/training/train.js'
const emit = defineEmits(['prev', 'next'])
const props = defineProps({
activity: {
type: Object,
default: () => {}
},
trainId: {
type: String,
default: () => {}
},
active: {
type: Number,
default: 0
}
})
const customInfo = computed(() => {
if (props.activity.customInfo) {
return JSON.parse(props.activity.customInfo).info
} else {
return []
}
})
const data = reactive({
form: {
invoiceFlag: '1',
customInfoObj: {}
},
invoiceFlag: [{
value: '0',
text: '否'
}, {
value: '1',
text: '是'
}],
invoiceType: [{
value: 0,
text: '电子票'
}, {
value: 1,
text: '纸质专票'
}, {
value: 2,
text: '纸质普票'
}]
})
const {
form,
invoiceType,
invoiceFlag
} = toRefs(data)
watch(() => props.activity.invoiceFlag, (val) => {
if (val == '1') {
if (!form.value.invoiceType) {
form.value.invoiceType = _.orderBy(props.activity.invoiceType.split(','))[0]
}
}
}, {
immediate: true
})
watch(() => props.active, (val) => {
if (val == 2) {
uni.showLoading({
title:'加载中'
})
train.getTrainPersonalInfo(props.trainId).then(res => {
form.value = res.data || {}
if (res.data?.customInfo) {
form.value.customInfoObj = JSON.parse(res.data.customInfo)
} else {
form.value.customInfoObj = {}
}
uni.hideLoading()
})
}
})
function prev() {
emit('prev')
}
function next() {
// 判断必填
if(!form.value.unitName){
uni.showToast({
title: '请填写所在单位',
icon: 'none'
})
return
}
if(!form.value.unitRole){
uni.showToast({
title: '请填写职务信息',
icon: 'none'
})
return
}
form.value.activityId = props.trainId
form.value.customInfo = JSON.stringify(form.value.customInfoObj)
train.savePersonalInfo(form.value).then(() => {
uni.showToast({
title: '保存成功',
icon: 'none'
}).finally(res=>{
emit('next')
})
})
}
</script>
<style scoped lang="scss">
</style>