<template>
    <view class="page">
        <u-cell-group :border="false">
            <u-cell title="姓名" :value="this.info.patient ? this.info.patient.name : ''" />
            <u-cell title="类别" :value="info.type ? info.type.name : ''" />
            <u-cell title="病种" :value="info.illness_type ? info.illness_type.name : ''" />
            <u-cell :title="`${type.text}时间`" :value="info.treat_at | date" />
            <u-cell title="划线价" :value="info.origin_price" />
            <u-cell title="实收价" :value="info.sell_price" />
            <u-cell title="收费情况" :value="info.order_status" />
            <u-cell :title="`${type.text}医师`" :value="info.doctor ? info.doctor.name : ''" />
            <u-cell :title="`${type.text}情况`">
                <view slot="value">
                    <!-- <rich-text :nodes="info.illness" /> -->
                    <text>{{info.content}}</text>
                </view>
            </u-cell>
			<u-cell title="图片资料">
				<view slot="value">
                    <u-album :urls="info.images" />
				</view>
			</u-cell>
            <u-cell
                title="下次就诊时间"
                :value="info.next_treat_at | date"
            />
        </u-cell-group>
    </view>
</template>

<script>

export default {
    data() {
        return {
            id: '',
            info: {
                patient_id: '',
                type_id: '',
                origin_price: '',
                sell_price: '',
                notify_remarks: '',
                is_notified: 0,
            },
            type: {
                text: ''
            }
        }
    },
    onLoad(e) {
        this.id = e.id
        this.loadData()
    },
    onPullDownRefresh() {
        this.loadData()
    },
    methods: {
        async loadData() {
            if (!this.id) {
                return
            }
            uni.showLoading()
            let res = await this.$ajax.get(`/api/client/record/${this.id}`)
            uni.stopPullDownRefresh()
            if (res.status == 0) {
                this.info = res.data
                // this.info = {
                //     ...res.data,
                //     treat_at: res.data.treat_at ? res.data.treat_at.replaceAll('-', '/') : '',
                //     next_treat_at: res.data.next_treat_at ? res.data.next_treat_at.replaceAll('-', '/') : '',
                //     notify_at: res.data.notify_at ? res.data.notify_at.replaceAll('-', '/') : '',
                // }
                this.type.text = this.info.type.name
            }

        },
    }
}
</script>
<style scoped>
    .page {
        padding: 20px;
        background: white;
    }
    .btn {
        padding: 0 10px;
    }
    .btn .u-button {
        margin-top: 20px;
    }
	.text-gray {
		color: gray;
	}
</style>