Bang Hu
1 天以前 8a709ba6db50831048f9c3e2452ea6dc6c3de36f
src/views/tradeManage/buyer/index.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%">
@@ -35,11 +51,11 @@
              <el-option v-for="item in productTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>
          <el-form-item label="" class="col-17">
            <el-select v-model="query.productSubType" placeholder="请选择产品类型子级" clearable style="width: 100%">
              <el-option v-for="item in productSubTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
            </el-select>
          </el-form-item>
<!--          <el-form-item label="" class="col-17">-->
<!--            <el-select v-model="query.productSubType" placeholder="请选择产品类型子级" clearable style="width: 100%">-->
<!--              <el-option v-for="item in productSubTypeOptions" :key="item.value" :label="item.label" :value="item.value" />-->
<!--            </el-select>-->
<!--          </el-form-item>-->
          <el-form-item label="申请时间" class="col-30">
            <el-date-picker
              v-model="query.dateRange"
@@ -57,8 +73,8 @@
        <!-- 第三行:操作按钮(右对齐) -->
        <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>
@@ -74,7 +90,7 @@
              <template #default="{ row }">
                <div v-if="row.isMainOrder" class="main-order-info">
                  <div class="order-header">
                    <div class="order-item">
                      <span class="label">申请时间:</span>
                      <span class="value">{{ row.applyTime }}</span>
@@ -103,7 +119,7 @@
              </template>
            </el-table-column>
          </el-table-column>
          <!-- 购买方式 -->
          <el-table-column label="购买方式" align="center">
            <el-table-column label="销售形式/账户数量" width="150">
@@ -137,39 +153,20 @@
              </template>
            </el-table-column>
          </el-table-column>
          <!-- 总价 -->
          <el-table-column label="总价" align="center">
            <el-table-column label="单价" prop="unitPrice" width="90">
              <template #default="{ row }">
                <div v-if="row.isSpacer" class="spacer-cell"></div>
                <div v-else-if="!row.isMainOrder" class="price-info">
                  <span v-if="row.priceType === 'points'" class="price-points">
                    积分 {{ row.unitPrice }}
                  </span>
                  <span v-else-if="row.priceType === 'currency'" class="price-currency">
                    货币 {{ row.unitPrice }}
                  </span>
                  <span v-else-if="row.priceType === 'agreement'" class="price-agreement">
                    协议
                  </span>
                  <span v-else-if="row.priceType === 'free'" class="price-free">
                    免费
                  </span>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="数量" prop="quantity" width="50">
          <!-- 数量 -->
          <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>
              </template>
            </el-table-column>
          </el-table-column>
          <!-- 期限(年) -->
          <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">
@@ -179,7 +176,7 @@
              </template>
            </el-table-column>
          </el-table-column>
          <!-- 操作 -->
          <el-table-column label="操作" align="center" width="120" class="operation-column">
            <el-table-column label="" width="120">
@@ -190,56 +187,56 @@
                    <div class="action-item">
                      <div class="action-buttons">
                        <template v-for="action in getAvailableActions(row.parentOrder)" :key="action.type">
                          <el-button
                          <el-button
                            v-if="action.type === ActionType.VIEW"
                            type="primary"
                            link
                            size="small"
                            type="primary"
                            link
                            size="small"
                            @click="handleAction(action, row.parentOrder)"
                          >
                            查看
                          </el-button>
                          <el-button
                          <el-button
                            v-else-if="action.type === ActionType.TRACK"
                            type="primary"
                            link
                            size="small"
                            type="primary"
                            link
                            size="small"
                            @click="handleAction(action, row.parentOrder)"
                          >
                            追踪
                          </el-button>
                          <el-button
                          <el-button
                            v-else-if="action.type === ActionType.UPLOAD_FILE"
                            type="primary"
                            link
                            size="small"
                            type="primary"
                            link
                            size="small"
                            @click="handleAction(action, row.parentOrder)"
                          >
                            提交文件
                          </el-button>
                          <el-button
                          <el-button
                            v-else-if="action.type === ActionType.CONFIRM_TRADE"
                            type="primary"
                            link
                            size="small"
                            type="primary"
                            link
                            size="small"
                            @click="handleAction(action, row.parentOrder)"
                          >
                            交易确认
                          </el-button>
                          <el-button
                            v-else-if="action.type === ActionType.EVALUATE"
                            type="primary"
                            link
                            size="small"
                          <el-button
                            v-else-if="action.type === ActionType.EVALUATE && row.parentOrder.isEvaluate === '未评价'"
                            type="primary"
                            link
                            size="small"
                            @click="handleAction(action, row.parentOrder)"
                          >
                            评价
                          </el-button>
                          <el-button
                          <el-button
                            v-else-if="action.type === ActionType.CANCEL_ORDER"
                            type="danger"
                            link
                            size="small"
                            type="danger"
                            link
                            size="small"
                            @click="handleAction(action, row.parentOrder)"
                          >
                            取消订单
@@ -268,11 +265,11 @@
        />
      </div>
    </el-card>
    <!-- 订单状态对话框 -->
    <!-- <ProductOrderStatusDialog
      v-model="orderStatusDialogVisible"
      :order-id="currentOrderId"
    <!-- <ProductOrderStatusDialog
      v-model="orderStatusDialogVisible"
      :order-id="currentOrderId"
    /> -->
  </div>
</template>
@@ -280,17 +277,17 @@
<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, ElMessageBox } from 'element-plus'
import orderApi from '@/api/orderApi'
import productApi from '@/api/productApi'
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 = [
@@ -309,12 +306,25 @@
const productSubTypeOptions = ref<any[]>([])
// 查询条件
const query = reactive({
type BuyerQuery = {
  productName: string
  industry: string
  unitProject: string[]
  productType: string
  productSubType: string
  importantDistrictIdList: string[]
  orderNo: string
  status: string
  dateRange: string[]
}
const query = reactive<BuyerQuery>({
  productName: '',
  industry: '',
  unitProject: '',
  unitProject: [],
  productType: '',
  productSubType: '',
  importantDistrictIdList: [],
  orderNo: '',
  status: '',
  dateRange: [],
@@ -345,6 +355,7 @@
  [OrderStatus.WAIT_CONFIRM]: 'WAIT_CONFIRM',
  [OrderStatus.COMPLETED]: 'COMPLETED',
  [OrderStatus.EVALUATED]: 'EVALUATED',
  [OrderStatus.CANCELED]: 'CANCELED'
}
const formatDateTime = (val?: string) => {
@@ -359,6 +370,25 @@
  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,7 +409,8 @@
// 获取产品类型选项
const getProductTypeOptions = async () => {
  try {
    const res = await productApi.getCategoryByParent({ parentCode: 'product_type' })
      // product_type
    const res = await productApi.getCategoryByParent({ parentCode: 'ProductTechnologyType' })
    if (res?.code === 200 && res.data) {
      productTypeOptions.value = res.data.map((item: any) => ({
        label: item.name,
@@ -400,14 +431,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
  }
}
@@ -434,7 +491,8 @@
// 处理行业领域变化
const handleIndustryChange = async (value: string) => {
  // 清空单位工程选择
  query.unitProject = ''
  query.unitProject = []
  query.importantDistrictIdList = []
  // 获取对应的单位工程选项
  await getUnitProjectOptions(value)
}
@@ -444,7 +502,7 @@
  // 清空产品子级选择
  query.productSubType = ''
  // 获取对应的产品子级选项
  await getProductSubTypeOptions(value)
 //  await getProductSubTypeOptions(value)
}
// 获取状态类型
@@ -455,6 +513,7 @@
    WAIT_CONFIRM: 'warning',
    COMPLETED: 'success',
    EVALUATED: 'success',
    CANCELED: 'danger'
  }
  return statusMap[status] || 'info'
}
@@ -477,7 +536,7 @@
    // 主订单行,合并所有列显示订单信息
    if (columnIndex === 0) { // 第一列,合并所有列
      return {
        colspan: 8, // 总共8列:订单信息2列 + 购买方式2列 + 总价2列 + 期限1列 + 操作1列
        colspan: 7, // 总共7列:订单信息2列 + 购买方式2列 + 数量1列 + 期限1列 + 操作1列
        rowspan: 1
      }
    } else {
@@ -509,7 +568,7 @@
          }
        }
      }
    } else if (columnIndex === 7) { // 操作列(第8列)
    } else if (columnIndex === 6) { // 操作列(第7列)
      // 找到当前子订单所属的主订单
      const parentOrder = row.parentOrder
      if (parentOrder && parentOrder.subOrders) {
@@ -540,6 +599,7 @@
// 搜索处理(接入真实后端)
const handleSearch = async () => {
  const filterEvaluated = query.status === 'EVALUATED'
  const payload: any = {
    pageNum: page.current,
    pageSize: page.size,
@@ -547,25 +607,32 @@
    orderId: query.orderNo || undefined,
    userId: userStore.getUserId ? userStore.getUserId : undefined,
  }
  if (query.status) payload.orderStatus = statusUiToServer[query.status]
  if (query.status) {
    payload.orderStatus = filterEvaluated ? OrderStatus.COMPLETED : statusUiToServer[query.status]
  }
  if (Array.isArray(query.dateRange) && query.dateRange.length === 2) {
    payload.applyTimeStart = query.dateRange[0]
    payload.applyTimeEnd = query.dateRange[1]
  }
  // 添加产品条件查询
  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 ? orderApi.getBuyerOrderPageWithProductConditions : orderApi.getBuyerOrderPage
  const res = (await apiMethod(payload)) as any
  const pageData = res?.data
  const list: any[] = Array.isArray(pageData?.list) ? pageData.list : []
  let list: any[] = Array.isArray(pageData?.list) ? pageData.list : []
  // 若筛选“已评价”,先以已完成查询,再在前端按已评价过滤
  if (filterEvaluated) {
    list = list.filter((order: any) => order?.isEvaluate === '已评价')
  }
  page.total = Number(pageData?.total || 0)
  const flatData: any[] = []
@@ -581,7 +648,8 @@
      status: uiStatus,
      statusName: order.orderStatus || '',
      orderStatus: StatusMapper.toUIStatus(order.orderStatus), // 转换为标准状态枚举
      workFlowId: order.workflowId || ''
      workFlowId: order.workflowId || '',
      isEvaluate: order.isEvaluate || ''
    }
    const subOrders: any[] = Array.isArray(order?.orderDetails)
      ? order.orderDetails.map((d: any, i: number) => ({
@@ -615,9 +683,10 @@
  Object.assign(query, {
    productName: '',
    industry: '',
    unitProject: '',
    unitProject: [],
    productType: '',
    productSubType: '',
    importantDistrictIdList: [],
    orderNo: '',
    status: '',
    dateRange: [],
@@ -690,9 +759,9 @@
      type: 'warning',
      confirmButtonClass: 'el-button--danger'
    })
    const res = await orderApi.cancelOrder(order.id)
    if (res && res.code === 200) {
      ElMessage.success('订单取消成功')
      handleSearch() // 刷新列表
@@ -724,13 +793,13 @@
      return
    }
  }
  // 获取初始选项数据
  await Promise.all([
    getIndustryOptions(),
    getProductTypeOptions()
  ])
  // 执行搜索
  handleSearch()
})
@@ -768,7 +837,7 @@
      border-bottom: 2px solid #e4e7ed; // 与分隔行一致的下边框
    }
  }
  // 调整表头高度
  tr:first-child {
    th {
@@ -785,18 +854,18 @@
.search-card {
  margin-bottom: 20px;
  .query-form {
    .form-row {
      display: flex;
      gap: 0;
      width: 100%;
      margin-bottom: 8px;
      &.actions {
        justify-content: flex-end;
      }
      .el-form-item { margin-right: 0 !important; }
      > .el-form-item { padding-right: 8px; }
      > .el-form-item:last-child { padding-right: 0; }
@@ -810,7 +879,7 @@
    .el-form-item {
      margin-bottom: 16px;
      margin-right: 20px;
      &:last-child {
        margin-right: 0;
      }
@@ -821,7 +890,7 @@
.table-container {
  position: relative;
  z-index: 1;
  .custom-table {
    // 表头第二行文字大小调整
    .el-table__header-wrapper {
@@ -834,7 +903,7 @@
        }
      }
    }
    // 确保表头所有行的文字大小一致
    .el-table__header {
      th {
@@ -844,23 +913,23 @@
        }
      }
    }
    .el-table {
      position: relative;
      z-index: 1;
      .main-order-row {
        background-color: #f8f9fa;
        font-weight: 600;
        td {
          border-bottom: 2px solid #e4e7ed;
        }
      }
      .sub-order-row {
        background-color: #ffffff;
        td {
          border-bottom: 1px solid #ebeef5;
        }
@@ -886,14 +955,14 @@
      gap: 8px;
      flex-shrink: 0;
      flex: 1;
      .label {
        color: #909399;
        font-size: 12px;
        min-width: 60px;
        flex-shrink: 0;
      }
      .value {
        color: #303133;
        font-size: 12px;
@@ -908,22 +977,22 @@
.price-info {
  font-size: 12px;
  .price-points {
    color: #e6a23c;
    font-weight: 500;
  }
  .price-currency {
    color: #67c23a;
    font-weight: 500;
  }
  .price-agreement {
    color: #409eff;
    font-weight: 500;
  }
  .price-free {
    color: #909399;
    font-style: italic;
@@ -933,9 +1002,10 @@
.period-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  .permanent {
    color: #909399;
    font-size: 12px;
@@ -967,18 +1037,18 @@
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    &:last-child {
      margin-bottom: 0;
    }
    .label {
      color: #909399;
      font-size: 12px;
      min-width: 60px;
      flex-shrink: 0;
    }
    .value {
      color: #303133;
      font-size: 12px;
@@ -999,7 +1069,7 @@
  color: #303133;
  text-align: center;
  line-height: 1.4;
  .all-actions {
    display: flex;
    flex-direction: column;
@@ -1007,10 +1077,10 @@
    justify-content: center;
    gap: 6px;
    width: 100%;
    .action-item {
      width: 100%;
      .action-buttons {
        display: flex;
        flex-direction: column;
@@ -1018,7 +1088,7 @@
        align-items: center;
        justify-content: center;
        width: 100%;
        .el-button {
          width: 100%;
          text-align: center;
@@ -1030,7 +1100,7 @@
          height: auto;
          line-height: 1.2;
        }
        .op-text {
          margin: 4px 0;
          text-align: center;
@@ -1050,12 +1120,12 @@
  flex-wrap: wrap;
}
.op-text {
  color: #606266;
.op-text {
  color: #606266;
  font-size: 12px;
}
.op-text.warning {
  color: #f59e0b;
.op-text.warning {
  color: #f59e0b;
  font-size: 12px;
}
@@ -1063,6 +1133,7 @@
  font-size: 12px;
  color: #303133;
  font-weight: 500;
  text-align: center;
}
.pagination-container {
@@ -1076,11 +1147,11 @@
  .el-table__fixed-right {
    z-index: 2 !important;
  }
  .el-table__fixed-right-patch {
    z-index: 2 !important;
  }
  // 操作列样式优化
  .operation-column {
    .cell {