<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="id" 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="warehouse_name" show-overflow-tooltip />
                        <el-table-column
                            label="供应商"
                            prop="supplier_name"
                            show-overflow-tooltip
                        />
                        <el-table-column label="供货价" prop="purchase" show-overflow-tooltip />
                        <el-table-column label="数量" prop="nums" show-overflow-tooltip />
                        <el-table-column label="价值" prop="total_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>
        </el-drawer>
    </div>
</template>

<script lang="ts" setup name="storeProductDETAILS">
import { usePaging } from '@/hooks/usePaging'
import { total_warehouse_product_list } from '@/api/workbench'
import type { PropType } from 'vue'

const emit = defineEmits(['success', 'close'])
const isOpen = ref(false)
const stock_type = ref(1)
// 查询条件
const queryParams = reactive({
    product_id: '',
    type: 1
})
const getDetail = async (row: Record<string, any>, type: number) => {
    queryParams.product_id = row.id
    queryParams.type = type
    stock_type.value = type

    getLists()
}

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

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

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