Browse Source

获取申请抚慰的人员的数据并且显示

master
buaixuexideshitongxue 2 months ago
parent
commit
2a7b819fb2
  1. 12
      src/api/rightsComfort/comfort.ts
  2. 103
      src/utils/numberUtil.ts
  3. 30
      src/views/rightsComfort/MyComfort.vue

12
src/api/rightsComfort/comfort.ts

@ -55,3 +55,15 @@ export function comfortApprove(body) {
body
});
}
/**
*
* @param times
*/
export function getPoliceInfo(body){
return request.post({
url: `/comfort/getPoliceInfo`,
body
})
}

103
src/utils/numberUtil.ts

@ -0,0 +1,103 @@
/**
* numberUtil
*
*
*
* int / Integer
* double / Double
* BigDecimal string
*/
const numberUtil = {
/**
* Number
* - string / number
* - BigDecimal(JSON) -> string -> number
*/
toNumber(val) {
if (val === null || val === undefined || val === '') return null;
const n = Number(val);
return Number.isNaN(n) ? null : n;
},
/**
* Number
*/
toNumberOr(val, defaultVal = 0) {
const n = this.toNumber(val);
return n === null ? defaultVal : n;
},
/**
* int / long
* "1.0" -> 1
* 1.9 -> 1
*/
toInt(val) {
const n = this.toNumber(val);
return n === null ? null : Math.trunc(n);
},
/**
* double / BigDecimal
* 2
*/
toDecimal(val, scale = 2) {
const n = this.toNumber(val);
if (n === null) return null;
return Number(n.toFixed(scale));
},
/**
* string / number
*/
isNumber(val) {
if (val === null || val === undefined || val === '') return false;
return !Number.isNaN(Number(val));
},
/**
* int / string
* 0 / "0" -> 0
* 1 / "1" -> 1
*/
normalizeSex(val) {
const n = this.toInt(val);
return n === 0 || n === 1 ? n : null;
},
/**
* / radio / checkbox
* 0/1, "0"/"1", true/false
*/
normalizeYesNo(val) {
if (val === true || val === 'true') return 1;
if (val === false || val === 'false') return 0;
const n = this.toInt(val);
return n === 0 || n === 1 ? n : null;
},
/**
* BigDecimal string
* JS
*/
toBigDecimalString(val, scale = 2) {
const n = this.toNumber(val);
if (n === null) return null;
return n.toFixed(scale);
},
/**
* null
*/
sum(list, field) {
if (!Array.isArray(list)) return 0;
return list.reduce((total, item) => {
const v = item?.[field];
const n = this.toNumber(v);
return total + (n ?? 0);
}, 0);
}
};
export default numberUtil;

30
src/views/rightsComfort/MyComfort.vue

@ -408,6 +408,7 @@
clearable
style="width: 300px"
placeholder="请输入"
@keyup.enter="formData.idCode && onKeyEnter()"
/>
</el-form-item>
</el-col>
@ -448,6 +449,7 @@
v-model="formData.empNo"
style="width: 300px"
placeholder="请输入"
@keyup.enter="formData.empNo && onKeyEnter()"
/>
</el-form-item>
</el-col>
@ -818,12 +820,12 @@
import { BASE_PATH } from "@/api/request";
import moment from "moment";
import {
listComfortTodos,
listDone,
applyComfort,
updateComfort,
delComfort,
getDetail,
listComfortTodos,
listDone,
applyComfort,
updateComfort,
delComfort,
getDetail, getPoliceInfo,
} from "@/api/rightsComfort/comfort";
import { listPolice } from "@/api/system/police";
import { listRightPersonByDepartId } from "@/api/system/rightPerson";
@ -834,6 +836,7 @@ import feedback from "@/utils/feedback";
import useCatchStore from "@/stores/modules/catch";
import useUserStore from "@/stores/modules/user";
import numberUtil from "@/utils/numberUtil.ts"
const catchStore = useCatchStore();
const dict = catchStore.getDicts([
@ -1073,6 +1076,21 @@ function handleSelectIsSelf() {
}
const resultShow = ref(true);
const onKeyEnter = async ()=>{
const body = {
idCode: formData.value.idCode,
empNo: formData.value.empNo
}
const res= await getPoliceInfo(body)
formData.value.applicantEmpName = res.name;
formData.value.sex =numberUtil.normalizeSex(res.gender);
formData.value.idCode = res.idCode;
formData.value.departId = res.orgId;
formData.value.empNo = res.empNo;
}
</script>
<style lang="scss" scoped>
h5 {

Loading…
Cancel
Save