chooseExaminer.vue
7.22 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<template>
<view class="container">
<!-- 搜索区域:固定在顶部 -->
<view class="search-area">
<view class="search-item">
<text>考官姓名:</text>
<input v-model="queryParams.name" class="search-input" placeholder="请输入考官姓名"/>
</view>
<view class="search-item">
<text>考官编号:</text>
<input v-model="queryParams.certCode" class="search-input" placeholder="请输入考官编号"/>
</view>
<view class="search-buttons">
<button class="search-btn" @click="handleQuery">查询</button>
<button class="reset-btn" @click="resetQuery">重置</button>
</view>
</view>
<view v-for="(item, index) in infoList" :key="item.perId" class="list-item">
<view class="info">
<view class="name">{{ item.name }} {{ item.perCode }}</view>
<view class="idc">证件号码:{{ item.idcCode }}</view>
<view class="reg">注册地:{{ item.memName }}</view>
</view>
<button
:class="{ disabled: checkChosen(item) }"
:disabled="checkChosen(item)"
class="choose-btn"
@click="handleChoose(item)"
>
{{ checkChosen(item) ? '已选择' : '选择' }}
</button>
</view>
<uni-popup ref="expirePopup" background-color="rgba(0,0,0,0.5)" type="center">
<view class="custom-modal">
<view class="modal-title">提示</view>
<view class="modal-content">该考官资质已过期,是否继续添加?</view>
<view class="modal-btns">
<button class="btn-cancel" @click="closeExpirePopup()">取消</button>
<button class="btn-confirm" @click="confirmAddExpireExaminer()">确定</button>
</view>
</view>
</uni-popup>
</view>
</template>
<script setup>
import {ref, reactive, toRefs} from 'vue'
import {onLoad} from '@dcloudio/uni-app';
import * as api from '@/common/api.js'
import _ from 'lodash'
const props = defineProps({
isValidity: {
type: String,
default: '0'
}
})
const isValidity = ref('0')
const memId = ref('')
const chosen = ref([])
const expirePopup = ref(null)
const currentExpireItem = ref(null)
const infoList = ref([])
const loading = ref(false)
const total = ref(0)
const selfSelect = ref('0')
const data = reactive({
queryParams: {
pageNum: 1,
pageSize: 10,
name: null,
certCode: null,
type: 1,
shenMemId: ''
}
})
const {queryParams} = toRefs(data)
onLoad((option) => {
console.log(option)
isValidity.value = option.isValidity
memId.value = option.memId
chosen.value = JSON.parse(option.chosen)
selfSelect.value = option.selfSelect ?? '1'
})
// 获取考官列表
async function getList() {
if (!queryParams.value.name)
return uni.showToast({title: '请输入考官姓名', icon: 'none'})
if (queryParams.value.type == 1 && !queryParams.value.certCode)
return uni.showToast({title: '请输入考官编号', icon: 'none'})
loading.value = true
try {
const res = await api.getCoachList(queryParams.value)
infoList.value = res.rows || []
total.value = res.total || 0
} catch (err) {
console.error('获取考官列表失败:', err)
infoList.value = []
total.value = 0
} finally {
loading.value = false
}
// 空数组提示
if (infoList.value.length === 0) {
uni.showToast({title: '请核实考官编号、有效期及归属地', icon: 'none', duration: 2000})
}
}
// 检查是否已选择
function checkChosen(row) {
return _.some(chosen.value, (c) => {
return c.perId == row.perId
})
}
// 查询
function handleQuery() {
queryParams.value.pageNum = 1
getList()
}
// 重置
function resetQuery() {
queryParams.value.name = null
queryParams.value.certCode = null
infoList.value = []
total.value = 0
}
function handleChoose(row) {
if (checkChosen(row)) {
return uni.showToast({title: '已选择该考官', icon: 'none'})
}
// 暂存当前考官数据
currentExpireItem.value = row
// 资质过期逻辑
if (row.canChoose != 1) {
// 打开自定义过期确认弹窗
expirePopup.value.open()
return
}
confirmAddExpireExaminer()
}
// 关闭过期确认弹窗
function closeExpirePopup() {
expirePopup.value.close()
}
// 确认添加过期考官
async function confirmAddExpireExaminer() {
if (!currentExpireItem.value) return
try {
if (selfSelect.value == 1) {
// 自己添
await api.selfAdd(currentExpireItem.value.perId)
} else {
// 省级添加
await api.otherAdd(memId.value, currentExpireItem.value.perId)
}
uni.showToast({title: '添加成功', icon: 'success'})
uni.navigateBack({delta: 1})
} catch (err) {
console.log(err)
const errMsg = err?.data?.msg || err?.msg || '添加失败'
uni.showToast({title: errMsg, icon: 'none', duration: 3000})
} finally {
expirePopup.value.close()
currentExpireItem.value = null
await getList()
}
}
</script>
<style scoped>
.container {
display: flex;
flex-direction: column;
background: #f7f7f7;
min-height: 100vh;
padding: 0;
}
.search-area {
background: #ffffff;
border-radius: 16rpx;
padding: 30rpx;
margin: 30rpx;
flex-shrink: 0;
}
.search-item {
display: flex;
align-items: center;
margin-bottom: 20rpx;
}
.search-input {
flex: 1;
border: 1rpx solid #ddd;
border-radius: 8rpx;
padding: 20rpx;
font-size: 28rpx;
}
.search-buttons {
display: flex;
justify-content: space-between;
margin-top: 30rpx;
margin-left: 80px;
}
.search-btn, .reset-btn {
width: 220rpx;
height: 70rpx;
line-height: 70rpx;
border-radius: 8rpx;
text-align: center;
font-size: 28rpx;
}
.search-btn {
background: #C4121B;
color: #fff;
}
.reset-btn {
background: #f7f7f7;
color: #333;
}
/* 列表区域:滚动 */
.list-area {
flex: 1;
background: #ffffff;
border-radius: 16rpx;
margin: 0 30rpx 30rpx;
padding: 0 30rpx;
}
.list-item {
padding: 30rpx;
margin: 0 30rpx;
border-bottom: 1rpx solid #eee;
background-color: #fff;
}
.info {
flex: 1;
}
.name {
font-size: 30rpx;
font-weight: bold;
color: #333;
}
.idc, .reg {
font-size: 26rpx;
color: #666;
margin: 20rpx 0;
}
.choose-btn {
color: #C4121B;
font-size: 26rpx;
border: 1rpx solid #C4121B;
border-radius: 8rpx;
padding: 10rpx 20rpx;
background-color: #fff;
margin: 10rpx auto;
}
.choose-btn.disabled {
color: #ccc;
border-color: #ccc;
}
/* 自定义弹窗样式(和之前保持统一) */
.custom-modal {
width: 600rpx;
background: #fff;
border-radius: 20rpx;
padding: 40rpx 30rpx;
box-sizing: border-box;
text-align: center;
}
.modal-title {
font-size: 36rpx;
font-weight: 600;
color: #333;
margin-bottom: 30rpx;
}
.modal-content {
font-size: 30rpx;
color: #666;
line-height: 1.6;
margin-bottom: 30rpx;
}
.modal-btns {
display: flex;
justify-content: space-between;
gap: 20rpx;
}
.btn-cancel {
flex: 1;
height: 80rpx;
line-height: 80rpx;
background: #f5f5f5;
color: #999;
border-radius: 40rpx;
font-size: 32rpx;
border: none;
}
.btn-confirm {
flex: 1;
height: 80rpx;
line-height: 80rpx;
background: #C4121B;
color: #fff;
border-radius: 40rpx;
font-size: 32rpx;
border: none;
}
/* 去除button默认边框 */
.btn-cancel::after, .btn-confirm::after {
border: none;
}
</style>