From 349091f54dab47b15ca81613f02765490a2ce7d0 Mon Sep 17 00:00:00 2001 From: p-honggang.li <p-honggang.li@pcitc.com> Date: 星期四, 11 九月 2025 10:50:36 +0800 Subject: [PATCH] 修改买家中心卖家中心产品类型等条件查询问题 --- src/views/approveManage/tradeApproval/list.vue | 821 +++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 546 insertions(+), 275 deletions(-) diff --git a/src/views/approveManage/tradeApproval/list.vue b/src/views/approveManage/tradeApproval/list.vue index 73d6f4b..1ba6586 100644 --- a/src/views/approveManage/tradeApproval/list.vue +++ b/src/views/approveManage/tradeApproval/list.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,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"> @@ -74,9 +132,6 @@ <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> @@ -92,6 +147,9 @@ <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> @@ -148,13 +206,13 @@ <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"> 鍏嶈垂 @@ -176,8 +234,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,10 +250,45 @@ <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"> - <el-button v-if="row.parentOrder.canApprove" type="primary" link size="small" @click="toApprove(row.parentOrder)">瀹℃壒</el-button> - <el-button v-if="row.parentOrder.canCheck" type="primary" link size="small" @click="toCheckFiles(row.parentOrder)">鏍告煡鏂囦欢</el-button> - <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.AUTHORIZE" + type="primary" + link + size="small" + @click="handleAction(action, row.parentOrder)" + > + 鎺堟潈 + </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> </div> @@ -219,65 +312,54 @@ /> </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 { fetchApprovalPage } from '@/api/approvalManage' +import { ElMessage } from 'element-plus' +import { fetchApprovalPage, fetchApprovalPageWithProductConditions } from '@/api/approvalManage' +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_APPROVAL' }, { label: '寰呬笂浼犳枃浠�', value: 'WAIT_UPLOAD' }, - { label: '寰呮牳鏌ユ枃浠�', value: 'WAIT_CHECK' }, + { label: '寰呮巿鏉�', value: 'WAIT_AUTHORIZE' }, + { label: '寰呭鎵规巿鏉�', value: 'WAIT_APPROVAL_AUTHORIZE' }, { label: '寰呬氦鏄撶‘璁�', value: 'WAIT_CONFIRM' }, - { label: '宸查┏鍥�', value: 'REJECTED' }, - { label: '宸插畬鎴�', value: 'FINISH' }, + { 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({ productName: '', industry: '', - unitProject: '', + unitProject: [], productType: '', productSubType: '', + importantDistrictIdList: [], orderNo: '', status: '', dateRange: [], @@ -289,209 +371,188 @@ // 璁㈠崟鍒楄〃鏁版嵁锛堝寘鍚富璁㈠崟鍜屽瓙璁㈠崟锛� const orderList = ref<any[]>([]) -// 妯℃嫙鏁版嵁鐢ㄤ簬灞曠ず -const mockData = [ - { - id: '1', - isMainOrder: true, - applyTime: '2025-05-21 10:00:00', - orderNo: '4348442557619205545', - demandSide: '涓氦鏂硅繙寤鸿鏈夐檺鍏徃', - supplySide: '涓氦鏂硅繙绉戞妧鏈夐檺鍏徃', - status: 'WAIT_APPROVAL', - statusName: '寰呭鏍�', - canApprove: true, - canCheck: false, - 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: '0', - quantity: 1, - period: 3, - isPermanent: true, - }, - ], - }, - { - id: '2', - isMainOrder: true, - applyTime: '2025-05-20 10:00:00', - orderNo: '4347442557619205545', - demandSide: '鍗庝负鎶�鏈湁闄愬叕鍙�', - supplySide: '鍗庝负杞欢鎶�鏈湁闄愬叕鍙�', - status: 'WAIT_UPLOAD', - statusName: '寰呬笂浼犳枃浠�', - canApprove: false, - canCheck: false, - subOrders: [ - { - id: '2-1', - isMainOrder: false, - productName: '鍩轰簬鍥戒骇鑺墖瀹界獎铻嶅悎鑷粍缃戣澶囩殑搴旂敤', - suiteName: '浼佷笟鍏湁SaaS鐗堣鍙�', - salesForm: '绉熻祦', - accountCount: 100, - customerObject: '浼佷笟', - concurrentCount: 100, - priceType: 'currency', - unitPrice: '80,000', - quantity: 1, - period: 1, - isPermanent: false, - }, - ], - }, - { - id: '3', - isMainOrder: true, - applyTime: '2025-05-19 10:00:00', - orderNo: '4347342557619205545', - demandSide: '涓氦绗洓鑸姟宸ョ▼灞�鏈夐檺鍏徃', - supplySide: '涓氦绗洓鑸姟宸ョ▼灞�鏈夐檺鍏徃', - status: 'WAIT_CHECK', - statusName: '寰呮牳鏌ユ枃浠�', - canApprove: true, - canCheck: true, - subOrders: [ - { - id: '3-1', - isMainOrder: false, - productName: '楂樻々鐮佸ご杈呭姪鍑哄浘宸ュ叿绠�', - suiteName: '椤圭洰鍏湁SaaS鐗堣鍙�', - salesForm: '绉熻祦', - accountCount: 50, - customerObject: '椤圭洰閮�', - concurrentCount: 50, - priceType: 'currency', - unitPrice: '60,000', - quantity: 1, - period: 1, - isPermanent: false, - }, - ], - }, - { - id: '4', - isMainOrder: true, - applyTime: '2025-05-18 10:00:00', - orderNo: '4347442557619205545', - demandSide: '涓浗浜ら�氬缓璁捐偂浠芥湁闄愬叕鍙�', - supplySide: '涓氦鍏矾瑙勫垝璁捐闄㈡湁闄愬叕鍙�', - status: 'WAIT_CONFIRM', - statusName: '寰呬氦鏄撶‘璁�', - canApprove: false, - canCheck: false, - 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: 'REJECTED', - statusName: '宸查┏鍥�', - canApprove: false, - canCheck: false, - subOrders: [ - { - id: '5-1', - isMainOrder: false, - productName: '鍩轰簬鏃犱汉鏈虹殑浼佷笟绾у彲瑙嗗寲椤圭洰绠$悊绯荤粺', - suiteName: '椤圭洰鍏湁SaaS鐗堣鍙�', - salesForm: '绉熻祦', - accountCount: 50, - customerObject: '椤圭洰閮�', - concurrentCount: 50, - priceType: 'free', - unitPrice: '0', - quantity: 1, - period: 1, - isPermanent: true, - }, - ], - }, -] +// 璁㈠崟鐘舵�佸璇濇鐩稿叧 +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> = { + 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.WAIT_APPROVAL_AUTHORIZE]: 'WAIT_APPROVAL_AUTHORIZE' +} + +const formatDateTime = (val?: string) => { + if (!val) return '' + // 鍚庣 LocalDateTime 鍙兘鏄� 2025-05-21T10:00:00 + 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 { + 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 = '' + // 鑾峰彇瀵瑰簲鐨勫崟浣嶅伐绋嬮�夐」 + 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_APPROVAL: 'warning', WAIT_UPLOAD: 'warning', - WAIT_CHECK: 'warning', + WAIT_AUTHORIZE: 'warning', + WAIT_APPROVAL_AUTHORIZE: 'warning', WAIT_CONFIRM: 'warning', - REJECTED: 'danger', - FINISH: 'success', + COMPLETED: 'success', + EVALUATED: 'success', } return statusMap[status] || 'info' } @@ -575,26 +636,94 @@ } } -// 鎼滅储澶勭悊 +// 鎼滅储澶勭悊锛堟帴鍏ョ湡瀹炲悗绔級 const handleSearch = async () => { - // 妯℃嫙API璋冪敤锛屽疄闄呴」鐩腑杩欓噷浼氳皟鐢ㄧ湡瀹炵殑API - // const { data } = (await fetchApprovalPage({ ...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, + 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) { + 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 + + // 鏍规嵁鏄惁鏈変骇鍝佹潯浠堕�夋嫨涓嶅悓鐨凙PI + const hasProductConditions = query.industry || query.unitProject.length > 0 || query.productType || query.productSubType + const apiMethod = hasProductConditions ? fetchApprovalPageWithProductConditions : fetchApprovalPage + + const res = (await apiMethod(payload)) as any + const pageData = res?.data + const list: any[] = Array.isArray(pageData?.list) ? pageData.list : [] + 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, 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), // 杞崲涓烘爣鍑嗙姸鎬佹灇涓� + workFlowId: order.workflowId || '', + taskId: order.taskId || '' } - // 鍦ㄦ瘡涓鍗曞潡鐨勬湯灏炬彃鍏ヤ竴涓垎闅旂┖琛� - 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 = mockData.length +} + +const btnClick = (workFlowType?: any,businessType?: any) => { + workFlowStatus.btnClassShow = businessType+workFlowType + workFlowStatus.workFlowType = workFlowType + workFlowStatus.businessType = businessType + + // 鑾峰彇list鏁版嵁 + handleSearch() } // 閲嶇疆 @@ -609,6 +738,9 @@ status: '', dateRange: [], }) + // 娓呯┖鍔ㄦ�侀�夐」 + unitProjectOptions.value = [] + productSubTypeOptions.value = [] page.current = 1 handleSearch() } @@ -617,9 +749,76 @@ const toApprove = (row: any) => router.push({ name: 'tradeApproval', params: { id: row.id } }) const toCheckFiles = (row: any) => router.push({ name: 'tradeCheckFiles', params: { id: row.id } }) const toDetail = (row: any) => router.push({ name: 'tradeOrderDetail', 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.TRADE_APPROVAL, order.orderStatus) +} + +// 澶勭悊鎿嶄綔鐐瑰嚮 +const handleAction = (action: any, order: any) => { + switch (action.type) { + case ActionType.VIEW: + toDetail(order) + break + case ActionType.TRACK: + toTrack(order) + break + case ActionType.WAIT_APPROVAL_AUTHORIZE: + case ActionType.AUTHORIZE: + toAuthorize(order) + break + default: + console.warn('鏈煡鐨勬搷浣滅被鍨�:', action.type) + } +} + +// 鎺堟潈锛氳烦杞埌鎺堟潈椤甸潰 +const toAuthorize = (row: any) => { + router.push({ name: 'tradeAuthorization', params: { id: row.id, taskId: row.taskId } }) +} + +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"> @@ -757,12 +956,16 @@ 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; @@ -778,6 +981,11 @@ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + } + + &.status-item { + justify-content: flex-start; + margin-left: 0; } } } @@ -1003,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> -- Gitblit v1.8.0