<script lang="ts" setup name="ReportOnCredentialsAdd">
import { ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import type { FormInstance } from 'element-plus'
import dayjs from 'dayjs'
import type { IFileList, IFixedAssetsList, IFromListInfoType } from '../report_interface'
import ApprovalDialog from '@/components/Approval/ApprovalDialog.vue'
import { getStaffList } from '@/api/measure/person'
import EquipmentDialog from '@/views/device/standardEquipment/components/standardList/equipmentDialog.vue'
import {
  getStandardLisAdd,
  getStandardLisdetali,
  getStandardListDetail,
  getUsersDept,
  submitStandardEquipmentApply,
  updateStandardEquipmentApply,
} from '@/api/device/standard'
import { UploadFile } from '@/api/measure/file'
import useUserStore from '@/store/modules/user'
import showPhoto from '@/views/system/tool/showPhoto.vue'
import { submitApproval } from '@/api/approval'
const infoId = ref('') // id
const buttonArray = ref<string[]>([]) // 顶部按钮数组
const pageType = ref('add') // 页面类型: add,edit, detail
const buttonLoading = ref(false) // 按钮加载状态
const textMap: { [key: string]: string } = {
  edit: '编辑',
  add: '新建',
  detail: '查看',
} // 字典
// 从路由中获取页面类型参数
const $route = useRoute()
const formId = ref<string>('')
const { username } = useUserStore()
if ($route.params && $route.params.type) {
  pageType.value = $route.params.type as string
  formId.value = $route.query.formId as string
  if (pageType.value === 'add') {
    buttonArray.value = ['提交', '保存']
  }
  else if (pageType.value === 'edit') {
    buttonArray.value = ['保存']
  }
  else {
    buttonArray.value = ['同意', '驳回', '拒绝']
  }
  if ($route.query.id) {
    infoId.value = $route.query.id as string
  }
}
const ruleFormRef = ref<FormInstance>()
// 逻辑代码
const formInline = ref({
  certificateReportCategory: '', // 证书类别,多个逗号分割
  certificateReportName: '', // 证书报告名称
  orderId: '', // 委托书id
  certificateReportCode: '', // 	证书报告编号
  sampleId: '', // 样品id
  measureDeptId: '', // 检定部门id
  calibrationMajor: '', // 检校专业
  issuanceDate: '', // 出具日期
  expirationDate: '', // expirationDate
  templateId: '', // 证书报告模板id
  signId: '', // 电子签章id
  approvalSignId: '', // 认可标志专用章id
  certificateReportFile: '', // 证书报告附件
  originalRecordId: '', // 原始记录id
  remark: '', // 备注
  createUser: '', // 创建人id
})

const fromListInfo = ref<IFromListInfoType>({
  templateName: '', // 证书报告模板名称
  signName: '', // 电子签章名称
  approvalSignName: '', // 认可标准专用章
  originalRecordName: '', // 原始记录名称
  calibrationPlace: '', // 校验地点
  temperature: '', // 温度
  humidity: '', // 相对湿度
  sampleNo: '', // 样品编号
  sampleName: '', // 样品名称
  leaveNo: '', // 出厂编号
  customerId: '', // 委托方代码
  customerName: '', // 委托方名称
  customerPhone: '', // 委托方电话
  customerLocation: '', // 委托方地址
  censorshipUser: '', // 送检人
  phone: '', // 送检人联系方式
  taskId: '',
  expectedDeliveryTime: '', // 预计送达时间
  expectedCompletionTime: '', // 预计检完时间
  verificationItems: '', // 检定项目
  model: '', // 型号
  manufacturer: '', // 生产厂家
  applyEquipmentList: [],
  fixedAssetsList: [],
  fileList: [],
})
// 下拉框数组类型
interface IOptions {
  id: string
  name: string
  value: string
  organizeName: string
  deptId: string
}
interface standardOwnerOptionsType {
  id: string
  name: string
}
// 标准所在部门下拉框
const standardUsersDeptList = ref<IOptions[]>([])
const approvalDialog = ref()
const params = ref({
  director: '',
  meterMajor: '',
  createEndTime: '',
  createstartTime: '',
  organizeName: '',
  organizeNo: '',
  organizeType: '2',
  pdeptId: null,
  offset: 1,
  limit: 999999,
})
// 获取部门信息
getUsersDept(params.value).then((res) => {
  standardUsersDeptList.value = res.data.rows
})
const standardOwnerOptions = ref<standardOwnerOptionsType[]>([])
// 获取到标准负责人数组
const getStandardOwnerOptions = () => {
  const params = {
    staffNo: '', // 人员编号
    name: '', // 姓名
    deptId: '', // 工作部门
    major: '', // 计量专业
    verifierCertificateNo: '', // 证书号
    certificateStatus: '', // 证书状态
    limit: 100000,
    offset: 1,
  }
  getStaffList(params).then((res) => {
    standardOwnerOptions.value = res.data.records
  })
}
// 数据
const list = ref<object[]>([])
// 审批弹窗开关
const applyShow = ref(false)
// 审批弹窗信息收集类型
interface applyListType {
  select: string
  epilog: string
  approval: string
  approvalTime: string
}
// 审批弹窗信息收集
const applyList = ref<applyListType>({
  select: '',
  epilog: '',
  approval: '',
  approvalTime: '',
})
// 标准配套设备表头类型
interface columnsType {
  text: string
  value: string
  align: string
  required: Boolean
  choose: Boolean
  time: Boolean
}

// 标准配套设备更换表头
const columns = ref<columnsType[]>([
  {
    text: '设备名称',
    value: 'equipmentName',
    align: 'center',
    required: true,
    choose: true,
    time: false,
  },
  {
    text: '设备编号',
    value: 'equipmentNo',
    align: 'center',
    required: true,
    choose: false,
    time: false,
  },
  {
    text: '型号',
    value: 'modelNo',
    align: 'center',
    required: true,
    choose: false,
    time: false,
  },
  {
    text: '出厂编号',
    value: 'mesureResult',
    align: 'center',
    required: true,
    choose: false,
    time: false,
  },
  {
    text: '证书有效期',
    value: 'validDate',
    align: 'center',
    required: true,
    choose: false,
    time: false,
  },
])
// 标准配套设备更换查询条件
const listQuery = ref<object>({
  limit: 10,
  offset: 1,
})
// 标准配套设备更换表格loding
const loadingTable = ref(false)
// 申请文档表头
const columnsFiles = ref<columnsType[]>([
  {
    text: '文件编号',
    value: 'fileName',
    align: 'center',
    required: true,
    choose: true,
    time: false,
  },
  {
    text: '文件名称',
    value: 'createTime',
    align: 'center',
    required: true,
    choose: false,
    time: true,
  },
  {
    text: '文件代号',
    value: 'remark',
    align: 'center',
    required: true,
    time: false,
    choose: false,
  },
])
// 标准配套设备更换表格分页
const changePage = () => {}
getStandardOwnerOptions()
// 添加表格数据对象
const addList = ref({})
// 添加表格弹窗开关
const dialogVisible = ref(false)
// 选择标准装置数据列表下拉框类型
interface standardListType {
  id: string
  standardName: string
}
// 选择标准装置数据列表下拉框
const standardList = ref<standardListType[]>([])
// 初始化路由
const $router = useRouter()
// 关闭
const close = () => {
  // emit('close')
  $router.back()
}
// 表单验证规则
const rules = ref({
  calibrationMajor: [{ required: true, message: '检校专业不能为空', trigger: ['blur', 'change'] }],
  certificateReportCode: [{ required: true, message: '证书编号不能为空', trigger: ['blur', 'change'] }],
  certificateReportName: [{ required: true, message: '证书名称不能为空', trigger: ['blur', 'change'] }],
  issuanceDate: [{ required: true, message: '出具日期不能为空', trigger: ['blur', 'change'] }],
  templateName: [{ required: true, message: '证书模板不能为空', trigger: ['blur', 'change'] }],
  signName: [{ required: true, message: '电子签章不能为空', trigger: ['blur', 'change'] }],
  approvalSignName: [{ required: true, message: '认可标志专用章不能为空', trigger: ['blur', 'change'] }],
  originalRecordName: [{ required: true, message: '原始记录不能为空', trigger: ['blur', 'change'] }],
  sampleNo: [{ required: true, message: '样品编号不能为空', trigger: ['blur', 'change'] }],
  sampleName: [{ required: true, message: '样品名称不能为空', trigger: ['blur', 'change'] }],
  model: [{ required: true, message: '型号不能为空', trigger: ['blur', 'change'] }],
  manufacturer: [{ required: true, message: '生产厂家不能为空', trigger: ['blur', 'change'] }],
  temperature: [{ required: true, message: '温度(℃)不能为空', trigger: ['blur', 'change'] }],
  humidity: [{ required: true, message: '相对湿度(%)不能为空', trigger: ['blur', 'change'] }],
  leaveNo: [{ required: true, message: '出厂编号不能为空', trigger: ['blur', 'change'] }],
  customerId: [{ required: true, message: '委托方代码不能为空', trigger: ['blur', 'change'] }],
  customerName: [{ required: true, message: '委托方名称不能为空', trigger: ['blur', 'change'] }],
  customerPhone: [{ required: true, message: '委托方电话不能为空', trigger: ['blur', 'change'] }],
  customerLocation: [{ required: true, message: '委托方地址不能为空', trigger: ['blur', 'change'] }],
  verificationItems: [{ required: true, message: '检定项目不能为空', trigger: ['blur', 'change'] }],
})
// 第几条数据选择
const listIndex = ref(0)
interface IRowIndexType {
  $index: number
}
const uploadIndex = (row: IRowIndexType) => {
  listIndex.value = row.$index
}
// 选择标准配套设备
const equipmentDialog = ref()
// 点击标准配套设备选择按钮
const chooseList = (row: object, index: number) => {
  listIndex.value = index
  equipmentDialog.value.initDialog()
}
// 测试数据
const simulateObject = {
  data: dayjs(`${new Date()}`).format('YYYY.MM.DD'), // 有效日期
  certificateNo: '199926465422', // 证书编号
  authorityOfIssue: 'xxx公司', // 发证单位
  authorityOfDate: dayjs(`${new Date()}`).format('YYYY.MM.DD'), // 发证日期
}
// 点击增加行
const addRoow = () => {
  if (
    fromListInfo.value.applyEquipmentList.length >= 1
    && fromListInfo.value.applyEquipmentList[
      fromListInfo.value.applyEquipmentList.length - 1
    ].equipmentId === ''
  ) {
    ElMessage.warning('请完善上一条设备信息')
  }
  else {
    fromListInfo.value.applyEquipmentList.push({
      equipmentName: '', // 设备名称
      equipmentNo: '', // 设备编号
      modelNo: '', // 型号
      mesureResult: '',
      validDate: '', // 到期时间
      id: '', // 主键
      equipmentId: '', // 设备id
      standardApplyId: '',
    })
    fromListInfo.value.fixedAssetsList.push({
      equipmentName: '', // 设备名称
      equipmentNo: '', // 设备编号
      modelNo: '', // 型号
      mesureResult: '',
      validDate: '', // 到期时间
      id: '', // 主键
      equipmentId: '', // 设备id
      standardApplyId: '',
    })
  }
}
// 选择设备之后
const equipmentAddRow = (data: IFixedAssetsList) => {
  fromListInfo.value.fixedAssetsList[listIndex.value] = data
  fromListInfo.value.applyEquipmentList[listIndex.value].equipmentId = data.id
  fromListInfo.value.applyEquipmentList[listIndex.value].standardApplyId
    = infoId.value || ''
}
// 增加申请文档列表
const addRow = () => {
  if (
    fromListInfo.value.fileList.length >= 1
    && !fromListInfo.value.fileList[fromListInfo.value.fileList.length - 1]
      .fileName
  ) {
    ElMessage.warning('请完善上一条文件信息')
  }
  else {
    fromListInfo.value.fileList.push({ choose: false, fileName: '' })
  }
}
// 点击文件预览
const uploadShow = (e: any) => {
  const URL = window.URL || window.webkitURL
  window.open(URL.createObjectURL(e.raw))
}
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) {
        formInline.value.certificateReportFile = res.data[0]
        // 重置当前验证
        ElMessage.success('文件上传成功')
      }
      else {
        ElMessage.error(res.message)
      }
    })
  }
}
const upload = () => {
  fileRef.value.click()
}

// 表格选中的数组
const SelectionList = ref<object[]>([])
// 标准实验室发生改变row类型
interface rowReturn {
  phone: string
  director: string
  deptId: string
  organizeName: string
  id: string
}
// 标准实验室发生改变
const changeDeptList = (row: rowReturn) => {}
// 标准实验室清空时
const clearDeptList = () => {}
// 获取详情信息
const getInfo = (id: string | number) => {
  getStandardLisdetali({ id }).then((res) => {
    Object.keys(res.data).map((item) => {
      if (typeof res.data[item] === 'number') {
        res.data[item] = res.data[item].toString()
      }
    })
    formInline.value = res.data.meterStandardEquipment
    fromListInfo.value.fixedAssetsList = res.data.fixedAssetsList
    fromListInfo.value.fileList = res.data.fileList.map((item: IFileList) => {
      item.choose = true
      return item
    })
  })
}
if (pageType.value !== 'add') {
  getInfo(infoId.value)
}

// 取消
const handleCancel = () => {
  const params = {
    taskId: fromListInfo.value.taskId!,
    comments: '',
  }
  ElMessageBox.confirm('确认取消该审批吗？', '提示', {
    confirmButtonText: '确认',
    cancelButtonText: '取消',
    type: 'warning',
  }).then(() => {
    submitApproval('revoke', params).then((res) => {
      ElMessage({
        type: 'success',
        message: '取消成功',
      })
    })
  })
}
// 点击数据后的操作按钮
const clickBtn = (buttonType: string) => {
  switch (buttonType) {
    case '同意':
      approvalDialog.value.initDialog('agree', fromListInfo.value.taskId)
      break
    case '驳回':
      approvalDialog.value.initDialog('reject', fromListInfo.value.taskId)
      break
    case '拒绝':
      approvalDialog.value.initDialog('refuse', fromListInfo.value.taskId)
      break
    case '取消':
      handleCancel()
      break
  }
}

// 保存后的id
const addId = ref('')
// 点击顶部一排按钮
const getAddList = async (item: string, formEl: FormInstance | undefined) => {
  if (item === '保存' && pageType.value === 'add') {
    if (!formEl) {
      return
    }
    await formEl.validate((valid, fields) => {
      if (valid) {
        ElMessageBox.confirm('确认保存吗？', '提示', {
          confirmButtonText: '确认',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(() => {
          getStandardLisAdd(fromListInfo.value).then((res) => {
            if (res.code === 200) {
              ElMessage.success('保存成功')
              addId.value = res.data.id
            }
          })
        })
      }
    })
  }
  else if (item === '保存' && pageType.value === 'edit') {
    if (!formEl) {
      return
    }
    await formEl.validate((valid, fields) => {
      if (valid) {
        ElMessageBox.confirm('确认保存吗？', '提示', {
          confirmButtonText: '确认',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(() => {
          updateStandardEquipmentApply(fromListInfo.value).then((res) => {
            if (res.code === 200) {
              ElMessage.success('保存成功')
              addId.value = res.data.id
            }
          })
        })
      }
    })
  }
  else if (item === '提交') {
    if (addId.value === '') {
      ElMessage.warning('请先保存')
    }
    else {
      submitStandardEquipmentApply({
        id: addId.value,
        formId: formId.value,
      }).then((res) => {
        if (res.code === 200) {
          close()
        }
      })
    }
  }
  else {
    clickBtn(item)
  }
}
// 审批流程模拟数据
const approvalActivities = [
  {
    name: '张三',
    deptName: '审计局',
    content: '同意',
    timestamp: '2018-04-15 08:00:00',
  },
  {
    name: '张三',
    content: 'Approved',
    timestamp: '2018-04-13',
  },
  {
    name: '张三',
    content: 'Success',
    timestamp: '2018-04-11',
  },
]
// 审批完成后的回调
const approvalSuccess = () => {}
// 选择标准装置弹窗ref
const standarDialog = ref()
// 选择了标准名称后
const standardChange = () => {
  standarDialog.value.initDialog()
}

// 点击关闭
const handleClose = () => {
  dialogVisible.value = false
}
// 标准配套设备更换表格删除行
const removeRow = (type: string) => {
  if (SelectionList.value.length > 0) {
    ElMessageBox.confirm('确认删除选中的数据吗？', '提示', {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }).then(() => {
      if (type == '1') {
        // 删除设备行
        fromListInfo.value.fixedAssetsList = fromListInfo.value.fixedAssetsList.filter((item) => {
          return !SelectionList.value.includes(item)
        })
        fromListInfo.value.applyEquipmentList = fromListInfo.value.fixedAssetsList.filter((item) => {
          return !SelectionList.value.includes(item)
        })
        ElMessage.success('删除成功')
      }
      else {
        // 删除文件行
        fromListInfo.value.fileList = fromListInfo.value.fileList.filter(
          (item) => {
            return !SelectionList.value.includes(item)
          },
        )
        ElMessage.success('删除成功')
      }
    })
  }
  else {
    ElMessage.warning('请先选择需要删除的数据')
  }
}
// 文件表格多选框
const handleSelectionChange = (e: any) => {
  SelectionList.value = e
}
watch(
  () => formInline.value,
  (newVal) => {
    // 变化后存储
  },
  { deep: true, immediate: true },
)
// 审批弹窗的关闭
const applyListClose = () => {
  applyShow.value = false
}
// 审批弹窗的提交
const applyListSubmit = () => {
  console.log(applyList.value)
  if (applyList.value.select == '') {
    return ElMessage.error('必须选择审批意见')
  }
  applyListClose()
}
// 标准装置发生改变data类型
interface dataReturn {
  id: string
}
// 获取详情信息
const getStandarInfo = (id: string | number) => {
  getStandardListDetail({ id }).then((res) => {
    Object.keys(res.data).map((item) => {
      if (typeof res.data[item] === 'number') {
        res.data[item] = res.data[item].toString()
      }
    })
    formInline.value = res.data
  })
}
// 选择标准装置完成之后
const StandarAddRow = (data: dataReturn) => {
  getStandarInfo(data.id)
}
</script>

<template>
  <app-container>
    <detail-page :title="`证书报告 -- ${textMap[pageType]}`">
      <template #btns>
        <el-button
          v-for="(item, index) in buttonArray"
          :key="index"
          type="primary"
          @click="getAddList(item, ruleFormRef)"
        >
          {{ item }}
        </el-button>
        <el-button type="info" @click="close">
          关闭
        </el-button>
      </template>
      <el-form
        ref="ruleFormRef"
        :model="formInline"
        label-position="right"
        label-width="auto"
        :rules="rules"
      >
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="检校专业:" prop="calibrationMajor">
              <el-select
                v-model="formInline.calibrationMajor"
                clearable
                :placeholder="pageType === 'detail' ? '' : '请选择检校专业'"
                size="default"
                style="width: 100%;"
                :disabled="pageType === 'detail'"
              >
                <el-option
                  v-for="item in standardOwnerOptions"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="出具日期:" prop="issuanceDate">
              <el-date-picker
                v-model="formInline.issuanceDate"
                type="date"
                style="width: 100%;"
                clearable
                :placeholder="pageType === 'detail' ? '' : '请选择出具日期'"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="证书编号:" prop="certificateReportCode">
              <el-input
                v-model.trim="formInline.certificateReportCode"
                :placeholder="pageType === 'detail' ? '' : '请输入证书编号'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="证书报告名称:" prop="certificateReportName">
              <el-input
                v-model.trim="formInline.certificateReportName"
                :placeholder="pageType === 'detail' ? '' : '请输入证书报告名称'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="证书报告模板:" prop="templateName">
              <el-input
                v-model.trim="fromListInfo.templateName"
                :placeholder="pageType === 'detail' ? '' : '请选择证书报告模板'"
                class="full-width-input"
                :disabled="pageType === 'detail'"
              >
                <template v-if="pageType !== 'detail'" #append>
                  <el-button
                    size="small"
                  >
                    选择
                  </el-button>
                </template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item
              label="电子签章:"
              prop="signName"
            >
              <el-input
                v-model.trim="fromListInfo.signName"
                :placeholder="pageType === 'detail' ? '' : '请选择电子签章'"
                class="full-width-input"
                :disabled="pageType === 'detail'"
              >
                <template v-if="pageType !== 'detail'" #append>
                  <el-button
                    size="small"
                  >
                    选择
                  </el-button>
                </template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="认可标志专用章:" prop="approvalSignName">
              <el-input
                v-model.trim="fromListInfo.approvalSignName"
                :placeholder="pageType === 'detail' ? '' : '请选择认可标志专用章'"
                class="full-width-input"
                :disabled="pageType === 'detail'"
              >
                <template v-if="pageType !== 'detail'" #append>
                  <el-button
                    size="small"
                  >
                    选择
                  </el-button>
                </template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="证书报告附件:">
              <show-photo v-if="formInline.certificateReportFile" :minio-file-name="formInline.certificateReportFile" />
              <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': formInline.certificateReportFile === '' ? '0px' : '20px' }" @click="upload">
                {{ formInline.certificateReportFile === '' ? '上传' : '更换附件' }}
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="原始记录编号:" prop="originalRecordName">
              <el-input
                v-model.trim="fromListInfo.originalRecordName"
                :placeholder="pageType === 'detail' ? '' : '请选择原始记录编号'"
                class="full-width-input"
                :disabled="pageType === 'detail'"
              >
                <template v-if="pageType !== 'detail'" #append>
                  <el-button
                    size="small"
                  >
                    选择
                  </el-button>
                </template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="检校地点:" prop="calibrationPlace">
              <el-input
                v-model.trim="fromListInfo.calibrationPlace"
                :placeholder="pageType === 'detail' ? '' : '请输入检校地点'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="温度(℃):" prop="temperature">
              <el-input
                v-model.trim="fromListInfo.temperature"
                :placeholder="pageType === 'detail' ? '' : '请输入温度(℃)'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="相对湿度(%):" prop="humidity">
              <el-input
                v-model.trim="fromListInfo.humidity"
                :placeholder="pageType === 'detail' ? '' : '请输入相对湿度(%)'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="样品编号:" prop="sampleNo">
              <el-input
                v-model.trim="fromListInfo.sampleNo"
                :placeholder="pageType === 'detail' ? '' : '请输入样品编号'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="样品名称:" prop="sampleName">
              <el-input
                v-model.trim="fromListInfo.sampleName"
                :placeholder="pageType === 'detail' ? '' : '请输入样品名称'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="出厂编号:" prop="leaveNo">
              <el-input
                v-model.trim="fromListInfo.leaveNo"
                :placeholder="pageType === 'detail' ? '' : '请输入出厂编号'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="型号:" prop="model">
              <el-input
                v-model.trim="fromListInfo.model"
                :placeholder="pageType === 'detail' ? '' : '请输入型号'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="生产厂家:" prop="manufacturer">
              <el-input
                v-model.trim="fromListInfo.manufacturer"
                :placeholder="pageType === 'detail' ? '' : '请输入生产厂家'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="委托方代码:" prop="customerId">
              <el-input
                v-model.trim="fromListInfo.customerId"
                :placeholder="pageType === 'detail' ? '' : '请输入委托方代码'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="委托方名称:" prop="customerName">
              <el-input
                v-model.trim="fromListInfo.customerName"
                :placeholder="pageType === 'detail' ? '' : '请输入委托方名称'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="委托方电话:" prop="customerPhone">
              <el-input
                v-model.trim="fromListInfo.customerPhone"
                :placeholder="pageType === 'detail' ? '' : '请输入委托方电话'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="委托方地址:" prop="customerLocation">
              <el-input
                v-model.trim="fromListInfo.customerLocation"
                :placeholder="pageType === 'detail' ? '' : '请输入委托方地址'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="送检人:">
              <el-input
                v-model.trim="fromListInfo.censorshipUser"
                :placeholder="pageType === 'detail' ? '' : '请输入送检人'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="联系方式:">
              <el-input
                v-model.trim="fromListInfo.phone"
                :placeholder="pageType === 'detail' ? '' : '请输入联系方式'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="预计送达时间:">
              <el-date-picker
                v-model="fromListInfo.expectedDeliveryTime"
                type="datetime"
                style="width: 100%;"
                clearable
                :placeholder="pageType === 'detail' ? '' : '请选择预计送达时间'"
                format="YYYY-MM-DD hh:mm:ss"
                value-format="YYYY-MM-DD HH:mm:ss a"
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="预计检完时间:">
              <el-date-picker
                v-model="fromListInfo.expectedCompletionTime"
                type="datetime"
                style="width: 100%;"
                :placeholder="pageType === 'detail' ? '' : '请选择预计送达时间'"
                format="YYYY-MM-DD hh:mm:ss"
                clearable
                value-format="YYYY-MM-DD HH:mm:ss a"
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="检定项目:" prop="verificationItems">
              <el-input
                v-model.trim="fromListInfo.verificationItems"
                :placeholder="pageType === 'detail' ? '' : '请输入检定项目'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="备注:">
              <el-input
                v-model.trim="formInline.remark"
                :placeholder="pageType === 'detail' ? '' : '请输入备注'"
                class="full-width-input"
                clearable
                :disabled="pageType === 'detail'"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </detail-page>
    <detail-block title=" 所用设备">
      <template v-if="pageType !== 'detail'" #btns>
        <el-button v-if="pageType !== 'detail'" type="primary" @click="addRoow">
          增加行
        </el-button>
        <el-button
          v-if="pageType !== 'detail'"
          type="info"
          @click="removeRow('1')"
        >
          删除行
        </el-button>
      </template>
      <el-table
        :data="fromListInfo.fixedAssetsList"
        border
        style="width: 100%;"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          v-if="pageType !== 'detail'"
          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
            v-if="item.text === '设备名称' && pageType !== 'detail'"
            #default="scope"
          >
            <el-input
              v-model="scope.row[item.value]"
              :placeholder="`${item.text}`"
              class="input"
            >
              <template v-if="item.choose" #append>
                <el-button
                  v-if="pageType !== 'detail'"
                  size="small"
                  @click="chooseList(scope.row, scope.$index)"
                >
                  选择
                </el-button>
              </template>
            </el-input>
          </template>
        </el-table-column>
      </el-table>
    </detail-block>
    <detail-block title="所依据的技术文件">
      <template v-if="pageType !== 'detail'" #btns>
        <el-button type="primary" @click="addRow">
          增加行
        </el-button>
        <el-button type="info" @click="removeRow('2')">
          删除行
        </el-button>
      </template>
      <el-table
        :data="fromListInfo.fileList"
        border
        style="width: 100%;"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          v-if="pageType !== 'detail'"
          type="selection"
          width="38"
        />
        <el-table-column align="center" label="序号" width="80" type="index" />
        <el-table-column
          v-for="item in columnsFiles"
          :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
            v-if="item.text === '文件编号' && pageType !== 'detail'"
            #default="scope"
          >
            <el-input
              v-model="scope.row[item.value]"
              :placeholder="`${item.text}`"
              class="input"
            >
              <template v-if="item.choose" #append>
                <el-button
                  v-if="pageType !== 'detail'"
                  size="small"
                >
                  选择
                </el-button>
              </template>
            </el-input>
          </template>
        </el-table-column>
      </el-table>
    </detail-block>
    <div v-if="pageType === 'detail'">
      <detail-block title="审批流程">
        <!-- 审批流程 -->
        <div>
          <el-timeline>
            <el-timeline-item
              v-for="(activity, index) in approvalActivities"
              :key="index"
              :timestamp="activity.timestamp"
            >
              <div>
                <span>审批人：</span>{{ activity.name }}
                <span style="margin-left: 10px;">审批意见：</span>{{ activity.content }}
              </div>
            </el-timeline-item>
          </el-timeline>
        </div>
      </detail-block>
    </div>
  </app-container>
  <!-- 审批弹窗信息收集 -->
  <approval-dialog ref="approvalDialog" @on-success="approvalSuccess" />
  <!-- 选择设备弹窗 -->
  <equipment-dialog ref="equipmentDialog" @add="equipmentAddRow" />
</template>

<style lang="scss">
.el-upload-list {
  display: none !important;
}
</style>
