From 2c55b1a8a0700df79268550335506637b41610ce Mon Sep 17 00:00:00 2001 From: seatonwan9 Date: 星期日, 24 八月 2025 20:36:36 +0800 Subject: [PATCH] 提交源码 --- src/views/tradeManage/buyer/index.vue | 487 +++++++++++++++++++++++++++-------------------------- 1 files changed, 247 insertions(+), 240 deletions(-) diff --git a/src/views/tradeManage/buyer/index.vue b/src/views/tradeManage/buyer/index.vue index 73ccae5..dc072b9 100644 --- a/src/views/tradeManage/buyer/index.vue +++ b/src/views/tradeManage/buyer/index.vue @@ -86,10 +86,6 @@ <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> @@ -148,16 +144,16 @@ <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 }} + 绉垎 {{ row.unitPrice }} </span> <span v-else-if="row.priceType === 'currency'" class="price-currency"> - {{ row.unitPrice }} + 璐у竵 {{ 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> @@ -176,8 +172,8 @@ <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> @@ -192,30 +188,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" + 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,6 +267,12 @@ /> </div> </el-card> + + <!-- 璁㈠崟鐘舵�佸璇濇 --> + <ProductOrderStatusDialog + v-model="orderStatusDialogVisible" + :order-id="currentOrderId" + /> </div> </template> @@ -247,17 +280,23 @@ 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 { useUserInfo } from '@/stores/modules/userInfo' +import ProductOrderStatusDialog from '@/views/productManage/productOrderStatusDialog/index.vue' +import { OrderWorkflowController, OrderStatus, ActionType, PageType, StatusMapper } from '@/utils/orderWorkflow' const router = useRouter() +const userStore = useUserInfo() -// 鐘舵�侀�夐」 +// 鐘舵�侀�夐」锛堟洿鏂颁负鏂扮殑宸ヤ綔娴佺▼鐘舵�侊級 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' }, ] // 琛屼笟棰嗗煙閫夐」 @@ -303,203 +342,54 @@ }) // 鍒嗛〉淇℃伅 -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鐗圤TA鍗囩骇鏈嶅姟', - 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', +} + +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 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', } return statusMap[status] || 'info' } @@ -583,26 +473,79 @@ } } -// 鎼滅储澶勭悊 +// 鎼滅储澶勭悊锛堟帴鍏ョ湡瀹炲悗绔級 const handleSearch = async () => { - // 妯℃嫙API璋冪敤锛屽疄闄呴」鐩腑杩欓噷浼氳皟鐢ㄧ湡瀹炵殑API - // const { data } = (await fetchOrderPage({ ...query, pageNo: page.current, pageSize: page.size })) as any - - // 浣跨敤妯℃嫙鏁版嵁 + const payload: any = { + pageNum: page.current, + pageSize: page.size, + productName: query.productName || undefined, + orderId: query.orderNo || undefined, + userId: userStore.getUserId ? Number(userStore.getUserId) : undefined, + } + 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] + } + + const res = (await orderApi.getBuyerOrderPage(payload)) as any + const pageData = res?.data + const list: any[] = Array.isArray(pageData?.list) ? pageData.list : [] + page.total = Number(pageData?.total || 0) + + // 骞跺彂鑾峰彇姣忎釜璁㈠崟鐨勮鎯咃紙鐢ㄤ簬鏋勯�犲瓙璁㈠崟琛岋級 + const detailsArr = await Promise.all( + list.map(async (order: any) => { + try { + const detailRes = (await orderApi.getOrderDetail(order.orderId)) as any + return detailRes?.data + } catch (e) { + return null + } + }) + ) + 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, idx: number) => { + 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), // 杞崲涓烘爣鍑嗙姸鎬佹灇涓� } - // 鍦ㄦ瘡涓鍗曞潡鐨勬湯灏炬彃鍏ヤ竴涓垎闅旂┖琛� - flatData.push({ isSpacer: true, isMainOrder: false, parentOrder: order }) + + const detail = detailsArr[idx] + const subOrders: any[] = Array.isArray(detail?.orderDetails) + ? detail.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 } // 閲嶇疆 @@ -628,6 +571,70 @@ 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 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) + 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(handleSearch) </script> -- Gitblit v1.8.0