<script lang="ts" setup name="ListSourceAdd">
/**
 * 添加/编辑/详情客户
 */
import type { Ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import type { FormInstance, UploadUserFile } from 'element-plus'
import type { CustomerPerson, ICustomer, SimpleCertification, SimpleContract, SimpleMeasureRecord, SimpleSample } from './customer_interface'
import TemplateTable from './templateTable.vue'
import showPhoto from '@/views/system/tool/showPhoto.vue'
import { UploadFile } from '@/api/measure/file'
import { addCustomer, getCustomerDetail, updateCustomer } from '@/api/customer/customer'
import { validatePhone } from '@/utils/validate'
import { SCHEDULE } from '@/utils/scheduleDict'
import type { IAddress } from '@/components/AddressSelect/address-interface'
import { getDictByCode } from '@/api/system/dict'
import type { TableColumn } from '@/components/NormalTable/table_interface'
const loading = ref(false) // 表单加载状态
const infoId = ref('') // id
const pageType = ref('add') // 页面类型: add, edit, detail
const buttonLoading = ref(false) // 按钮加载状态
const textMap: { [key: string]: string } = {
  edit: '编辑',
  add: '新建',
  detail: '详情',
}// 字典
interface dictType {
  id: string
  name: string
  value: string
}
// 从路由中获取页面类型参数
const $route = useRoute()
if ($route.params && $route.params.type) {
  pageType.value = $route.params.type as string
  if ($route.params.id) {
    infoId.value = $route.params.id as string
  }
}
const dataForm: Ref<ICustomer> = ref({
  id: '',
  businessContent: '',
  customerName: '',
  customerNo: '',
  bankAccount: '',
  bankAccountNumber: '',
  bankName: '',
  briefName: '',
  businessScope: '',
  grade: '', // 履约评级
  companySize: '', // 公司规模
  businessSize: '', // 业务规模
  evaluation: '', // 整体评价
  companyAddress: '',
  companyArea: '',
  companyCity: '',
  companyCountry: '',
  companyProvince: '',
  companyAreaName: '',
  companyCityName: '',
  companyCountryName: '',
  companyProvinceName: '',
  director: '',
  fax: '',
  invoiceAddress: '',
  invoiceArea: '',
  invoiceCity: '',
  invoiceCountry: '',
  invoiceProvince: '',
  invoiceAreaName: '',
  invoiceCityName: '',
  invoiceCountryName: '',
  invoiceProvinceName: '',
  mailbox: '',
  minioFileName: '',
  mobile: '',
  phone: '',
  postalCode: '',
  remark: '',
  taxNumber: '',
  website: '',
  customerPersonList: [],
})
const companyAddress = ref<string[]>([]) // 公司地址
const invoiceAddress = ref<string[]>([]) // 开票地址
const CustomerPersonList: Ref<CustomerPerson[]> = ref([]) // 人员列表
const columns = ref([
  { text: '姓名', value: 'name', required: true },
  { text: '工作部门', value: 'department', required: false },
  { text: '职务', value: 'job', required: false },
  { text: '联系方式', value: 'phone', required: true, reg: validatePhone },
])

// 其他关联数据列表
const dataList = ref({
  personList: [] as CustomerPerson[],
  sampleRecords: [] as SimpleSample[],
  contractRecords: [] as SimpleContract[],
  measureRecords: [] as SimpleMeasureRecord[],
  certificationRecords: [] as SimpleCertification[],
})
// 获取人员列表
const fetchPerson = function (query = null) {
  dataList.value.personList = dataForm.value.customerPersonList
  dataList.value.personList = [{ name: '张三', department: '', job: '总经理', phone: '68387447' }, { name: '李四', department: '营销', job: '销售', phone: '68387447' }]
}
// 获取样品列表
const fetchSampleList = function (query = null) {
  dataList.value.sampleRecords = [{ sampleCode: 'abc123', sampleName: '血压计', sampleModel: 'xxxx', manufacturingNo: '111', mesureTime: '2022-12-25 00:00:00', mesurePeriod: '6个月' }]
}
// 获取合同记录
const fetchContractRecords = function (query = null) {
  dataList.value.contractRecords = []
}
// 获取检定记录
const fetchMeasureRecords = function (query = null) {
  dataList.value.measureRecords = []
}
// 获取检定证书
const fetchCertifications = function (query = null) {
  dataList.value.certificationRecords = []
}
interface Menu {
  name: string
  columns: TableColumn[]
  pagination: boolean
  list: 'personList' | 'sampleRecords' | 'contractRecords' | 'measureRecords' | 'certificationRecords'
  searchFunc: Function
}
// 菜单
const menu: Menu[] = [
  {
    name: '客户人员',
    columns: [
      { text: '姓名', value: 'name' },
      { text: '工作部门', value: 'department' },
      { text: '职务', value: 'job' },
      { text: '联系方式', value: 'phone' },
    ],
    pagination: false,
    list: 'personList',
    searchFunc: fetchPerson,
  },
  {
    name: '样品记录',
    columns: [
      { text: '样品编号', value: 'sampleCode' },
      { text: '样品名称', value: 'sampleName' },
      { text: '型号', value: 'sampleModel' },
      { text: '出厂编号', value: 'manufacturingNo' },
      { text: '上次检定时间', value: 'mesureTime' },
      { text: '检定周期', value: 'mesurePeriod' },
    ],
    pagination: true,
    list: 'sampleRecords',
    searchFunc: fetchSampleList,
  },
  {
    name: '合同记录',
    columns: [
      { text: '合同编号', value: 'contractCode' },
      { text: '合同名称', value: 'contractName' },
      { text: '合同金额', value: 'contractPrice' },
      { text: '合同状态', value: 'contractStatus' },
      { text: '合同时间', value: 'contractTime' },
      { text: '负责人', value: 'aCompanyDutyman' },
    ],
    list: 'contractRecords',
    pagination: true,
    searchFunc: fetchContractRecords,
  },
  {
    name: '检定记录',
    columns: [
      { text: '委托单编号', value: 'orderCode' },
      { text: '委托单日期', value: 'orderTime' },
      { text: '委托方代码', value: 'customerCode' },
      { text: '委托方名称', value: 'customerName' },
      { text: '送检人', value: 'deliverer' },
      { text: '送检日期', value: 'deliverTime' },
    ],
    list: 'measureRecords',
    pagination: true,
    searchFunc: fetchMeasureRecords,
  },
  {
    name: '检定证书',
    columns: [
      { text: '证书编号', value: 'certificationCode' },
      { text: '证书名称', value: 'certificationName' },
      { text: '证书类型', value: 'certificationType' },
      { text: '证书出具日期', value: 'effectiveDate' },
      { text: '证书有效期', value: 'expirationDate' },
    ],
    list: 'certificationRecords',
    pagination: true,
    searchFunc: fetchCertifications,
  },
]
const currentMenu = ref('客户人员')
const currentMenuObj = computed(() => {
  return menu.find(item => item.name === currentMenu.value)
})
const ruleFormRef = ref<FormInstance>()
// 人员对象
const addPersonObj: CustomerPerson = {
  id: '',
  personNo: '',
  name: '',
  department: '',
  job: '',
  phone: '',
  editable: true,
}

const SelectionList: Ref<CustomerPerson[]> = ref([])
// 校验规则
const rules = ref({
  customerName: [{ required: true, message: '公司名称不能为空', trigger: 'blur' }],
  businessContent: [{ required: true, message: '业务内容不能为空', trigger: 'blur' }],
}) // 表单验证规则
// 初始化router
const $router = useRouter()
// 关闭新增页面的回调
const close = () => {
  $router.back()
}
const companySizeList = ref<dictType[]>([]) // 公司规模列表
const businessSizeList = ref<dictType[]>([]) // 业务规模列表
const gradeList = ref<dictType[]>([]) // 履约评级列表
const evaluationList = ref<dictType[]>([]) // 整体评价列表
function getDict() {
  // 获取公司规模
  getDictByCode('companySize').then((response) => {
    companySizeList.value = response.data
  })
  // 获取业务规模
  getDictByCode('businessSize').then((response) => {
    businessSizeList.value = response.data
  })
  // 获取履约评级
  getDictByCode('grade').then((response) => {
    gradeList.value = response.data
  })
  // 获取整体评价
  getDictByCode('evaluation').then((response) => {
    evaluationList.value = response.data
  })
}
getDict()

const getInfo = () => {
  getCustomerDetail({ id: infoId.value }).then((res) => {
    res.data = { bankAccount: '银行账户', bankAccountNumber: '银行账号', bankName: '工商银行', briefName: '京东', businessContent: '电商', businessScope: 'test1', grade: '1', gradeName: '优质', companySize: '1', companySizeName: '优质', businessSize: '1', businessSizeName: '小微企业', evaluation: '1', evaluationName: '优质', companyAddress: '五棵松', companyAreaName: '海淀区', companyCityName: '北京市', companyCountryName: '中国', companyProvinceName: '北京', companyArea: '110107', companyCity: '110100', companyCountry: 'CN', companyProvince: '110000', createTime: '2022-11-29 21:14:50', director: '刘强东', fax: 'test1', id: '1597579843411234817', invoiceAddress: '五棵松', invoiceAreaName: '海淀区', invoiceCityName: '北京市', invoiceCountryName: '中国', invoiceProvinceName: '北京', invoiceyArea: '110107', invoiceCity: '110100', invoiceCountry: 'CN', invoiceProvince: '110000', mailbox: 'test1', minioFileName: 'test', mobile: 'test', phone: '950618', postalCode: 'test', remark: 'test', customerName: '京东集团', customerNo: 'sygf202211290001', taxNumber: 'test', updateTime: '2023-01-10 09:56:57', website: 'test' }
    dataForm.value = res.data
    if (pageType.value == 'detail') {
      companyAddress.value = [dataForm.value.companyCountryName, dataForm.value.companyProvinceName, dataForm.value.companyCityName, dataForm.value.companyAreaName, dataForm.value.companyAddress]
      invoiceAddress.value = [dataForm.value.invoiceCountryName, dataForm.value.invoiceProvinceName, dataForm.value.invoiceCityName, dataForm.value.invoiceAreaName, dataForm.value.invoiceAddress]
      for (const item of menu) {
        item.searchFunc()
      }
    }
    else {
      companyAddress.value = [dataForm.value.companyCountry, dataForm.value.companyProvince, dataForm.value.companyCity, dataForm.value.companyArea, dataForm.value.companyAddress]
      invoiceAddress.value = [dataForm.value.invoiceCountry, dataForm.value.invoiceProvince, dataForm.value.invoiceCity, dataForm.value.invoiceArea, dataForm.value.invoiceAddress]
    }
  })
}

// 表格选中
const handleSelectionChange = (e: CustomerPerson[]) => {
  SelectionList.value = e
}

// 公司地址变化后给对象赋值
function companyAddressChange(addressObj: IAddress) {
  dataForm.value.companyCountry = addressObj.country
  dataForm.value.companyProvince = addressObj.province
  dataForm.value.companyCity = addressObj.city
  dataForm.value.companyArea = addressObj.area
  dataForm.value.companyAddress = addressObj.address
  dataForm.value.companyCountryName = addressObj.countryName
  dataForm.value.companyProvinceName = addressObj.provinceName
  dataForm.value.companyCityName = addressObj.cityName
  dataForm.value.companyAreaName = addressObj.areaName
}

function invoiceAddressChange(addressObj: IAddress) {
  dataForm.value.invoiceCountry = addressObj.country
  dataForm.value.invoiceProvince = addressObj.province
  dataForm.value.invoiceCity = addressObj.city
  dataForm.value.invoiceArea = addressObj.area
  dataForm.value.invoiceAddress = addressObj.address
  dataForm.value.invoiceCountryName = addressObj.countryName
  dataForm.value.invoiceProvinceName = addressObj.provinceName
  dataForm.value.invoiceCityName = addressObj.cityName
  dataForm.value.invoiceAreaName = addressObj.areaName
}
// 点击增加行
const addRow = () => {
  // 检查上一行必填项
  if (checkPersonList()) {
    setAllRowReadable()
    CustomerPersonList.value.push({ ...addPersonObj })
  }
}
// 检查人员列表
function checkPersonList() {
  for (let index = 0; index < CustomerPersonList.value.length; index++) {
    const item = CustomerPersonList.value[index]
    for (const prop of columns.value) {
      // 检查必填
      if (prop.required && !item[prop.value]) {
        ElMessage.warning(`请先完善第${index + 1}行中${prop.text}`)
        return false
      }
      // 验证正则
      if (prop.reg && typeof prop.reg === 'function') {
        if (!prop.reg(item[prop.value])) {
          ElMessage.warning(`第${index + 1}行中${prop.text}输入不合法`)
          return false
        }
      }
    }
  }
  return true
}

// 删除行
const deleteList = () => {
  CustomerPersonList.value = CustomerPersonList.value.filter((item: CustomerPerson) => {
    return !SelectionList.value.includes(item)
  })
}
// 打印表单
const printObj = ref({
  id: 'form', // 需要打印元素的id
  popTitle: '客户详情', // 打印配置页上方的标题
  extraHead: '<div style="display: flex;flex-direction: column;text-align: center"><h3>客户详情</h3></div>', // 最上方的头部文字，附加在head标签上的额外标签，使用逗号分割
  preview: false, // 是否启动预览模式，默认是false
  standard: '',
  extarCss: '',
})

// 保存
function saveForm(formEl: FormInstance | undefined) {
  if (!formEl) { return }
  formEl.validate((valid, fields) => {
    if (valid) {
      ElMessageBox.confirm(
        '确认保存吗？',
        '提示',
        {
          confirmButtonText: '确认',
          cancelButtonText: '取消',
          type: 'warning',
        },
      ).then(() => {
        if (dataForm.value.id) {
          updateCustomer(dataForm.value).then((res) => {
            if (res.code === 200) {
              dataForm.value.id = res.data.id
              dataForm.value.customerNo = res.data.customerNo
              ElMessage.success('已保存')
              $router.go(-1)
            }
          })
        }
        else {
          addCustomer(dataForm.value).then((res) => {
            if (res.code === 200) {
              dataForm.value.id = res.data.id
              dataForm.value.customerNo = res.data.customerNo
              ElMessage.success('已保存')
              $router.go(-1)
            }
          })
        }
      })
    }
  })
}

const testForm = ref({
  fileList: [],
  fileContent: '',
})
const fileRef = ref() // 文件上传input
const onFileChange = (event: any) => {
  // 原生上传
  console.log(event.target.files)
  if (event.target.files?.length !== 0) {
    // 创建formdata对象
    const fd = new FormData()
    fd.append('multipartFile', event.target.files[0])
    UploadFile(fd).then((res) => {
      if (res.code === 200) {
        dataForm.value.minioFileName = res.data[0]
        // 重置当前验证
        ElMessage.success('文件上传成功')
      }
      else {
        ElMessage.error(res.message)
      }
    })
  }
}
const upload = () => {
  fileRef.value.click()
}
// 双击行显示输入框
const dblclickRow = (row: CustomerPerson) => {
  setAllRowReadable()
  row.editable = true
}
// 将所有人员信息列表置为不可编辑状态
function setAllRowReadable() {
  for (const item of CustomerPersonList.value) {
    item.editable = false
  }
}
// 非添加页面获取详情
if (pageType.value !== 'add') {
  getInfo()
}
</script>

<template>
  <app-container>
    <detail-page :title="`客户-${textMap[pageType]}`">
      <template #btns>
        <el-button v-if="pageType === 'detail'" v-print="printObj" type="primary">
          打印
        </el-button>
        <el-button v-if="pageType !== 'detail'" type="primary" @click="saveForm(ruleFormRef)">
          保存
        </el-button>
        <el-button type="info" @click="close">
          关闭
        </el-button>
      </template>
      <div id="form">
        <el-form
          ref="ruleFormRef"
          :model="dataForm"
          :label-width="120"
          label-position="right"
          :rules="rules"
        >
          <el-row :gutter="24">
            <el-col :span="6">
              <el-form-item label="客户编号:" prop="customerNo">
                <el-input
                  v-model="dataForm.customerNo"
                  :placeholder="pageType === 'detail' ? '' : '系统自动生成'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                  disabled
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="公司名称:" prop="customerName">
                <el-input
                  v-model="dataForm.customerName"
                  :placeholder="pageType === 'detail' ? '' : '请输入公司名称'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                  :disabled="pageType === 'detail'"
                />
              </el-form-item>
            </el-col><el-col :span="6">
              <el-form-item label="公司简称:">
                <el-input
                  v-model="dataForm.briefName"
                  :placeholder="pageType === 'detail' ? '' : '请输入公司简称'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                  :disabled="pageType === 'detail'"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="业务内容:" prop="businessContent">
                <el-input
                  v-model="dataForm.businessContent"
                  :placeholder="pageType === 'detail' ? '' : '请输入业务内容'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                  :disabled="pageType === 'detail'"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="公司规模" prop="companySize">
                <el-select v-model="dataForm.companySize" :placeholder="pageType === 'detail' ? '' : '请选择公司规模'" :disabled="pageType === 'detail'" class="full-width-input">
                  <el-option v-for="item in companySizeList" :key="item.id" :label="item.name" :value="item.value" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="业务规模" prop="businessSize">
                <el-select v-model="dataForm.businessSize" :placeholder="pageType === 'detail' ? '' : '请选择业务规模'" :disabled="pageType === 'detail'" class="full-width-input">
                  <el-option v-for="item in businessSizeList" :key="item.id" :label="item.name" :value="item.value" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="履约评级" prop="grade">
                <el-select v-model="dataForm.grade" :placeholder="pageType === 'detail' ? '' : '请选择履约评级'" :disabled="pageType === 'detail'" class="full-width-input">
                  <el-option v-for="item in gradeList" :key="item.id" :label="item.name" :value="item.value" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="整体评价" prop="evaluation">
                <el-select v-model="dataForm.evaluation" :placeholder="pageType === 'detail' ? '' : '请选择整体评价'" :disabled="pageType === 'detail'" class="full-width-input">
                  <el-option v-for="item in evaluationList" :key="item.id" :label="item.name" :value="item.value" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="税号:" prop="taxNumber">
                <el-input
                  v-model="dataForm.taxNumber"
                  :placeholder="pageType === 'detail' ? '' : '请输入税号'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                  :disabled="pageType === 'detail'"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="银行账户名:">
                <el-input
                  v-model="dataForm.bankAccount"
                  :placeholder="pageType === 'detail' ? '' : '请输入银行账户名'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                  :disabled="pageType === 'detail'"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="银行名称:">
                <el-input
                  v-model="dataForm.bankName"
                  :placeholder="pageType === 'detail' ? '' : '请输入银行名称'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                  :disabled="pageType === 'detail'"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="银行账号:">
                <el-input
                  v-model="dataForm.bankAccountNumber"
                  :placeholder="pageType === 'detail' ? '' : '请输入银行账号'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                  :disabled="pageType === 'detail'"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="邮编:">
                <el-input
                  v-model="dataForm.postalCode"
                  :placeholder="pageType === 'detail' ? '' : '请输入邮编'"
                  :disabled="pageType === 'detail'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="负责人:">
                <el-input
                  v-model="dataForm.director"
                  :placeholder="pageType === 'detail' ? '' : '请输入负责人'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                  :disabled="pageType === 'detail'"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="电话:">
                <el-input
                  v-model="dataForm.phone"
                  :placeholder="pageType === 'detail' ? '' : '请输入电话'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                  :disabled="pageType === 'detail'"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="传真:">
                <el-input
                  v-model="dataForm.fax"
                  :placeholder="pageType === 'detail' ? '' : '请输入传真'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                  :disabled="pageType === 'detail'"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="手机:">
                <el-input
                  v-model="dataForm.mobile"
                  :placeholder="pageType === 'detail' ? '' : '请输入手机'"
                  :disabled="pageType === 'detail'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="邮箱:">
                <el-input
                  v-model="dataForm.mailbox"
                  :placeholder="pageType === 'detail' ? '' : '请输入邮箱'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                  :disabled="pageType === 'detail'"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="网址:">
                <el-input
                  v-model="dataForm.website"
                  :placeholder="pageType === 'detail' ? '' : '请输入网址'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                  :disabled="pageType === 'detail'"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="5">
            <el-form-item label="公司地址:">
              <address-select :data="companyAddress" :detail="pageType === 'detail'" @on-change="companyAddressChange" />
            </el-form-item>
          </el-row>
          <el-row :gutter="5">
            <el-form-item label="开票地址:">
              <address-select :data="invoiceAddress" :detail="pageType === 'detail'" @on-change="invoiceAddressChange" />
            </el-form-item>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="14">
              <el-form-item label="公司业务范围:">
                <el-input
                  v-model="dataForm.businessScope"
                  :placeholder="pageType === 'detail' ? '' : '请输入公司业务范围'"
                  :disabled="pageType === 'detail'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="14">
              <el-form-item label="备注:">
                <el-input
                  v-model="dataForm.remark"
                  :placeholder="pageType === 'detail' ? '' : '请输入备注'"
                  :disabled="pageType === 'detail'"
                  :class="{ 'detail-input': pageType === 'detail' }"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24" class="marg">
            <el-col :span="14">
              <el-form-item label="附件:">
                <show-photo v-if="dataForm.minioFileName" :minio-file-name="dataForm.minioFileName" />
                <span v-else-if="pageType === 'detail'">无</span>
                <input v-show="pageType === ''" ref="fileRef" type="file" @change="onFileChange">
                <el-button v-if="pageType !== 'detail'" id="file" type="primary" :disabled="pageType === 'detail'" :style="{ 'margin-left': dataForm.minioFileName === '' ? '0px' : '20px' }" @click="upload">
                  {{ dataForm.minioFileName === '' ? '上传' : '更换附件' }}
                </el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </detail-page>
    <detail-block v-if="pageType !== 'detail'" title="人员信息">
      <template v-if="pageType !== 'detail'" #btns>
        <el-button type="info" @click="deleteList">
          删除行
        </el-button>
        <el-button type="primary" @click="addRow">
          增加行
        </el-button>
      </template>
      <el-table
        :data="CustomerPersonList"
        border
        style="width: 100%;"
        @selection-change="handleSelectionChange"
        @row-dblclick="dblclickRow"
      >
        <el-table-column type="selection" width="38" />
        <el-table-column align="center" label="序号" width="80" type="index" />
        <el-table-column
          v-for="item in columns"
          :key="item.value"
          :prop="item.value"
          :label="item.text"
          align="center"
        >
          <template #header>
            <span v-show="item.required" style="color: red;">*</span><span>{{ item.text }}</span>
          </template>
          <template #default="scope">
            <span v-if="!scope.row.editable">{{ scope.row[item.value] }}</span>
            <el-input v-else v-model="scope.row[item.value]" :autofocus="true" :placeholder="`${item.text}`" class="input" />
          </template>
        </el-table-column>
      </el-table>
    </detail-block>
    <detail-block-switch v-else :title="currentMenu">
      <template #menu>
        <el-radio-group v-model="currentMenu">
          <el-radio-button v-for="item in menu" :key="item.name" :label="item.name">
            {{ item.name }}
          </el-radio-button>
        </el-radio-group>
      </template>
      <template-table v-if="currentMenuObj" :columns="currentMenuObj.columns" :list="dataList[currentMenuObj.list]" :loading="false" :pagination="currentMenuObj.pagination" @change-page="currentMenuObj?.searchFunc" />
    </detail-block-switch>
  </app-container>
</template>

<style lang="scss" scoped>
// 样式
</style>
