<template>
    <div class="table-box">
        <div>
            <div style="padding-bottom: 16px">
                <el-button type="primary" @click="handleBlack">返回</el-button>
            </div>
        </div>
        <div class="table-box card">
            <div style="display: flex">
                <el-table :data="dataStore.tableData" border style="width: 70%">
                    <el-table-column type="index" :index="indexMethod" label="序号" width="100" />
                    <el-table-column prop="position" label="仓位" />
                    <el-table-column prop="priority_item" label="匹配项" />
                </el-table>
            </div>
        </div>
    </div>
</template>

<script setup lang="ts" name="foundationSetGoodsPreview">
import { getGoodsPreviewApi } from "@/api/modules/setGoods";
const $router = useRouter();
const route = useRoute();
const dataStore = reactive<any>({
    tableData: []
});
const indexMethod = (index: number) => {
    return index + 1;
};
//预览
const getGoodsPreview = async () => {
    const result = await getGoodsPreviewApi(route.query.id);
    if (result?.code === 0) {
        dataStore.tableData = result?.data ? result?.data : [];
        console.log(result?.data);
    }
};
getGoodsPreview();
const handleBlack = () => {
    if (route.query.name === "新增仓位找货优先级") {
        $router.push({
            path: "/foundation/set/goods/add",
            query: { title: route.query.name }
        });
    } else {
        $router.push({
            path: "/foundation/set/goods/add",
            query: { id: route.query.id, title: route.query.name }
        });
    }
};
</script>

<style scoped></style>
