<template>
    <div class="edit-popup">
        <popup ref="popupRef" :async="true" width="60vw" @close="handleClose" :bottom-btn="false">
            <el-descriptions class="margin-top" :title="popupTitle" :column="3" border>
                <el-descriptions-item label="所属商户">
                    <!-- <material-picker v-model="formData.merchant_info" disabled /> -->
                    {{ formData.merchant_info?.mer_name }}
                </el-descriptions-item>
                <el-descriptions-item label="收货人">
                    {{ formData.real_name }}
                </el-descriptions-item>
                <el-descriptions-item label="单据时间">
                    {{ formData.create_time }}
                </el-descriptions-item>
                <el-descriptions-item label="单据编号">
                    {{ formData.number }}
                </el-descriptions-item>
                <el-descriptions-item label="单据金额">
                    {{ formData.total }}
                </el-descriptions-item>
                <el-descriptions-item label="抵扣金额">
                    {{ formData.deduction_price }}
                </el-descriptions-item>
                <el-descriptions-item label="实际金额">
                    {{ formData.actual }}
                </el-descriptions-item>
                <el-descriptions-item label="实收金额">
                    {{ formData.money }}
                </el-descriptions-item>
                <el-descriptions-item label="支付方式">
                    <dict-value :options="dictData.pay_type" :value="formData.pay_type" />
                </el-descriptions-item>
                <el-descriptions-item label="审核状态">
                    <dict-value :options="dictData.auditing_type" :value="formData.type" />
                </el-descriptions-item>
                <el-descriptions-item label="审核人">
                    {{ formData.auditinguser_name }}
                </el-descriptions-item>
                <el-descriptions-item label="审核时间">
                    {{ formData.auditingtime }}
                </el-descriptions-item>
            </el-descriptions>

            <div class="mt-4">
                <el-table :data="pager.lists">
                    <!-- <el-table-column type="selection" width="55" /> -->
                    <el-table-column label="ID" prop="id" show-overflow-tooltip />
                    <el-table-column label="所属ID" prop="pid" show-overflow-tooltip />
                    <el-table-column label="仓储" prop="room" show-overflow-tooltip />
                    <el-table-column label="商品" prop="goods_name" show-overflow-tooltip />
                    <el-table-column label="仓库" prop="warehouse" show-overflow-tooltip />
                    <el-table-column label="串号" prop="cashier_number" show-overflow-tooltip />
                    <el-table-column label="数量" prop="nums" show-overflow-tooltip />
                    <el-table-column label="单价" prop="price" show-overflow-tooltip />
                    <el-table-column label="折扣" prop="discount" show-overflow-tooltip />
                    <el-table-column label="总价" prop="total" show-overflow-tooltip />
                    <el-table-column label="备注" prop="data" show-overflow-tooltip />
                    <el-table-column label="扩展信息" prop="more" show-overflow-tooltip />
                </el-table>
            </div>
            <div class="flex mt-4 justify-end">
                <pagination v-model="pager" @change="getLists" />
            </div>

        </popup>
    </div>
</template>

<script lang="ts" setup name="brandEdit">
import Popup from '@/components/popup/index.vue'
import type { PropType } from 'vue'
import { usePaging } from '@/hooks/usePaging'
import { apiCashierinfoLists } from '@/api/cashierinfo'
import { apiCashierclassDetail } from '@/api/cashierclass'
defineProps({
    dictData: {
        type: Object as PropType<Record<string, any[]>>,
        default: () => ({})
    }
})
const emit = defineEmits(['success', 'close'])
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')
const queryParams = reactive({
    pid: ''
})

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

// 弹窗标题
const popupTitle = computed(() => {
    return '订单详情'
})

// 表单数据
const formData = ref({})

// 表单验证
const formRules = reactive<any>({
    name: [{
        required: true,
        message: '请输入品牌名称',
        trigger: ['blur']
    }]
})


// 获取详情
const setFormData = async (data: Record<any, any>) => {
    formData.value = data

}

const getDetail = (data:any)=>{
    apiCashierclassDetail({
        id: data.id
    }).then(res=>{
        setFormData(res);
    })
    queryParams.pid = data.id
    getLists()
}



//打开弹窗
const open = (type = 'add') => {
    mode.value = type
    popupRef.value?.open()
}

// 关闭回调
const handleClose = () => {
    emit('close')
}



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