<template>
  <div class="app-container">
    <el-form :model="form" ref="form" inline>
      <h3>基础信息</h3>
      <el-form-item label="订单号：" prop="name">{{form.orderNo}}</el-form-item>
      <br>
      <el-form-item label="下单人姓名：" prop="name">{{form.userName}}</el-form-item>
      <el-form-item label="下单人手机号：" prop="name">{{form.userMobile}}</el-form-item>
      <el-form-item label="下单时间：" prop="name">{{ parseTime(form.createTime, '{y}-{m}-{d} {h}:{i}') }}</el-form-item>
      <el-form-item label="订单状态：" prop="name">
        {{dealStatus(form.status)}}
      </el-form-item>
      <h3>服务信息</h3>
      <el-form-item label="下单医院：" prop="name">{{form.hospitalVo.name}}</el-form-item>
      <el-form-item label="所在科室：" prop="name">{{form.hospitalDepartmentName}}</el-form-item>
      <el-form-item label="医院地址：" prop="name">{{form.hospitalVo.address}}</el-form-item>
      <el-form-item label="期望时间：" prop="name">{{parseTime(form.expectedTime, '{y}-{m}-{d} {h}:{i}')||'-'}}</el-form-item>
      <el-form-item label="服务名称：" prop="name">{{form.serviceName}}</el-form-item>
      <el-form-item label="房床号：" prop="name">{{form.roomNumber}}</el-form-item>
      <el-form-item label="下单数量：" prop="name">{{form.orderNum}}{{dealServiceUnitList(form.serviceUnit)}}</el-form-item>
      <el-form-item label="销售价格：" prop="name">{{form.sellingPrice}}</el-form-item>
      <el-form-item label="应付金额：" prop="name">{{form.totalPrice}}</el-form-item>
      <el-form-item label="特殊需求：" prop="name">{{form.remarks||'-'}}</el-form-item>
      <h3>就诊人信息</h3>
      <el-form-item label="就诊人姓名：" prop="name">{{ form.patientVo.name}}</el-form-item>
      <el-form-item label="电话：" prop="name">{{form.patientVo.mobile}}</el-form-item>
      <el-form-item label="性别：" prop="name">{{dealGender(form.patientVo.gender)}}</el-form-item>
      <el-form-item label="年龄：" prop="name">{{form.patientVo.age}}</el-form-item>
      <el-form-item label="关系：" prop="name">
        <div v-for="(v,i) in dict.type.patient_relationship" :key="i" v-if="v.value==form.patientVo.relationship">{{v.label}}</div>
      </el-form-item>
    </el-form>
    <div class="form-footer">
      <el-button @click="back">返回</el-button>
    </div>
  </div>
</template>

<script>
import { businessProductOrderInfo, orderCouponList, verification } from '@/api/order.js'
import { orderInfo, orderEnum } from '@/api/hospitalOrder.js'
import { serviceProductEnum } from '@/api/service.js'

export default {
  dicts: ['patient_relationship'],
  data () {
    return {
      form: {
        hospitalVo: {},
        patientVo: {}
      },
      couponStatusList: [
        { label: '待使用', value: 0 },
        { label: '已使用', value: 10 },
        { label: '已退款', value: 20 },
        { label: '退款中', value: 21 },
        { label: '已过期', value: 30 },
      ],
      couponList: [],
      gameRecord: {},
      statusList: [],
      genderList: [
        { label: '0', value: '未知' },
        { label: '1', value: '男' },
        { label: '2', value: '女' }
      ],
      serviceUnitList: []
    }
  },
  created () {
    this.init()
  },
  methods: {
    init () {
      this.getDetails();
      this.getOrderEnum();
      this.getServiceUnitList();
    },
    // 获取服务单位列表
    getServiceUnitList () {
      serviceProductEnum().then(res => {
        this.serviceUnitList = res.data.serviceUnit
      })
    },
    dealStatus (status) {
      for (let i = 0; i < this.statusList.length; i++) {
        if (this.statusList[i].code == status) {
          return this.statusList[i].value
        }
      }
    },
    dealGender (gender) {
      for (let i = 0; i < this.genderList.length; i++) {
        if (this.genderList[i].label == gender) {
          return this.genderList[i].value
        }
      }
    },
    dealServiceUnitList (val) {
      for (let i = 0; i < this.serviceUnitList.length; i++) {
        if (this.serviceUnitList[i].code == val) {
          return this.serviceUnitList[i].value
        }
      }
    },
    back () {
      this.$router.go(-1)
    },
    getOrderEnum () {
      orderEnum().then(res => {
        this.statusList = res.data.orderStatus;
      })
    },
    getDetails () {
      orderInfo(this.$route.query.id).then(res => {
        this.form = res.data
        // this.getGameRecordPage(res.data.orderNumber)
      })
    },
  }

}
</script>

<style lang='scss' scoped>
h3 {
  font-weight: 700;
}
.el-form--inline .el-form-item {
  width: 24%;
}
.active {
  color: rgb(64, 158, 255);
  cursor: pointer;
}
.form-footer {
  margin-top: 20px;
  text-align: center;
}
::v-deep .el-form-item__content {
  width: calc(100% - 120px);
}
</style>