Newer
Older
xc-business-system / src / components / buttonBox / useBridgeCount.ts
dutingting on 23 Dec 9 KB bug修复
import { getEquipmentList } from '@/api/equipment/info/book'
import { getResumeUnpackList } from '@/api/equipment/resume/unpack'
import { getStateMaintenanceList } from '@/api/equipment/stateMaintenance/stateMaintenance'
import { getResumeLendList } from '@/api/equipment/resume/lend'
import { getResumeBorrowList } from '@/api/equipment/resume/borrow'
import { getResumeErrorList } from '@/api/equipment/resume/error'
import { getStandardList } from '@/api/equipment/standard/book'
import { getCheckRecordList } from '@/api/equipment/standard/checkRecords'
import { getBuildList } from '@/api/equipment/standard/build'
import { getSourcePlanList } from '@/api/equipment/source/plan'
import { getResultConfirmList } from '@/api/equipment/source/resultConfirm'
import { getResultCompleteList } from '@/api/equipment/source/resultComplete'
import { getChangeList } from '@/api/equipment/source/change'
import { getStateMaintenanceList as getStandardStateMaintenanceList } from '@/api/equipment/standardStateMaintenance/stateMaintenance'
import { getCertificateList } from '@/api/business/taskMeasure/certificate'
import { getCertList } from '@/api/business/certManage/cert'
import { getChangeCertApplyList } from '@/api/business/certManage/changeApply'
import { getSupplementList } from '@/api/business/certManage/supplement'
import { getReviewList } from '@/api/business/subpackage/review'
import { getAgreementList } from '@/api/business/subpackage/agreement'
import { getInformList } from '@/api/business/subpackage/inform'
import { getFieldTestApprovalList } from '@/api/business/fieldTest/approve'
import { getOrderList } from '@/api/resource/order'
import { getFileApprovalFormList } from '@/api/resource/fileApproval'
import { getFileGrantNoticeList } from '@/api/resource/fileGrantNotice'
import { getFileChangeFormList } from '@/api/resource/fileChange'
import { getFileRecallArchiveList } from '@/api/resource/fileArchive'
import { getReviewReportList } from '@/api/resource/softwareReport'
import { getRevisionApplyList } from '@/api/resource/softwareRevision'
import { getMethodConfirmList } from '@/api/resource/fileConfirm'
import { getNoveltySearchList } from '@/api/resource/fileNovelty'
import {
  getResistanceRecordList,
  getVoltageRecordList,
} from '@/api/resource/environmentTest'
import { getSupplierInfoList } from '@/api/resource/supplier'
import { getServiceEvaluateList } from '@/api/resource/supplierService'
import { getEquipmentEvaluateList } from '@/api/resource/supplierEquipment'
import {
  getConsumableApplyList,
  getConsumableEvaluateList,
  getConsumableStoreList,
  getConsumableUseList,
  getGoodsCheckList,
} from '@/api/resource/supplierConsumable'
import { getCustomerInfoList } from '@/api/resource/customer'
import { getReviewNoticeList } from '@/api/resource/reviewNotice'
import { getFormList } from '@/api/resource/suggestForm'
import { getExamineList } from '@/api/resource/examine'
import { getCustomerContractList } from '@/api/resource/contract'
import { getSealNoteList } from '@/api/resource/seal'
import { getQualityReportList } from '@/api/quality/supervise/report'
import { getQualityNoReportList } from '@/api/quality/supervise/analysis'
import { getSceneList } from '@/api/quality/internal/scene'
import { getRegistrationList } from '@/api/quality/internal/registration'
import { getInspectList } from '@/api/quality/internal/inspect'
import { getDissatisfiedList } from '@/api/quality/internal/dissatisfied'
import { getReportList } from '@/api/quality/internal/report'
import { getReviewPlanList } from '@/api/quality/review/plan'
import { getReportList as getQualityReviewReportList } from '@/api/quality/review/report'
import { getQualityCorrectList } from '@/api/quality/correct/index'
import { getQualityPreventList } from '@/api/quality/prevent/index'

let totalToApproval = 0 // 待审批数据条数
let totalApproval = 0 // 审批中数据条数
let totalRefuse = 0 // 未通过数据条数

const apiMap = {
  // 设备与装置
  sbyzzsbtzgl: getEquipmentList, // 设备台账管理
  sbyzzsbqfsq: getStateMaintenanceList, // 设备启封申请
  sbyzzsbfcsq: getStateMaintenanceList, // 设备封存申请
  sbyzzsbjysq: getStateMaintenanceList, // 设备禁用申请
  sbyzzsbbfsq: getStateMaintenanceList, // 设备报废申请
  sbyzzbzzztzxx: getStandardList, // 标准装置台账信息
  sbyzzhcjlgl: getCheckRecordList, // 核查记录管理
  sbyzzjbgl: getBuildList, // 建标管理
  sbyzzghsq: getStandardStateMaintenanceList, // 更换申请
  sbyzzfcsq: getStandardStateMaintenanceList, // 复查申请
  sbyzzcxsq: getStandardStateMaintenanceList, // 撤销申请
  sbyzzsyjhgl: getSourcePlanList, // 溯源计划管理
  sbyzzsyjgqr: getResultConfirmList, // 溯源结果确认
  sbyzzsyjgwcqk: getResultCompleteList, // 溯源结果完成情况
  sbyzzsybggl: getChangeList, // 溯源变更管理
  sbyzzkxysgl: getResumeUnpackList, // 开箱验收管理
  sbyzzsbjcgl: getResumeLendList, // 设备借出管理
  sbyzzsbjygl: getResumeBorrowList, // 设备借用管理
  sbyzzycqkczgl: getResumeErrorList, // 异常情况处置管理

  // 计量检定业务
  jljdywzsspgl: getCertificateList, // 检定审批管理
  jljdywzsgl: getCertList, // 证书管理
  jljdywzsbchghsqd: getChangeCertApplyList, // 证书/报告补充或更换申请单
  jljdywzsbcj: getSupplementList, // 对编号为XXX的证书/报告的补充件
  // jljdywcsjzhgfbfml: getDirectoriesList // 测试、校准或检定合格分包方名录(新需求已经无审批)
  jljdywcsjzfbpsb: getReviewList, // 测试、校准或检定工作分包评审表
  jljdywcsjzfbxys: getAgreementList, // 测试、校准或检定工作分包协议书
  jljdywcsjzfbtzs: getInformList, // 测试、校准或检定工作分包通知书
  jljdywxccsjzsp: getFieldTestApprovalList, // 现场测试、校准或检定审批

  // 资源管理
  zyglsqwts: getOrderList, // 授权(代理)委托书审批
  zyglwjggsq: getFileChangeFormList, // 文件更改申请
  zyglwjsp: getFileApprovalFormList, // 文件审批
  zyglwjfftzd: getFileGrantNoticeList, // 文件发放通知单
  zyglwjshcddjb: getFileRecallArchiveList, // 文件作废登记表
  zyglcsjzjdffcxjlb: getNoveltySearchList, // 测试校准检定方法查新记录表
  zyglffqrdjb: getMethodConfirmList, // 方法确认登记表
  zyglrjxdsq: getRevisionApplyList, // 软件修订申请
  zyglrjpsbg: getReviewReportList, // 软件评审报告
  zyglsysjddzjl: getResistanceRecordList, // 实验室接地电阻记录
  zyglgzjgddyjl: getVoltageRecordList, // 工作间供电电压记录
  zyglupscsjl: getResistanceRecordList, // UPS蓄电池内阻测试记录
  zyglhggfml: getSupplierInfoList, // 合格供方名录
  zyglyhwzsqd: getConsumableApplyList, // 易耗物资申请单
  zyglwzysjl: getGoodsCheckList, // 物资验收记录
  zyglwzrkd: getConsumableStoreList, // 物资入库单
  zyglyhwzsyjl: getConsumableUseList, // 易耗物资使用记录
  zyglwbfwpjb: getServiceEvaluateList, // 外部服务评价表
  zyglyhwzgfpjb: getConsumableEvaluateList, // 易耗物资供方评价表
  zyglsbgfpjb: getEquipmentEvaluateList, // 设备供方评价表
  zyglwtfml: getCustomerInfoList, // 委托方名录
  zyglwtfyjdjb: getFormList, // 委托方意见登记表
  zyglyqwtsjhtpsb: getExamineList, // 要求、委托书及合同评审表
  zyglhtzxbgdjb: getCustomerContractList, // 合同执行变更登记表
  zyglyzsydj: getSealNoteList, // 印章使用登记
  zygljcjgfctzd: getReviewNoticeList, // 检测结果复查通知单审批流程

  // 质量活动
  zlhdzlbgspgl: getQualityReportList, // 质量监督报告
  zlhdbfhyqqkfxbg: getQualityNoReportList, // 不符合要求情况分析报告
  zlhdxcshjh: getSceneList, // 现场审核计划
  zlhdnbshjcb: getInspectList, // 内部审核检查表
  zhhdnbshgzdj: getRegistrationList, // 内部审核工作登记表
  zlhdnbshbfhxbg: getDissatisfiedList, // 内部审核不符合项报告
  zlhdnbshbg: getReportList, // 内部审核报告
  zlhdglpsjh: getReviewPlanList, // 管理评审计划
  zlhdglpsbg: getQualityReviewReportList, // 管理评审报告
  zlhdjzcscld: getQualityCorrectList, // 纠正措施处理单
  zlhdyfcscld: getQualityPreventList, // 预防措施处理单
} as any

/**
 * 公共方法:获取列表页的待审批、审批中、未通过数据条数
 * @param listQuery 列表请求参数
 * @returns Object 待审批、审批中、未通过数据条数
 */
export default async function useBridgeCount(listQuery: any) {
  console.log('调公共方法:获取列表页的待审批、审批中、未通过数据条数')
  return new Promise((resolve) => {
    const allRequest = [] as any // 所有的请求
    // 待审批
    const totalToApprovalAPI = apiMap[listQuery.formId]({
      ...listQuery,
      approvalStatus: '2',
    }).then((res: any) => {
      totalToApproval = res.data.total
      console.log('待审批数据条数', totalToApproval)
    })
    // 审批中
    const totalApprovalAPI = apiMap[listQuery.formId]({
      ...listQuery,
      approvalStatus: '3',
    }).then((res: any) => {
      totalApproval = res.data.total
      console.log('审批中数据条数', totalApproval)
    })
    // 未通过
    const totalRefuseAPI = apiMap[listQuery.formId]({
      ...listQuery,
      approvalStatus: '5',
    }).then((res: any) => {
      totalRefuse = res.data.total
      console.log('未通过数据条数', totalRefuse)
    })
    allRequest.push(totalToApprovalAPI, totalApprovalAPI, totalRefuseAPI)
    Promise.all(allRequest).then(() => {
      const result = {
        totalToApproval, // 待审批数据条数
        totalApproval, // 审批中数据条数
        totalRefuse, // 未通过数据条数
      }
      resolve(result)
    })
  })
}