<template>
	<navigation-general title="居民详情">
		<template v-slot:right>
			<u-button style="margin-right: 20rpx;" type="error" size="mini" @click="handlerDel">删除</u-button>
		</template>
		<u-cell-group>
			<u-cell-item title="姓名" :arrow="false" :value="info.name"></u-cell-item>
			<u-cell-item title="身份证" :arrow="false" :value="info.credentialNo || '/'"></u-cell-item>
			<u-cell-item title="手机号" :arrow="false" :value="info.phone || '/'"></u-cell-item>
			<u-cell-item title="类型" :arrow="false" :value="info.typename"></u-cell-item>
			<u-cell-item title="分色" :arrow="false" :value="info.color"></u-cell-item>
			<u-cell-item title="参保单位" :arrow="false" :value="info.qymc || '/'"></u-cell-item>
			<u-cell-item title="社保电话" :arrow="false" :value="info.lxdh || '/'"></u-cell-item>
			<u-cell-item title="参保类型" :arrow="false" :value="info.eacaabbff"></u-cell-item>
			<u-cell-item title="民族" :arrow="false" :value="info.mzcgf"></u-cell-item>
			<u-cell-item title="社保地址" :arrow="false" :value="info.lxdzDzmc || '/'"></u-cell-item>
			<u-cell-item title="实际工作单位" :arrow="false" :value="info.workunit || '/'"></u-cell-item>
			<u-cell-item title="数据更新时间" :arrow="false" :value="info.updateTime || '/'"></u-cell-item>
			<u-cell-item title="备注" :arrow="false" :value="info.remark || '/'"></u-cell-item>
		</u-cell-group>
		<u-top-tips ref="uTips"></u-top-tips>
		<bottom-btn title="修改信息" @handlerClick="handlerClick"></bottom-btn>
	</navigation-general>
</template>

<script>
	import {
		getPerson,
		delPerson
	} from "@/api/taicangpop/person.js";
	import {
		getDicts
	} from "@/api/system/dict/data";

	export default {
		data() {
			return {
				info: {},
				personId: null,
				nationList: [],
				sbList: []
			};
		},
		onLoad(option) {
			this.personId = option.personId


		},
		onShow() {
			this.getnationList()
		},
		methods: {
			async getnationList() {
				const res = await getDicts('sys_nationality')
				this.nationList = res.data
				const reslut = await getDicts('sys_sb_type')
				this.sbList = reslut.data
				this.getPersonInfo()
			},
			async getPersonInfo() {
				const res = await getPerson(this.personId)
				const mzcgf = this.nationList.find(item => item.dictValue == res.data.mzcgf)
				res.data.mzcgf = mzcgf && mzcgf.dictLabel ? mzcgf.dictLabel : '/'

				const eacaabbff = this.sbList.find(item => item.dictValue == res.data.eacaabbff)
				res.data.eacaabbff = eacaabbff && eacaabbff.dictLabel ? eacaabbff.dictLabel : '/'
				this.info = res.data
			},
			handlerDel() {
				uni.showModal({
					title: `删除操作`,
					content: `确定要删除编号为${this.personId}的居民吗？`,
					success: (res) => {
						if (res.confirm) {
							delPerson(this.personId).then(res => {
								uni.showToast({
									title: '删除成功',
									success: () => {
										setTimeout(() => {
											uni.navigateBack()
										}, 1000)
									}
								})
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},
			handlerClick() {
				this.$u.route({
					url: 'pages/house/addAndEdit',
					params: {
						personId: this.personId
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	/deep/ .u-cell {
		padding: 15rpx 20rpx;
	}
</style>