diff --git a/src/api/person/person.js b/src/api/person/person.js index 452a3e5..e9927ff 100644 --- a/src/api/person/person.js +++ b/src/api/person/person.js @@ -9,6 +9,7 @@ const personApi = { quit: 'person/quit', resetPwd: 'person/resetPwd', setAdmin: 'person/setAdmin', + changeLogPage: '/person/changeLog/pageList' } export function personAddOrUpdate (params) { @@ -67,3 +68,10 @@ export function personSetAdmin (params) { params: params }) } +export function personChangeLogPage (params) { + return request({ + url: personApi.changeLogPage, + method: 'get', + params: params + }) +} diff --git a/src/views/person/PersonDetail.vue b/src/views/person/PersonDetail.vue index 48d48ea..ecc6f73 100644 --- a/src/views/person/PersonDetail.vue +++ b/src/views/person/PersonDetail.vue @@ -1,8 +1,368 @@ + import { STable } from '@/components' + import { personGet, personChangeLogPage } from '@/api/person/person' + import { dictionaryDropDown } from '@/api/sys/dictionaryItem' + export default { + components: { + STable + }, + data () { + return { + labelCol: { + xs: { span: 24 }, + sm: { span: 6 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 } + }, + modalTitle: '人员详情', + visible: false, + confirmLoading: false, + form: this.$form.createForm(this), + jobsData: [], + workTypeData: [], + degreeData: [], + typeData: [], + // 查询参数 + queryParam: { }, + // 表头 + columns: [ + { + title: '日期', + dataIndex: 'createTime', + scopedSlots: { customRender: 'createTime' } + }, + { + title: '人员变动信息', + dataIndex: 'changeType' + }, + { + title: '部门信息', + dataIndex: 'orgName' + } + ], + // 加载数据方法 必须为 Promise 对象 + loadData: parameter => { + return personChangeLogPage(Object.assign(parameter, this.queryParam)).then((res) => { + return res + }) + } + } + }, + mounted () { + this.dictionaryDropDown() + }, + methods: { + // 编辑初始化方法 + detail (record) { + this.confirmLoading = true + this.visible = true - + this.queryParam.userId = record.userId + this.queryParam.orgId = record.orgId + + + // 基本信息加入表单 + personGet({ id: record.id }).then((res) => { + if (res.code === 200) { + const data = res.data + + // 默认选中的多选框 + const type = data.type.split(',') + const typeIntArr = []// 保存转换后的整型字符串 + type.forEach(item => { + typeIntArr.push(+item) + }) + this.form.getFieldDecorator('type', { valuePropName: 'checked', initialValue: typeIntArr }) + + console.log(data) + this.form.setFieldsValue( + { + id: data.id, + userId: data.userId, + name: data.name, + userName: data.userName, + idCardNo: data.idCardNo, + // age: data.age, + // sex: data.sex, + phone: data.phone, + jobs: parseInt(data.jobs), + workType: parseInt(data.workType), + degreeId: data.degreeId, + orgId: data.orgId, + orgName: data.orgName + } + ) + // 动态赋值年龄和性别 + this.analyzeIdCardNo(data.idCardNo) + } else { + this.$message.error('查询失败:' + res.msg) + } + }) + this.confirmLoading = false + }, + + /** + * 获取字典数据 + */ + dictionaryDropDown () { + this.formLoading = true + // 岗位 + dictionaryDropDown({ dictionaryCode: '0002' }).then((res) => { + this.jobsData = res.data + }) + // 工种 + dictionaryDropDown({ dictionaryCode: '0003' }).then((res) => { + this.workTypeData = res.data + }) + // 学历 + dictionaryDropDown({ dictionaryCode: '0004' }).then((res) => { + this.degreeData = res.data + }) + // 人员类型 + dictionaryDropDown({ dictionaryCode: '0005' }).then((res) => { + this.typeData = res.data + this.formLoading = false + }) + }, + idCardNoBlur (event) { + const idCardNo = event.target.value + this.analyzeIdCardNo(idCardNo) + }, + analyzeIdCardNo (idCardNo) { + // 如果用户身份证号码为undefined则返回空 + if (!idCardNo) { + return + } + + // 获取性别 + if (parseInt(idCardNo.substr(16, 1)) % 2 === 1) { + this.form.setFieldsValue({ sex: 1 }) + } else { + console.log('sex 2') + this.form.setFieldsValue({ sex: 2 }) + } + + // 获取出生日期 + var yearBirth = idCardNo.substring(6, 10) + var monthBirth = idCardNo.substring(10, 12) + var dayBirth = idCardNo.substring(12, 14) + // 获取当前年月日并计算年龄 + var myDate = new Date() + var monthNow = myDate.getMonth() + 1 + var dayNow = myDate.getDate() + var age = myDate.getFullYear() - yearBirth + if (monthNow < monthBirth || (monthNow === monthBirth && dayNow < dayBirth)) { + age-- + } + console.log(age) + // 得到年龄 + this.form.setFieldsValue({ age }) + }, + handleCancel () { + this.form.resetFields() + this.visible = false + } + } + } + \ No newline at end of file diff --git a/src/views/person/PersonList.vue b/src/views/person/PersonList.vue index d27d6b8..07c4479 100644 --- a/src/views/person/PersonList.vue +++ b/src/views/person/PersonList.vue @@ -72,7 +72,7 @@ - 详情 + 详情