<template>
    <el-drawer v-model="showDialog" title="资金走向" :size="1000">
        <el-table :data="pager.lists" @selection-change="handleSelectionChange" >
                    <el-table-column label="ID" prop="id" min-width="100" show-overflow-tooltip />
                    <el-table-column label="交易单号" prop="order_sn" min-width="120" show-overflow-tooltip />
                    <el-table-column label="交易时间" prop="create_time" min-width="120" show-overflow-tooltip />
                    <el-table-column label="金额" prop="number" min-width="100" show-overflow-tooltip>
                        <template #default="{ row }">
                            <span v-if="row.number > 0" class="text-success">{{ row.number }}</span>
                            <span v-else class="text-danger">{{ row.number }}</span>
                        </template>
                    </el-table-column>
                    <!-- <el-table-column label="门店名称" prop="store_name" show-overflow-tooltip /> -->
                    <!-- <el-table-column label="用户" prop="nickname" min-width="80" show-overflow-tooltip /> -->
                    <el-table-column label="收益/扣除" prop="financial_type_name" show-overflow-tooltip />
                    <!-- <el-table-column label="支付方式" prop="pay_type_name" show-overflow-tooltip /> -->
                    <el-table-column label="备注" prop="remark" show-overflow-tooltip />

                </el-table>
                <div class="flex mt-4 justify-end">
                <pagination v-model="pager" @change="getLists" />
            </div>
    </el-drawer>
</template>

<script lang="ts" setup name="storeOrderDETAILS">
import { ElMessage, type FormInstance } from 'element-plus'
import { timeFormat } from '@/utils/util'
import { usePaging } from '@/hooks/usePaging'
import { apiStoreFinanceFlowLists } from '@/api/store_finance_flow'
import moment from 'moment'
import type { PropType } from 'vue'
import feedback from '@/utils/feedback'
defineProps({
    dictData: {
        type: Object as PropType<Record<string, any[]>>,
        default: () => ({})
    }
})
const emit = defineEmits(['success', 'close'])
const showDialog = ref(false)
const mode = ref('add')

// 表单数据
const formData = ref({
    order_id: ''
})

// 获取详情
const setFormData = async (data: Record<any, any>) => {
    formData.value = { ...data };
    queryParams.order_id = data.order_id;
    getLists();
}

const getDetail = async (row: Record<string, any>) => {
    formData.value.order_id = row.order_id;
    // const data = await apiStoreOrderDetail({
    //     id: row.id
    // })
    // setFormData(data)
}

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

const open = ()=>{
    showDialog.value = true
}

const close = () => {
    showDialog.value = false
    emit('close')
}


defineExpose({
    open,
    setFormData,
    getDetail
})
</script>
