<template>
    <hc-new-dialog widths="500px" :show="isShow" title="开工预付款计量单新增" @save="modalSave" @close="modalClose">
        <el-scrollbar>
            <hc-card-item>
                <el-form ref="baseFormRef" :model="baseForm" :rules="baseFormRules" label-position="top" label-width="auto">
                    <el-form-item label="计量期：">
                        <el-select v-model="baseForm.key1" block>
                            <el-option label="第一期" value="1" />
                            <el-option label="第二期" value="2" />
                        </el-select>
                    </el-form-item>
                    <el-form-item label="业务日期：">
                        <el-date-picker v-model="baseForm.key2" class="block" format="YYYY-MM-DD" type="date" value-format="YYYY-MM-DD" disabled />
                    </el-form-item>
                    <el-form-item label="计量金额：">
                        <el-input v-model="baseForm.key3" />
                    </el-form-item>
                    <el-form-item label="开工预付款总额：">
                        <el-input v-model="baseForm.key4" />
                    </el-form-item>
                    <el-form-item label="申请依据：">
                        <el-input v-model="baseForm.key5" :autosize="{ minRows: 2, maxRows: 6 }" type="textarea" />
                    </el-form-item>
                </el-form>
            </hc-card-item>
            <!-- 附件列表 -->
            <hc-card-item class="mt-3" title="附件列表" extra-text="可上传:图片、Excel、PDF、Word文件">
                <el-form :model="baseForm" label-position="top">
                    <el-form-item label="">
                        <hc-form-upload type="list" :src="baseForm.key11" />
                    </el-form-item>
                </el-form>
            </hc-card-item>
        </el-scrollbar>
    </hc-new-dialog>
</template>

<script setup>
import { nextTick, ref, watch } from 'vue'

const props = defineProps({
    ids: {
        type: [String, Number],
        default: '',
    },
})

//事件
const emit = defineEmits(['close'])

//双向绑定
// eslint-disable-next-line no-undef
const isShow = defineModel('modelValue', {
    default: false,
})

//监听
watch(() => [
    props.ids,
], ([ids]) => {
    console.log('ids', ids)
}, { immediate: true })

//监听
watch(isShow, (val) => {
    if (val) {
        detailsModalShow()
    }
})

const detailsModalShow = () => {
    nextTick(() => {
        window.$split(['#hc_modal_tree', '#hc_modal_form'], {
            sizes: [30, 70],
            snapOffset: 0,
            minSize: [170, 500],
        })
    })
}

//数据格式
const treeProps = {
    label: 'name',
    children: 'children',
    isLeaf: 'leaf',
}

//懒加载的数据
const treeLoadNode = ({ level }, resolve) => {
    if (level === 0) {
        return resolve([{ name: 'region' }])
    }
    if (level > 3) {
        return resolve([])
    }
    setTimeout(() => {
        resolve([
            { name: 'leaf', leaf: true },
            { name: 'zone' },
        ])
    }, 500)
}

//基础表单
const baseFormRef = ref(null)
const baseForm = ref({})
const baseFormRules = {}

const modalSave = () => {
    modalClose()
}

const modalClose = () => {
    isShow.value = false
    emit('close')
}
</script>

<style scoped lang="scss">

</style>
