<template>
    <div>
        <div>
            <el-table :data="pager.lists" v-loading="pager.loading" @selection-change="handleSelectionChange">
                <el-table-column label="商品信息" prop="store_name" show-overflow-tooltip width="400">
                    <template #default="{ row }">
                        <div class="flex items-center">
                            <el-image :src="row.image" class="w-16 h-16 mr-2" :preview-teleported="true"></el-image>
                            <div>{{ row.store_name }}</div>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column label="数量" prop="cart_info.cart_num" show-overflow-tooltip />
                <el-table-column label="合计" prop="cart_info.total" show-overflow-tooltip />
                <el-table-column label="实付金额" prop="cart_info.price" show-overflow-tooltip />
            </el-table>
        </div>
        <div class="flex mt-4 justify-end" v-if="pager.lists.length<pager.count">
            <pagination v-model="pager" @change="getLists" />
        </div>
    </div>
</template>

<script lang="ts" setup name="storeTable">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiStoreOrderCartInfo } from '@/api/store_order'
import { timeFormat } from '@/utils/util'
import feedback from '@/utils/feedback'

const props = defineProps({
    oid: {
        type: [String,Number],
        required: true
    }
})


const emit = defineEmits(['change'])

// 选中的数据
const selectionList = ref([])

// 选中数据时触发
const handleSelectionChange = (val: any) => {
    selectionList.value = val
    emit('change', selectionList.value)
}

// 查询条件
const queryParams = reactive({
    oid: '',
    pay_type: ''
})

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

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

defineExpose({
    getLists
})


</script>
