|  | @@ -1,6 +1,7 @@
 | 
	
		
			
				|  |  |  <template>
 | 
	
		
			
				|  |  |    <window-size>
 | 
	
		
			
				|  |  | -    <van-cell title="选择年月" is-link arrow-direction="down" :value="dateText" @click="data.showDatePicker = true" />
 | 
	
		
			
				|  |  | +    <van-cell title="选择日期区间" :value="date" @click="showDateRange = true" />
 | 
	
		
			
				|  |  | +    <van-calendar v-model:show="showDateRange" :min-date="minDate" type="range" @confirm="onConfirm" />
 | 
	
		
			
				|  |  |      <div v-show="examIndex.length > 0">
 | 
	
		
			
				|  |  |        <div style="height: 5px"></div>
 | 
	
		
			
				|  |  |        <van-tag type="success" size="large" round plain>已发布报告</van-tag>
 | 
	
	
		
			
				|  | @@ -20,26 +21,17 @@
 | 
	
		
			
				|  |  |        </div>
 | 
	
		
			
				|  |  |      </div>
 | 
	
		
			
				|  |  |      <van-empty :image="empty" description="您当前没有报告项目" v-show="examIndex.length === 0" />
 | 
	
		
			
				|  |  | -    <van-popup v-model:show="data.showDatePicker" position="bottom" :style="{ height: '50%' }">
 | 
	
		
			
				|  |  | -      <van-datetime-picker
 | 
	
		
			
				|  |  | -        v-model="data.currentDate"
 | 
	
		
			
				|  |  | -        type="year-month"
 | 
	
		
			
				|  |  | -        title="选择年月"
 | 
	
		
			
				|  |  | -        :min-date="data.minDate"
 | 
	
		
			
				|  |  | -        :max-date="data.maxDate"
 | 
	
		
			
				|  |  | -        :formatter="formatter"
 | 
	
		
			
				|  |  | -        @confirm="confirmPickDate"
 | 
	
		
			
				|  |  | -      />
 | 
	
		
			
				|  |  | -    </van-popup>
 | 
	
		
			
				|  |  |    </window-size>
 | 
	
		
			
				|  |  |  </template>
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  <script>
 | 
	
		
			
				|  |  | +import Cookies from 'js-cookie'
 | 
	
		
			
				|  |  |  import store from '../../../store'
 | 
	
		
			
				|  |  |  import empty from '../../../assets/empty.png'
 | 
	
		
			
				|  |  |  import { useRouter } from 'vue-router'
 | 
	
		
			
				|  |  | -import { computed, onMounted, reactive } from 'vue'
 | 
	
		
			
				|  |  | +import { computed, onMounted, ref } from 'vue'
 | 
	
		
			
				|  |  |  import { checkExamIndex } from '../../../api/check-exam'
 | 
	
		
			
				|  |  | +import { formatDate } from '../../../utils/date'
 | 
	
		
			
				|  |  |  export default {
 | 
	
		
			
				|  |  |    name: 'CheckExamIndex',
 | 
	
		
			
				|  |  |    setup() {
 | 
	
	
		
			
				|  | @@ -49,55 +41,53 @@ export default {
 | 
	
		
			
				|  |  |        height: store.state.windowSize.h - 125 + 'px',
 | 
	
		
			
				|  |  |        overflowY: 'auto',
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    const data = reactive({
 | 
	
		
			
				|  |  | -      showDatePicker: true,
 | 
	
		
			
				|  |  | -      minDate: new Date(2015, 0, 1),
 | 
	
		
			
				|  |  | -      maxDate: new Date(),
 | 
	
		
			
				|  |  | -      currentDate: store.state.currentExamDate ? store.state.currentExamDate : new Date(),
 | 
	
		
			
				|  |  | -    })
 | 
	
		
			
				|  |  | +    const date = ref('')
 | 
	
		
			
				|  |  | +    const showDateRange = ref(false)
 | 
	
		
			
				|  |  |      const examIndex = computed(() => {
 | 
	
		
			
				|  |  |        return store.state.examIndexArray
 | 
	
		
			
				|  |  |      })
 | 
	
		
			
				|  |  | -    const dateText = computed(() => {
 | 
	
		
			
				|  |  | -      return data.currentDate.getFullYear() + '年' + (data.currentDate.getMonth() + 1) + '月'
 | 
	
		
			
				|  |  | -    })
 | 
	
		
			
				|  |  | -    const formatter = (type, val) => {
 | 
	
		
			
				|  |  | -      if (type === 'year') {
 | 
	
		
			
				|  |  | -        return `${val}年`
 | 
	
		
			
				|  |  | -      } else if (type === 'month') {
 | 
	
		
			
				|  |  | -        return `${val}月`
 | 
	
		
			
				|  |  | -      }
 | 
	
		
			
				|  |  | -      return val
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    const confirmPickDate = (val) => {
 | 
	
		
			
				|  |  | -      data.showDatePicker = false
 | 
	
		
			
				|  |  | -      store.commit('SET_CURRENTEXAMDATE', val)
 | 
	
		
			
				|  |  | -      const year = val.getFullYear()
 | 
	
		
			
				|  |  | -      const month = val.getMonth() + 1
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    const onConfirm = (values) => {
 | 
	
		
			
				|  |  | +      showDateRange.value = false
 | 
	
		
			
				|  |  | +      const start = formatDate(values[0])
 | 
	
		
			
				|  |  | +      const end = formatDate(values[1])
 | 
	
		
			
				|  |  | +      Cookies.set('inspection-start-date', start)
 | 
	
		
			
				|  |  | +      Cookies.set('inspection-end-date', end)
 | 
	
		
			
				|  |  | +      date.value = `${start} - ${end}`
 | 
	
		
			
				|  |  |        const param = {
 | 
	
		
			
				|  |  |          patientId,
 | 
	
		
			
				|  |  | -        year,
 | 
	
		
			
				|  |  | -        month,
 | 
	
		
			
				|  |  | +        start,
 | 
	
		
			
				|  |  | +        end,
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        checkExamIndex(param).then((res) => {
 | 
	
		
			
				|  |  |          store.commit('SET_EXAMINDEXARRAY', res)
 | 
	
		
			
				|  |  |        })
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      onMounted(() => {
 | 
	
		
			
				|  |  | -      if (examIndex.value.length === 0) {
 | 
	
		
			
				|  |  | -        confirmPickDate(data.currentDate)
 | 
	
		
			
				|  |  | -      } else {
 | 
	
		
			
				|  |  | -        data.showDatePicker = false
 | 
	
		
			
				|  |  | +      if (Cookies.get('inspection-start-date')) {
 | 
	
		
			
				|  |  | +        date.value = Cookies.get('inspection-start-date') + ' - ' + Cookies.get('inspection-end-date')
 | 
	
		
			
				|  |  | +        if (examIndex.value.length === 0) {
 | 
	
		
			
				|  |  | +          const param = {
 | 
	
		
			
				|  |  | +            patientId,
 | 
	
		
			
				|  |  | +            start: Cookies.get('inspection-start-date'),
 | 
	
		
			
				|  |  | +            end: Cookies.get('inspection-end-date'),
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +          checkExamIndex(param).then((res) => {
 | 
	
		
			
				|  |  | +            store.commit('SET_EXAMINDEXARRAY', res)
 | 
	
		
			
				|  |  | +          })
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | +      showDateRange.value = false
 | 
	
		
			
				|  |  |      })
 | 
	
		
			
				|  |  |      return {
 | 
	
		
			
				|  |  |        scrollStyle,
 | 
	
		
			
				|  |  |        empty,
 | 
	
		
			
				|  |  | -      data,
 | 
	
		
			
				|  |  | -      dateText,
 | 
	
		
			
				|  |  | -      formatter,
 | 
	
		
			
				|  |  | +      minDate: new Date(2010, 0, 1),
 | 
	
		
			
				|  |  | +      date,
 | 
	
		
			
				|  |  |        examIndex,
 | 
	
		
			
				|  |  | -      confirmPickDate,
 | 
	
		
			
				|  |  | +      onConfirm,
 | 
	
		
			
				|  |  | +      showDateRange,
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    },
 | 
	
		
			
				|  |  |  }
 |