OrderList.vue 15.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
<script setup lang="ts">
import { ref, reactive } from 'vue'
import { useRouter } from 'vue-router'
import { Search, Download, View, Edit, Warning } from '@element-plus/icons-vue'
import type { Order, OrderQuery } from '../types/order'
import { generateMockOrders } from '../mock/orderData'
import { ElMessage, ElMessageBox } from 'element-plus'

// --- State ---
const loading = ref(false)
const tableData = ref<Order[]>([])
const cities = ['南京市', '无锡市', '徐州市', '常州市', '苏州市', '南通市', '连云港市', '淮安市', '盐城市', '扬州市', '镇江市', '泰州市', '宿迁市']
const router = useRouter()

// Search Form
const queryForm = reactive<OrderQuery>({
  businessAccount: '',
  applyId: '',
  orderId: '',
  workerId: '',
  city: '',
  status: '',
  dateRange: undefined,
  noPhotoCountMin: undefined,
  manualInputCountMin: undefined,
  envAbnormalCountMin: undefined,
  isAbnormal: '',
  page: 1,
  pageSize: 10
})

const total = ref(100) // Mock total

// --- Methods ---
const fetchData = () => {
  loading.value = true
  setTimeout(() => {
    tableData.value = generateMockOrders(queryForm.pageSize)
    loading.value = false
  }, 500)
}

const handleSearch = () => {
  queryForm.page = 1
  fetchData()
}

const handleReset = () => {
  // Reset logic
  queryForm.businessAccount = ''
  queryForm.applyId = '' 
  // ... others
  handleSearch()
}

const handleExport = () => {
  ElMessage.success('正在导出Excel...')
}

// Table Handlers
const handlePageChange = (val: number) => {
  queryForm.page = val
  fetchData()
}

// Dialogs State
const dialogVisible = reactive({
  orderIds: false,
  cannotQc: false,
  markCheating: false,
  cancelCheating: false,
  details: false,
  cheatingInfo: false
})

const currentOrder = ref<Order | null>(null)
const detailsType = ref<'noPhoto' | 'manual' | 'env'>('noPhoto')
const detailsTitle = ref('')
const detailsData = ref<DetailRecord[]>([])

// Forms
const cannotQcForm = reactive({
  type: '',
  reason: ''
})
const markCheatingForm = reactive({
  reason: '',
  remark: ''
})

// --- Actions ---

// 1. Order IDs
const openIdsDialog = (row: Order) => {
  currentOrder.value = row
  dialogVisible.orderIds = true
}

// 2. Numeric Details Popup
const openDetailsDialog = (row: Order, type: 'noPhoto' | 'manual' | 'env') => {
  currentOrder.value = row
  detailsType.value = type
  
  if (type === 'noPhoto') {
    detailsTitle.value = '无法拍摄明细'
    // Mock details
    detailsData.value = [
      { id: 1, process: '光猫识别', reason: '光线太暗', time: '2023-10-01 10:05:00' },
      { id: 2, process: '机顶盒识别', reason: '设备遮挡', time: '2023-10-01 10:10:00' }
    ]
  } else if (type === 'manual') {
    detailsTitle.value = '手动输入明细'
    detailsData.value = [
       { id: 1, process: 'SN码输入', time: '2023-10-01 10:15:00' }
    ]
  } else {
    detailsTitle.value = '环境异常明细'
    detailsData.value = [
       { id: 1, process: '背景检测', reason: '疑似非用户家', time: '2023-10-01 10:00:00' }
    ]
  }
  dialogVisible.details = true
}

// 3. Cheating Info Popup
const openCheatingInfo = (row: Order) => {
  currentOrder.value = row
  dialogVisible.cheatingInfo = true
}

// 4. Cannot QC Action
const openCannotQcDialog = (row: Order) => {
  currentOrder.value = row
  cannotQcForm.type = ''
  cannotQcForm.reason = ''
  dialogVisible.cannotQc = true
}
const submitCannotQc = () => {
  if (!cannotQcForm.type || !cannotQcForm.reason) {
    ElMessage.warning('请填写完整信息')
    return
  }
  ElMessage.success('提交成功')
  dialogVisible.cannotQc = false
  // Refresh data logic here
}

// 5. Mark Cheating Action
const openMarkCheating = (row: Order) => {
  currentOrder.value = row
  markCheatingForm.reason = ''
  markCheatingForm.remark = ''
  dialogVisible.markCheating = true
}
const submitMarkCheating = () => {
  if (!markCheatingForm.reason) {
    ElMessage.warning('请选择异常原因')
    return
  }
  ElMessage.success('标记成功')
  dialogVisible.markCheating = false
  if (currentOrder.value) currentOrder.value.isCheating = true
}

// 6. Cancel Cheating Action
const openCancelCheating = (row: Order) => {
  ElMessageBox.confirm(
    '确认要取消该工单的作弊标记吗?',
    '取消作弊',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  ).then(() => {
    ElMessage.success('取消成功')
    row.isCheating = false
  })
}

// Initial Fetch
fetchData()
</script>

<template>
  <div class="p-4">
    <!-- Search Area -->
    <el-card shadow="never" class="mb-4">
      <el-form :model="queryForm" label-width="90px" class="flex flex-wrap">
        <el-form-item label="业务账号">
          <el-input v-model="queryForm.businessAccount" placeholder="手机号/固话" clearable class="!w-48" />
        </el-form-item>
        <el-form-item label="Apply_id">
          <el-input v-model="queryForm.applyId" placeholder="请输入" clearable class="!w-48" />
        </el-form-item>
        <el-form-item label="工单ID">
          <el-input v-model="queryForm.orderId" placeholder="请输入" clearable class="!w-48" />
        </el-form-item>
        <el-form-item label="师傅工号">
          <el-input v-model="queryForm.workerId" placeholder="请输入" clearable class="!w-48" />
        </el-form-item>
        <el-form-item label="所属地市">
          <el-select v-model="queryForm.city" placeholder="请选择" clearable class="!w-48">
            <el-option v-for="city in cities" :key="city" :label="city" :value="city" />
          </el-select>
        </el-form-item>
        <el-form-item label="质检状态">
          <el-select v-model="queryForm.status" placeholder="请选择" clearable class="!w-48">
            <el-option label="全部" value="" />
            <el-option label="未开始" value="未开始" />
            <el-option label="进行中" value="进行中" />
            <el-option label="已完成" value="已完成" />
            <el-option label="无法质检" value="无法质检" />
          </el-select>
        </el-form-item>
        <el-form-item label="质检时间">
          <el-date-picker
            v-model="queryForm.dateRange"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
            value-format="YYYY-MM-DD HH:mm:ss"
            class="!w-80"
          />
        </el-form-item>
        <el-form-item label="无法拍摄">
          <el-input-number v-model="queryForm.noPhotoCountMin" :min="1" controls-position="right" class="!w-32" placeholder=">=1" />
        </el-form-item>
        <el-form-item label="手动输入">
          <el-input-number v-model="queryForm.manualInputCountMin" :min="1" controls-position="right" class="!w-32" placeholder=">=1" />
        </el-form-item>
        <el-form-item label="环境异常">
          <el-input-number v-model="queryForm.envAbnormalCountMin" :min="1" controls-position="right" class="!w-32" placeholder=">=1" />
        </el-form-item>
        <el-form-item label="是否异常">
          <el-select v-model="queryForm.isAbnormal" placeholder="请选择" clearable class="!w-32">
            <el-option label="全部" value="" />
            <el-option label="异常" value="abnormal" />
            <el-option label="正常" value="normal" />
          </el-select>
        </el-form-item>
        <el-form-item class="ml-auto">
          <el-button type="primary" :icon="Search" @click="handleSearch">查询</el-button>
          <el-button @click="handleReset">重置</el-button>
          <el-button type="success" :icon="Download" @click="handleExport">导出</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <!-- Table Area -->
    <el-card shadow="never">
      <el-table :data="tableData" v-loading="loading" border style="width: 100%">
        <el-table-column prop="applyId" label="Apply_id" min-width="120" />
        <el-table-column prop="workerId" label="师傅工号" width="100" />
        <el-table-column prop="businessAccount" label="业务账号" min-width="120" />
        <el-table-column label="工单ID" width="100">
          <template #default="{ row }">
            <el-button link type="primary" @click="openIdsDialog(row)">查看</el-button>
          </template>
        </el-table-column>
        <el-table-column prop="city" label="所属地市" width="100" />
        <el-table-column prop="status" label="质检状态" width="100">
           <template #default="{ row }">
             <el-tag :type="row.status === '已完成' ? 'success' : row.status === '无法质检' ? 'info' : ''">{{ row.status }}</el-tag>
           </template>
        </el-table-column>
        <el-table-column prop="cannotQcReason" label="无法质检原因" min-width="120" show-overflow-tooltip />
        <el-table-column prop="startTime" label="开始时间" width="160" />
        <el-table-column prop="endTime" label="结束时间" width="160" />
        
        <!-- Numeric Columns with Sort -->
        <el-table-column prop="noPhotoCount" label="无法拍摄" sortable width="110">
           <template #default="{ row }">
             <span class="text-blue-500 cursor-pointer font-bold hover:underline" 
                   v-if="row.noPhotoCount > 0"
                   @click="openDetailsDialog(row, 'noPhoto')">
                {{ row.noPhotoCount }}
             </span>
             <span v-else>0</span>
           </template>
        </el-table-column>
        <el-table-column prop="manualInputCount" label="手动输入" sortable width="110">
          <template #default="{ row }">
             <span class="text-blue-500 cursor-pointer font-bold hover:underline" 
                   v-if="row.manualInputCount > 0"
                   @click="openDetailsDialog(row, 'manual')">
                {{ row.manualInputCount }}
             </span>
             <span v-else>0</span>
           </template>
        </el-table-column>
        <el-table-column prop="envAbnormalCount" label="环境异常" sortable width="110">
          <template #default="{ row }">
             <span class="text-blue-500 cursor-pointer font-bold hover:underline" 
                   v-if="row.envAbnormalCount > 0"
                   @click="openDetailsDialog(row, 'env')">
                {{ row.envAbnormalCount }}
            </span>
             <span v-else>0</span>
           </template>
        </el-table-column>
        
        <el-table-column label="疑似作弊" width="100">
          <template #default="{ row }">
            <span v-if="row.isCheating" class="text-red-500 cursor-pointer hover:underline" @click="openCheatingInfo(row)"></span>
            <span v-else></span>
          </template>
        </el-table-column>
        
        <el-table-column label="操作" width="220" fixed="right">
          <template #default="{ row }">
            <el-button link type="primary" @click="router.push(`/order-detail/${row.id}`)">详情</el-button>
            <el-button link type="warning" @click="openCannotQcDialog(row)">无法质检</el-button>
            <el-button link type="danger" v-if="!row.isCheating" @click="openMarkCheating(row)">标记作弊</el-button>
            <el-button link type="info" v-else @click="openCancelCheating(row)">取消作弊</el-button>
          </template>
        </el-table-column>
      </el-table>
      
      <div class="mt-4 flex justify-end">
        <el-pagination
          v-model:current-page="queryForm.page"
          v-model:page-size="queryForm.pageSize"
          :page-sizes="[10, 20, 50]"
          :total="total"
          layout="total, sizes, prev, pager, next, jumper"
          @current-change="handlePageChange"
        />
      </div>
    </el-card>

    <!-- Dialog: Order IDs -->
    <el-dialog v-model="dialogVisible.orderIds" title="工单ID列表" width="400px">
      <div v-if="currentOrder">
        <p class="mb-2"><strong>Apply_id:</strong> {{ currentOrder.applyId }}</p>
        <p class="mb-4"><strong>业务账号:</strong> {{ currentOrder.businessAccount }}</p>
        <el-table :data="currentOrder.orderIds.map(id => ({ id }))" border stripe max-height="300">
           <el-table-column prop="id" label="工单ID" />
        </el-table>
      </div>
    </el-dialog>

    <!-- Dialog: Numeric Details (NoPhoto/Manual/Env) -->
    <el-dialog v-model="dialogVisible.details" :title="detailsTitle" width="600px">
      <el-table :data="detailsData" border stripe>
        <el-table-column type="index" label="序号" width="60" align="center" />
        <el-table-column prop="process" label="流程" />
        <el-table-column prop="reason" label="原因" v-if="detailsType !== 'manual'" />
        <el-table-column prop="time" label="提交时间" />
      </el-table>
    </el-dialog>

    <!-- Dialog: Cheating Info -->
    <el-dialog v-model="dialogVisible.cheatingInfo" title="疑似作弊详情" width="400px">
      <div v-if="currentOrder">
        <p class="mb-2"><strong>疑似作弊原因:</strong> {{ currentOrder.cheatingReason }}</p>
        <p class="mb-2"><strong>备注:</strong> {{ currentOrder.cheatingRemark || '无' }}</p>
        <p class="mb-2"><strong>标记时间:</strong> {{ currentOrder.cheatingTime }}</p>
      </div>
    </el-dialog>

    <!-- Dialog: Cannot QC Form -->
    <el-dialog v-model="dialogVisible.cannotQc" title="无法质检处理" width="500px">
      <el-form label-width="80px">
        <el-form-item label="原因类型" required>
          <el-radio-group v-model="cannotQcForm.type">
            <el-radio value="个人原因">个人原因</el-radio>
            <el-radio value="用户原因">用户原因</el-radio>
            <el-radio value="其他">其他</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="具体原因" required>
          <el-input type="textarea" v-model="cannotQcForm.reason" placeholder="请填写具体原因" :rows="3" />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="dialogVisible.cannotQc = false">取消</el-button>
        <el-button type="primary" @click="submitCannotQc">提交</el-button>
      </template>
    </el-dialog>

    <!-- Dialog: Mark Cheating Form -->
    <el-dialog v-model="dialogVisible.markCheating" title="标记作弊" width="500px">
       <div v-if="currentOrder" class="mb-4 p-2 bg-gray-50 rounded">
         <p class="text-sm text-gray-600">Apply_id: {{ currentOrder.applyId }}</p>
         <p class="text-sm text-gray-600">业务账号: {{ currentOrder.businessAccount }}</p>
       </div>
       <el-form label-width="80px">
        <el-form-item label="异常原因" required>
          <el-select v-model="markCheatingForm.reason" class="w-full">
            <el-option value="在家质检" label="在家质检" />
            <el-option value="一直点击无法质检" label="一直点击无法质检" />
            <el-option value="其他" label="其他" />
          </el-select>
        </el-form-item>
        <el-form-item label="备注">
          <el-input type="textarea" v-model="markCheatingForm.remark" placeholder="选填" :rows="3" />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="dialogVisible.markCheating = false">取消</el-button>
        <el-button type="primary" @click="submitMarkCheating">提交</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<style scoped>
.el-form-item {
  margin-right: 16px;
  margin-bottom: 16px;
}
</style>