<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_name">
                    <el-input class="w-[280px]" v-model="queryParams.contract_name" clearable placeholder="请输入合同名称" />
                </el-form-item>
                <el-form-item label="合同编号" prop="contract_num">
                    <el-input class="w-[280px]" v-model="queryParams.contract_num" clearable placeholder="请输入合同编号" />
                </el-form-item>
                <el-form-item label="甲方单位" prop="part_b">
                    <el-input class="w-[280px]" v-model="queryParams.part_b" clearable placeholder="请输入甲方单位" />
                </el-form-item>
                <el-form-item label="合同类型" prop="contract_type">
                    <el-input class="w-[280px]" v-model="queryParams.contract_type" 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 border :data="pager.lists">
                    <el-table-column label="合同名称" prop="contract_name" :render-header="pager.calcWidth" />
                    <el-table-column label="合同编号" prop="contract_num" :render-header="pager.calcWidth" />
                    <el-table-column label="合同类型" prop="contract_type" show-overflow-tooltip width='90'>
                        <template #default="{ row }">
                            <dict-value :options="dictData.cost_contract_type" :value="row.contract_type" />
                        </template>
                    </el-table-column>
                    <el-table-column label="业务性质" prop="business_nature" show-overflow-tooltip width='90'>
                        <template #default="{ row }">
                            <dict-value :options="dictData.cost_consultation_business_nature"
                                :value="row.business_nature" />
                        </template>
                    </el-table-column>
                    <el-table-column :render-header="pager.calcWidth" label="甲方签约单位" prop="part_a" show-overflow-tooltip />
                    <el-table-column :render-header="pager.calcWidth" label="签订部门" prop="dept" show-overflow-tooltip />
                    <el-table-column :render-header="pager.calcWidth" label="合同签订金额" prop="money" show-overflow-tooltip />
                    <el-table-column :render-header="pager.calcWidth" label="已开票金额" prop="total_invoice_amount"
                        show-overflow-tooltip />
                    <el-table-column :render-header="pager.calcWidth" label="已到账金额" prop="total_refund_amount"
                        show-overflow-tooltip />
                    <el-table-column :render-header="pager.calcWidth" label="已结算金额" prop="total_settlement_amount"
                        show-overflow-tooltip />
                    <el-table-column :render-header="pager.calcWidth" label="未开票金额" prop="not_total_invoice_amount"
                        show-overflow-tooltip />
                    <el-table-column :render-header="pager.calcWidth" label="未到账金额" prop="not_total_refund_amount"
                        show-overflow-tooltip />
                    <el-table-column :render-header="pager.calcWidth" label="开票未回款金额" prop="invoice_not_refund_amount"
                        show-overflow-tooltip />
                    <el-table-column label="回款未开票金额" prop="refund_not_invoice_amount" show-overflow-tooltip />
                    <el-table-column label="合同结算日期" prop="settlement_date" show-overflow-tooltip width="120" />
                </el-table>
            </div>
            <div class="flex mt-4 justify-end">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
        <!-- <edit-popup v-if="showEdit" ref="editRef" :dict-data="dictData" @success="getLists" @close="showEdit = false" /> -->
    </div>
</template>

<script lang="ts" setup name="financialRefundLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiContractLedgerLists } from '@/api/contract_ledger'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'
// import EditPopup from './edit.vue'

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


// 查询条件
const queryParams = reactive({
    contract_name: "",
    part_b: '',
    contract_type: '',
})

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



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

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

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

// // 编辑
// const handleEdit = async (data: any) => {
//     showEdit.value = true
//     await nextTick()
//     editRef.value?.open('edit')
//     editRef.value?.setFormData(data)
// }

// // 删除
// const handleDelete = async (id: number | any[]) => {
//     await feedback.confirm('确定要删除？')
//     await apiFinancialRefundDelete({ id })
//     getLists()
// }

getLists()
</script>

