diff --git a/src/utils/request.ts b/src/utils/request.ts index c79588d..af2c8b7 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -19,6 +19,20 @@ const service = axios.create({ timeout: 10000 }) +// 全局参数过滤函数 抽出来 +function filterEmptyParams(obj: Record): Record { + if (!obj || typeof obj !== 'object') return obj + const newObj: Record = {} + for (const key in obj) { + const val = obj[key] + // 剔除 null、undefined、空字符串;0 / false 保留(数字0业务不能丢) + if (val !== null && val !== undefined && val !== '') { + newObj[key] = val + } + } + return newObj +} + // request拦截器 service.interceptors.request.use((config: any) => { // 是否需要设置 token @@ -31,6 +45,16 @@ service.interceptors.request.use((config: any) => { config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 config.headers['hos_id'] = useUserStore().sysLoginParam.loginYLJG // 登录院区ID } + + // ========== 全局过滤参数 ========== + // post json请求 + if (config.data) { + config.data = filterEmptyParams(config.data) + } + // get params参数 + if (config.params) { + config.params = filterEmptyParams(config.params) + } // get请求映射params参数 if (config.method === 'get' && config.params) { let url = config.url + '?' + tansParams(config.params) diff --git a/src/views/blood/clinical/index.vue b/src/views/blood/clinical/index.vue index d22c7ef..928ce48 100644 --- a/src/views/blood/clinical/index.vue +++ b/src/views/blood/clinical/index.vue @@ -284,7 +284,7 @@ - + @@ -302,12 +302,12 @@ - + - + @@ -315,7 +315,7 @@ - + diff --git a/src/views/blood/recycling/index.vue b/src/views/blood/recycling/index.vue index d2e2e44..ceead41 100644 --- a/src/views/blood/recycling/index.vue +++ b/src/views/blood/recycling/index.vue @@ -15,7 +15,8 @@
逐袋扫描
- + @@ -53,7 +54,7 @@
- + 已登记列表
数量:{{ registeredList.length }}
- + @@ -109,7 +109,7 @@ - +
diff --git a/src/views/blood/retreat/index.vue b/src/views/blood/retreat/index.vue index 4d78d08..73c6932 100644 --- a/src/views/blood/retreat/index.vue +++ b/src/views/blood/retreat/index.vue @@ -52,7 +52,7 @@
逐袋扫描
- + @@ -220,7 +220,7 @@ import BloodMask from '../component/bloodMask.vue' const userInfo = useUserStore() const bloodInfo = ref({}) - +const bloodNoInputRef = useTemplateRef('bloodNoInputRef') const formData = ref({ handle_person: userInfo.name, back_date: dayjs().format('YYYY-MM-DD HH:mm:ss'), @@ -309,9 +309,14 @@ const handleClose = () => { } const scanHandle = () => { if (!reason.value) return ElMessage.warning('请选择退血原因') - if (!bloodInfo.value.blood_no) return - const index = bloodList.value.findIndex(item => item.blood_no == bloodInfo.value.blood_no) - if (index > -1) return ElMessage.warning("该血液流水号已被扫描过") + + const bloodNo = bloodInfo.value.blood_no?.trim() + if (!bloodNo) return + if (bloodList.value.some(item => item.blood_no == bloodNo)) { + bloodInfo.value.blood_no = '' + bloodNoInputRef.value?.focus() + return ElMessage.warning("该血液流水号已被扫描过") + } queryBloodInfoByBloodNo({ bloodNo: bloodInfo.value.blood_no }).then(res => { if (res.data.length == 1) { const row = res.data[0] @@ -321,6 +326,7 @@ const scanHandle = () => { } }).finally(() => { bloodInfo.value.blood_no = '' + bloodNoInputRef.value?.focus() }) } diff --git a/src/views/blood/scrap/index.vue b/src/views/blood/scrap/index.vue index 624cfd8..55909c4 100644 --- a/src/views/blood/scrap/index.vue +++ b/src/views/blood/scrap/index.vue @@ -71,7 +71,7 @@
逐袋扫描
- + @@ -206,6 +206,7 @@ const searchForm = ref({ stime: dayjs().format('YYYY-MM-DD'), etime: dayjs().format('YYYY-MM-DD'), }) +const bloodNoInputRef = useTemplateRef('bloodNoInputRef') const total = ref(0) const bloodList = ref([]) const visible = ref(false) @@ -262,9 +263,13 @@ const handleClose = () => { } const scanHandle = () => { if (!reason.value) return ElMessage.warning('请选择报废单原因') - if (!bloodInfo.value.blood_no) return - const index = bloodList.value.findIndex(item => item.blood_no == bloodInfo.value.blood_no) - if (index > -1) return ElMessage.warning("该血液流水号已被扫描过") + const bloodNo = bloodInfo.value.blood_no?.trim() + if (!bloodNo) return + if (bloodList.value.some(item => item.blood_no == bloodNo)) { + bloodInfo.value.blood_no = '' + bloodNoInputRef.value?.focus() + return ElMessage.warning("该血液流水号已被扫描过") + } queryBloodInfoByBloodNo({ bloodNo: bloodInfo.value.blood_no }).then(res => { if (res.data.length == 1) { const row = res.data[0] @@ -274,6 +279,7 @@ const scanHandle = () => { } }).finally(() => { bloodInfo.value.blood_no = '' + bloodNoInputRef.value?.focus() }) }