<template>
    <div>
        <el-card class="!border-none" shadow="never">
            <el-form class="mb-[-16px]" :model="queryParams" inline>
                <el-form-item label="查询" prop="name">
                    <el-input class="w-[280px]" v-model="queryParams.contract_no" 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" @cell-click="handleCurrentChange">
                    <el-table-column type="selection" width="55" />
                    <el-table-column label="序号" type="index" width="55" />

                    <el-table-column label="合同编号" prop="project_name" show-overflow-tooltip />
                    <el-table-column label="合同类型" prop="contract_type" show-overflow-tooltip />
                    <el-table-column label="客户名称" prop="project_name" show-overflow-tooltip />
                    <el-table-column label="项目名称" prop="project_name" show-overflow-tooltip />

                    <el-table-column label="项目编码" prop="project_code" show-overflow-tooltip />
                    <el-table-column label="期次" prop="period" show-overflow-tooltip />
                    <el-table-column label="计划回款日期" prop="return_date" show-overflow-tooltip />
                    <el-table-column label="状态" prop="return_status" show-overflow-tooltip />
                    <el-table-column label="金额" prop="amount" show-overflow-tooltip />
                    <el-table-column label="已回款" prop="has_return_amount" show-overflow-tooltip />
                    <el-table-column label="未回款" prop="not_return_amount" show-overflow-tooltip />
                    <el-table-column label="回款责任人" prop="return_duty" show-overflow-tooltip />
                    <el-table-column label="备注" prop="remark" 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>
import { usePaging } from "@/hooks/usePaging"
import { useDictData } from "@/hooks/useDictOptions"
import { apireturnedLists } from '@/api/remittance'

import { defineEmits } from "vue"
import { timeFormat } from '@/utils/util'
const props = defineProps({

    contract_id: {
        type: String
    },
})
// 查询条件
const queryParams = reactive({
    contract_no: '',
    contract_id: props.contract_id
});

// 获取字典数据
const { dictData } = useDictData('return_status,pay_period,contract_type')
// 选中数据
const emits = defineEmits(["customEvent"]);

// 选中数据子父传递
const handleCurrentChange = (value: any) => {
    emits("customEvent", value);
};

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

});

getLists();
</script>