<template>
    <div>
        <el-card class="!border-none" shadow="never">
            <el-form class="mb-[-16px]" :model="queryParams" inline>
                <el-form-item label="查询" prop="contract_code">
                    <el-input class="w-[280px]" v-model="queryParams.contract_code" 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 label="序号" type="index" />
                    <el-table-column label="合同类型" property="contract_type" />
                    <el-table-column label="客户名称" property="custom_name" />
                    <el-table-column label="订单编号" property="province_name" />
                    <el-table-column label="订单金额" property="city_name" />
                    <el-table-column label="调整金额" property="street_name" />
                    <el-table-column label="实际合同金额" property="reality_contract_amount" />
                    <el-table-column label="项目名称" property="project_name" />
                    <el-table-column label="项目编码" property="project_code" />
                    <el-table-column label="签约日期" property="contract_date" />
                    <el-table-column label="已回款" property="returned_amount" />
                    <el-table-column label="未回款" property="not_returned_amount" />
                    <el-table-column label="已开票" property="invoicing_amount" />
                    <el-table-column label="未开票" property="not_invoicing_amount" />
                </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 { apiContractLists } from '@/api/contract'
import { defineEmits } from "vue"
const props = defineProps({
    project_id: {
        type: String
    },
    contract_type: {
        type: String
    }
})


// 查询条件
const queryParams = reactive({
    contract_code: '',
    project_id: props.project_id,
    contract_type: props.contract_type,
});
const { dictData } = useDictData('contract_type')


// 选中数据
const emits = defineEmits(["customEvent"]);

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

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

getLists();
</script>