
<template>
    <div class="detail-popup">
        <popup ref="popupRef" title="合同洽商详情" :async="true" width="80%" @confirm="handleSubmit" @close="handleClose">
            <el-form ref="formRef" :model="formData" label-width="120px">
                <el-descriptions :column="2" border>


                    <el-descriptions-item label="合同名称" label-align="left" align="left" label-class-name="my-label"> {{ formData.contract_name
                    }}</el-descriptions-item>
                    <el-descriptions-item label="合同编号" label-align="left" align="left" label-class-name="my-label"> {{ formData.contract_code
                    }}</el-descriptions-item>
                    <el-descriptions-item label="项目名称" label-align="left" align="left" label-class-name="my-label"> {{ formData.project_name

                    }}</el-descriptions-item>
                    <el-descriptions-item label="客户名称" label-align="left" align="left" label-class-name="my-label"> {{ formData.custom_name

                    }}</el-descriptions-item>

                    <el-descriptions-item label="合同类型" label-align="left" align="left" label-class-name="my-label"> {{ formData.contract_type

                    }}</el-descriptions-item>
                    <el-descriptions-item label="合同计价方式" label-align="left" align="left" label-class-name="my-label"> {{ formData.contract_pricing_method

                    }}</el-descriptions-item>

                    <el-descriptions-item label="签约日期" label-align="left" align="left" label-class-name="my-label"> {{ formData.contract_date

                    }}</el-descriptions-item>
                    <el-descriptions-item label="业务负责人" label-align="left" align="left" label-class-name="my-label"> {{ formData.business_director

                    }}</el-descriptions-item>
                    <el-descriptions-item label="洽商单名称" label-align="left" align="left" label-class-name="my-label"> {{ formData.negotiation_name

                    }}</el-descriptions-item>
                    <el-descriptions-item label="洽商编号" label-align="left" align="left" label-class-name="my-label"> {{ formData.negotiation_no

                    }}</el-descriptions-item>

                    <el-descriptions-item label="洽商类别" label-align="left" align="left" label-class-name="my-label"> {{ formData.negotiation_type_text

                    }}</el-descriptions-item>
                    <el-descriptions-item label="成本金额（人工）" label-align="left" align="left" label-class-name="my-label"> {{ formData.labor_costs

                    }}</el-descriptions-item>
                    <el-descriptions-item label="成本金额（材料）" label-align="left" align="left" label-class-name="my-label"> {{ formData.material_costs

                    }}</el-descriptions-item>
                    <el-descriptions-item label="洽商质保金额" label-align="left" align="left" label-class-name="my-label"> {{ formData.warranty_amount

                    }}</el-descriptions-item>

                    <el-descriptions-item label="洽商质保到期时间" label-align="left" align="left" label-class-name="my-label"> {{ formData.warranty_expire_date

                    }}</el-descriptions-item>

                    <el-descriptions-item label="利润" label-align="left" align="left" label-class-name="my-label"> {{ formData.profit

                    }}</el-descriptions-item>
                    <el-descriptions-item label="利润率(%)" label-align="left" align="left" label-class-name="my-label"> {{ formData.profit_rate

                    }}</el-descriptions-item>

                    <el-descriptions-item label="洽商内容" label-align="left" align="left" label-class-name="my-label"> {{ formData.negotiation_content

                    }}</el-descriptions-item>
                    <el-descriptions-item label="具体说明" label-align="left" align="left" label-class-name="my-label"> {{ formData.negotiation_detail

                    }}</el-descriptions-item>


                    <el-descriptions-item label="签证报价表" label-align="left" align="left" label-class-name="my-label">
                        <div v-if="formData.negotiation_quotation.length > 0">
                            <div v-for="(item, index) in formData.negotiation_quotation" style="margin-left: 5px;display: block;">
                                <el-link style="margin-left: 10px; color: #4a5dff; align-self: flex-start" :href="item" target="_blank">文件{{ index + 1 }}查看</el-link>

                            </div>
                        </div>
                        <div v-else>
                            暂无附件
                        </div>
                    </el-descriptions-item>
                    <el-descriptions-item label="洽商依据" label-align="left" align="left" label-class-name="my-label">
                        <div v-if="formData.negotiation_basis.length > 0">
                            <div v-for="(item, index) in formData.negotiation_basis" style="margin-left: 5px;display: block;">
                                <el-link style="margin-left: 10px; color: #4a5dff; align-self: flex-start" :href="item" target="_blank">文件{{ index + 1 }}查看</el-link>

                            </div>
                        </div>
                        <div v-else>
                            暂无附件
                        </div>
                    </el-descriptions-item>
                </el-descriptions>
            </el-form>
        </popup>
    </div>
</template>

<script lang="ts" setup name="customdetail">

import type { FormInstance } from 'element-plus'
import Popup from '@/components/popup/index.vue'
import { apiCustomDetail } from '@/api/custom'
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 datas = reactive({
    provinceOptions: [],
    cityOptions: [],
    areaOptions: [],
});


// 表单数据
const formData = reactive({

})



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



}

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


// 提交按钮
const handleSubmit = async () => {
    popupRef.value?.close()

}

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

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








defineExpose({
    open,
    setFormData,
    getDetail
})
</script>
<style lang="scss" scoped>
.tit {
    font-size: 1.2em;
    margin-bottom: 10px;
}

:deep(.my-label) {
    width: 150px;
}
</style>
