<template>
    <van-form>
        <div class="label-title" required>专病名称</div>
        <van-field
            v-model="form.diseaseTypeName"
            isLink
            readonly
            placeholder="请选择"
            :rules="rules.diseaseTypeName"
            @click="showDiseaseType = true"
            class="form-input"
        />
        <van-popup v-model:show="showDiseaseType" position="bottom">
            <van-picker
                :columns-field-names="{ text: 'name', value: 'value' }"
                :columns="store.getDict('CP00117')"
                @confirm="diseaseConfirm"
                @cancel="showDiseaseType = false"
            />
        </van-popup>

        <div class="label-title mt-5" required>请选择</div>
        <van-field style="padding: 0" class="mb-5">
            <template #input>
                <van-radio-group
                    v-model="form.serveType"
                    shape="dot"
                    direction="horizontal"
                    class="doc-radio-group"
                >
                    <van-radio :name="3" label-position="left">新增专病随访（常规）</van-radio>
                    <van-radio :name="4" label-position="left" class="mt-2">新增专病随访（增加）</van-radio>
                </van-radio-group>
            </template>
        </van-field>

        <!-- <div class="font-semibold mt-4">居民信息</div> -->
        <!-- <div class="label-title mt-4" required>证件类型</div>
        <van-field
            v-model="form.certificateTypeName"
            isLink
            readonly
            placeholder="请选择"
            :rules="rules.certificateTypeName"
            @click="showCertificateType = true"
            class="form-input"
        />
        <van-popup v-model:show="showCertificateType" position="bottom">
            <van-picker
                :columns-field-names="{ text: 'name', value: 'value' }"
                :columns="store.getDict('DC00004')"
                @confirm="certificateConfirm"
                @cancel="showDiseaseType = false"
            />
        </van-popup> -->
        <ArchiveCommon ref="archive"></ArchiveCommon>
    </van-form>
</template>
<script>
import { useStore } from '@/doctor/store'
import ArchiveCommon from '@/doctor/components/archiveCommon/archiveCommon.vue'
export default {
    components: { ArchiveCommon },
    data() {
        return {
            store: useStore(),
            form: {},
            rules: {},
            showDiseaseType: false,
            showCertificateType: false
        }     
    },
    methods: {
        diseaseConfirm({ selectedValues, selectedOptions }) {
            this.form.diseaseType = selectedValues[0]
            this.form.diseaseTypeName = selectedOptions[0].name
            this.showDiseaseType = false
        },
        certificateConfirm({ selectedValues, selectedOptions }) {
            this.form.certificateType = selectedValues[0]
            this.form.certificateTypeName = selectedOptions[0].name
            this.showCertificateType = false
        },
        async onSubmit() {
            let baseInfo = {}
            try {
                baseInfo = await this.$refs.archive.onSubmit()
            } catch(e) {

            }
        }
    }
}
</script>
<style lang="less" scoped>
.label-title {
    font-size: 13px;
    color: #595959;
    font-weight: 500;
    margin-bottom: 8px;
    &[required] {
        &::after {
            content: '*';
            color: #FF4D4F;
            font-weight: bold;
            margin-left: 4px;
        }
    }
}
.form-input {
    background-color: #FAFAFA;
    padding: 8px 12px;
    border-radius: 8px;
}
:deep(.van-cell:after) {
    border-bottom: 0px;
}
</style>