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
<template>
<div>
<a-spin :spinning="loading" style="width: 100%;height: 100%;">
<a-form-model ref="form" :model="formData" :rules="rules" class="from-table">
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">证件号</div>
</a-col>
<a-col :span="20">
<a-form-model-item ref="certId" prop="certId">
{{formData.certId}}
<!-- <a-input v-model="formData.certId" @blur="() => { $refs.certId.onFieldBlur();}" disabled style="width: 180px" /> -->
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">姓名</div>
</a-col>
<a-col :span="20">
<a-form-model-item ref="personName" prop="personName">
<a-input v-model="formData.personName" @blur="() => {$refs.personName.onFieldBlur(); }" style="width: 180px" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">邮箱</div>
</a-col>
<a-col :span="20">
<a-form-model-item ref="email" prop="email">
<a-input v-model="formData.email" @blur="() => {$refs.email.onFieldBlur();}" style="width: 180px" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">学历</div>
</a-col>
<a-col :span="20">
<a-form-model-item ref="education" prop="education">
<para-select v-model="formData.education" :typeId="8" :width="180" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">职称</div>
</a-col>
<a-col :span="20">
<a-form-model-item ref="title" prop="title" :label-col="{ span: 3 }" :wrapper-col="{ span: 21 }">
<para-multi-select v-model="formData.title" :typeId="7" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">专业</div>
</a-col>
<a-col :span="20">
<a-form-model-item ref="spec" prop="spec" >
<cascader-select v-model="formData.spec" />
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24" style="text-align:center;">
<a-button type="primary" style="margin-right:50px;" @click="submit">保存</a-button>
</a-col>
</a-row>
</a-form-model>
</a-spin>
</div>
</template>
<script>
import { isEmptyParams, getCardInfo } from "@/views/utils/common"
import { isIdentityId } from '@/views/utils/validate'
import moment from 'moment'
import cascaderSelect from '@/views/components/common/cascaderSelect'
export default {
name: "personEdit",
components: {
cascaderSelect
},
data () {
return {
formData: {
id: null, certId: null, sex: null, birthday: null, mobile: null, email: null, title: null, unitId: null, education: null, spec: null, address: null
},
rules: {
personName: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
email: [{ required: true, message: '请输入邮箱', trigger: 'blur' }],
title: [{ required: true, message: '请选择职称', trigger: 'change' }],
unitId: [{ required: true, message: '请选择单位', trigger: 'change' }],
education: [{ required: true, message: '请选择学历', trigger: 'change' }],
spec: [{ required: true, message: '请选择专业', trigger: 'change' }],
},
loading: false,
}
},
props: {
value: {
type: String,
default: () => {
return null
}
},
obj: {
type: Object
}
},
created () {
this.getPersonById()
},
methods: {
moment,
getPersonById () {
this.loading = true
this.$api.person.getPersonById({ id: this.value }).then(({ data = {} }) => {
if (data) {
this.formData = data
}
this.loading = false
}).catch(() => { this.loading = false })
},
onBirthdayChange (date, dateString) {
this.formData.birthday = dateString;
},
submit () {
this.$refs.form.validate(valid => {
if (valid) {
this.loading = true
let pars = isEmptyParams(this.formData)
let par = { ...pars }
this.$api.person.updatePerson(par).then(({ data = {} }) => {
if (data) {
this.$message.success('成功!')
this.$emit('close', 'edit')
}
this.loading = false
}).catch(() => { this.loading = false })
} else {
this.$message.info('信息未填写完整!')
return false
}
})
}
}
}
</script>