<template>
    <div>
        <el-card class="!border-none mb-4" shadow="never">
            <el-form class="mb-[-16px]" :model="queryParams" inline>
                <el-form-item label="合同名称" prop="contract_id">
                    <select-remote model="contract_id" :formData="queryParams"
                        :api="apiCostApprovedProjectSerch"></select-remote>
                </el-form-item>

                <el-form-item label="预算书编号">
                    <el-input class="w-[280px]" v-model="queryParams.code" clearable placeholder="请输入预算书编号" />
                </el-form-item>

                <el-form-item label="预算书名称">
                    <el-input class="w-[280px]" v-model="queryParams.name" clearable placeholder="请输入预算书名称" />
                </el-form-item>


                <el-form-item>
                    <el-button type="primary" @click="resetPage">查询</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" @selection-change="handleSelectionChange" border>
                    <el-table-column type="selection" width="55" />
                    <el-table-column label="合同名称" prop="contract_name" :render-header="pager.calcWidth" />
                    <el-table-column label="预算书名称" prop="name" :render-header="pager.calcWidth" />
                    <el-table-column label="预算书编号" prop="code" show-overflow-tooltip />
                    <el-table-column label="合同金额" prop="money" show-overflow-tooltip />
                    <el-table-column label="分成金额合计" prop="amount" show-overflow-tooltip />
                    <el-table-column label="累计金额结算" prop="settlement_amount" show-overflow-tooltip />
                    <el-table-column label="未结算金额" prop="not_settlement_amount" show-overflow-tooltip />

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

    </div>
</template>

<script lang="ts" setup name="financialRefundLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiFinancialBudgetDocLists } from '@/api/financial_budget_doc_income'
import { apiCostApprovedProjectSerch } from "@/api/cost_approved_project";

const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const detailRef = ref('')
// 是否显示编辑框
const showEdit = ref(false)
const showDetail = ref(false)


// 查询条件
const queryParams = reactive({
    code: "",
    name: "",
    contract_id: ""
})

// 选中数据
const selectData = ref<any[]>([])

// 表格选择后回调事件
const handleSelectionChange = (val: any[]) => {
    selectData.value = val.map(({ id }) => id)
}

// 获取字典数据
const { dictData } = useDictData('')

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

// 添加
const handleAdd = async () => {
    showEdit.value = true
    await nextTick()
    editRef.value?.open('add')
}



getLists()
</script>

