<template>
  <window-size>
    <van-cell title="项目名称" :value="bookItem.name"></van-cell>
    <van-cell title="执行科室" :value="bookItem.execUnitName"></van-cell>
    <van-cell title="预约人" :value="bookItem.patientName"></van-cell>
    <van-cell title="预约日期" :value="bookItem.recordDate"></van-cell>
    <van-cell title="预约时间段" :value="bookItem.beginTime + ' - ' + bookItem.endTime"></van-cell>
    <div style="height: 8px"></div>
    <van-button block type="primary" icon="passed" @click="executeBook">执行预约</van-button>
  </window-size>
</template>

<script>
import { Toast } from 'vant'
import { saveBookPrescription } from '../../../api/bookable'
import router from '../../../router'
import store from '../../../store'
export default {
  setup() {
    const bookItem = store.state.currentBook
    const executeBook = () => {
      saveBookPrescription(bookItem).then((res) => {
        store.commit('SET_YJREQNO', res)
        Toast.success('自助开单成功。')
        router.push('/unPaidList/' + bookItem.patientId)
      })
    }
    return {
      bookItem,
      executeBook,
    }
  },
}
</script>