This commit is contained in:
2025-04-29 15:45:52 +08:00
parent fcf9fa5420
commit 1fafd27208
14 changed files with 149 additions and 176 deletions

View File

@ -8,43 +8,92 @@
</div>
</div>
<div class="form_cnt">
<FormMessage :formList="formData" ref="elform" :rules="rules"></FormMessage>
<FormMessage v-model="listQuery" :formList="formData" ref="elform" :rules="rules"></FormMessage>
</div>
</div>
</template>
<script setup>
import { IdCard } from "@/utils/validate.js";
import FormMessage from '@/components/aboutTable/FormMessage.vue'
import { qcckGet, qcckPost, qcckPut } from "@/api/qcckApi.js";
import * as rule from "@/utils/rules.js";
import { ref, defineExpose, reactive, onMounted, defineEmits, getCurrentInstance, nextTick } from "vue";
const emit = defineEmits(["updateDate"]);
const props = defineProps({
dic: Object
dic: Object,
});
const validateIdentity = () => {
return (rule, value, callback) => {
if (!value) {
return callback(new Error('身份证号不能为空'));
} else if (!/(^\d{15}$)|(^\d{17}(\d|X|x)$)/.test(value)) {
callback(new Error("输入的身份证长度或格式错误"));
}
//身份证城市
var aCity = {11: "北京",12: "天津",13: "河北",14: "山西",15: "内蒙古",21: "辽宁",22: "吉林",23: "黑龙江",31: "上海",32: "江苏",33: "浙江",34: "安徽",35: "福建",36: "江西",37: "山东",41: "河南",42: "湖北",43: "湖南",44: "广东",45: "广西",46: "海南",50: "重庆",51: "四川",52: "贵州",53: "云南",54: "西藏",61: "陕西",62: "甘肃",63: "青海",64: "宁夏",65: "新疆",71: "台湾",81: "香港",82: "澳门",91: "国外"};
if (!aCity[parseInt(value?.substr(0, 2))]) callback(new Error("身份证地区非法"));
// 出生日期验证
var sBirthday = ( value.substr(6, 4) + "-" + Number(value.substr(10, 2)) + "-" + Number(value.substr(12, 2))).replace(/-/g, "-"),
d = new Date(sBirthday);
let yyyy = d.getFullYear();
let mm = d.getMonth() + 1;
let dd = d.getDate();
if (sBirthday !== yyyy + "-" + mm + "-" + dd) {
listQuery.value.ryCsrq= "";
callback(new Error("身份证上的出生日期非法"));
} else {
let month = mm < 10 ? "0" + mm : mm;
listQuery.value.ryCsrq= yyyy + "-" + month + "-" + dd;
}
// 身份证号码校验
var sum = 0, weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2], codes = "10X98765432";
for (var i = 0; i < value.length - 1; i++) {
sum += value[i] * weights[i];
}
var last = codes[sum % 11]; //计算出来的最后一位身份证号码
if (value[value.length - 1] !== last) {
listQuery.value.ryXb = ''
callback(new Error("输入的身份证号非法"));
} else {
if(value.length === 18){
listQuery.value.ryCsrq= IdCard(value,1)
listQuery.value.ryXb = parseInt(value.substr(16, 1)) % 2 === 1 ? "1" : "2";
}
}
callback();
};
};
const { proxy } = getCurrentInstance();
const dialogForm = ref(false); //弹窗
const formData = ref([
{ label: "管线部门", prop: "gxbm", type: "input" },
{ label: "所属辖区", prop: "ssxq", type: "input", },
{ label: "信息员姓名", prop: "xm", type: "input" },
{ label: "身份证号", prop: "sfzh", type: "input" },
{ label: "性别", prop: "xb", type: "select", options: [] },
{ label: "年龄", prop: "age", type: "input" },
{ label: "联系方式", prop: "lxfs", type: "input" },
{ label: "考核得分", prop: "kgdf", type: "input" },
{ label: "管部门", prop: "gxbmDm", type: "department" },
{ label: "姓名", prop: "ryXm", type: "input" },
{ label: "联系电话", prop: "ryLxdh", type: "input" },
{ label: "身份证号", prop: "rySfzh", type: "input" },
{ label: "出生日期", prop: "ryCsrq", type: "date" },
{ label: "性别", prop: "ryXb", type: "select", options:props.dic.D_BZ_XB },
{ label: "民族", prop: "ryMz", type: "select", options:props.dic.D_BZ_MZ },
{ label: "学历", prop: "ryXl", type: "select", options: props.dic.D_BZ_WHCD },
{ label: "政治面貌", prop: "ryZzmm", type: "select", options: props.dic.D_BZ_ZZMM },
{ label: "所在单位", prop: "rySzdw", type: "input" },
{ label: "居住地地址", prop: "jzdDz", type: "textarea",width:'100%' },
]);
const listQuery = ref({
sfbqdj: []
}); //表单
const listQuery = ref({}); //表单
const loading = ref(false);
const elform = ref();
const title = ref("");
const rules = reactive({
rwbt: [{ required: true, message: "请输入任务标题", trigger: "blur" }]
gxbmDm: [{ required: true, message: "请选择管辖部门", trigger: "change" }],
ryXm: [{ required: true, message: "请输入人员姓名", trigger: "blur" }],
rySfzh: [
{ required: true, message: "请输入人员身份证号", trigger: ["blur",'change'] },
{ trigger: ["blur",'change'], validator: validateIdentity()}
],
...rule.phoneRule({ require: true, validator: true }, "ryLxdh"), // 是否必填 是否进行校验 可以传第二个参数
});
const editpeo = ref();
onMounted(() => {});
// 初始化数据
const init = (type, row,) => {
dialogForm.value = true;
@ -53,21 +102,21 @@ const init = (type, row,) => {
};
// 根据id查询详情
const getDataById = (id) => {
// qcckGet({}, '/mosty-gsxt/tbGsxtBqgl/'+id).then((res) => {
// listQuery.value = res;
// });
qcckGet({}, '/mosty-gsxt/tbGsxtJwry/'+id).then((res) => {
listQuery.value = res;
});
};
// 提交
const submit = () => {
elform.value.submit((data)=>{
// let url = title.value == "新增" ? '/mosty-gsxt/tbGsxtBqgl/save':'/mosty-gsxt/tbGsxtBqgl/update';
// let params = { ...data }
// qcckPost(params, url).then((res) => {
// proxy.$message({ type: "success", message: title.value + "成功" });
// emit("updateDate");
// close();
// }).catch(() => {});
let url = title.value == "新增" ? '/mosty-gsxt/tbGsxtJwry/save':'/mosty-gsxt/tbGsxtJwry/update';
let params = { ...data,ryLx: '01' }
qcckPost(params, url).then((res) => {
proxy.$message({ type: "success", message: title.value + "成功" });
emit("updateDate");
close();
}).catch(() => {});
});
};