From c2d879c83d5d242d32b376193e1a4680067d169c Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期三, 31 五月 2023 15:14:38 +0800
Subject: [PATCH] 优化逻辑
---
src/views/paiban/index.vue | 37 ++++++++++++++++++++-----------------
1 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/src/views/paiban/index.vue b/src/views/paiban/index.vue
index 96a9a68..1c18325 100644
--- a/src/views/paiban/index.vue
+++ b/src/views/paiban/index.vue
@@ -56,7 +56,6 @@
</div>
</template>
<script lang="ts" setup>
- // import {ref,reactive,watchEffect,watch} from 'vue'
import { Calendar as vanCalendar } from 'vant'
import { ref,onMounted } from 'vue'
import {useRouter} from 'vue-router'
@@ -67,7 +66,7 @@
const day=new Date()
const Year = day.getFullYear()
const minDate=ref( new Date(Date.parse(Year+'-01-01'.replace(/-/g, '/'))))
- const selectDate=ref([{y:2000,m:1,d:1,type:'',code:'',deviceGroupName:'',deviceName:'',timeSlot:1}])
+ const selectDate=ref([{y:2000,m:1,d:1,type:'',code:'',id:0,deviceGroupName:'',deviceName:'',timeSlot:1}])
const fanhui=()=>{
router.go(-1)
}
@@ -84,26 +83,30 @@
year:y,
month:m,
}
- const lisd = selectDate.value.filter(el=>{
- return el.y!==pagedata.year&&el.m!==pagedata.month
- })
- selectDate.value=lisd
ajaxPost('/hemo/med/schedule/listMonthSchedulesByPat',pagedata).then((re:any)=>{
console.log(re)
re.forEach((element:any) => {
const dey=element.scheduleDay.split('-')
- // console.log(dey,'444')
- selectDate.value.push({
- y:Number(dey[0]),
- m:Number(dey[1]),
- d:Number(dey[2].substring(0,2)),
- type:element.patientVsHemoMedSchemeName,
- deviceGroupName:element.deviceGroupName,
- deviceName:element.deviceName,
- timeSlot:element.timeSlot,
- code:element.code
+ // 不能添加重复的
+ const x=selectDate.value.findIndex(e=>{return e.code===element.code})
+ if (x===-1){
+ selectDate.value.push({
+ y:Number(dey[0]),
+ m:Number(dey[1]),
+ d:Number(dey[2].substring(0,2)),
+ type:element.patientVsHemoMedSchemeName,
+ deviceGroupName:element.deviceGroupName,
+ deviceName:element.deviceName,
+ timeSlot:element.timeSlot,
+ code:element.code,
+ id:element.id
- })
+ })
+ }
+
+ })
+ selectDate.value= selectDate.value.sort((a,b)=>{
+ return a.id-b.id
})
console.log(selectDate.value)
})
--
Gitblit v1.8.0