<template>
    <div>
        <!-- <el-card class="!border-none mb-4" shadow="never">
            <el-form class="mb-[-16px]" :model="queryParams" inline>
                <el-form-item label="银行名称" prop="name">
                    <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>
                <el-table :data="pager.lists" @selection-change="handleSelectionChange">
                    <!-- <el-table-column type="selection" width="55" /> -->
                    <el-table-column label="ID" prop="id" width="120" show-overflow-tooltip />
                    <el-table-column label="订单号" prop="number_sn" show-overflow-tooltip />
                    <el-table-column label="用户类型" prop="type" width="120" show-overflow-tooltip />
                    <el-table-column label="用户" prop="user_nickname" show-overflow-tooltip>
                        <template #default="{ row }">
                            <span>{{ row.type=='用户' ? row.user_nickname : row.mer_name }}</span>
                        </template>
                        </el-table-column>
                    <el-table-column label="收支" prop="financial_pm" width="80" show-overflow-tooltip />
                    <el-table-column label="金额" prop="number" show-overflow-tooltip />
                    <el-table-column label="支付单号" prop="financial_record_sn" show-overflow-tooltip />
                    <el-table-column label="创建时间" prop="create_time" 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="bankLists">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiFinancialRecordLists, apiBankDelete } from '@/api/bank'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'

// 是否显示编辑框
const showEdit = ref(false)


// 查询条件
const queryParams = reactive({
    name: ''
})

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

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

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

// 分页相关
const { pager, getLists, resetParams, resetPage } = usePaging({
    fetchFun: apiFinancialRecordLists,
    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 apiBankDelete({ id })
    getLists()
}

getLists()
</script>

