addLevel.vue
11.7 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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
<template>
<div class="app-container">
<el-card>
<div>
<br>
<el-form ref="formRef" :model="queryParams" :rules="rules" size="small" label-width="auto">
<el-form-item label="证件号码:" prop="idcCode">
<el-select v-model="form.idcType" placeholder="请选择" style="width: 200px;">
<el-option v-for="item in cardType" :key="item.value" :hidden="item.value==2" :label="item.label" :value="item.value" />
</el-select>
<el-input v-model.trim="form.idcCode" placeholder="请输入" style="width: 300px;" />
<el-button :loading="loading" class="btn" icon="Search" type="primary" @click="searchFN"> 查询</el-button>
</el-form-item>
</el-form>
</div>
<br>
<div>
<el-table border :data="list" style="width: 100%">
<el-table-column label="序号" align="center" type="index" width="55" />
<el-table-column
label="姓名"
align="center"
prop="perName"
min-width="120"
:show-overflow-tooltip="true"
/>
<el-table-column
label="证件类型"
align="center"
prop=""
min-width="120"
:show-overflow-tooltip="true"
>
<template #default="scope">
<div>{{ cardType[scope.row.idcType].label }}</div>
</template>
</el-table-column>
<el-table-column
label="证件号"
align="center"
prop="idcCode"
min-width="140"
:show-overflow-tooltip="true"
/>
<el-table-column
label="级位"
align="center"
prop=""
min-width="100"
>
<template #default="scope">
{{ szToHz(scope.row.oldJi) }}级
</template>
</el-table-column>
<el-table-column
label="级位编号"
align="center"
prop="examPersonData.certCode"
min-width="120"
:show-overflow-tooltip="true"
/>
<el-table-column
label="通过日期"
align="center"
prop=""
min-width="100"
>
<template #default="scope">
<span>{{ parseTime(scope.row?.examPersonData?.certTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column
label="变更后级别"
align="center"
prop=""
min-width="100"
>
<template #default="scope">
<!-- {{ szToHz(scope.row.examPersonData.levelOld) }}级-->
<el-select v-model="scope.row.newJi" placeholder="" style="width: 100px;" @change="editJIFN(scope.row)">
<el-option v-for="item in levelList" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</template>
</el-table-column>
<el-table-column
label="变更理由"
align="center"
prop=""
min-width="140"
>
<template #default="scope">
<el-select v-model="scope.row.reason" placeholder="请选择" style="width: 100%;" @change="reasonFN(scope.row)">
<el-option label="报错级位" value="1" />
<el-option label="以前有级位无法报下一级" value="2" />
<el-option label="其它" value="3" />
</el-select>
</template>
</el-table-column>
<el-table-column
label="附件"
align="center"
prop=""
min-width="220"
>
<template #default="scope">
<el-button v-if="scope.row.fileUrl" size="small" type="text" @click="handleDownload(scope.row,'fileUrl')">下载</el-button>
<span v-else style="color: #d51515;font-size: 12px">需上传以前级位资料或相关情况说明</span>
<el-button type="text" size="small" @click="handleUpdate(scope.row,'fileUrl')">编辑</el-button>
</template>
</el-table-column>
<el-table-column
label="操作"
align="center"
fixed="right"
class-name="small-padding"
width="100"
>
<template #default="scope">
<el-button type="danger" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
:total="total"
@pagination="getList"
/>
</div>
<br>
<br>
<el-row justify="center">
<!-- <el-button :disabled="list<=0" type="primary" @click="commitFN"> 保存</el-button>-->
<el-button :disabled="list<=0" type="primary" @click="commitFN"> 保存并提交</el-button>
</el-row>
</el-card>
<onLine ref="onLineRef" @backFN="backFN" />
<update ref="updateRef" @lastStep="getList" />
<imgView ref="imgViewRef" />
<el-link v-show="false" ref="linkRef" :href="fillImgUrl(url)" :underline="false" target="_blank" />
</div>
</template>
<script setup>
import { ref, toRefs, reactive, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { getCurrentInstance } from '@vue/runtime-core'
import onLine from '@/views/member/dataAlteration/level/onLine.vue'
import {
pickUpByPersonInfo,
addList,
editNewJi,
commitApi,
addLevelModToRange, deleteApi
} from '@/api/member/dataAlteration/level.js'
import imgView from './imgView.vue'
import { szToHz } from '@/utils/ruoyi'
import update from './updata.vue'
const url = ref()
const cardType = ref([
{ label: '身份证', value: '0' },
{ label: '港澳台通行证 ', value: '1' },
{ label: '中国护照', value: '2' },
{ label: '外国护照', value: '3' },
{ label: '其它', value: '4' },
{ label: '户口本', value: '5' }
])
const levelList = ref([
{ label: '九级', value: '9' },
{ label: '八级', value: '8' },
{ label: '七级', value: '7' },
{ label: '六级', value: '6' },
{ label: '五级', value: '5' },
{ label: '四级', value: '4' },
{ label: '三级', value: '3' },
{ label: '二级', value: '2' },
{ label: '一级', value: '1' }
])
const router = useRouter()
const route = useRoute()
const { proxy } = getCurrentInstance()
const data = reactive({
rules: {
idcCode: [
{ validator: validateMin, trigger: 'blur' }
// { required: true, message: '请输入证件号!', trigger: 'blur' }
]
},
form: {},
queryParams: {
rangeId: '',
pageSize: 10,
pageNum: 1
},
formData: {}
})
const total = ref(0)
const list = ref([])
const loading = ref(false)
const { form, queryParams, rules } = toRefs(data)
onMounted(() => {
if (route.query.rangeId && route.query.rangeId != 0) {
form.value.rangeId = route.query.rangeId
queryParams.value.rangeId = route.query.rangeId
getList()
} else {
form.value.rangeId = ''
queryParams.value.rangeId = ''
}
})
// 身份证校验
// 自定义表单验证
function validateMin(rule, value, callback) {
const i = /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/
if (!form.value.idcType) callback(new Error('请选择证件类型!'))
if (form.value.idcType == 0) {
if (!form.value.idcCode) {
callback(new Error('请输证件号!'))
}
if (!i.test(form.value.idcCode)) {
callback(new Error('请输入正确的证件号!'))
} else {
callback()
}
} else {
callback()
}
}
// 窗口关闭
function backFN(rangeId) {
form.value.idcCode = null
form.value.idcType = null
if (rangeId && rangeId != 0) {
form.value.rangeId = rangeId
queryParams.value.rangeId = rangeId
console.log(rangeId)
getList()
}
}
async function getList() {
const res = await addList(queryParams.value)
if (res.code == 200) {
list.value = res.rows
list.value.forEach(item => {
item.examPersonData = JSON.parse(item.examPersonData)
item.fileUrl = JSON.parse(item.fileUrl)
})
total.value = res.total
}
}
// 提交审核
async function commitFN() {
const flag = list.value.some(item => {
if (!item.fileUrl && !item.reason) {
proxy.$modal.msgError(item.perName + '信息不完整,请确认必填项!')
return !item.fileUrl && !item.reason
}
})
if (flag) return
if (form.value.rangeId == -1) return
const res = await commitApi([queryParams.value.rangeId])
if (res.code == 200) {
proxy.$modal.msgSuccess('提交成功!')
router.go(-1)
} else {
proxy.$modal.msgError('提交失败!')
}
}
/** 删除按钮操作 */
function handleDelete(row) {
proxy.$modal.confirm('是否确认删除姓名为"' + row.perName + '"的数据项?').then(function() {
return deleteApi([row.id])
}).then(() => {
proxy.$modal.msgSuccess('删除成功')
if (list.value.length == 1 && queryParams.value.pageNum === 1) {
form.value.rangeId = ''
queryParams.value.rangeId = ''
list.value = list.value.filter(item => {
return item.id != row.id
})
} else if (list.value.length == 1 && queryParams.value.pageNum > 1) {
queryParams.value.pageNum--
getList()
} else {
getList()
}
}).catch(() => {
}).finally(() => {
})
}
// 查询
async function searchFN() {
proxy.$refs['formRef'].validate(async(valid) => {
if (valid) {
loading.value = true
try {
const res = await pickUpByPersonInfo(form.value.idcType, form.value.idcCode)
if (res.code == 200) {
proxy.$refs['onLineRef'].open(res.data, queryParams.value.rangeId)
console.log(queryParams.value.rangeId)
}
loading.value = false
} catch (e) {
loading.value = false
}
} else {
proxy.$modal.msgError('请完善查询信息!')
}
})
}
// 更改级位
async function editJIFN(row) {
const res = await editNewJi({ modId: row.id, NewJi: row.newJi })
if (res.code == 200) {
proxy.$modal.msgSuccess('操作成功!')
await getList()
}
}
// 文件上传
function handleUpdate(row, val) {
proxy.$refs['updateRef'].open(row, val)
}
// 变更理由
async function reasonFN(row) {
console.log(row)
const res = await addLevelModToRange({
reason: row.reason,
fileUrl: row.fileUrl,
modId: row.id
})
if (res.code == 200) {
proxy.$modal.msgSuccess('操作成功!')
}
await getList()
}
// 图片预览
function imgRul(row) {
proxy.$refs['imgView'].open(row)
}
function handleDownload(row) {
url.value = row.fileUrl?.[0]?.url
proxy.$refs['linkRef'].$el.click()
}
</script>
<style scoped lang="scss">
.box{
padding: 50px;
width: 100%;
}
.tdFlex {
display: flex;
}
.w50 {
width: 50%;
}
.ml20 {
margin-left: 20px;
}
:deep(.el-button--info){
background-color: #920f20;
border: 1px solid #920f20;
}
.idCode{
:deep(.el-upload--picture-card){
width: 380px;
height: 240px;
}
:deep(.fileItem ){
width: 380px;
height: 240px;
}
:deep(.el-upload__tip){
display: none;
}
:deep(.el-upload-list--picture-card){
// text-align: center;
display: flex;
justify-content: center;
}
}
.text-center{
display: flex;
margin-top: 30px;
margin-bottom: 40px;
}
.text-center>div{
margin-left: 20px;
}
.btn{
margin-left: 10px;
}
.a{
color:#0000ff;
border-bottom: 1px solid #0000ff;
}
.nav-box{
padding: 10px;
font-size: 16px;
background-color: #fff;
span{
font-weight: 600;
font-size: 18px;
margin: 0 10px;
}
}
</style>