p-honggang.li
2 天以前 349091f54dab47b15ca81613f02765490a2ce7d0
src/views/approveManage/tradeApproval/list.vue
@@ -14,9 +14,25 @@
            </el-select>
          </el-form-item>
          <el-form-item label="" class="col-17">
            <el-select v-model="query.unitProject" placeholder="请选择单位工程" clearable style="width: 100%">
              <el-option v-for="item in unitProjectOptions" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
<!--            <el-select v-model="query.unitProject" placeholder="请选择单位工程" clearable style="width: 100%">-->
<!--              <el-option v-for="item in unitProjectOptions" :key="item.value" :label="item.label" :value="item.value" />-->
<!--            </el-select>-->
            <el-tree-select
                ref="areaIdTreeRef"
                v-model="query.unitProject"
                :data="unitProjectOptions"
                placeholder="请选择单位工程"
                multiple
                collapse-tags
                collapse-tags-tooltip
                clearable
                :default-expand-all="true"
                :render-after-expand="false"
                show-checkbox
                style="width: 170px;"
                @change="importantAreaCh"
                @clear="importantAreaClear"
            />
          </el-form-item>
          <el-form-item label="交易状态" class="col-30">
            <el-select v-model="query.status" placeholder="全部" style="width: 100%">
@@ -57,12 +73,54 @@
        <!-- 第三行:操作按钮(右对齐) -->
        <div class="form-row actions">
          <el-form-item class="row-actions">
            <el-button type="primary" @click="handleSearch" :icon="Search">查询</el-button>
            <el-button @click="reset" :icon="Refresh">重置</el-button>
            <el-button type="primary" @click="handleSearch" icon="Search">查询</el-button>
            <el-button @click="reset" icon="Refresh">重置</el-button>
          </el-form-item>
        </div>
      </el-form>
    </el-card>
    <div class="buttonDiv">
      <el-row>
        <el-col :span="6" style="margin-top: 10px"> </el-col>
        <el-col :span="18" align="right" style="margin-top: 10px">
          <div class="btnBox">
            <div
                class="btnDiv"
                :class="{ btnDivClass: workFlowStatus.btnClassShow == 'trade_point0' }"
                @click="btnClick('0','trade_point')"
            >
              <span class="numjx">积分待办</span>
<!--              <span>{{ workFlowStatus.tradePointDealData }}</span>-->
            </div>
            <div
                class="btnDiv"
                :class="{ btnDivClass: workFlowStatus.btnClassShow == 'trade_point1' }"
                @click="btnClick('1','trade_point')"
            >
              <span class="numjx">积分已办</span>
<!--              <span>{{ workFlowStatus.completedData }}</span>-->
            </div>
            <div
                class="btnDiv"
                :class="{ btnDivClass: workFlowStatus.btnClassShow == 'trade_agreement0' }"
                @click="btnClick('0','trade_agreement')"
            >
              <span class="numjx">协议待办</span>
<!--              <span>{{ workFlowStatus.dealwithData }}</span>-->
            </div>
            <div
                class="btnDiv"
                :class="{ btnDivClass: workFlowStatus.btnClassShow == 'trade_agreement1' }"
                @click="btnClick('1','trade_agreement')"
            >
              <span class="numjx">协议已办</span>
<!--              <span>{{ workFlowStatus.completedData }}</span>-->
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
    <!-- 订单列表区域 -->
    <el-card class="mt15" shadow="never">
@@ -220,6 +278,16 @@
                          >
                            授权
                          </el-button>
                          <el-button
                              v-else-if="action.type === ActionType.WAIT_APPROVAL_AUTHORIZE"
                              type="primary"
                              link
                              size="small"
                              @click="handleAction(action, row.parentOrder)"
                          >
                            审批
                          </el-button>
                        </template>
                      </div>
                    </div>
@@ -246,35 +314,33 @@
    </el-card>
    
    <!-- 订单状态对话框 -->
    <ProductOrderStatusDialog
      v-model="orderStatusDialogVisible"
      :order-id="currentOrderId"
    />
<!--    <ProductOrderStatusDialog -->
<!--      v-model="orderStatusDialogVisible" -->
<!--      :order-id="currentOrderId" -->
<!--    />-->
  </div>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import { Search, Refresh } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import { fetchApprovalPage, fetchApprovalPageWithProductConditions } from '@/api/approvalManage'
import orderApi from '@/api/orderApi'
import productApi from '@/api/productApi'
import { authorizeApproval, fetchApprovalByOrderId } from '@/api/approvalManage'
import { useUserInfo } from '@/stores/modules/userInfo'
import ProductOrderStatusDialog from '@/views/productManage/productOrderStatusDialog/index.vue'
import { OrderWorkflowController, OrderStatus, ActionType, PageType, StatusMapper } from '@/utils/orderWorkflow'
import { queryUserDetail } from '@/api/userInfo'
const router = useRouter()
const userStore = useUserInfo()
const areaIdTreeRef=ref()
// 状态选项(更新为新的工作流程状态)
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' },
@@ -290,9 +356,10 @@
const query = reactive({
  productName: '',
  industry: '',
  unitProject: '',
  unitProject: [],
  productType: '',
  productSubType: '',
  importantDistrictIdList: [],
  orderNo: '',
  status: '',
  dateRange: [],
@@ -307,6 +374,12 @@
// 订单状态对话框相关
const orderStatusDialogVisible = ref(false)
const currentOrderId = ref<string>('')
const workFlowStatus = reactive<any>({
  btnClassShow: 'trade_point0',
  workFlowType: 0,
  businessType: 'trade_point' // trade_point
})
// 使用工作流程控制器的状态映射
const statusUiToServer: Record<string, string> = {
@@ -323,6 +396,7 @@
  [OrderStatus.WAIT_CONFIRM]: 'WAIT_CONFIRM',
  [OrderStatus.COMPLETED]: 'COMPLETED',
  [OrderStatus.EVALUATED]: 'EVALUATED',
  [OrderStatus.WAIT_APPROVAL_AUTHORIZE]: 'WAIT_APPROVAL_AUTHORIZE'
}
const formatDateTime = (val?: string) => {
@@ -338,6 +412,24 @@
  if (/(协议|agreement)/i.test(s)) return 'agreement'
  if (/(免费|free)/i.test(s)) return 'free'
  return 'currency'
}
const importantAreaCh=()=>{
  let checkedKeys = areaIdTreeRef.value!.getCheckedNodes(false, true)
  if(checkedKeys&&checkedKeys.length>0&& query.unitProject.length>0){
    query.importantDistrictIdList=[]
    checkedKeys.forEach((item:any)=>{
      if(item.children&&item.children.length>0){
        query.importantDistrictIdList.push(item.value)
      }
    })
  }
}
const importantAreaClear=()=>{
  query.unitProject = []
  query.importantDistrictIdList = []
  areaIdTreeRef.value.setCheckedKeys([])
}
// 获取行业领域选项
@@ -379,14 +471,40 @@
  try {
    const res = await productApi.getCategoryByParent({ parentId: industryCode })
    if (res?.code === 200 && res.data) {
      unitProjectOptions.value = res.data.map((item: any) => ({
        label: item.name,
        value: item.id
      }))
      unitProjectOptions.value = handleIndustryData(res.data)
    }
  } catch (error) {
    console.error('获取单位工程选项失败:', error)
    unitProjectOptions.value = []
  }
}
const handleIndustryData=(list:any)=>{
  if(list&& list.length>0){
    let data=list.map((item:any)=>{
      return {
        label:item.name,
        value:item.id,
        parentId:item.parentId,
        parentName:item.parentName,
        children:item.childrenList?handleIndustryChildData(item,item.childrenList):[]
      }
    })
    return data
  }
}
const handleIndustryChildData=(parentItem:any,childList:any)=>{
  if(childList&& childList.length>0){
    let data=childList.map((item:any)=>{
      return {
        parentId:parentItem.id,
        parentName:parentItem.name,
        label:item.name,
        value:item.id,
        children:item.childrenList?handleIndustryChildData(item,item.childrenList):[]
      }
    })
    return data
  }
}
@@ -431,6 +549,7 @@
  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',
@@ -524,6 +643,11 @@
    pageSize: page.size,
    productName: query.productName || undefined,
    orderId: query.orderNo || undefined,
    userId: userStore.getUserId,
    unitId: userStore.getUnitId,
    workFlowType: workFlowStatus.workFlowType,
    businessType: workFlowStatus.businessType,
    departmentId: userStore.getDepartmentId
  }
  if (query.status) payload.orderStatus = statusUiToServer[query.status]
  if (Array.isArray(query.dateRange) && query.dateRange.length === 2) {
@@ -533,12 +657,13 @@
  
  // 添加产品条件查询
  if (query.industry) payload.industryId = query.industry
  if (query.unitProject) payload.unitProjectId = query.unitProject
  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
  // 根据是否有产品条件选择不同的API
  const hasProductConditions = query.industry || query.unitProject || query.productType || query.productSubType
  const hasProductConditions = query.industry || query.unitProject.length > 0 || query.productType || query.productSubType
  const apiMethod = hasProductConditions ? fetchApprovalPageWithProductConditions : fetchApprovalPage
  
  const res = (await apiMethod(payload)) as any
@@ -560,7 +685,8 @@
      status: uiStatus,
      statusName: order.orderStatus || '',
      orderStatus: StatusMapper.toUIStatus(order.orderStatus), // 转换为标准状态枚举
      workFlowId: order.workflowId || ''
      workFlowId: order.workflowId || '',
      taskId: order.taskId || ''
    }
    const subOrders: any[] = Array.isArray(order?.orderDetails)
@@ -589,6 +715,15 @@
  })
  orderList.value = flatData
}
const btnClick = (workFlowType?: any,businessType?: any) => {
  workFlowStatus.btnClassShow = businessType+workFlowType
  workFlowStatus.workFlowType = workFlowType
  workFlowStatus.businessType = businessType
  // 获取list数据
  handleSearch()
}
// 重置
@@ -643,6 +778,7 @@
    case ActionType.TRACK:
      toTrack(order)
      break
    case ActionType.WAIT_APPROVAL_AUTHORIZE:
    case ActionType.AUTHORIZE:
      toAuthorize(order)
      break
@@ -653,7 +789,7 @@
// 授权:跳转到授权页面
const toAuthorize = (row: any) => {
  router.push({ name: 'tradeAuthorization', params: { id: row.id } })
  router.push({ name: 'tradeAuthorization', params: { id: row.id, taskId: row.taskId } })
}
onMounted(async ()=>{
@@ -1075,6 +1211,69 @@
  padding-bottom: 0 !important;
  border-bottom: 2px solid #e4e7ed; // 显示分隔边框线
}
.buttonDiv {
  width: 100%;
  height: 33px;
}
.btnBox {
  width: 505px;
  height: 33px;
  //background-color: pink;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  .btnDivClass {
    background-color: #2f4589 !important;
    color: #fff;
  }
  .btnDiv {
    width: 120px;
    height: 33px;
    border-radius: 5px;
    border: 1px solid #ebeef5;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    //color: #919399;
    cursor: pointer;
    background-color: #FFFFFF;
    span :nth-child(2) {
      color: #f04844;
    }
  }
  .elFormDiv {
    width: 100%;
    height: 100px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    .searchFormDiv {
      display: flex;
      flex-direction: row;
      align-items: center;
    }
    .searchBtnDiv {
      //width: 20%;
      height: 100%;
      display: flex;
      flex-direction: row;
      align-items: center;
    }
  }
}
.numjx {
  padding-right: 5px;
}
</style>