|
@@ -0,0 +1,117 @@
|
|
|
+<template>
|
|
|
+ <div id="detail">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="main animate__animated animate__backInRight">
|
|
|
+ <el-col :span="24" class="one">
|
|
|
+ <data-form :fields="fields" :data="form" @save="toSave" returns="/involved">
|
|
|
+ <template #custom="{ item }">
|
|
|
+ <template v-if="item.model == 'card'">
|
|
|
+ <el-input v-model="form.card" placeholder="请输入身份证号" @blur="toBlur"></el-input>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </data-form>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions } = createNamespacedHelpers('involved');
|
|
|
+export default {
|
|
|
+ name: 'detail',
|
|
|
+ props: {},
|
|
|
+ components: {},
|
|
|
+ data: function () {
|
|
|
+ return {
|
|
|
+ form: {},
|
|
|
+ fields: [
|
|
|
+ { label: '姓名', model: 'name' },
|
|
|
+ { label: '曾用名', model: 'beforename' },
|
|
|
+ { label: '身份证号', model: 'card', custom: true },
|
|
|
+ { label: '性别', model: 'gender' },
|
|
|
+ { label: '年龄', model: 'age' },
|
|
|
+ { label: '籍贯', model: 'nativeaddr' },
|
|
|
+ { label: '住址', model: 'address' },
|
|
|
+ { label: '工作单位', model: 'unit' },
|
|
|
+ { label: '职业', model: 'work' },
|
|
|
+ { label: '社会关系', model: 'sociology' },
|
|
|
+ { label: '涉案信息', model: 'involvedinfo' },
|
|
|
+ ],
|
|
|
+ genderList: [
|
|
|
+ { label: '男', value: '男' },
|
|
|
+ { label: '女', value: '女' },
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ if (this.id) this.search();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapActions(['fetch', 'create', 'update']),
|
|
|
+ async search() {
|
|
|
+ let res = await this.fetch(this.id);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `form`, res.data);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 提交
|
|
|
+ async toSave({ data }) {
|
|
|
+ let dup = _.cloneDeep(data);
|
|
|
+ if (data.id) {
|
|
|
+ let res = await this.update(dup);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$message({ type: `success`, message: `维护信息成功` });
|
|
|
+ this.$router.push('/involved');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let res = await this.create(dup);
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$message({ type: `success`, message: `创建信息成功` });
|
|
|
+ this.$router.push('/involved');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 输入身份证号,解析身份证信息
|
|
|
+ // 获取身份证信息
|
|
|
+ toBlur(event) {
|
|
|
+ let value = _.get(event.target, 'value');
|
|
|
+ if (value) {
|
|
|
+ // 获取性别
|
|
|
+ if (parseInt(value.substr(16, 1)) % 2 == 1) this.$set(this.form, `gender`, '男');
|
|
|
+ else this.$set(this.form, `gender`, '女');
|
|
|
+ // // 获取出生日期
|
|
|
+ // let birthday = '';
|
|
|
+ // if (value != null && value != '') {
|
|
|
+ // if (value.length == 15) {
|
|
|
+ // birthday = '19' + value.slice(6, 12);
|
|
|
+ // } else if (value.length == 18) {
|
|
|
+ // birthday = value.slice(6, 14);
|
|
|
+ // }
|
|
|
+ // birthday = birthday.replace(/(.{4})(.{2})/, '$1-$2-');
|
|
|
+ // }
|
|
|
+ // this.$set(this.form, `birth`, birthday);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapState(['user']),
|
|
|
+ id() {
|
|
|
+ return this.$route.query.id;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ metaInfo() {
|
|
|
+ return { title: this.$route.meta.title };
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ test: {
|
|
|
+ deep: true,
|
|
|
+ immediate: true,
|
|
|
+ handler(val) {},
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped></style>
|