<template>
    <div>
        <el-card class="!border-none mb-4" shadow="never">
            <el-tabs v-model="activeName" class="demo-tabs" @tab-change="tabChange">
                <el-tab-pane label="概况" name="detail">
                    <el-descriptions class="margin-top" :column="4" border>
                        <el-descriptions-item :span="4" label="单据编号">
                            {{ form.order_id }}
                        </el-descriptions-item>
                        <el-descriptions-item :span="2" label="单据金额">
                            {{ form.total }}
                        </el-descriptions-item>
                        <el-descriptions-item :span="2" label="实际金额">
                            {{ form.actual }}
                        </el-descriptions-item>
                        <el-descriptions-item :span="2" label="实收金额">
                            {{ form.money }}
                        </el-descriptions-item>
                        <el-descriptions-item label="所属商户">
                            {{ form.system_store }}
                        </el-descriptions-item>
                    </el-descriptions>
                    <el-table :data="pager.lists" border style="width: 100%; margin-top: 20px">
                        <el-table-column prop="id" label="ID" width="120" />
                        <el-table-column prop="store_name" label="商品名称" />
                        <el-table-column prop="unit_name" label="单位" />
                        <el-table-column prop="store_info" label="规格" />
                        <el-table-column prop="need_num" label="数量" />
                        <el-table-column prop="price" label="单价(元)" />
                        <el-table-column prop="total_price" label="总价" />
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="商户订单" name="order" v-if="form.is_mer == 2">
                    <subOrder ref="subOrderRef" />
                </el-tab-pane>
                <el-tab-pane label="采购列表" name="offer">
                    <goodsOffer ref="goodsOfferRef" />
                </el-tab-pane>
                <!-- <el-tab-pane label="入库记录" name="putStorage">
                    <putStorage ref="putStorageRef" />
                </el-tab-pane> -->
                <!--  <el-tab-pane label="出库记录" name="outStorage">
            <outStorage ref="outStorageRef" />
          </el-tab-pane> -->
            </el-tabs>
        </el-card>
    </div>
</template>

<script lang="ts" setup name="purchaseOrderDetail">
import { usePaging } from '@/hooks/usePaging'
import { useDictData } from '@/hooks/useDictOptions'
import { apiPurchaseOrderDetail, apiPurchaseOrderInfoLists } from '@/api/purchase_order'
import { apiPurchaseProductOfferLists } from '@/api/purchase_product_offer'
import { useRoute } from 'vue-router'
import subOrder from './component/subOrder.vue'
import goodsOffer from './component/goodsOffer.vue'
//   import noPush from "./component/noPush.vue";
//   import putStorage from "./component/putStorage.vue";
//   import outStorage from "./component/outStorage.vue";

const route = useRoute()
const form = ref({})

const activeName = ref('detail')

const getDetail = async () => {
    const data = await apiPurchaseOrderDetail({
        id: route.query.id
    })
    form.value = data
}
getDetail()

const subOrderRef = ref(null)
const goodsOfferRef = ref(null)
const noPushRef = ref(null)
const putStorageRef = ref(null)
const outStorageRef = ref(null)
const tabChange = (type: any) => {
    if (type == 'order') subOrderRef.value?.getLists()
    if (type == 'offer') goodsOfferRef.value?.getLists()
    // if (type == 'notPushedGoods') noPushRef.value?.getLists()
    // if (type == 'putStorage') putStorageRef.value?.getLists()
    // if (type == 'outStorage') outStorageRef.value?.getLists()
}

// 查询条件
const queryParams = reactive({
    order_id: route.query.id
})

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