Bang Hu
2 天以前 b3fedd4221b807a07058be9d5d5d8ba8998adbcb
src/views/tradeManage/buyer/index.vue
@@ -9,14 +9,30 @@
            <el-input v-model="query.productName" placeholder="请输入产品名称" clearable style="width: 100%" />
          </el-form-item>
          <el-form-item label="行业领域" class="col-25">
            <el-select v-model="query.industry" placeholder="请选择行业领域" clearable style="width: 100%">
            <el-select v-model="query.industry" placeholder="请选择行业领域" clearable style="width: 100%" @change="handleIndustryChange">
              <el-option v-for="item in industryOptions" :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.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%">
@@ -31,15 +47,15 @@
            <el-input v-model="query.orderNo" placeholder="请输入订单编号" clearable style="width: 100%" />
          </el-form-item>
          <el-form-item label="产品类型" class="col-25">
            <el-select v-model="query.productType" placeholder="请选择产品类型" clearable style="width: 100%">
            <el-select v-model="query.productType" placeholder="请选择产品类型" clearable style="width: 100%" @change="handleProductTypeChange">
              <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,9 +90,7 @@
              <template #default="{ row }">
                <div v-if="row.isMainOrder" class="main-order-info">
                  <div class="order-header">
                    <div class="order-item status-item">
                      <el-tag :type="getStatusType(row.status)" size="small">{{ row.statusName }}</el-tag>
                    </div>
                    <div class="order-item">
                      <span class="label">申请时间:</span>
                      <span class="value">{{ row.applyTime }}</span>
@@ -86,12 +100,11 @@
                      <span class="value">{{ row.orderNo }}</span>
                    </div>
                    <div class="order-item">
                      <span class="label">需求方:</span>
                      <span class="value">{{ row.demandSide }}</span>
                    </div>
                    <div class="order-item">
                      <span class="label">供应方:</span>
                      <span class="value">{{ row.supplySide }}</span>
                    </div>
                    <div class="order-item status-item">
                      <el-tag :type="getStatusType(row.status)" size="small">{{ row.statusName }}</el-tag>
                    </div>
                  </div>
                </div>
@@ -106,7 +119,7 @@
              </template>
            </el-table-column>
          </el-table-column>
          <!-- 购买方式 -->
          <el-table-column label="购买方式" align="center">
            <el-table-column label="销售形式/账户数量" width="150">
@@ -140,49 +153,30 @@
              </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">
                    {{ row.unitPrice }}
                  </span>
                  <span v-else-if="row.priceType === 'free'" class="price-free">
                    {{ row.unitPrice }}
                  </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">
                  <span>{{ row.period }}</span>
                  <span v-if="row.isPermanent" class="permanent">永久</span>
                  <span v-if="row.period === 0" class="permanent">永久</span>
                  <span v-else>{{ row.period }}</span>
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <!-- 操作 -->
          <el-table-column label="操作" align="center" width="120" class="operation-column">
            <el-table-column label="" width="120">
@@ -192,30 +186,61 @@
                  <div v-if="row.parentOrder && row.parentOrder.subOrders && row.parentOrder.subOrders.findIndex((sub: any) => sub.id === row.id) === 0" class="all-actions">
                    <div class="action-item">
                      <div class="action-buttons">
                        <span v-if="row.parentOrder.status === 'WAIT_REVIEW'" class="op-text warning">待审核</span>
                        <template v-else-if="row.parentOrder.status === 'WAIT_UPLOAD'">
                          <el-button type="danger" link size="small">取消交易</el-button>
                          <el-button type="primary" link size="small" @click="toUpload(row.parentOrder)">上传文件</el-button>
                          <el-button type="primary" link size="small" @click="toTrack(row.parentOrder)">追踪</el-button>
                        </template>
                        <template v-else-if="row.parentOrder.status === 'WAIT_CHECK'">
                          <span class="op-text warning">待核查文件</span>
                          <el-button type="primary" link size="small" @click="toDetail(row.parentOrder)">查看</el-button>
                          <el-button type="primary" link size="small" @click="toTrack(row.parentOrder)">追踪</el-button>
                        </template>
                        <template v-else-if="row.parentOrder.status === 'WAIT_CONFIRM'">
                          <span class="op-text warning">待交易确认</span>
                          <el-button type="primary" link size="small" @click="toConfirm(row.parentOrder)">确认交易</el-button>
                          <el-button type="primary" link size="small" @click="toTrack(row.parentOrder)">追踪</el-button>
                        </template>
                        <template v-else-if="row.parentOrder.status === 'WAIT_EVALUATE'">
                          <span class="op-text warning">待评价</span>
                          <el-button type="primary" link size="small" @click="toEvaluate(row.parentOrder)">评价</el-button>
                          <el-button type="primary" link size="small" @click="toTrack(row.parentOrder)">追踪</el-button>
                        </template>
                        <template v-else>
                          <el-button type="primary" link size="small" @click="toDetail(row.parentOrder)">查看</el-button>
                          <el-button type="primary" link size="small" @click="toTrack(row.parentOrder)">追踪</el-button>
                        <template v-for="action in getAvailableActions(row.parentOrder)" :key="action.type">
                          <el-button
                            v-if="action.type === ActionType.VIEW"
                            type="primary"
                            link
                            size="small"
                            @click="handleAction(action, row.parentOrder)"
                          >
                            查看
                          </el-button>
                          <el-button
                            v-else-if="action.type === ActionType.TRACK"
                            type="primary"
                            link
                            size="small"
                            @click="handleAction(action, row.parentOrder)"
                          >
                            追踪
                          </el-button>
                          <el-button
                            v-else-if="action.type === ActionType.UPLOAD_FILE"
                            type="primary"
                            link
                            size="small"
                            @click="handleAction(action, row.parentOrder)"
                          >
                            提交文件
                          </el-button>
                          <el-button
                            v-else-if="action.type === ActionType.CONFIRM_TRADE"
                            type="primary"
                            link
                            size="small"
                            @click="handleAction(action, row.parentOrder)"
                          >
                            交易确认
                          </el-button>
                          <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
                            v-else-if="action.type === ActionType.CANCEL_ORDER"
                            type="danger"
                            link
                            size="small"
                            @click="handleAction(action, row.parentOrder)"
                          >
                            取消订单
                          </el-button>
                        </template>
                      </div>
                    </div>
@@ -240,266 +265,255 @@
        />
      </div>
    </el-card>
    <!-- 订单状态对话框 -->
    <!-- <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, ElMessageBox } from 'element-plus'
import orderApi from '@/api/orderApi'
import productApi from '@/api/productApi'
import { useUserInfo } from '@/stores/modules/userInfo'
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_REVIEW' },
  { label: '待上传文件', value: 'WAIT_UPLOAD' },
  { label: '待核查文件', value: 'WAIT_CHECK' },
  { label: '待授权', value: 'WAIT_AUTHORIZE' },
  { label: '待交易确认', value: 'WAIT_CONFIRM' },
  { label: '待评价', value: 'WAIT_EVALUATE' },
  { label: '已完成', value: 'COMPLETED' },
  { label: '已评价', value: 'EVALUATED' },
]
// 行业领域选项
const industryOptions = [
  { label: '建筑工程', value: 'construction' },
  { label: '交通工程', value: 'transportation' },
  { label: '水利工程', value: 'water' },
  { label: '电力工程', value: 'power' },
]
// 单位工程选项
const unitProjectOptions = [
  { label: '土建工程', value: 'civil' },
  { label: '安装工程', value: 'installation' },
  { label: '装饰工程', value: 'decoration' },
]
// 产品类型选项
const productTypeOptions = [
  { label: '企业私有SaaS版许可', value: 'enterprise_private' },
  { label: '企业公有SaaS版许可', value: 'enterprise_public' },
  { label: '项目公有SaaS版许可', value: 'project_public' },
  { label: '个人公有SaaS版许可', value: 'personal_public' },
]
// 产品类型子级选项
const productSubTypeOptions = [
  { label: '基础版', value: 'basic' },
  { label: '标准版', value: 'standard' },
  { label: '高级版', value: 'premium' },
]
// 动态选项数据
const industryOptions = ref<any[]>([])
const unitProjectOptions = ref<any[]>([])
const productTypeOptions = ref<any[]>([])
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: [],
})
// 分页信息
const page = reactive({ current: 1, size: 10, total: 18 })
const page = reactive({ current: 1, size: 10, total: 0 })
// 订单列表数据(包含主订单和子订单)
const orderList = ref<any[]>([])
// 模拟数据用于展示
const mockData = [
  {
    id: '1',
    isMainOrder: true,
    applyTime: '2025-05-21 10:00:00',
    orderNo: '4348442557619205545',
    demandSide: '中交方远建设有限公司',
    supplySide: '中交方远科技有限公司',
    status: 'WAIT_REVIEW',
    statusName: '待审核',
    subOrders: [
      {
        id: '1-1',
        isMainOrder: false,
        productName: '中交方远智能实测实量管理系统',
        suiteName: '企业私有SaaS版许可',
        salesForm: '买断',
        accountCount: 50,
        customerObject: '企业',
        concurrentCount: 50,
        priceType: 'points',
        unitPrice: '积分: 50,000/套',
        quantity: 1,
        period: 1,
        isPermanent: true,
      },
      {
        id: '1-2',
        isMainOrder: false,
        productName: '中交方远智能实测实量管理系统',
        suiteName: '企业私有SaaS版OTA升级服务',
        salesForm: 'OTA服务',
        accountCount: 50,
        customerObject: '企业',
        concurrentCount: 50,
        priceType: 'currency',
        unitPrice: '货币: 7,500/套/年',
        quantity: 1,
        period: 1,
        isPermanent: false,
      },
      {
        id: '1-3',
        isMainOrder: false,
        productName: '中交方远智能实测实量管理系统',
        suiteName: '企业私有SaaS版用户增量包',
        salesForm: '私有增量包',
        accountCount: 100,
        customerObject: '企业',
        concurrentCount: 100,
        priceType: 'agreement',
        unitPrice: '协议:/年',
        quantity: 1,
        period: 1,
        isPermanent: false,
      },
      {
        id: '1-4',
        isMainOrder: false,
        productName: '中交方远智能实测实量管理系统',
        suiteName: '个人公有SaaS版许可',
        salesForm: '私有增量包',
        accountCount: 50,
        customerObject: '个人',
        concurrentCount: 50,
        priceType: 'free',
        unitPrice: '免费:/年',
        quantity: 3,
        period: 1,
        isPermanent: true,
      },
    ],
  },
  {
    id: '2',
    isMainOrder: true,
    applyTime: '2025-05-20 10:00:00',
    orderNo: '4347442557619205545',
    demandSide: '华为技术有限公司',
    supplySide: '华为软件技术有限公司',
    status: 'WAIT_UPLOAD',
    statusName: '待上传文件',
    subOrders: [
      {
        id: '2-1',
        isMainOrder: false,
        productName: '基于国产芯片宽窄融合自组网设备的应用',
        suiteName: '企业公有SaaS版许可',
        salesForm: '租赁',
        accountCount: 100,
        customerObject: '企业',
        concurrentCount: 100,
        priceType: 'currency',
        unitPrice: '货币: 80,000/年',
        quantity: 1,
        period: 2,
        isPermanent: false,
      },
    ],
  },
  {
    id: '3',
    isMainOrder: true,
    applyTime: '2025-05-19 10:00:00',
    orderNo: '4347342557619205545',
    demandSide: '中交第四航务工程局有限公司',
    supplySide: '中交第四航务工程局有限公司',
    status: 'WAIT_CHECK',
    statusName: '待核查文件',
    subOrders: [
      {
        id: '3-1',
        isMainOrder: false,
        productName: '高桩码头辅助出图工具箱',
        suiteName: '项目公有SaaS版许可',
        salesForm: '租赁',
        accountCount: 50,
        customerObject: '项目部',
        concurrentCount: 50,
        priceType: 'currency',
        unitPrice: '货币: 60,000/年',
        quantity: 1,
        period: 3,
        isPermanent: false,
      },
    ],
  },
  {
    id: '4',
    isMainOrder: true,
    applyTime: '2025-05-18 10:00:00',
    orderNo: '4347442557619205545',
    demandSide: '中国交通建设股份有限公司',
    supplySide: '中交公路规划设计院有限公司',
    status: 'WAIT_CONFIRM',
    statusName: '待交易确认',
    subOrders: [
      {
        id: '4-1',
        isMainOrder: false,
        productName: '公路数字化方案设计系统',
        suiteName: '企业公有SaaS版许可',
        salesForm: '租赁',
        accountCount: 100,
        customerObject: '企业',
        concurrentCount: 100,
        priceType: 'currency',
        unitPrice: '货币: 80,000/年',
        quantity: 1,
        period: 1,
        isPermanent: false,
      },
    ],
  },
  {
    id: '5',
    isMainOrder: true,
    applyTime: '2025-05-17 10:00:00',
    orderNo: '4347342557619205545',
    demandSide: '中交第三航务工程局有限公司',
    supplySide: '中交第三航务工程局有限公司',
    status: 'WAIT_EVALUATE',
    statusName: '待评价',
    subOrders: [
      {
        id: '5-1',
        isMainOrder: false,
        productName: '基于无人机的企业级可视化项目管理系统',
        suiteName: '项目公有SaaS版许可',
        salesForm: '租赁',
        accountCount: 50,
        customerObject: '项目部',
        concurrentCount: 50,
        priceType: 'free',
        unitPrice: '免费:/年',
        quantity: 1,
        period: 1,
        isPermanent: true,
      },
    ],
  },
]
// 订单状态对话框相关
const orderStatusDialogVisible = ref(false)
const currentOrderId = ref<string>('')
// 使用工作流程控制器的状态映射
const statusUiToServer: Record<string, string> = {
  WAIT_UPLOAD: OrderStatus.WAIT_UPLOAD,
  WAIT_AUTHORIZE: OrderStatus.WAIT_AUTHORIZE,
  WAIT_CONFIRM: OrderStatus.WAIT_CONFIRM,
  COMPLETED: OrderStatus.COMPLETED,
  EVALUATED: OrderStatus.EVALUATED,
}
const statusServerToUi: Record<string, string> = {
  [OrderStatus.WAIT_UPLOAD]: 'WAIT_UPLOAD',
  [OrderStatus.WAIT_AUTHORIZE]: 'WAIT_AUTHORIZE',
  [OrderStatus.WAIT_CONFIRM]: 'WAIT_CONFIRM',
  [OrderStatus.COMPLETED]: 'COMPLETED',
  [OrderStatus.EVALUATED]: 'EVALUATED',
  [OrderStatus.CANCELED]: 'CANCELED'
}
const formatDateTime = (val?: string) => {
  if (!val) return ''
  return val.replace('T', ' ').slice(0, 19)
}
const normalizePriceType = (val?: string): 'points' | 'currency' | 'agreement' | 'free' => {
  if (!val) return 'currency'
  const s = String(val)
  if (/(积分|points)/i.test(s)) return 'points'
  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([])
}
// 获取行业领域选项
const getIndustryOptions = async () => {
  try {
    const res = await productApi.getCategoryByParent({ parentCode: 'business_direction' })
    if (res?.code === 200 && res.data) {
      industryOptions.value = res.data.map((item: any) => ({
        label: item.name,
        value: item.id
      }))
    }
  } catch (error) {
    console.error('获取行业领域选项失败:', error)
  }
}
// 获取产品类型选项
const getProductTypeOptions = async () => {
  try {
      // 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,
        value: item.id
      }))
    }
  } catch (error) {
    console.error('获取产品类型选项失败:', error)
  }
}
// 根据行业领域获取单位工程选项
const getUnitProjectOptions = async (industryCode: string) => {
  if (!industryCode) {
    unitProjectOptions.value = []
    return
  }
  try {
    const res = await productApi.getCategoryByParent({ parentId: industryCode })
    if (res?.code === 200 && res.data) {
      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
  }
}
// 根据产品类型获取产品子级选项
const getProductSubTypeOptions = async (productTypeCode: string) => {
  if (!productTypeCode) {
    productSubTypeOptions.value = []
    return
  }
  try {
    const res = await productApi.getCategoryByParent({ parentId: productTypeCode })
    if (res?.code === 200 && res.data) {
      productSubTypeOptions.value = res.data.map((item: any) => ({
        label: item.name,
        value: item.id
      }))
    }
  } catch (error) {
    console.error('获取产品子级选项失败:', error)
    productSubTypeOptions.value = []
  }
}
// 处理行业领域变化
const handleIndustryChange = async (value: string) => {
  // 清空单位工程选择
  query.unitProject = []
  query.importantDistrictIdList = []
  // 获取对应的单位工程选项
  await getUnitProjectOptions(value)
}
// 处理产品类型变化
const handleProductTypeChange = async (value: string) => {
  // 清空产品子级选择
  query.productSubType = ''
  // 获取对应的产品子级选项
 //  await getProductSubTypeOptions(value)
}
// 获取状态类型
const getStatusType = (status: string) => {
  const statusMap: Record<string, 'warning' | 'danger' | 'success' | 'info'> = {
    WAIT_REVIEW: 'warning',
    WAIT_UPLOAD: 'warning',
    WAIT_CHECK: 'warning',
    WAIT_AUTHORIZE: 'warning',
    WAIT_CONFIRM: 'warning',
    WAIT_EVALUATE: 'warning',
    COMPLETED: 'success',
    EVALUATED: 'success',
    CANCELED: 'danger'
  }
  return statusMap[status] || 'info'
}
@@ -522,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 {
@@ -554,7 +568,7 @@
          }
        }
      }
    } else if (columnIndex === 7) { // 操作列(第8列)
    } else if (columnIndex === 6) { // 操作列(第7列)
      // 找到当前子订单所属的主订单
      const parentOrder = row.parentOrder
      if (parentOrder && parentOrder.subOrders) {
@@ -583,26 +597,85 @@
  }
}
// 搜索处理
// 搜索处理(接入真实后端)
const handleSearch = async () => {
  // 模拟API调用,实际项目中这里会调用真实的API
  // const { data } = (await fetchOrderPage({ ...query, pageNo: page.current, pageSize: page.size })) as any
  // 使用模拟数据
  const filterEvaluated = query.status === 'EVALUATED'
  const payload: any = {
    pageNum: page.current,
    pageSize: page.size,
    productName: query.productName || undefined,
    orderId: query.orderNo || undefined,
    userId: userStore.getUserId ? userStore.getUserId : undefined,
  }
  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.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.length > 0 || query.productType || query.productSubType
  const apiMethod = hasProductConditions ? orderApi.getBuyerOrderPageWithProductConditions : orderApi.getBuyerOrderPage
  const res = (await apiMethod(payload)) as any
  const pageData = res?.data
  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[] = []
  mockData.forEach(order => {
    flatData.push(order)
    if (order.subOrders) {
      order.subOrders.forEach((subOrder: any) => {
        flatData.push({ ...subOrder, parentOrder: order })
      })
  list.forEach((order: any) => {
    const uiStatus = statusServerToUi[order.orderStatus] || 'WAIT_UPLOAD'
    const mainRow: any = {
      id: order.orderId,
      isMainOrder: true,
      applyTime: formatDateTime(order.applyTime || ''),
      orderNo: order.orderId,
      demandSide: '',
      supplySide: order.providerName || '',
      status: uiStatus,
      statusName: order.orderStatus || '',
      orderStatus: StatusMapper.toUIStatus(order.orderStatus), // 转换为标准状态枚举
      workFlowId: order.workflowId || '',
      isEvaluate: order.isEvaluate || ''
    }
    // 在每个订单块的末尾插入一个分隔空行
    flatData.push({ isSpacer: true, isMainOrder: false, parentOrder: order })
    const subOrders: any[] = Array.isArray(order?.orderDetails)
      ? order.orderDetails.map((d: any, i: number) => ({
          id: `${order.orderId}-${i + 1}`,
          isMainOrder: false,
          productName: order.productName || '',
          suiteName: d.suiteName,
          salesForm: d.salesForm,
          accountCount: d.accountLimit,
          customerObject: d.customerType,
          concurrentCount: d.concurrentNodes,
          priceType: normalizePriceType(d.priceType),
          unitPrice: d.unitPrice,
          quantity: d.quantity,
          period: d.duration,
        }))
      : []
    ;(mainRow as any).subOrders = subOrders
    flatData.push(mainRow)
    subOrders.forEach((sub) => flatData.push({ ...sub, parentOrder: mainRow }))
    flatData.push({ isSpacer: true, isMainOrder: false, parentOrder: mainRow })
  })
  orderList.value = flatData
  page.total = 18
}
// 重置
@@ -610,13 +683,17 @@
  Object.assign(query, {
    productName: '',
    industry: '',
    unitProject: '',
    unitProject: [],
    productType: '',
    productSubType: '',
    importantDistrictIdList: [],
    orderNo: '',
    status: '',
    dateRange: [],
  })
  // 清空动态选项
  unitProjectOptions.value = []
  productSubTypeOptions.value = []
  page.current = 1
  handleSearch()
}
@@ -626,9 +703,106 @@
const toUpload = (row: any) => router.push({ name: 'tradeOrderUpload', params: { id: row.id } })
const toConfirm = (row: any) => router.push({ name: 'tradeOrderConfirm', params: { id: row.id } })
const toEvaluate = (row: any) => router.push({ name: 'tradeOrderEvaluate', params: { id: row.id } })
const toTrack = (row: any) => router.push({ name: 'tradeTrack', params: { id: row.id } })
const toTrack = (row: any) => {
  if (!row.workFlowId) {
    ElMessage.warning('该订单暂无工作流信息')
    return
  }
  router.push({ name: 'tradeTrack', params: { id: row.workFlowId } })
}
onMounted(handleSearch)
// 追踪订单 - 显示订单状态对话框
const showOrderTrack = (row: any) => {
  currentOrderId.value = row.id
  orderStatusDialogVisible.value = true
}
// 获取可用操作列表
const getAvailableActions = (order: any) => {
  if (!order.orderStatus) return []
  return OrderWorkflowController.getAvailableActions(PageType.BUYER_CENTER, order.orderStatus)
}
// 处理操作点击
const handleAction = (action: any, order: any) => {
  switch (action.type) {
    case ActionType.VIEW:
      toDetail(order)
      break
    case ActionType.TRACK:
      // showOrderTrack(order)
      toTrack(order)
      break
    case ActionType.UPLOAD_FILE:
      toUpload(order)
      break
    case ActionType.CONFIRM_TRADE:
      toConfirm(order)
      break
    case ActionType.EVALUATE:
      toEvaluate(order)
      break
    case ActionType.CANCEL_ORDER:
      cancelOrder(order)
      break
    default:
      console.warn('未知的操作类型:', action.type)
  }
}
// 取消订单
const cancelOrder = async (order: any) => {
  try {
    await ElMessageBox.confirm('确定要取消这个订单吗?此操作将删除订单的所有相关信息,包括订单详情和附件文件,且不可恢复。', '确认取消订单', {
      confirmButtonText: '确定取消',
      cancelButtonText: '取消',
      type: 'warning',
      confirmButtonClass: 'el-button--danger'
    })
    const res = await orderApi.cancelOrder(order.id)
    if (res && res.code === 200) {
      ElMessage.success('订单取消成功')
      handleSearch() // 刷新列表
    } else {
      ElMessage.error(res?.msg || '取消订单失败')
    }
  } catch (error) {
    if (error !== 'cancel') {
      console.error('取消订单失败:', error)
      ElMessage.error('取消订单失败,请重试')
    }
  }
}
onMounted(async ()=>{
  // 获取用户信息
  if (!userStore.getUserId) {
    try {
      const res: any = await queryUserDetail()
      if (res?.code === 200 && res.data) {
        userStore.updateUserDetail(res.data)
      } else {
        ElMessage.error(res?.msg || '无法获取用户信息,请先登录')
        return
      }
    } catch (e) {
      console.error('获取用户详情失败:', e)
      ElMessage.error('获取用户信息失败,请稍后重试')
      return
    }
  }
  // 获取初始选项数据
  await Promise.all([
    getIndustryOptions(),
    getProductTypeOptions()
  ])
  // 执行搜索
  handleSearch()
})
</script>
<style scoped lang="scss">
@@ -663,7 +837,7 @@
      border-bottom: 2px solid #e4e7ed; // 与分隔行一致的下边框
    }
  }
  // 调整表头高度
  tr:first-child {
    th {
@@ -680,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; }
@@ -705,7 +879,7 @@
    .el-form-item {
      margin-bottom: 16px;
      margin-right: 20px;
      &:last-child {
        margin-right: 0;
      }
@@ -716,7 +890,7 @@
.table-container {
  position: relative;
  z-index: 1;
  .custom-table {
    // 表头第二行文字大小调整
    .el-table__header-wrapper {
@@ -729,7 +903,7 @@
        }
      }
    }
    // 确保表头所有行的文字大小一致
    .el-table__header {
      th {
@@ -739,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;
        }
@@ -772,20 +946,23 @@
    gap: 20px;
    align-items: center;
    overflow: hidden;
    .status-item{
      flex-direction: row-reverse;
    }
    .order-item {
      display: flex;
      align-items: center;
      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;
@@ -800,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;
@@ -825,9 +1002,10 @@
.period-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  .permanent {
    color: #909399;
    font-size: 12px;
@@ -859,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;
@@ -891,7 +1069,7 @@
  color: #303133;
  text-align: center;
  line-height: 1.4;
  .all-actions {
    display: flex;
    flex-direction: column;
@@ -899,10 +1077,10 @@
    justify-content: center;
    gap: 6px;
    width: 100%;
    .action-item {
      width: 100%;
      .action-buttons {
        display: flex;
        flex-direction: column;
@@ -910,7 +1088,7 @@
        align-items: center;
        justify-content: center;
        width: 100%;
        .el-button {
          width: 100%;
          text-align: center;
@@ -922,7 +1100,7 @@
          height: auto;
          line-height: 1.2;
        }
        .op-text {
          margin: 4px 0;
          text-align: center;
@@ -942,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;
}
@@ -955,6 +1133,7 @@
  font-size: 12px;
  color: #303133;
  font-weight: 500;
  text-align: center;
}
.pagination-container {
@@ -968,11 +1147,11 @@
  .el-table__fixed-right {
    z-index: 2 !important;
  }
  .el-table__fixed-right-patch {
    z-index: 2 !important;
  }
  // 操作列样式优化
  .operation-column {
    .cell {