<template>
    <div class="edit-popup">
        <el-drawer title="商品详情" :size="1000" v-model="isOpen">
            <div>
                <div>
                    <el-table :data="pager.lists">
                        <el-table-column label="订单id" prop="oid" show-overflow-tooltip />
                        <el-table-column label="商品图片" prop="image" min-width="80">
                            <template #default="{ row }">
                                <el-image
                                    style="width: 50px; height: 50px"
                                    :src="row.image"
                                    :preview-teleported="true"
                                />
                            </template>
                        </el-table-column>
                        <el-table-column label="商品名称" prop="store_name" show-overflow-tooltip />
                        <el-table-column label="数量" prop="cart_num" show-overflow-tooltip />
                        <el-table-column label="单价" prop="price" show-overflow-tooltip />
                        <el-table-column label="总价" prop="total_price" show-overflow-tooltip />
                        <el-table-column
                            label="购买时间"
                            prop="create_time"
                            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>
        </el-drawer>
    </div>
</template>

<script lang="ts" setup name="storeProductDETAILS">
import { usePaging } from '@/hooks/usePaging'
import { apiStoreOrderCartInfo } from '@/api/store_order'
import type { PropType } from 'vue'
defineProps({
    dictData: {
        type: Object as PropType<Record<string, any[]>>,
        default: () => ({})
    }
})
const emit = defineEmits(['success', 'close'])
const isOpen = ref(false)

const getDetail = async (row: Record<string, any>) => {
    queryParams.product_id = row.id

    getLists()
}

//打开弹窗
const open = () => {
    isOpen.value = true
}

// 查询条件
const queryParams = reactive({
    product_id: '',
    is_pay: 1
})
// 分页相关
const { pager, getLists, resetParams, resetPage } = usePaging({
    fetchFun: apiStoreOrderCartInfo,
    params: queryParams
})

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