Browse Source

fix: 添加年龄计算

master
buaixuexideshitongxue 24 hours ago
parent
commit
9278039f38
  1. 18
      src/components/negativeInfo/police-dialog.vue

18
src/components/negativeInfo/police-dialog.vue

@ -45,6 +45,7 @@
<dl class="profile-fields"> <dl class="profile-fields">
<div><dt>姓名</dt><dd>{{ policeInfo.name || "/" }}</dd></div> <div><dt>姓名</dt><dd>{{ policeInfo.name || "/" }}</dd></div>
<div><dt>性别</dt><dd>{{ policeInfo.idCode ? getGenderFromIdCode(policeInfo.idCode) : "/" }}</dd></div> <div><dt>性别</dt><dd>{{ policeInfo.idCode ? getGenderFromIdCode(policeInfo.idCode) : "/" }}</dd></div>
<div><dt>年龄</dt><dd>{{ policeAge }}</dd></div>
<div><dt>所属单位</dt><dd>{{ activeRow.parentDepartName ? activeRow.parentDepartName + "/" : "" }}{{ activeRow.departName || "/" }}</dd></div> <div><dt>所属单位</dt><dd>{{ activeRow.parentDepartName ? activeRow.parentDepartName + "/" : "" }}{{ activeRow.departName || "/" }}</dd></div>
<div><dt>警号</dt><dd>{{ policeInfo.empNo || "/" }}</dd></div> <div><dt>警号</dt><dd>{{ policeInfo.empNo || "/" }}</dd></div>
<div><dt>身份证号</dt><dd>{{ policeInfo.idCode || "/" }}</dd></div> <div><dt>身份证号</dt><dd>{{ policeInfo.idCode || "/" }}</dd></div>
@ -120,10 +121,11 @@
<negative-dialog v-model="negativeShow" :id="activeNegativeId" @close="negativeShow = false" /> <negative-dialog v-model="negativeShow" :id="activeNegativeId" @close="negativeShow = false" />
</template> </template>
<script setup> <script setup>
import { computed } from "vue";
import { BASE_PATH } from "@/api/request"; import { BASE_PATH } from "@/api/request";
import vCharts from "vue-echarts"; import vCharts from "vue-echarts";
import { getPoliceProfile, listNegativeMonthly } from "@/api/sensitivePerception/profilePolice"; import { getPoliceProfile, listNegativeMonthly } from "@/api/sensitivePerception/profilePolice";
import { getGenderFromIdCode } from "@/utils/util"; import { calculateAge, getGenderFromIdCode } from "@/utils/util";
import moment from "moment"; import moment from "moment";
const props = defineProps({ const props = defineProps({
@ -137,6 +139,20 @@ const emit = defineEmits(["update:modelValue"]);
const time = ref([]); const time = ref([]);
const policeInfo = ref({}); const policeInfo = ref({});
const policeAge = computed(() => {
const idCode = String(policeInfo.value.idCode || "").trim();
let birthText;
if (/^\d{17}[\dXx]$/.test(idCode)) {
birthText = idCode.slice(6, 14);
} else if (/^\d{15}$/.test(idCode)) {
birthText = `19${idCode.slice(6, 12)}`;
} else {
return "/";
}
const birthDate = moment(birthText, "YYYYMMDD", true);
if (!birthDate.isValid() || birthDate.isAfter(moment(), "day")) return "/";
return `${calculateAge(birthDate.toDate())}岁`;
});
const negativeInfo = ref({}); const negativeInfo = ref({});
const loading = ref(false); const loading = ref(false);
const negativeList = ref([]); const negativeList = ref([]);

Loading…
Cancel
Save