3 changed files with 406 additions and 4 deletions
@ -0,0 +1,386 @@ |
|||
<template> |
|||
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" |
|||
:close-on-press-escape="false" custom-class="mobile"> |
|||
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" |
|||
:label-width="$i18n.locale === 'en-US' ? '120px' : '80px'"> |
|||
<el-form-item label="身份证号码" prop="idcard" label-width="120px"> |
|||
<el-input v-model="dataForm.idcard" placeholder="身份证号码" @blur="getSexAndBirthDay" style="width:250px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="姓名" prop="name" label-width="120px"> |
|||
<el-input v-model="dataForm.name" placeholder="姓名" style="width:250px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="手机号码" prop="mobile" label-width="120px"> |
|||
<el-input v-model="dataForm.mobile" placeholder="手机号码" style="width:250px"></el-input> |
|||
</el-form-item> |
|||
<!-- <el-form-item label="签发机关" prop="organ" label-width="120px"> |
|||
<el-input v-model="dataForm.organ" placeholder="签发机关" style="width:250px"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="性别" prop="sex" label-width="120px"> |
|||
<el-radio-group v-model="dataForm.sex" disabled> |
|||
<el-radio label="女">女</el-radio> |
|||
<el-radio label="男">男</el-radio> |
|||
</el-radio-group> |
|||
</el-form-item> |
|||
<el-form-item label="出生日期" prop="birthday" label-width="120px"> |
|||
<el-date-picker disabled |
|||
v-model="dataForm.birthday" |
|||
type="date" |
|||
placeholder="出生日期" |
|||
value-format="yyyy-MM-dd" |
|||
format="yyyy-MM-dd" |
|||
style="width:250px"> |
|||
</el-date-picker> |
|||
</el-form-item> --> |
|||
<!-- <el-form-item label="检测时间" prop="testingTime" label-width="120px"> |
|||
<el-date-picker |
|||
v-model="dataForm.testingTime" |
|||
type="datetime" |
|||
placeholder="核酸检测时间" |
|||
value-format="yyyy-MM-dd HH:mm:ss" |
|||
format="yyyy-MM-dd HH:mm:ss" |
|||
style="width:250px"> |
|||
</el-date-picker> |
|||
</el-form-item> --> |
|||
<!-- |
|||
<el-form-item label="照片" |
|||
v-loading="loading" |
|||
prop="imgUrl" |
|||
label-width="120px"> |
|||
<el-upload class="avatar-uploader" |
|||
:action="uploadUrl" |
|||
:show-file-list="false" |
|||
:on-success="handleAvatarSuccess" |
|||
:before-upload="beforeAvatarUpload"> |
|||
<img v-if="dataForm.imgUrl" |
|||
:src="dataForm.imgUrl" |
|||
class="avatar"> |
|||
<i v-else |
|||
class="el-icon-plus avatar-uploader-icon"></i> |
|||
<div slot="tip" |
|||
class="el-upload__tip">只能上传jpg/png文件,且不超过500kb |
|||
</div> |
|||
</el-upload> |
|||
</el-form-item> |
|||
<el-form-item label="住址" prop="address" label-width="120px"> |
|||
<el-input v-model="dataForm.address" placeholder="住址"></el-input> |
|||
</el-form-item> |
|||
<el-form-item label="核酸检测点" label-width="120px"> |
|||
<el-select v-model="dataForm.testingPointId" placeholder="请选择..." clearable style="width: 100%;"> |
|||
<el-option v-for="item in optionTestingPoint" |
|||
:key="item.tagValue" |
|||
:label="item.tagName" |
|||
:value="item.tagValue"> |
|||
</el-option> |
|||
</el-select> |
|||
</el-form-item> --> |
|||
</el-form> |
|||
<template slot="footer"> |
|||
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|||
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|||
</template> |
|||
</el-dialog> |
|||
</template> |
|||
|
|||
<script> |
|||
import Cookies from 'js-cookie' |
|||
import debounce from 'lodash/debounce' |
|||
|
|||
export default { |
|||
data() { |
|||
return { |
|||
visible: false, |
|||
dataForm: { |
|||
id: '', |
|||
name: '', |
|||
sex: '', |
|||
nation: '', |
|||
birthday: '', |
|||
address: '', |
|||
idcard: '', |
|||
organ: '', |
|||
imgCode: '', |
|||
imgUrl: '', |
|||
testingResult: '', |
|||
testingTime: '', |
|||
revision: '', |
|||
createdBy: '', |
|||
createdTime: '', |
|||
updatedBy: '', |
|||
updatedTime: '', |
|||
delFlag: '', |
|||
mobile:'', |
|||
testingPointId:'' |
|||
}, |
|||
uploadUrl: '', |
|||
loading: false, |
|||
optionTestingPoint: [] |
|||
} |
|||
}, |
|||
computed: { |
|||
dataRule() { |
|||
return { |
|||
name: [ |
|||
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|||
], |
|||
// sex: [ |
|||
// {required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|||
// ], |
|||
// nation: [ |
|||
// { required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
// ], |
|||
// birthday: [ |
|||
// { required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
// ], |
|||
// address: [ |
|||
// { required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
// ], |
|||
idcard: [ |
|||
{required: true, message: this.$t('validate.required'), trigger: 'blur'}, |
|||
{ pattern: /(^\d{15}$)|bai(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '请输入正确身份证号', trigger: 'blur' } |
|||
], |
|||
// organ: [ |
|||
// { required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
// ], |
|||
// imgCode: [ |
|||
// { required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
// ], |
|||
// imgUrl: [ |
|||
// { required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
// ], |
|||
// testingResult: [ |
|||
// { required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
// ], |
|||
// testingTime: [ |
|||
// {required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|||
// ], |
|||
// revision: [ |
|||
// { required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
// ], |
|||
// createdBy: [ |
|||
// { required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
// ], |
|||
// createdTime: [ |
|||
// { required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
// ], |
|||
// updatedBy: [ |
|||
// { required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
// ], |
|||
// updatedTime: [ |
|||
// { required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
// ], |
|||
// delFlag: [ |
|||
// { required: true, message: this.$t('validate.required'), trigger: 'blur' } |
|||
// ] |
|||
} |
|||
} |
|||
}, |
|||
created() { |
|||
console.log('add') |
|||
// this.visible = true |
|||
this.$nextTick(() => { |
|||
// this.dataForm.communityId = this.dataForm.streetId = this.dataForm.gridId = null |
|||
// 富文本 |
|||
// this.hideUpload = false |
|||
this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/oss/file/upload?token=${Cookies.get('token')}` |
|||
}) |
|||
// var oMeta = document.createElement('meta') |
|||
// oMeta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0, user-scalable=0' |
|||
// oMeta.name = 'viewport' |
|||
// document.getElementsByTagName('head')[0].appendChild(oMeta) |
|||
}, |
|||
methods: { |
|||
init() { |
|||
this.visible = true |
|||
this.dataForm.testingPointId = '' |
|||
this.getListSimpleByDictType() |
|||
this.$nextTick(() => { |
|||
this.$refs['dataForm'].resetFields() |
|||
// this.$set(this.dataForm,'testingTime', new Date()) |
|||
this.dataForm.testingTime = new Date() |
|||
if (this.dataForm.id) { |
|||
this.getInfo() |
|||
} |
|||
}) |
|||
}, |
|||
// 上传图片 |
|||
handleAvatarSuccess(res, file) { |
|||
this.loading = false |
|||
this.dataForm.imgUrl = res.data.url |
|||
}, |
|||
beforeAvatarUpload(file) { |
|||
this.loading = true |
|||
}, |
|||
getSexAndBirthDay () { |
|||
// 先判断身份证是否合法 |
|||
// this.$http.get(`/custom/populationinformation/isIdentifyNoLegal/${this.dataForm.idcard}`).then(({ data: res }) => { |
|||
// if (res.code !== 0) { |
|||
// this.dataForm.idcard = '' |
|||
// return this.$message.error(res.msg) |
|||
// } |
|||
// let identifyNo = this.dataForm.idcard |
|||
// this.dataForm.sex = this.IdCard(identifyNo, 2) |
|||
// this.dataForm.birthday = this.IdCard(identifyNo, 1) |
|||
// }).catch(() => { }) |
|||
this.$http.get(`/custom/persontesting/v2/getNameByIDcard/${this.dataForm.idcard}`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
this.dataForm.idcard = '' |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dataForm.name = res.data.userName |
|||
this.dataForm.mobile = res.data.mobile |
|||
}).catch(() => { }) |
|||
}, |
|||
IdCard (UUserCard, num) { |
|||
if (num === 1) { |
|||
// 获取出生日期 |
|||
return UUserCard.substring(6, 10) + '-' + UUserCard.substring(10, 12) + '-' + UUserCard.substring(12, 14) |
|||
} |
|||
if (num === 2) { |
|||
// 获取性别 |
|||
if (parseInt(UUserCard.substr(16, 1)) % 2 === 1) { |
|||
// 男 |
|||
return '男' |
|||
} else { |
|||
// 女 |
|||
return '女' |
|||
} |
|||
} |
|||
}, |
|||
getListSimpleByDictType () { |
|||
this.$http.get(`/custom/testingpoint/testingPointSelection`).then(({ data: res }) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.optionTestingPoint = res.data |
|||
}).catch(() => {}) |
|||
}, |
|||
// 获取信息 |
|||
getInfo() { |
|||
this.$http.get(`/custom/persontesting/${this.dataForm.id}`).then(({data: res}) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.dataForm = { |
|||
...this.dataForm, |
|||
...res.data |
|||
} |
|||
}).catch(() => { |
|||
}) |
|||
}, |
|||
// 表单提交 |
|||
dataFormSubmitHandle: debounce(function () { |
|||
this.$refs['dataForm'].validate((valid) => { |
|||
if (!valid) { |
|||
return false |
|||
} |
|||
this.dataForm.testingTime = new Date() |
|||
this.$http[!this.dataForm.id ? 'post' : 'put']('/custom/persontesting/v2/', this.dataForm).then(({data: res}) => { |
|||
if (res.code !== 0) { |
|||
return this.$message.error(res.msg) |
|||
} |
|||
this.$message({ |
|||
message: this.$t('prompt.success'), |
|||
type: 'success', |
|||
duration: 1000, |
|||
onClose: () => { |
|||
// this.visible = false |
|||
this.$emit('refreshDataList') |
|||
this.$refs['dataForm'].resetFields() |
|||
} |
|||
}) |
|||
}).catch(() => { |
|||
}) |
|||
}) |
|||
}, 1000, {'leading': true, 'trailing': false}) |
|||
} |
|||
} |
|||
</script> |
|||
<style> |
|||
.avatar-uploader .el-upload { |
|||
border: 1px dashed #d9d9d9; |
|||
border-radius: 6px; |
|||
cursor: pointer; |
|||
position: relative; |
|||
overflow: hidden; |
|||
} |
|||
|
|||
.avatar-uploader .el-upload:hover { |
|||
border-color: #409eff; |
|||
} |
|||
|
|||
.avatar-uploader-icon { |
|||
font-size: 28px; |
|||
color: #8c939d; |
|||
width: 178px; |
|||
height: 178px; |
|||
line-height: 178px; |
|||
text-align: center; |
|||
} |
|||
|
|||
.avatar { |
|||
width: 178px; |
|||
height: 178px; |
|||
display: block; |
|||
} |
|||
.mobile { |
|||
margin: 0 !important; |
|||
width: 100vw; |
|||
height: 100vh; |
|||
position: fixed; |
|||
left: 0; |
|||
top: 0; |
|||
} |
|||
|
|||
.mobile .el-form .el-form-item__label { |
|||
font-size: 40px; |
|||
width: 24vw !important; |
|||
} |
|||
.mobile .el-form .el-form-item__content { |
|||
margin-left: 20px !important; |
|||
} |
|||
.mobile .el-form .el-form-item { |
|||
display: flex; |
|||
align-items: center; |
|||
margin-bottom: 50px !important; |
|||
} |
|||
.mobile .el-form .el-input { |
|||
font-size: 40px; |
|||
width: 70vw !important; |
|||
height: 80px; |
|||
} |
|||
.mobile .el-form .el-input input{ |
|||
font-size: 40px; |
|||
height: 80px; |
|||
line-height: 80px; |
|||
padding-left: 50px; |
|||
} |
|||
.mobile .el-form .el-form-item__error { |
|||
font-size: 30px; |
|||
} |
|||
.mobile .el-form .el-input__prefix { |
|||
top: 25%; |
|||
} |
|||
.mobile .el-form .el-input__suffix { |
|||
top: 25%; |
|||
right: 10px; |
|||
} |
|||
.mobile .el-button { |
|||
width: 300px !important; |
|||
height: 100px !important; |
|||
font-size: 40px !important; |
|||
} |
|||
.el-message { |
|||
width: 80vw !important; |
|||
height: 80px !important;; |
|||
} |
|||
.el-message .el-message__content { |
|||
font-size: 40px !important |
|||
} |
|||
.el-message .el-message__icon { |
|||
font-size: 40px !important |
|||
} |
|||
.mobile .el-dialog__body { |
|||
margin-top: 10vh; |
|||
} |
|||
</style> |
|||
|
Loading…
Reference in new issue