Bang Hu
昨天 8a709ba6db50831048f9c3e2452ea6dc6c3de36f
src/views/approveManage/tradeApproval/list.vue
@@ -91,7 +91,7 @@
                @click="btnClick('0','trade_point')"
            >
              <span class="numjx">积分待办</span>
<!--              <span>{{ workFlowStatus.tradePointDealData }}</span>-->
              <span class="count-num">({{ workFlowStatus.tradePointDealData }})</span>
            </div>
            <div
                class="btnDiv"
@@ -99,7 +99,7 @@
                @click="btnClick('1','trade_point')"
            >
              <span class="numjx">积分已办</span>
<!--              <span>{{ workFlowStatus.completedData }}</span>-->
              <span class="count-num">({{ workFlowStatus.tradePointCompletedData }})</span>
            </div>
            <div
                class="btnDiv"
@@ -107,7 +107,7 @@
                @click="btnClick('0','trade_agreement')"
            >
              <span class="numjx">协议待办</span>
<!--              <span>{{ workFlowStatus.dealwithData }}</span>-->
              <span class="count-num">({{ workFlowStatus.tradeAgreementDealData }})</span>
            </div>
            <div
                class="btnDiv"
@@ -115,7 +115,7 @@
                @click="btnClick('1','trade_agreement')"
            >
              <span class="numjx">协议已办</span>
<!--              <span>{{ workFlowStatus.completedData }}</span>-->
              <span class="count-num">({{ workFlowStatus.tradeAgreementCompletedData }})</span>
            </div>
          </div>
        </el-col>
@@ -199,9 +199,9 @@
            </el-table-column>
          </el-table-column>
          
          <!-- 总价 -->
          <el-table-column label="总价" align="center">
            <el-table-column label="单价" prop="unitPrice" width="90">
          <!-- 单价(与“期限(年)”保持相同的父子表头结构) -->
          <el-table-column label="单价" align="center" width="80">
            <el-table-column label="" prop="unitPrice" width="80">
              <template #default="{ row }">
                <div v-if="row.isSpacer" class="spacer-cell"></div>
                <div v-else-if="!row.isMainOrder" class="price-info">
@@ -220,7 +220,11 @@
                </div>
              </template>
            </el-table-column>
            <el-table-column label="数量" prop="quantity" width="50">
          </el-table-column>
          <!-- 数量(与“期限(年)”保持相同的父子表头结构) -->
          <el-table-column label="数量" align="center" width="80">
            <el-table-column label="" prop="quantity" width="80" align="center">
              <template #default="{ row }">
                <div v-if="row.isSpacer" class="spacer-cell"></div>
                <div v-else-if="!row.isMainOrder" class="quantity">{{ row.quantity }}</div>
@@ -230,7 +234,7 @@
          
          <!-- 期限(年) -->
          <el-table-column label="期限(年)" align="center" width="80">
            <el-table-column label="" prop="period" width="80">
            <el-table-column label="" prop="period" width="80" align="center">
              <template #default="{ row }">
                <div v-if="row.isSpacer" class="spacer-cell"></div>
                <div v-else-if="!row.isMainOrder" class="period-info">
@@ -333,14 +337,13 @@
const router = useRouter()
const userStore = useUserInfo()
const areaIdTreeRef=ref()
const areaIdTreeRef=ref<any>()
// 状态选项(更新为新的工作流程状态)
const statusOptions = [
  { label: '全部', value: '' },
  { label: '待上传文件', value: 'WAIT_UPLOAD' },
  { label: '待授权', value: 'WAIT_AUTHORIZE' },
  { label: '待审批授权', value: 'WAIT_APPROVAL_AUTHORIZE' },
  { label: '待交易确认', value: 'WAIT_CONFIRM' },
  { label: '已完成', value: 'COMPLETED' },
  { label: '已评价', value: 'EVALUATED' },
@@ -356,13 +359,13 @@
const query = reactive({
  productName: '',
  industry: '',
  unitProject: [],
  unitProject: [] as string[],
  productType: '',
  productSubType: '',
  importantDistrictIdList: [],
  importantDistrictIdList: [] as string[],
  orderNo: '',
  status: '',
  dateRange: [],
  dateRange: [] as string[],
})
// 分页信息
@@ -378,7 +381,12 @@
const workFlowStatus = reactive<any>({
  btnClassShow: 'trade_point0',
  workFlowType: 0,
  businessType: 'trade_point' // trade_point
  businessType: 'trade_point', // trade_point
  // 订单数量统计
  tradePointDealData: 1,    // 积分待办数量 - 临时测试数据
  tradePointCompletedData: 0, // 积分已办数量
  tradeAgreementDealData: 2,  // 协议待办数量 - 临时测试数据
  tradeAgreementCompletedData: 0 // 协议已办数量
})
// 使用工作流程控制器的状态映射
@@ -396,7 +404,7 @@
  [OrderStatus.WAIT_CONFIRM]: 'WAIT_CONFIRM',
  [OrderStatus.COMPLETED]: 'COMPLETED',
  [OrderStatus.EVALUATED]: 'EVALUATED',
  [OrderStatus.WAIT_APPROVAL_AUTHORIZE]: 'WAIT_APPROVAL_AUTHORIZE'
  [OrderStatus.CANCELED]: 'CANCELED'
}
const formatDateTime = (val?: string) => {
@@ -417,7 +425,7 @@
const importantAreaCh=()=>{
  let checkedKeys = areaIdTreeRef.value!.getCheckedNodes(false, true)
  if(checkedKeys&&checkedKeys.length>0&& query.unitProject.length>0){
    query.importantDistrictIdList=[]
    query.importantDistrictIdList=[] as string[]
    checkedKeys.forEach((item:any)=>{
      if(item.children&&item.children.length>0){
        query.importantDistrictIdList.push(item.value)
@@ -427,8 +435,8 @@
}
const importantAreaClear=()=>{
  query.unitProject = []
  query.importantDistrictIdList = []
  query.unitProject = [] as string[]
  query.importantDistrictIdList = [] as string[]
  areaIdTreeRef.value.setCheckedKeys([])
}
@@ -531,7 +539,7 @@
// 处理行业领域变化
const handleIndustryChange = async (value: string) => {
  // 清空单位工程选择
  query.unitProject = ''
  query.unitProject = [] as string[]
  // 获取对应的单位工程选项
  await getUnitProjectOptions(value)
}
@@ -549,10 +557,10 @@
  const statusMap: Record<string, 'warning' | 'danger' | 'success' | 'info'> = {
    WAIT_UPLOAD: 'warning',
    WAIT_AUTHORIZE: 'warning',
    WAIT_APPROVAL_AUTHORIZE: 'warning',
    WAIT_CONFIRM: 'warning',
    COMPLETED: 'success',
    EVALUATED: 'success',
    CANCELED: 'danger'
  }
  return statusMap[status] || 'info'
}
@@ -636,6 +644,116 @@
  }
}
// 根据当前选中的按钮类型更新对应的数量
const updateButtonCount = (total: number) => {
  const { workFlowType, businessType } = workFlowStatus
  console.log('updateButtonCount 被调用:', {
    total: total,
    workFlowType: workFlowType,
    businessType: businessType,
    currentButton: `${businessType}${workFlowType}`
  })
  if (businessType === 'trade_point') {
    if (workFlowType == 0) { // 使用 == 而不是 === 来处理字符串和数字的比较
      // 积分待办
      workFlowStatus.tradePointDealData = total
      console.log('更新积分待办数量为:', total)
    } else if (workFlowType == 1) { // 使用 == 而不是 === 来处理字符串和数字的比较
      // 积分已办
      workFlowStatus.tradePointCompletedData = total
      console.log('更新积分已办数量为:', total)
    }
  } else if (businessType === 'trade_agreement') {
    if (workFlowType == 0) { // 使用 == 而不是 === 来处理字符串和数字的比较
      // 协议待办
      workFlowStatus.tradeAgreementDealData = total
      console.log('更新协议待办数量为:', total)
    } else if (workFlowType == 1) { // 使用 == 而不是 === 来处理字符串和数字的比较
      // 协议已办
      workFlowStatus.tradeAgreementCompletedData = total
      console.log('更新协议已办数量为:', total)
    }
  }
  console.log('更新后的按钮数量:', {
    tradePointDealData: workFlowStatus.tradePointDealData,
    tradePointCompletedData: workFlowStatus.tradePointCompletedData,
    tradeAgreementDealData: workFlowStatus.tradeAgreementDealData,
    tradeAgreementCompletedData: workFlowStatus.tradeAgreementCompletedData
  })
}
// 获取订单统计数据(用于初始化和条件查询后更新)
const getOrderCounts = async () => {
  try {
    // 获取统计数据时使用当前的搜索条件,但不包括状态筛选
    const getCountForType = async (workFlowType: number, businessType: string) => {
      const payload: any = {
        pageNum: 1,
        pageSize: 10, // 与handleSearch保持一致
        userId: userStore.getUserId,
        unitId: userStore.getUnitId,
        workFlowType: workFlowType,
        businessType: businessType,
        departmentId: userStore.getDepartmentId
      }
      // 添加产品条件查询(与handleSearch完全保持一致)
      if (query.industry) payload.industryId = query.industry
      if (query.unitProject.length > 0) payload.unitProjectId = query.unitProject
      if (query.importantDistrictIdList.length > 0) payload.importantDistrictId = query.importantDistrictIdList
      if (query.productType) payload.productTypeId = query.productType
      if (query.productSubType) payload.productSubTypeId = query.productSubType
      if (query.productName) payload.productName = query.productName
      if (query.orderNo) payload.orderId = query.orderNo
      // 包含状态筛选条件,确保统计数据反映当前的筛选条件
      if (query.status) payload.orderStatus = statusUiToServer[query.status]
      if (Array.isArray(query.dateRange) && query.dateRange.length === 2) {
        payload.applyTimeStart = query.dateRange[0]
        payload.applyTimeEnd = query.dateRange[1]
      }
      // 根据是否有产品条件选择不同的API(与handleSearch保持一致)
      const hasProductConditions = query.industry || query.unitProject.length > 0 || query.productType || query.productSubType
      const apiMethod = hasProductConditions ? fetchApprovalPageWithProductConditions : fetchApprovalPage
      console.log(`统计数据-${businessType}${workFlowType}查询参数:`, payload)
      const res = await apiMethod(payload) as any
      console.log(`统计数据-${businessType}${workFlowType}API响应:`, res)
      return res?.data?.total || 0
    }
    // 并行获取所有统计数据
    const [pointDealCount, pointCompletedCount, agreementDealCount, agreementCompletedCount] = await Promise.all([
      getCountForType(0, 'trade_point'),    // 积分待办
      getCountForType(1, 'trade_point'),    // 积分已办
      getCountForType(0, 'trade_agreement'), // 协议待办
      getCountForType(1, 'trade_agreement')  // 协议已办
    ])
    workFlowStatus.tradePointDealData = pointDealCount
    workFlowStatus.tradePointCompletedData = pointCompletedCount
    workFlowStatus.tradeAgreementDealData = agreementDealCount
    workFlowStatus.tradeAgreementCompletedData = agreementCompletedCount
    console.log('更新后的统计数据:', {
      tradePointDealData: workFlowStatus.tradePointDealData,
      tradePointCompletedData: workFlowStatus.tradePointCompletedData,
      tradeAgreementDealData: workFlowStatus.tradeAgreementDealData,
      tradeAgreementCompletedData: workFlowStatus.tradeAgreementCompletedData
    })
  } catch (error) {
    console.error('获取统计数据失败:', error)
    // 如果获取失败,使用默认值
    workFlowStatus.tradePointDealData = 0
    workFlowStatus.tradePointCompletedData = 0
    workFlowStatus.tradeAgreementDealData = 0
    workFlowStatus.tradeAgreementCompletedData = 0
  }
}
// 搜索处理(接入真实后端)
const handleSearch = async () => {
  const payload: any = {
@@ -670,6 +788,12 @@
  const pageData = res?.data
  const list: any[] = Array.isArray(pageData?.list) ? pageData.list : []
  page.total = Number(pageData?.total || 0)
  console.log('搜索参数:', payload)
  console.log('API响应:', res)
  console.log('列表数据:', list)
  console.log('总记录数:', page.total)
  console.log('当前页记录数:', list.length)
  const flatData: any[] = []
@@ -715,11 +839,14 @@
  })
  orderList.value = flatData
  // 条件查询后,重新获取所有4种类型的订单总数并更新按钮显示
  await getOrderCounts()
}
const btnClick = (workFlowType?: any,businessType?: any) => {
  workFlowStatus.btnClassShow = businessType+workFlowType
  workFlowStatus.workFlowType = workFlowType
  workFlowStatus.workFlowType = Number(workFlowType) // 确保转换为数字类型
  workFlowStatus.businessType = businessType
  // 获取list数据
@@ -731,7 +858,7 @@
  Object.assign(query, {
    productName: '',
    industry: '',
    unitProject: '',
    unitProject: [],
    productType: '',
    productSubType: '',
    orderNo: '',
@@ -815,6 +942,9 @@
    getIndustryOptions(),
    getProductTypeOptions()
  ])
  // 获取初始统计数据
  await getOrderCounts()
  
  // 执行搜索
  handleSearch()
@@ -1018,6 +1148,7 @@
.period-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  
@@ -1227,6 +1358,10 @@
  .btnDivClass {
    background-color: #2f4589 !important;
    color: #fff;
    .count-num {
      color: #fff !important;
    }
  }
  .btnDiv {
@@ -1243,6 +1378,15 @@
    cursor: pointer;
    background-color: #FFFFFF;
    .numjx {
      padding-right: 5px;
    }
    .count-num {
      color: #f04844;
      font-weight: 500;
    }
    span :nth-child(2) {
      color: #f04844;
    }