<template>
    <hc-new-card>
        <template #header>
            <div class="mr-2 w-40">
                <el-select v-model="searchForm.key1" filterable block placeholder="报表分类">
                    <el-option label="中间计量申请" value="1" />
                </el-select>
            </div>
            <div class="mr-2 w-40">
                <el-input v-model="searchForm.key2" placeholder="报表编号" />
            </div>
            <hc-search-input v-model="searchForm.queryValue" placeholder="报表名称" @search="searchClick" />
        </template>
        <template #extra>
            <el-button hc-btn type="primary" @click="addRowData">新增</el-button>
            <el-button hc-btn color="#9e6ab8" style="color: white" @click="initReportForm">报表模板初始化</el-button>
            <el-button hc-btn type="danger">批量删除</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">修改</el-link>
                <el-link type="warning" @click="reportTemplateClick">修改报表模板</el-link>
                <el-link type="danger">删除</el-link>
            </template>
        </hc-table>
        <template #action>
            <hc-pages :pages="searchForm" @change="pageChange" />
        </template>

        <!-- 修改项目支付项 -->
        <rowDataInfo v-model="isRowDataShow" />

        <!-- 报表模板初始化 -->
        <reportForm v-model="isReportFormShow" />

        <!-- 修改报表模板 -->
        <reportTemplate v-model="isTemplateShow" />
    </hc-new-card>
</template>

<script setup>
import { onMounted, ref } from 'vue'
import rowDataInfo from './components/report/row-data.vue'
import reportForm from './components/report/report-form.vue'
import reportTemplate from './components/report/template.vue'
import { addDocumentsJs } from '~uti/tools'

defineOptions({
    name: 'ProjectPeriodsProjectReport',
})

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

//搜索表单
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: 'action', name: '操作', width: 180, align: 'center' },
])
const tableData = ref([
    { key1: '1111' },
])

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

}


//新增
const isRowDataShow = ref(false)
const addRowData = () => {
    isRowDataShow.value = true
}

//报表模板初始化
const isReportFormShow = ref(false)
const initReportForm = () => {
    isReportFormShow.value = true
}

const isTemplateShow = ref(false)
const reportTemplateClick = () => {
    isTemplateShow.value = true
}
</script>
