<template>
    <div>
        <el-card class="!border-none mb-4" shadow="never">
            <el-form class="mb-[-16px]" :model="queryParams" inline>
                <el-form-item label="项目名称">
                    <el-input class="w-[280px]" v-model="queryParams.project_name" clearable placeholder="请输入项目名称" />
                </el-form-item>
                <el-form-item label="日期">
                    <el-date-picker v-model="date" type="daterange" range-separator="-" start-placeholder="开始日期"
                        end-placeholder="结束日期" value-format="YYYY-MM-DD" />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="a">查询</el-button>
                    <el-button @click="resetParams">重置</el-button>
                </el-form-item>
            </el-form>
        </el-card>
        <el-card class="!border-none" v-loading="pager.loading" shadow="never">
            <div class="mt-4">
                <el-table :data="pager.lists">
                    <el-table-column type="selection" width="55" />
                    <el-table-column label="项目编号" prop="project_num" show-overflow-tooltip width="120" />
                    <el-table-column label="项目名称" prop="project_name" show-overflow-tooltip width="120" />
                    <el-table-column label="合同名称" prop="contract_name" show-overflow-tooltip width="120" />
                    <el-table-column prop="contract_name" show-overflow-tooltip align="center">
                        <template #default="{ row }">
                            <el-table :data="row.children">
                                <el-table-column label="专业" prop="professional_type" show-overflow-tooltip />
                                <el-table-column label="任务名称" prop="task_name" show-overflow-tooltip />
                                <el-table-column label="任务类型" prop="task_type" show-overflow-tooltip />
                                <el-table-column label="工程师" prop="engineer" show-overflow-tooltip />
                                <el-table-column label="造价金额" prop="zj_amount" show-overflow-tooltip />
                                <el-table-column label="收款金额" prop="sk_amount" show-overflow-tooltip />
                                <el-table-column label="提成比例" prop="tc_rate" show-overflow-tooltip />
                                <el-table-column label="其他加减项" prop="other_fee" show-overflow-tooltip />
                                <el-table-column label="应提成金额" prop="tc_amount" show-overflow-tooltip />
                                <el-table-column label="累计支付金额" prop="pay_amount" show-overflow-tooltip />
                            </el-table>
                        </template>
                    </el-table-column>

                </el-table>
            </div>
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
    </div>
</template>

<script lang="ts" setup name="jianliProjectProgressReportLists">
import { usePaging } from '@/hooks/usePaging'
import { apiproject_commission_statistics } from '@/api/data_report'

// 查询条件
const queryParams = reactive({
    project_name: '',
    date: '',
})

let date = ref('')

const a = () => {
    queryParams.date = date.value.join(',')
    resetPage()
}

// 分页相关
const { pager, getLists, resetParams, resetPage } = usePaging({
    fetchFun: apiproject_commission_statistics,
    params: queryParams
})

getLists()
</script>
