Newer
Older
xc-business-system / src / views / resource / file / grantNotice / detail.vue
<!-- 文件发放通知单详情 -->
<script name="FileGrantNoticeDetail" lang="ts" setup>
import { ElLoading, ElMessage, ElMessageBox, dayjs, formContextKey } from 'element-plus'
import type { IFileApprovalForm } from '../approval/approval-interface'
import type { IFileGrandNotice, IFileNoticeInfo } from './notice-interface'
import selectFileTypeDialog from './dialog/selectFileTypeDialog.vue'
import selectCustomerExamineList from './dialog/selectCustomerExamineList.vue'
import selectFileApprovalDialog from './dialog/selectFileApprovalDialog.vue'
import selectMethodDialog from '@/views/resource/file/methodConfirm/selectMethodDialog.vue'
import type { IDictType } from '@/commonInterface/resource-interface'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import ApprovalDialog from '@/views/resource/common/approvalDialog.vue'
import ApprovalRecordTable from '@/components/ApprovalRecord/ApprovalRecordTable.vue'
import useUserStore from '@/store/modules/user'
import { getStaffList } from '@/api/resource/register'
import { exportFile } from '@/utils/exportUtils'
import type { dictType } from '@/global'
import { getDictByCode } from '@/api/system/dict'
import { detailFileApprovalForm } from '@/api/resource/fileApproval'
import { addGrantNotice, cancelApproval, detailGrantNotice, failUpdateGrantNotice, grantStatusUpdate, refuseApproval, revokeDelete, submitGrantNotice, updateDraftNotice } from '@/api/resource/fileGrantNotice'
const $route = useRoute()
const user = useUserStore() // 用户信息

// 从路由中传过来的参数
const type = ref<string>('')
const id = ref<string>('')
const status = ref('')

// 关键字段是否可以编辑
const keyFieldsDisable = ref<boolean>(true)

const flowFormId = 'zyglwjfftzd' // 资源管理 - 文件发放通知单

const userInfo = useUserStore()
const route = useRoute()
const router = useRouter()
const title = ref('')

const radioItems = ref([
  { name: '基本信息', value: 'notice-basic' },
  { name: '审批详情', value: 'notice-approval' },
])

const current = ref('')
const currentLabel = ref('')

// 弹窗子组件
const apprDial = ref()
const grantNoticeRef = ref()
const refFileSelect = ref()

const grantNoticeRules = ref({
  labCode: [{ required: true, message: '实验室不能为空,请选择', trigger: ['change', 'blur'] }],
  groupCode: [{ required: true, message: '部门不能为空,请选择', trigger: ['change', 'blur'] }],
  distributor: [{ required: true, message: '发放人员不能为空,请选择', trigger: ['change', 'blur'] }],
}) // 表单验证规则

// 是否显示相关按钮
const saveButtVisable = ref<boolean>(false) // 是否显示 保存 按钮
const submitButtVisable = ref<boolean>(false) // 是否显示 提交 按钮
const flowButtsVisable = ref<boolean>(false) // 是否显示 同意和拒绝 按钮
const cancelButtVisable = ref<boolean>(false) // 是否显示 取消 按钮
const deleteButtVisable = ref<boolean>(false) // 是否显示 删除 按钮
const editButtVisable = ref<boolean>(false) // 是否显示 编辑 按钮

const grantNoticeForm = ref<IFileGrandNotice>({
  id: '',
  formNo: '',
  formName: '文件发放通知单',
  labCode: '',
  labCodeName: '',
  groupCode: '',
  groupCodeName: '',
  processId: '',
  taskId: '',
  createTime: '',
  createUserId: '',
  createUserName: '',
  fileApprovalCodes: '', // 文件审批编号----
  distributor: [], //	发放人员Ids,用逗号隔开
  distributorNames: [], // 发放人员名称集合,用逗号隔开
  noveltyId: '',
})

// -------------------------------------------文件列表------------------------------------------------
const list = ref([]) as any // 文件列表表格数据
const columns = ref<TableColumn[]>([
  { text: '实验室', value: 'labCodeName', align: 'center' },
  { text: '部门', value: 'groupCodeName', align: 'center' },
  { text: '文件发放类型', value: 'grantTypeName', align: 'center' },
  { text: '文件编号', value: 'fileNo', align: 'center' },
  { text: '文件名称', value: 'fileName', align: 'center' },
  { text: '版本号', value: 'fileVersion', align: 'center' },
  { text: '文件附件', value: 'pdfUrl', align: 'center' },
  { text: '备注', value: 'remark', align: 'center' },
]) // 表头
const selectCustomerExamineListRef = ref() // 选择要求、委托书及合同评审表组件ref
const selectFileApprovalDialogRef = ref() // 文件审批组件ref
const selectMethodDialogRef = ref() // 选择测试校准检定方法组件ref
// 选好文件的类型
const confirmSelectFileType = (type: string) => {
  console.log('选择的添加文件的类型', type)
  switch (type) {
    case '1': // 测试校准检定方法
      selectMethodDialogRef.value.initDialog()
      break
    case '2':
      ElMessage.info('敬请期待')

      break
    case '3': // 要求、委托书及合同评审表
      selectCustomerExamineListRef.value.initDialog()
      break
    case '4':
      ElMessage.info('敬请期待')
      break
    case '5': // 体系文件
      selectFileApprovalDialogRef.value.initDialog()
      break
  }
}

// 选好文件
const confirmSelectFile = (listParam: any, type: string) => {
  let title = '体系文件'
  let grantType = '1'
  switch (type) {
    case '1':
      title = '现行测试校准检定方法'
      grantType = '2'
      break
    case '2':
      title = '溯源链变更管理'
      grantType = '5'
      break
    case '3': // 要求委托书及合同评审表
      title = '要求、委托书及合同评审表'
      grantType = '4'
      break
    case '4':
      title = '合同执行变更登记表'
      grantType = '3'
      break
    case '5':
      title = '体系文件'
      grantType = '1'
      break
  }
  if (type === '5') {
    const listIds = listParam.map((item: { id: string }) => item.id)
    grantNoticeForm.value.fileApprovalCodes = listParam.map((item: { approvalNo: string }) => item.approvalNo).join(';')
    const requestList = listIds.map((id: string) => fetchFileApprovalDetail(id))
    const loading = ElLoading.service({
      lock: true,
      text: '正在处理数据,请耐心等待...',
      background: 'rgba(255, 255, 255, 0.6)',
    })
    Promise.all(requestList).then((res) => {
      const tempList = [] as any
      res.forEach((item) => {
        item.forEach((i: any) => {
          if (i.grantStatus === '未发放') {
            tempList.push({
              ...i,
              approvalFileId: i.id, // 文件审批表的关联文件表id
              fileApprovalId: i.fileApprovalId, // 文件审批表id
              fileVersion: i.fileVersion === '' ? '/' : i.fileVersion, // 版本号
              grantTypeName: title, // 文件发放类型名称
              grantType, // 文件发放类型
              id: '',
            })
          }
          else {
            ElMessage.info({
              message: `文件【${i.fileName}】发放状态为:${i.grantStatus},不添加到文件列表`,
              duration: 5000,
            },
            )
          }
        })
      })
      list.value = tempList
      loading.close()
    })
  }
  else {
    listParam.forEach((item: any) => {
      const index = list.value.findIndex((i: { id: string }) => item.id === i.id)
      if (index === -1) {
        list.value.push({
          ...item,
          labCode: item.labCode, // 实验室
          labCodeName: item.labCodeName, // 实验室名称
          groupCode: item.groupCode, // 部门
          groupCodeName: item.groupCodeName, // 部门名称
          fileNo: item.formNo || item.fileNo, // 文件编号
          fileName: item.formName || item.fileName, // 文件名称
          fileVersion: type === '3' || type === '2' ? '/' : item.fileVersion, // 版本号
          pdfUrl: type === '3' ? '/' : type === '2' ? (item.file || '/') : item.pdfUrl, // 文件附件
          remark: '', // 备注
          grantType, // 文件发放类型
          grantTypeName: title, // 文件发放类型名称
          id: '',
        })
      }
    })
  }
}

// 封装请求文件审批详情函数
function fetchFileApprovalDetail(id: string) {
  return new Promise((resolve, reject) => {
    detailFileApprovalForm({ id }).then((res) => {
      if (res.code === 200) {
        const tempList = res.data.approvalFileList.map((item: { fileApprovalId: string }) => {
          return {
            ...item,
            fileApprovalId: id,
          }
        })
        resolve(tempList)
      }
      else {
        console.log('存在文件审批查询详情接口失败')
      }
    })
  })
}

// -----------------------------------------------------------------------------------------------------

// 字典值
const labCodeDict = ref<IDictType[]>([])
const groupCodeDict = ref<IDictType[]>([])

const fileRecordSelected = ref<IFileNoticeInfo[]>([])

// 详情页的各个tab切换操作
const radioChangeHandler = (newVal: string | number | boolean) => {
  const radioTarget = radioItems.value.filter(item => item.name === newVal)
  if (radioTarget.length > 0) {
    currentLabel.value = radioTarget[0].name
    current.value = radioTarget[0].value
  }
  else {
    currentLabel.value = radioItems.value[0].name
    current.value = radioItems.value[0].value
  }
}

// 将所有流程操作的按钮隐藏
const hideAllOpterationButtons = () => {
  saveButtVisable.value = false
  submitButtVisable.value = false
  flowButtsVisable.value = false
  cancelButtVisable.value = false
  deleteButtVisable.value = false
  editButtVisable.value = false
}

// 根据审批状态显示对应的流程操作按钮
const showOperationButtonByStatus = () => {
  switch (status.value) {
    case '1':
      // 草稿箱:保存、提交按钮可见
      saveButtVisable.value = true
      submitButtVisable.value = true
      break

    case '2':
      // 待审批:同意、拒绝按钮可见
      flowButtsVisable.value = true
      break

    case '3':
      // 审批中:取消按钮可见
      cancelButtVisable.value = true
      break

    case '5':
      // 未通过:编辑 按钮可见
      editButtVisable.value = true
      break

    case '6':
      // 已取消:编辑 删除按钮可见
      editButtVisable.value = true
      deleteButtVisable.value = true
      break

    default:
      // 默认不显示所有的操作按钮
      hideAllOpterationButtons()
      break
  }
}

// 关闭
const resetForm = () => {
  sessionStorage.removeItem('grantNoticeTaskId')
  router.go(-1)
}

const selectFileTypeDialogRef = ref()
// 批量增加
const addEditableRow = () => {
  selectFileTypeDialogRef.value.initDialog()
}

const delFileRecords = () => {
  if (fileRecordSelected.value.length === 0) {
    ElMessage.warning('请至少选择一行')
    return
  }

  list.value = list.value.filter((item: any) => fileRecordSelected.value.includes(item) === false)
}

const handleSelectionChange = (e: any) => {
  fileRecordSelected.value = e
}

// 根据id查询详情
const detailById = async (id: string) => {
  await detailGrantNotice({ id }).then((res) => {
    if (res.code === 200) {
      grantNoticeForm.value = res.data
      list.value = res.data.fileList // 文件列表
      grantNoticeForm.value.distributor = res.data.distributor.split(',') //	发放人员Ids,用逗号隔开
      grantNoticeForm.value.distributorNames = res.data.distributorNames.split(',') // 发放人员名称集合,用逗号隔开
      if (grantNoticeForm.value.taskId === '') {
        grantNoticeForm.value.taskId = sessionStorage.getItem('grantNoticeTaskId')!
      }
    }
  })
}

// 保存至草稿箱--新建
const saveGrantNoticeForm = () => {
  grantNoticeForm.value.createTime = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss') // 创建时间改为提交时间

  const params = {
    ...grantNoticeForm.value,
    distributor: Array.isArray(grantNoticeForm.value.distributor) && grantNoticeForm.value.distributor.length ? grantNoticeForm.value.distributor.join(',') : grantNoticeForm.value.distributor, //	发放人员Ids,用逗号隔开
    distributorNames: Array.isArray(grantNoticeForm.value.distributorNames) && grantNoticeForm.value.distributorNames.length ? grantNoticeForm.value.distributorNames.join(',') : grantNoticeForm.value.distributorNames, // 发放人员名称集合,用逗号隔开
    fileList: list.value, // 文件列表
  }
  const loading = ElLoading.service({
    lock: true,
    text: '加载中...',
    background: 'rgba(255, 255, 255, 0.6)',
  })
  addGrantNotice(params).then((res) => {
    if (res.code === 200) {
      // 提示保存成功
      ElMessage.success('保存成功')
      // 设置返回的通知单id和通知单编号
      grantNoticeForm.value.formNo = res.data.formNo
      grantNoticeForm.value.id = res.data.id
      id.value = res.data.id

      type.value = 'update'
      status.value = '1' // 保存成功后进入草稿箱 为了不显示审批详情
    }
    else {
      // 提示失败信息
      ElMessage.error(`保存失败:${res.message}`)
    }
    loading.close()
  })
}

// 编辑草稿箱(不走流程审批)--草稿箱编辑
const updateGrantNoticeForm = () => {
  const params = {
    ...grantNoticeForm.value,
    distributor: Array.isArray(grantNoticeForm.value.distributor) && grantNoticeForm.value.distributor.length ? grantNoticeForm.value.distributor.join(',') : grantNoticeForm.value.distributor, //	发放人员Ids,用逗号隔开
    distributorNames: Array.isArray(grantNoticeForm.value.distributorNames) && grantNoticeForm.value.distributorNames.length ? grantNoticeForm.value.distributorNames.join(',') : grantNoticeForm.value.distributorNames, // 发放人员名称集合,用逗号隔开
    fileList: list.value, // 文件列表
  }
  const loading = ElLoading.service({
    lock: true,
    text: '加载中...',
    background: 'rgba(255, 255, 255, 0.6)',
  })
  updateDraftNotice(params).then((res) => {
    if (res.code === 200) {
      // 提示保存成功
      ElMessage.success('保存成功')
    }
    else {
      // 提示失败信息
      ElMessage.error(`保存失败:${res.message}`)
    }
    loading.close()
  })
}

// 编辑按钮点击事件处理函数
const editClickedHandler = () => {
  type.value = 'update'
  title.value = '文件发放通知单(编辑)'

  // 隐藏编辑按钮 显示提交按钮
  editButtVisable.value = false
  submitButtVisable.value = true
}

// 新建时保存后的处理 获取返回的id
const saveButtonHandler = async () => {
  if (!grantNoticeRef) { return }

  if (list.value.length === 0) {
    ElMessage.warning('文件列表不能为空')
    return
  }

  await grantNoticeRef.value.validate((valid: boolean) => {
    if (valid === true) {
      ElMessageBox.confirm(
        '确认保存吗?',
        '提示',
        {
          confirmButtonText: '确认',
          cancelButtonText: '取消',
          type: 'warning',
        },
      ).then(() => {
        if (type.value === 'create') {
          saveGrantNoticeForm()
        }
        else if (type.value === 'update') {
          updateGrantNoticeForm()
        }
      })
    }
  })
}

// 封装请求修改发放文件状态函数
function updateFileStatus(id: string, type: string) {
  return new Promise((resolve, reject) => {
    grantStatusUpdate({ id, type }).then((res) => {
      if (res.code === 200) {
        resolve(null)
      }
    })
  })
}

// 提交按钮
const submitButtonHandler = async () => {
  if (grantNoticeForm.value === null || grantNoticeForm.value.processId === undefined || grantNoticeForm.value.processId === '') {
    // 流程id为空 表示还未进入流程中 直接提交
    ElMessageBox.confirm(`是否提交文件发放通知单 ${grantNoticeForm.value.formNo}`, '提示', {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }).then(() => {
      const loading = ElLoading.service({
        lock: true,
        text: '加载中...',
        background: 'rgba(255, 255, 255, 0.6)',
      })
      submitGrantNotice({
        formId: flowFormId,
        id: grantNoticeForm.value.id,
      }).then((res) => {
        if (res.code === 200) {
          ElMessage.success('提交成功')
          updateFileStatus(id.value, '1').then(() => {
            loading.close()
          })
          type.value = 'detail'
          hideAllOpterationButtons()
        }
      })
    })
  }
  else {
    // 之前已经在流程中的表单 保存提交
    await grantNoticeRef.value.validate((valid: boolean) => {
      if (valid === true) {
        const loading = ElLoading.service({
          lock: true,
          text: '加载中...',
          background: 'rgba(255, 255, 255, 0.6)',
        })
        const params = {
          ...grantNoticeForm.value,
          distributor: Array.isArray(grantNoticeForm.value.distributor) && grantNoticeForm.value.distributor.length ? grantNoticeForm.value.distributor.join(',') : grantNoticeForm.value.distributor, //	发放人员Ids,用逗号隔开
          distributorNames: Array.isArray(grantNoticeForm.value.distributorNames) && grantNoticeForm.value.distributorNames.length ? grantNoticeForm.value.distributorNames.join(',') : grantNoticeForm.value.distributorNames, // 发放人员名称集合,用逗号隔开
          fileList: list.value, // 文件列表
        }
        failUpdateGrantNotice(params).then((res) => {
          if (res.code === 200) {
          // 提示保存成功
            ElMessage.success('保存成功')
            updateFileStatus(id.value, '1').then(() => {
              loading.close()
            })
            type.value = 'detail'
            hideAllOpterationButtons()
          }
          else {
          // 提示失败信息
            ElMessage.error(`保存失败:${res.message}`)
          }
          loading.close()
        })
      }
    })
  }
}
// ------------------------------------------审批-------------------------------------------
// 流程审批-同意
const approvalAgreeHandler = () => {
  apprDial.value.initDialog('agree', grantNoticeForm.value.id, grantNoticeForm.value.taskId || route.query.taskId, '')
}

// 流程审批-拒绝
const approvalRefuseHandler = () => {
  apprDial.value.initDialog('refuse', grantNoticeForm.value.id, grantNoticeForm.value.taskId || route.query.taskId, '')
}

// 取消(撤回审批单)
const revokeClickedHandler = () => {
  const params = {
    processInstanceId: route.query.processId!,
    comments: '',
    id: id.value,
  }
  ElMessageBox.confirm(
    '确认取消该审批吗?',
    '提示',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    },
  )
    .then(() => {
      const loading = ElLoading.service({
        lock: true,
        text: '加载中...',
        background: 'rgba(255, 255, 255, 0.6)',
      })
      cancelApproval(params).then((res) => {
        updateFileStatus(id.value, '2').then(() => {
          loading.close()
          ElMessage({
            type: 'success',
            message: '已取消',
          })
          cancelButtVisable.value = false
        }).catch(() => {
          loading.close()
          ElMessage.warning('文件发放状态修改失败!请联系管理员!')
        })
      })
    })
}

// 删除(只有已取消的可以在详情中删除)
const deleteClickedHandler = () => {
  ElMessageBox.confirm(
    `确认删除文件发放通知单 ${grantNoticeForm.value.formNo} 吗?`,
    '提示',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    },
  ).then(() => {
    revokeDelete({ id: grantNoticeForm.value.id, taskId: grantNoticeForm.value.taskId }).then((res) => {
      if (res.code === 200) {
        ElMessage.success('删除成功')
        resetForm()
      }
      else {
        ElMessage.error(`删除失败:${res.message}`)
      }
    })
  })
}

// 流程操作之后刷新
const approvalSuccessHandler = (type: string) => {
  if (type === 'agree' || type === 'refuse') {
    flowButtsVisable.value = false
  }
  else if (type === 'revoke') {
    cancelButtVisable.value = false
  }
}

// 拒绝
const refuseHandler = (param: any) => {
  const loading = ElLoading.service({
    lock: true,
    text: '加载中...',
    background: 'rgba(255, 255, 255, 0.6)',
  })
  refuseApproval(param).then((res) => {
    if (res.code === 200) {
      ElMessage.success('拒绝审批完成')
      updateFileStatus(id.value, '2').then(() => {
        loading.close()
      })
    }
    else {
      ElMessage.error(`拒绝审批失败:${res.message}`)
    }
    // 关闭弹窗
    apprDial.value.handleClose()

    flowButtsVisable.value = false
  })
}
// -------------------------------------字典-----------------------------------------------------------------

const getLabCodeDict = async () => {
  // 先从缓存中获取
  if (sessionStorage.getItem('bizLabCode') === null || sessionStorage.getItem('bizLabCode') === undefined) {
    // 缓存中没有则调用接口查询
    await getDictByCode('bizLabCode').then((res) => {
      if (res.code === 200) {
        labCodeDict.value = res.data
      }
    })
  }
  else {
    labCodeDict.value = JSON.parse(sessionStorage.getItem('bizLabCode')!)
  }
}

const getGroupCodeDict = async () => {
  // 先从缓存中获取
  if (sessionStorage.getItem('bizGroupCode') === null || sessionStorage.getItem('bizLabbizGroupCodeCode') === undefined) {
    // 缓存中没有则调用接口查询
    await getDictByCode('bizGroupCode').then((res) => {
      if (res.code === 200) {
        groupCodeDict.value = res.data
      }
    })
  }
  else {
    groupCodeDict.value = JSON.parse(sessionStorage.getItem('bizGroupCode')!)
  }
}
const staffUserList = ref<dictType[]>([]) // 计量人员

// 获取计量人员
const fetchStaffList = () => {
  // 计量人员
  getStaffList({
    staffNo: '', // 人员编号
    name: '', // 姓名
    deptId: '', // 所在部门
    limit: 999999,
    offset: 1,
  }).then((res: any) => {
    staffUserList.value = res.data.rows.map((item: { staffName: string;id: string }) => {
      return {
        name: item.staffName,
        id: item.id,
      }
    })
  })
}

// --------------------------------------------------------------------------------------------------

const initDict = async () => {
  fetchStaffList()
  await getLabCodeDict()
  await getGroupCodeDict()
}

const initDialog = (params: any) => {
  // 从路由中获取参数
  type.value = params.type
  id.value = params.id !== undefined ? params.id : ''
  status.value = params.status

  // 默认显示第一个tab内容
  current.value = radioItems.value[0].value
  currentLabel.value = radioItems.value[0].name

  switch (params.type) {
    case 'create' :
      title.value = '文件发放通知单(新增)'
      saveButtVisable.value = true
      submitButtVisable.value = true

      grantNoticeForm.value.createUserId = userInfo.id
      grantNoticeForm.value.createUserName = userInfo.name
      grantNoticeForm.value.createTime = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')
      grantNoticeForm.value.labCode = user.bizLabCode
      grantNoticeForm.value.labCodeName = user.labCodeName
      if ($route.query.noveltyId) {
        grantNoticeForm.value.noveltyId = $route.query.noveltyId as string
      }
      keyFieldsDisable.value = false

      break
    case 'update':
      title.value = '文件发放通知单(编辑)'

      detailById(id.value)

      // 判断显示哪些流程操作按钮
      showOperationButtonByStatus()
      keyFieldsDisable.value = true

      break
    case 'detail':
      title.value = '文件发放通知单'
      id.value = params.id

      detailById(id.value)

      // 查看详情时所有的操作按钮都隐藏
      showOperationButtonByStatus()
      keyFieldsDisable.value = true

      break
    default:
      title.value = ''
      keyFieldsDisable.value = true
      break
  }
}

const changeDistributor = (val: any) => {
  console.log(val)
  grantNoticeForm.value.distributorNames = []
  val.forEach((id: string) => {
    const index = staffUserList.value.findIndex(i => i.id === id)
    if (index !== -1) {
      grantNoticeForm.value.distributorNames.push(`${staffUserList.value[index].name}`)
    }
  })
  console.log(grantNoticeForm.value.distributorNames)
}

watch(() => status.value, (val) => {
  if (val === '1' || type.value === 'create') { // 草稿箱把审批详情删了
    if (radioItems.value[radioItems.value.length - 1].value === 'notice-approval') {
      radioItems.value.pop()
    }
  }
  else { // 非全部和草稿箱把审批详情加上
    if (radioItems.value[radioItems.value.length - 1].value !== 'notice-approval') {
      radioItems.value.push({ name: '审批详情', value: 'notice-approval' })
    }
  }
})

onMounted(() => {
  initDict()
  initDialog(route.query)
})
</script>

<template>
  <app-container>
    <detail-page :title="`${title}`">
      <template #btns>
        <el-button v-if="editButtVisable" type="primary" @click="editClickedHandler()">
          编辑
        </el-button>

        <template v-if="flowButtsVisable">
          <el-button type="primary" @click="approvalAgreeHandler">
            同意
          </el-button>
          <el-button type="danger" @click="approvalRefuseHandler">
            拒绝
          </el-button>
        </template>

        <el-button v-if="submitButtVisable" :disabled="id === ''" type="primary" @click="submitButtonHandler">
          {{ status === '5' || status === '6' ? '保存' : '提交' }}
        </el-button>
        <el-button v-if="saveButtVisable" type="primary" @click="saveButtonHandler">
          保存
        </el-button>

        <el-button v-if="deleteButtVisable" type="danger" @click="deleteClickedHandler">
          删除
        </el-button>
        <el-button v-if="cancelButtVisable" type="info" @click="revokeClickedHandler">
          取消
        </el-button>

        <el-button type="info" @click="resetForm()">
          关闭
        </el-button>
      </template>

      <el-radio-group v-model="currentLabel" @change="(val: any) => radioChangeHandler(val)">
        <el-radio-button v-for="item in radioItems" :key="item.value" :label="item.name" :disabled="id === ''" />
      </el-radio-group>
    </detail-page>
    <detail-block v-if="current === 'notice-basic'">
      <el-form ref="grantNoticeRef" :model="grantNoticeForm" :rules="grantNoticeRules" label-position="right" label-width="110px" border stripe>
        <el-row :gutter="24">
          <el-col :span="6">
            <el-form-item label="实验室" prop="labCode">
              <el-select v-model="grantNoticeForm.labCode" placeholder="请选择实验室" :disabled="type === 'detail'" style="width: 100%;">
                <el-option v-for="dict in labCodeDict" :key="dict.id" :label="dict.name" :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="部门" prop="groupCode">
              <el-select v-model="grantNoticeForm.groupCode" placeholder="请选择部门" :disabled="type === 'detail'" style="width: 100%;">
                <el-option v-for="dict in groupCodeDict" :key="dict.id" :label="dict.name" :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="文件编号">
              <el-input v-model="grantNoticeForm.formNo" placeholder="系统自动生成" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="文件名称">
              <el-input v-model="grantNoticeForm.formName" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="创建人" prop="createUserName">
              <el-input v-model="grantNoticeForm.createUserName" :disabled="true" />
              <el-input v-model="grantNoticeForm.createUserId" type="hidden" />
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="创建时间">
              <el-input v-model="grantNoticeForm.createTime" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="文件审批编号">
              <el-input v-model="grantNoticeForm.fileApprovalCodes" placeholder="请选择文件审批编号" disabled>
                <template v-if="type !== 'detail'" #append>
                  <el-button size="small" @click="confirmSelectFileType('5')">
                    选择
                  </el-button>
                </template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="发放人员" prop="distributor">
              <el-select v-model="grantNoticeForm.distributor" :disabled="type === 'detail'" multiple placeholder="请选择发放人员" style="width: 100%;" filterable @change="changeDistributor">
                <el-option
                  v-for="item in staffUserList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input
                v-model.trim="grantNoticeForm.remark" type="textarea" autosize
                placeholder="请输入备注"
                :disabled="type === 'detail'"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </detail-block>
    <detail-block v-if="current === 'notice-basic'" title="文件列表">
      <template v-if="type !== 'detail'" #btns>
        <el-button type="primary" @click="addEditableRow">
          批量增加
        </el-button>
        <el-button type="info" @click="delFileRecords">
          删除行
        </el-button>
      </template>
      <template #subhead>
        <div style="margin-left: 20px;">
          <span>文件总量</span>
          <span style="font-weight: 600; color: #de344a;margin-left: 10px;">{{ list.length }}</span>
        </div>
      </template>
      <el-table
        :data="list"
        border
        style="width: 100%;"
        @selection-change="handleSelectionChange"
      >
        <el-table-column v-if="type !== 'detail'" fixed="left" 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"
          :width="item.width"
          show-overflow-tooltip
          align="center"
        >
          <template #header>
            <span v-show="item.required" style="color: red;">*</span><span>{{ item.text }}</span>
          </template>
          <template #default="scope">
            <show-photo v-if="item.value === 'pdfUrl' && scope.row[item.value] !== '/'" :minio-file-name="scope.row[item.value]" />
            <el-input v-else-if="item.value === 'remark' && type !== 'detail'" v-model="scope.row[item.value]" :placeholder="type === 'detail' ? ' ' : '请输入备注'" type="textarea" autosize />
            <span v-else>{{ scope.row[item.value] }}</span>
          </template>
        </el-table-column>
      </el-table>
    </detail-block>

    <approval-dialog
      ref="apprDial"
      @on-success="approvalSuccessHandler"
      @on-refuse="refuseHandler"
    />

    <template v-if="current === 'notice-approval' && status !== '1'">
      <approval-record-table :process-id="grantNoticeForm.processId" />
    </template>

    <!-- 选择文件类别的弹窗 -->
    <select-file-type-dialog ref="selectFileTypeDialogRef" @confirm-select-file-type="confirmSelectFileType" />
    <!-- 选择要求、委托书及合同评审表组件 -->
    <select-customer-examine-list ref="selectCustomerExamineListRef" @confirm="(list: any) => confirmSelectFile(list, '3')" />
    <!-- 选择文件审批 -->
    <select-file-approval-dialog ref="selectFileApprovalDialogRef" @confirm="(list: any) => confirmSelectFile(list, '5')" />
    <!-- 选择测试校准检定方法 -->
    <select-method-dialog ref="selectMethodDialogRef" @confirm="(list: any, listParam: any) => confirmSelectFile(listParam, '2')" />
  </app-container>
</template>