<!-- components/FormPage.vue -->
<template>
  <div class="form-page">
    <el-form ref="formRef" :model="localData" label-width="120px" size="default">
      <!-- Tabs -->
      <el-tabs v-model="activeTab" @tab-click="handleTabClick" :before-leave="handleBeforeLeave">
        <el-tab-pane label="基础信息"       name="basic"></el-tab-pane>
        <el-tab-pane label="产品计划"       name="productPlan"></el-tab-pane>
        <el-tab-pane label="投保人"         name="policyholder"></el-tab-pane>
        <el-tab-pane label="受保人"         name="insured"></el-tab-pane>
        <el-tab-pane label="受益人"         name="beneficiary"></el-tab-pane>
        <el-tab-pane label="第二持有人"     name="secondHolder"></el-tab-pane>
        <el-tab-pane label="预约附件"       name="appointmentAttachment"></el-tab-pane>
        <el-tab-pane label="介绍人"         name="introducer"></el-tab-pane>
        <el-tab-pane label="邮寄信息"       name="postal"></el-tab-pane>
        <el-tab-pane label="关联记录"       name="relatedRecords"></el-tab-pane>
        <el-tab-pane label="新单附件"       name="policyAttachment"></el-tab-pane>
      </el-tabs>

      <!-- 基础信息 Tab 内容 -->
      <div v-if="activeTab === 'basic'" class="tab-content">
        <!-- 签单信息 -->
        <div class="section">
          <h3 class="sectionTitle">基础信息</h3>
          <SearchForm
            ref="basicInfoFormRef"
            :config="basicInfoFormConfig"
            v-model="basicInfoFormData"
          />
        </div>
        <!-- 保单信息 -->
        <div class="section">
          <h3 class="sectionTitle">保单信息</h3>
          <SearchForm
            ref="policyInfoFormRef"
            :config="policyInfoFormConfig"
            v-model="policyInfoFormData"
          />
        </div>
      </div>
      <!-- 产品计划 Tab 内容 -->
      <div v-else-if="activeTab === 'productPlan'" class="tab-content"> 
          <ProductPlan
            ref="productPlanRef"
            :api-product-plan-info-dto="policyProductData"
            :edit-status="!isEditing"
            active-name="productPlan"
            :ids-obj="{ appointmentBizId: null }"
            page-source="policyList"
            :father-tab-name="activeTab"
            anchor-container=".el-tabs__content"
            :affix-offset="60"
            :tab-index="1"
          />
      </div>
      <!-- 投保人 Tab 内容 -->
      <div v-else-if="activeTab === 'policyholder'" class="tab-content"> </div>
      <!-- 受保人 Tab 内容 -->
      <div v-else-if="activeTab === 'insured'" class="tab-content"> </div>
      <!-- 受益人 Tab 内容 -->
      <div v-else-if="activeTab === 'beneficiary'" class="tab-content"> </div>
        <!-- 第二持有人 Tab 内容 -->
      <div v-else-if="activeTab === 'secondHolder'" class="tab-content"> </div>
        <!-- 预约附件 Tab 内容 -->
      <div v-else-if="activeTab === 'appointmentAttachment'" class="tab-content"> </div>
      <!-- 介绍人 Tab 内容 -->
      <div v-else-if="activeTab === 'introducer'" class="tab-content">
        <!-- 签单信息 -->
        <div class="section">
          <h3 class="sectionTitle">介绍人信息</h3>
          <h5>
            第一位默认是客户主要负责人，客户资料出现在介绍人（主）账号下，其他介绍人不会看到客户信息
          </h5>
          <EditableTable
            v-model="introducerTableData"
            :row-config="introducerConfig"
            @batch-save="handleBatchSave"
            :disabled="props.mode === 'viewDetail'"
          />
        </div>
      </div>
      <!-- 邮寄信息 Tab 内容 -->
      <div v-else-if="activeTab === 'postal'" class="tab-content">
        <div class="section">
          <h3 class="sectionTitle">邮寄信息</h3>
          <SearchForm ref="postalFormRef" :config="postalFormConfig" v-model="postalFormData" />
        </div>
      </div>
      <!-- 关联记录 Tab 内容 -->
      <div v-else-if="activeTab === 'relatedRecords'" class="tab-content">
        <div class="section">
          <h3 class="sectionTitle">关联记录</h3>
          <el-table :data="relatedTableData" border style="width: 100%">
            <el-table-column prop="fnaNo" label="流程编号" width="180" />
            <el-table-column prop="policyNo" label="保单号" width="180" />
            <el-table-column prop="customerName" label="客户姓名" width="180" />
            <el-table-column
              prop="createTime"
              label="创建时间"
              width="180"
              :formatter="row => formatToDate(row.createTime)"
            />
            <el-table-column fixed="right" label="操作" min-width="120">
              <template #default>
                <el-button link type="primary" size="small" @click="viewRecordDetail">
                  查看
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!-- 附件 Tab 内容 -->
      <div v-else-if="activeTab === 'policyAttachment'" class="tab-content">
        <div class="section">
          <h3 class="sectionTitle">附件</h3>
          <el-button
            type="primary"
            @click="fileUploadDialogFlag = true"
            :disabled="props.mode === 'viewDetail'"
          >
            <el-icon class="el-icon--right"> <Upload /> </el-icon>上传附件
          </el-button>
          <el-table :data="attachmentTableData" border style="width: 100%">
            <el-table-column
              v-for="(column, index) in attachmentTableColumns"
              :key="index"
              :prop="column.prop"
              :label="column.label"
              :width="column.width"
              :sortable="column.sortable"
              :formatter="column.formatter"
            />
            <el-table-column fixed="right" label="操作" min-width="120">
              <template #default>
                <el-button
                  link
                  type="primary"
                  size="small"
                  @click="handleClick"
                  :disabled="props.mode === 'viewDetail'"
                >
                  修改 </el-button
                ><el-button
                  link
                  type="danger"
                  size="small"
                  @click="handleClick"
                  :disabled="props.mode === 'viewDetail'"
                >
                  删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!-- 其他 Tab 占位（你可以按需填充） -->
      <div v-else class="tab-placeholder">
        <el-empty description="该 Tab 内容待开发" />
      </div>
      <!-- 底部按钮 -->
      <div class="form-footer">
        <el-button size="default" @click="handleCancel">取消</el-button>
        <el-button type="primary" size="default" @click="handleSubmit">确认</el-button>
      </div>
    </el-form>

    <CommonDialog
      dialogTitle="文件导入"
      dialogWidth="80%"
      :openDialog="fileUploadDialogFlag"
      :showAction="true"
      :showClose="true"
      @close="((fileUploadDialogFlag = false), (files = ''))"
      @confirm="((fileUploadDialogFlag = false), (files = ''))"
    >
      <FileUpload
        v-model="files"
        :data="{ obiectTableName: 'policy_follow', objectBizId: props.policyBizId }"
        :file-type="['xlsx', 'xls', 'doc', 'docx', 'pdf', 'txt', 'jpg', 'jpeg', 'png', 'gif']"
        :action="'/oss/api/oss/batch/upload'"
        :limit="10"
        :fileSize="15"
        :name="'files'"
        @uploadEnd="handleUploadEnd"
      />
    </CommonDialog>
  </div>
</template>

<script setup>
import { ref, reactive, watch, nextTick, onMounted, computed } from 'vue'
import SearchForm from '@/components/SearchForm/SearchForm.vue'
import CommonDialog from '@/components/commonDialog'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Delete, Edit, Search, Share, Upload } from '@element-plus/icons-vue'
import { getPolicyfollow, getProductList } from '@/api/sign/underwritingMain'
import { uploadOssFileList } from '@/api/common'
import { getProcessDetail } from '@/api/sign/fna'
import { premiumReconciliationList } from '@/api/sign/policy'
import { loadDicts, getDictLabel } from '@/utils/useDict'
import { getNowTime, formatToDate, formatToDateTime } from '@/utils/date'
import EditableTable from '@/components/csf-common/EditableTable.vue'
import useUserStore from '@/store/modules/user'
// 引用预约界面的产品计划
import ProductPlan from '@/views/sign/appointment/components/productPlan.vue'
const productPlanRef = ref(null)
const policyProductData = ref({}) // 从 API 获取的保单产品计划数据
const isEditing = ref(false) // 控制整个页面编辑状态

const { proxy } = getCurrentInstance()
proxy.useDictLists([
  'sys_no_yes',
  'csf_ap_frequency',
  'bx_currency_type',
  'csf_ap_first_issue',
  'csf_ap_dividend',
  'csf_fortune_status',
  'csf_ap_mailing_method',
  'receipt_status'
])
const router = useRouter()
const userStore = useUserStore()
const files = ref('')
const fileUploadDialogFlag = ref(false)
// 记录每个 tab 是否有未保存的修改（dirty 状态）
const tabDirty = ref({
  basic: false,
  productPlan: false,
  introducer: false,
  postal: false,
  related: false,
  attachment: false
})
// ===== Props & Emits =====
const props = defineProps({
  modelValue: {
    type: Object,
    default: () => ({})
  },
  mode: {
    type: String,
    default: 'viewDetail'
  },
  policyBizId: {
    type: String,
    default: ''
  }
})

const emit = defineEmits(['update:modelValue', 'submit', 'cancel', 'saveRow'])

const introducerTableData = ref([])
const introducerConfig = [
  {
    type: 'select',
    prop: 'brokerName',
    label: '转介人',
    api: '/insurance/base/api/userSaleExpand/page',
    keywordField: 'realName',
    requestParams: { pageNo: 1, pageSize: 20 },
    placeholder: '输入转介人名称搜索',
    debounceWait: 500, // 自定义防抖时间
    onChangeExtraFields: {
      internalCode: 'code',
      team: 'teamName',
      phone: 'phone',
      brokerBizId: 'clientUserBizId'
    },
    transform: res => {
      return (res?.data.records || []).map(item => ({
        value: item.realName,
        label: item.realName,
        ...item
      }))
    }
  },

  // {
  //     type: 'select',
  //     prop: 'gender',
  //     label: '性别',
  //     span: 4,
  //     options: [
  //         { value: 'male', label: '男' },
  //         { value: 'female', label: '女' }
  //     ]
  // },
  {
    type: 'input',
    prop: 'phone',
    label: '手机号码',
    span: 4,
    disabled: true
  },
  {
    type: 'input',
    prop: 'internalCode',
    label: '内部编号',
    span: 4,
    disabled: true
  },
  {
    type: 'input',
    prop: 'team',
    label: '所属团队',
    span: 4,
    disabled: true
  },
  {
    type: 'input',
    prop: 'brokerRatio',
    label: '分配比例%',
    span: 4,
    inputType: 'integer',
    rules: [
      { required: true, message: '请输入比例' },
      {
        validator: (rule, value, cb) => {
          const n = Number(value)
          if (isNaN(n) || n < 0 || n > 100) cb(new Error('0～100'))
          else cb()
        }
      }
    ]
  },
  {
    type: 'textarea',
    prop: 'remark',
    label: '备注',
    span: 4
  }
]

// 附加计划表格
const additionalPlansConfig = [
  {
    type: 'input',
    prop: 'product',
    label: '产品名称',
    span: 4
  },
  {
    type: 'input',
    prop: 'frequency',
    label: '付款频率',
    span: 4
  },
  {
    type: 'input',
    prop: 'term',
    label: '保障期限',
    span: 4
  },
  {
    type: 'input',
    prop: 'phone',
    label: '付款频率',
    span: 4
  },
  {
    type: 'input',
    prop: 'periods',
    label: '供款期数',
    span: 4
  },
  {
    type: 'input',
    prop: 'currency',
    label: '保单币种',
    span: 4
  },
  {
    type: 'input',
    prop: 'premium',
    label: '每期保费',
    span: 4
  },
  {
    type: 'input',
    prop: 'fee',
    label: '保单征费',
    span: 4
  }
]

function handleBatchSave(validRows) {
  console.log('批量提交:', validRows)
  // 调用 API
  introducerTableData.value = validRows
}

function applyViewMode(fields, mode) {
  if (mode === 'viewDetail') {
    return fields.map(item => ({
      ...item,
      disabled: true
    }))
  }
  // 非查看模式：保留原对象，可选择性移除 disabled
  return fields.map(item => {
    // 如果你希望编辑模式下完全不禁用，可以删除 disabled 属性
    const newItem = { ...item }
    delete newItem.disabled
    return newItem
  })
}

const newOrderData = ref({})
const basicInfoFormRef = ref()
const basicInfoFormData = ref({})
const basicInfoFormConfig = ref([
  {
    type: 'date',
    prop: 'signDate',
    label: '签单日'
  },
  {
    type: 'select',
    prop: 'signer',
    label: '签单员',
    api: '/insurance/base/api/userSignExpand/page',
    keywordField: 'realName',
    requestParams: { pageNo: 1, pageSize: 20 },
    placeholder: '输入签单员姓名搜索',
    debounceWait: 500, // 自定义防抖时间
    onChangeExtraFields: {
      signerBizId: 'userSignBizId',
      practiceCode: 'practiceCode'
    },
    valueKey: 'realName',
    labelKey: 'realName',
    transform: res => {
      return res?.data.records || []
    },
    rules: [{ required: true, message: '请选择签单员', trigger: 'blur' }]
  },
  {
    type: 'input',
    prop: 'practiceCode',
    label: '签单员执业编号'
  },
  {
    type: 'select',
    prop: 'signLocation',
    label: '签单地点',
    dictType: 'csf_ap_meeting_point'
  }
])

// 保单信息
const policyInfoFormRef = ref()
const policyInfoFormData = ref({})
const policyInfoFormConfig = ref([
  {
    type: 'input',
    prop: 'policyNo',
    label: '保单号'
  },  {
    type: 'input',
    prop: 'coolingOffDays',
    label: '冷静期（天）',
    inputType: 'decimal',
    rules: [
      { pattern: /^\d+$/, message: '只能输入正整数', trigger: 'blur' },
      { required: true, message: '请填写冷静期', trigger: 'blur' }
    ]
  },
   {
    type: 'date',
    prop: 'coolingOffEndDate',
    label: '冷静期到期日',
     rules: [
      { required: true, message: '请填写冷静期到期日', trigger: 'blur' }
    ]
  },
  {
    type: 'date',
    prop: 'effectiveDate',
    label: '保单生效日'
  },
  {
    type: 'date',
    prop: 'policyExpirationDate',
    label: '保单截止日'
  },
  {
    type: 'date',
    prop: 'underwritingDate',
    label: '保单核保日'
  },
  {
    type: 'date',
    prop: 'receiptDate',
    label: '保单回执日'
  },
  {
    type: 'select',
    prop: 'receiptStatus',
    label: '回执状态',
    dictType: 'receipt_status'
  },
  {
    type: 'select',
    prop: 'directPaymentEnabled',
    label: '是否开通直接支付',
    dictType: 'sys_no_yes'
  },
  {
    type: 'input',
    prop: 'policyHolder',
    label: '保单持有人'
  },
  {
    type: 'input',
    prop: 'insured',
    label: '保单受保人'
  },
  {
    type: 'input',
    prop: 'insuredAge',
    label: '受保人年龄'
  },
  {
    type: 'input',
    prop: 'gracePeriod',
    label: '宽限期（天）',
    inputType: 'decimal',
    rules: [{ pattern: /^\d+$/, message: '只能输入正整数', trigger: 'blur' }]
  },
 {
    type: 'date',
    prop: 'latestPaymentDate',
    label: '最晚缴费日'
  },
  {
    type: 'select',
    prop: 'isJoin',
    label: '是否参加递增保障权益',
    dictType: 'sys_no_yes'
  },{
    type: 'select',
    prop: 'policyType',
    label: '保单类型',
    options:[
      {label:'纸质保单',value:2},
      {label:'电子保单',value:1},
    ]
  },
])


// 邮寄信息
const postalFormRef = ref(null)
const postalFormData = ref({})
const postalFormConfig = ref([
  {
    type: 'select',
    prop: 'mailingMethod',
    label: '寄送方式',
    dictType: 'csf_mailing_method'
  },
  {
    type: 'input',
    prop: 'deliveryNo',
    label: '快递单号',
    visible: formData => formData.mailingMethod == '2'
  },{
    type: 'input',
    prop: 'mailingItem',
    label: '邮寄物品',
    visible: formData => formData.mailingMethod == '2'
  },
  {
    type: 'date',
    prop: 'brokerSignDate',
    label: '我司签收日',
    rules: [{ required: true, message: '请输入我司签收日', trigger: 'blur' }]
  },
  {
    type: 'date',
    prop: 'customerSignDate',
    label: '客户签收日',
    rules: [{ required: true, message: '请输入客户签收日', trigger: 'blur' }]
  }
])

// 关联记录
const relatedTableData = ref([])
const attachmentTableData = ref([])
const attachmentTableColumns = ref([
  {
    prop: 'originalName',
    label: '文件名',
    sortable: true,
    width: '150',
    formatter: row => row.originalName || '-'
  },
  {
    prop: 'fileType',
    label: '文件类型',
    sortable: true,
    width: '150',
    formatter: row => row.fileType || '-'
  },
  {
    prop: 'createTime',
    label: '上传时间',
    sortable: true,
    width: '150',
    formatter: row => row.createTime || '-'
  },
  {
    prop: 'creatorName',
    label: '上传人',
    sortable: true,
    width: '150',
    formatter: row => row.creatorName || '-'
  }
])

// ===== 本地响应式数据 =====
const defaultFormData = () => ({})

// ✅ 使用 ref 而不是 reactive
const localData = ref(defaultFormData())

// ✅ 只在挂载时初始化一次（避免 watch 形成闭环）
onMounted(async () => {
  if (props.modelValue) {
    console.log('🚀 父组件 props.modelValue 挂载时:', props.modelValue)
    // 深拷贝 + 合并默认值，防止缺失字段
    localData.value = { ...defaultFormData(), ...props.modelValue }
  }
  try {
    getPolicyfollowDetail()
  } catch (error) {
    console.error('字典加载失败', error)
  } finally {
  }
  // 应用查看模式到基本信息表格
  basicInfoFormConfig.value = basicInfoFormConfig
    ? applyViewMode(basicInfoFormConfig.value, props.mode)
    : []
  policyInfoFormConfig.value = policyInfoFormConfig
    ? applyViewMode(policyInfoFormConfig.value, props.mode)
    : []
})
// 监听基本信息（basic）
watch(
  [basicInfoFormData, policyInfoFormData],
  () => {
    tabDirty.value.basic = true
  },
  { deep: true }
)
// 监听邮寄信息
watch(
  postalFormData,
  () => {
    tabDirty.value.postal = true
  },
  { deep: true }
)

// ✅ 监听 localData 变化，emit 出去（用于 v-model）
watch(
  () => localData.value,
  newVal => {
    console.log('========父组件监测的localData:', newVal)
    emit('update:modelValue', newVal)
  },
  { deep: true }
)
// ===== 表单引用 & 验证规则 =====
const formRef = ref()
const activeTab = ref('basic')
// ========================
// ✅ 新增：切换前确认
// ========================
const handleBeforeLeave = async (newTabName, oldTabName) => {
  console.log('切换前确认-----------------------', newTabName, oldTabName)
  if (tabDirty.value[oldTabName]) {
    try {
      await ElMessageBox.confirm(`“${getTabLabel(oldTabName)}” 未提交，确定要切换吗？`, '提示', {
        confirmButtonText: '继续切换',
        cancelButtonText: '取消',
        type: 'warning'
      })
      return true // 允许切换
    } catch {
      return false // 阻止切换
    }
  }
  return true // 无未保存内容，允许切换
}
const getTabLabel = name => {
  const labels = {
    basic: '基础信息',
    productPlan: '产品计划',
    policyholder: '投保人',
    insured: '受保人',
    beneficiary: '受益人',
    secondHolder: '第二持有人',
    appointmentAttachment: '预约附件',
    introducer: '介绍人',
    postal: '邮寄信息',
    relatedRecords: '关联记录',
    policyAttachment: '新单附件'
  }
  return labels[name] || name
}
const handleTabClick = tab => {
 if (tab.props.name === 'postal') {
    postalFormConfig.value = postalFormConfig
      ? applyViewMode(postalFormConfig.value, props.mode)
      : []
  } else if (tab.props.name === 'relatedRecords') {
    getRelationRecord(newOrderData.value.fnaBizId)
  } else if (tab.props.name === 'policyAttachment') {
    getAttachmentListDetail(newOrderData.value.policyBizId)
  } else if (tab.props.name === 'introducer') {
    // introducerConfig.value = introducerConfig ? applyViewMode(introducerConfig.value, props.mode) : []
  } else if (tab.props.name === 'basic') {
    basicInfoFormConfig.value = basicInfoFormConfig
      ? applyViewMode(basicInfoFormConfig.value, props.mode)
      : []
  }
}

const handleSubmit = () => {
    formRef.value?.validate((valid) => {
        if (valid) {
            console.log('提交数据', introducerTableData.value)
            if (activeTab.value === 'postal') {
                emit('submit', { ...postalFormData.value, activeTab: activeTab.value })
                tabDirty.value.postal = false
            } else if (activeTab.value === 'policyAttachment') {
                emit('submit', { activeTab: activeTab.value })
                tabDirty.value.attachment = false
            } else if (activeTab.value === 'introducer') {
                emit('submit', { ...introducerTableData.value, activeTab: activeTab.value })
                tabDirty.value.introducer = false
            } else if (activeTab.value === 'basic') {
                emit('submit', { ...basicInfoFormData.value, activeTab: activeTab.value, ...policyInfoFormData.value })
                tabDirty.value.basic = false
            } else if (activeTab.value === 'productPlan') {
                emit('submit', { ...basicInfoFormData.value, activeTab: activeTab.value, ...policyInfoFormData.value })
                tabDirty.value.basic = false
            } 

        }
    })
}

const handleCancel = () => {
  emit('cancel')
}

const handleClick = tab => {
  activeTab.value = tab.name
}

// 如果外部 modelValue 更新（比如重新加载数据），同步到 localData
watch(
  () => props.modelValue,
  newVal => {
    if (newVal) {
      Object.assign(localData, defaultFormData(), newVal)
    }
  },
  { deep: true }
)

// 查询新单跟进详情
const getPolicyfollowDetail = () => {
  if (!props.policyBizId) {
    return
  }
  getPolicyfollow(props.policyBizId).then(res => {
    if (res.code === 200) {
      newOrderData.value = res.data
      policyInfoFormData.value = { ...transformToFormData(res.data, policyInfoFormConfig.value) }
      basicInfoFormData.value = { ...transformToFormData(res.data, basicInfoFormConfig.value) }
      introducerTableData.value = res.data.brokerList || []
    }
  })
}
// 查询产品计划详情
const loadPolicyDetail = async () => {
  policyProductData.value = {
    policyBizId: 'POL_123',
    productPlan: {
      apiProductPlanMainInfoDto: {  },
      apiProductPlanAdditionalInfoDtoList: [  ]
    },
  }
  // const res = await getPolicyFollowDetail(policyBizId)
  // policyProductData.value = res.data.productPlan || {}
}

// 查询附件列表
const getAttachmentListDetail = policyBizId => {
  if (!policyBizId) {
    return
  }
  const params = {
    objectBizId: policyBizId,
    pageNo: 1,
    pageSize: 100
  }
  uploadOssFileList(params).then(res => {
    if (res.code === 200) {
      attachmentTableData.value = res.data || []
      console.log('attachmentTableData', res.data)
    }
  })
}

// 附件上传方法
const handleUploadEnd = code => {
  if (code === 200) {
    ElMessage.success('上传文件成功')
    fileUploadDialogFlag.value = false
    files.value = ''
    getAttachmentListDetail(props.policyBizId)
  } else {
    ElMessage.error('上传文件失败')
  }
}

// 组装表单数据
const transformToFormData = (apiData, formConfig) => {
  const formData = {}

  formConfig.forEach(item => {
    const { prop, dictType } = item

    let value = null

    // 特殊映射（按需添加）
    switch (prop) {
      case 'signLocation':
        value = apiData.signLocation
        break
      default:
        value = apiData[prop]
    }

    // 处理字典字段：如果配置了 dictType，且值是 number，转为 string
    if (dictType && typeof value === 'number') {
      value = String(value)
    }

    formData[prop] = value ?? null
  })

  return formData
}

// 获取关联流程记录
const getRelationRecord = fnaBizId => {
  getProcessDetail(fnaBizId).then(res => {
    if (res.code === 200) {
      relatedTableData.value = [res.data] || []
      console.log('relationRecordData', res.data)
    }
  })
}

const viewRecordDetail = e => {
  router.push({
    path: '/sign/FnaList/edit',
    query: {
      fnaBizId: newOrderData.value.fnaBizId,
      type: 'edit',
      status: newOrderData.value.status,
      source: 'newOrder',
      appointmentBizId: newOrderData.value.appointmentBizId
    }
  })
}
const handleSelectChange = async (prop, value, item, type) => {
  await nextTick()
  // console.log('======子组件选择选项后，父组件接收的值 :', basicPlanFormData.value)

}

// 获取产品列表
const getProductLists = params => {
  getProductList(params).then(res => {
    if (res.code === 200) {
      console.log('productList', res.data.records || [])
      // productList.value = res.data.records || []
    }
  })
}

defineExpose({
  getPolicyfollowDetail
})
</script>

<style scoped>
.form-page {
  padding: 10px;
  background: #fff;
  border-radius: 4px;
  padding-top: 0;
}

.tab-placeholder {
  padding: 40px 0;
}

.form-footer {
  text-align: center;
  margin-top: 30px;
}

.sectionTitle {
  margin: 0 0 15px 0;
  font-size: 16px;
  line-height: 1;
  position: relative;
  padding-left: 16px;
}

.sectionTitle::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 20px;
  background-color: #007bff;
  border-radius: 5px;
}

.section h5 {
  margin: 0;
  font-size: 14px;
  line-height: 1;
  position: relative;
  background-color: rgba(0, 119, 238, 0.05);
  color: #383838;
  padding: 15px 10px;
  border-radius: 4px;
}
</style>
