<template>
    <hc-new-card title="合同材料">
        <template #extra>
            <el-button hc-btn type="primary" @click="rowAddClick">
                <HcIcon name="add" />
                <span>新增</span>
            </el-button>
        </template>
        <div class="relative h-full flex">
            <div class="flex-1">
                <hc-card-item>
                    <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" is-new :index-style="{ width: 60 }">
                        <template #action="{ row }">
                            <el-link type="success" @click="rowEditClick(row)">修改</el-link>
                            <el-link type="danger">删除</el-link>
                        </template>
                    </hc-table>
                    <template #action>
                        <hc-pages :pages="searchForm" @change="pageChange" />
                    </template>
                </hc-card-item>
            </div>
            <div class="ml-3 w-[400px]">
                <hc-card-item title="详情信息" scrollbar>
                    <el-form label-position="left" :model="formModel" label-width="auto" size="large" disabled>
                        <el-form-item label="材料编号：">
                            <el-input v-model="formModel.key1" />
                        </el-form-item>
                        <el-form-item label="材料名称：">
                            <el-input v-model="formModel.key2" />
                        </el-form-item>
                        <el-form-item label="规格型号：">
                            <el-input v-model="formModel.key3" />
                        </el-form-item>
                        <el-form-item label="单位：">
                            <el-input v-model="formModel.key4" />
                        </el-form-item>
                        <el-form-item label="单价：">
                            <el-input v-model="formModel.key5" />
                        </el-form-item>
                        <el-form-item label="数量：">
                            <el-input v-model="formModel.key6" />
                        </el-form-item>
                    </el-form>
                </hc-card-item>
            </div>
        </div>
        <!-- 新增/修改 -->
        <hc-new-dialog widths="30rem" :show="isFormModal" title="合同材料新增" @save="modalSave" @close="modalClose">
            <el-form ref="formRef" class="p-2" label-position="top" :model="formModel" :rules="formRules" size="large">
                <el-form-item label="材料编号：">
                    <el-input v-model="formModel.key1" />
                </el-form-item>
                <el-form-item label="材料名称：" prop="key2">
                    <el-input v-model="formModel.key2" />
                </el-form-item>
                <el-form-item label="规格型号：">
                    <el-input v-model="formModel.key3" />
                </el-form-item>
                <el-form-item label="单位：">
                    <el-input v-model="formModel.key4" />
                </el-form-item>
                <el-form-item label="单价：">
                    <el-input v-model="formModel.key5" />
                </el-form-item>
                <el-form-item label="数量：">
                    <el-input v-model="formModel.key6" />
                </el-form-item>
            </el-form>
        </hc-new-dialog>
    </hc-new-card>
</template>

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

defineOptions({
    name: 'PeriodsMaterialContract',
})

//渲染完成
onMounted(() => {

})

//搜索表单
const searchForm = ref({
    current: 1, size: 10, total: 0,
})

//分页
const pageChange = ({ current, size }) => {
    searchForm.value.current = current
    searchForm.value.size = size
}

//表格数据
const tableLoading = ref(false)
const tableColumn = ref([
    { key: 'key1', name: '材料编号' },
    { key: 'key2', name: '材料名称' },
    { key: 'key3', name: '规格型号' },
    { key: 'key4', name: '单位' },
    { key: 'key5', name: '单价' },
    { key: 'key6', name: '数量' },
    { key: 'action', name: '操作', width: 100 },
])
const tableData = ref([
    { key1: '1111' },
])

//新增
const isFormModal = ref(false)
const rowAddClick = () => {
    isFormModal.value = true
}

//表单数据
const formRef = ref(null)
const formModel = ref({})
const formRules = {}

//修改
const rowEditClick = () => {

}

//保存
const modalSave = () => {
    modalClose()
}

//关闭弹窗
const modalClose = () => {
    isFormModal.value = false
}
</script>

<style scoped lang="scss">

</style>
