<template>
    <div>
        <el-card class="!border-none" shadow="never">
            <el-form class="mb-[-16px]" :model="queryParams" inline>
                <el-form-item label="查询" prop="contract_name">
                    <el-input class="w-[280px]" v-model="queryParams.contract_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" @cell-click="handleCurrentChange">
                    <el-table-column label="序号" type="index" />
                    <el-table-column label="合同名称" prop="contract_name" show-overflow-tooltip />
                    <el-table-column label="合同编号" prop="contract_no" show-overflow-tooltip />
                    <el-table-column label="开始日期" property="start_date" />
                    <el-table-column label="结束日期" property="end_date" />
                    <el-table-column label="签约日期" property="signing_date" />
                    <el-table-column label="合同金额" property="amount" />
                    <el-table-column label="付款方式" prop="pay_type">
                        <template #default="{ row }">
                            <dict-value :options="dictData.pay_type" :value="row.pay_type" />
                        </template>
                    </el-table-column>
                    <el-table-column label="备注" property="remark" />
                    <el-table-column label="已付款" property="master_name" />
                    <el-table-column label="未付款" property="master_name" />
                    <el-table-column label="已开票" property="master_name" />
                    <el-table-column label="未开票" property="master_name" />
                </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 { apiadministrativeLists } from '@/api/administrative'
import { defineEmits } from "vue"

// 查询条件
const queryParams = reactive({
    contract_name: ''


});
const { dictData } = useDictData('pay_type')


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

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

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

getLists();
</script>