<template>
    <hc-new-card>
        <template #header>
            <hc-search-input v-model="searchForm.queryValue" placeholder="请输入文件名称关键词" @search="searchClick" />
        </template>
        <template #extra>
            <el-button hc-btn type="primary" @click="addDataClick">新增附件</el-button>
            <el-button hc-btn type="success">一键引入系统变更附件</el-button>
        </template>
        <hc-table
            is-new is-check :check-style="{ width: 29 }" :index-style="{ width: 60 }"
            :column="tableColumn" :datas="tableData" :loading="tableLoading"
            @selection-change="tableCheckChange"
        >
            <template #action="{ row }">
                <el-link type="success" @click="editDataClick(row)">修改</el-link>
                <el-link type="danger">删除</el-link>
            </template>
        </hc-table>
        <template #action>
            <hc-pages :pages="searchForm" @change="pageChange" />
        </template>

        <!-- 新增编辑 -->
        <hc-new-dialog v-model="dataModalShow" widths="500px" :title="dataModalTitle" @save="dataModalSave">
            <el-form ref="formRef" class="p-2" label-position="top" size="large" :model="formModel" :rules="formRules">
                <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-select v-model="formModel.key3" block>
                        <el-option label="变更方案" :value="1" />
                    </el-select>
                </el-form-item>
                <el-form-item label="变更类型：">
                    <el-select v-model="formModel.key4" block>
                        <el-option label="重大变更" :value="1" />
                    </el-select>
                </el-form-item>
                <el-form-item label="排序号：">
                    <el-input v-model="formModel.key5" />
                </el-form-item>
            </el-form>
        </hc-new-dialog>
    </hc-new-card>
</template>

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

defineOptions({
    name: 'ProjectPeriodsProjectAffix',
})

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

})

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

//搜索
const searchClick = () => {
    searchForm.value.current = 1
}

//分页
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: '是否必须上传', align: 'center' },
    { key: 'key3', name: '所属申请类型', align: 'center' },
    { key: 'key4', name: '变更类型', align: 'center' },
    { key: 'action', name: '操作', width: 100, align: 'center' },
])
const tableData = ref([
    { key1: '1111' },
])

//表格选择
const tableCheckChange = () => {

}

//弹窗
const dataModalShow = ref(false)
const dataModalTitle = ref('')

//新增
const addDataClick = () => {
    dataModalTitle.value = '新增项目变更附件'
    dataModalShow.value = true
}

//编辑
const editDataClick = (row) => {
    dataModalTitle.value = '修改项目变更附件'
    dataModalShow.value = true
}

//弹窗表单
const formRef = ref(null)
const formModel = ref({})
const formRules = ref({})

//弹窗保存
const dataModalSave = () => {

}
</script>
