<template>
    <div class="edit-popup">
        <popup
            ref="popupRef"
            title="详情"
            :async="true"
            width="550px"
            :cancelButtonText="false"
            :confirmButtonText="false"
        >
            <el-form ref="formRef" :model="formData" label-width="90px">
                <el-form-item label="门店" prop="store_name">
                    <el-input v-model="formData.store_name" readonly />
                </el-form-item>
                <el-form-item label="应收金额" prop="receivable">
                    <el-input v-model="formData.receivable" readonly />
                </el-form-item>
                <el-form-item label="备注" prop="remark">
                    <el-input v-model="formData.remark" readonly />
                </el-form-item>
                <el-form-item label="状态" prop="status">
                    <el-switch v-model="formData.status" active-text="已转账" inactive-text="未转账" :active-value="1" :inactive-value="0" size="large" inline-prompt></el-switch>
                </el-form-item>
                <el-form-item label="凭证" prop="file">
                    <material-picker v-model="formData.file" :limit="1" />
                </el-form-item>
            </el-form>
        </popup>
    </div>
</template>

<script lang="ts" setup name="storeCashFinanceFlowDETAILS">
import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiStoreCashFinanceFlowAdd, apiStoreCashFinanceFlowEdit, apiStoreCashFinanceFlowDetail } from '@/api/store_cash_finance_flow'
import { timeFormat } from '@/utils/util'
import type { PropType } from 'vue'
defineProps({
    dictData: {
        type: Object as PropType<Record<string, any[]>>,
        default: () => ({})
    }
})
const emit = defineEmits(['success', 'close'])
const formRef = shallowRef<FormInstance>()
const popupRef = shallowRef<InstanceType<typeof Popup>>()
const mode = ref('add')



// 表单数据
const formData = reactive({
    id: '',
    
})



// 获取详情
const setFormData = async (data: Record<any, any>) => {
    for (const key in formData) {
        if (data[key] != null && data[key] != undefined) {
            //@ts-ignore
            formData[key] = data[key]
        }
    }
    
    
}

const getDetail = async (row: Record<string, any>) => {
    const data = await apiStoreCashFinanceFlowDetail({
        id: row.id
    })
    setFormData(data)
}

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

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



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