|
|
@@ -89,7 +89,8 @@
|
|
89
|
89
|
<view class="fe-thinking-dots__dot" />
|
|
90
|
90
|
</view>
|
|
91
|
91
|
<view v-else class="fe-chat-bubble__text-wrap">
|
|
92
|
|
- <text class="fe-chat-bubble__text" user-select>{{ msg.content }}</text>
|
|
|
92
|
+ <FeChatMarkdown v-if="msg.role === 'ai'" :content="msg.content" />
|
|
|
93
|
+ <text v-else class="fe-chat-bubble__text" user-select>{{ msg.content }}</text>
|
|
93
|
94
|
</view>
|
|
94
|
95
|
</view>
|
|
95
|
96
|
</view>
|
|
|
@@ -105,7 +106,7 @@
|
|
105
|
106
|
<view class="fe-biz-card__row"><text>3. 结算单待确认</text><text class="fe-biz-card__val">¥12,800</text></view>
|
|
106
|
107
|
<view class="fe-biz-card__actions">
|
|
107
|
108
|
<view class="fe-biz-btn" @tap.stop="toast('已发送催办')">一键催办</view>
|
|
108
|
|
- <view class="fe-biz-btn" @tap.stop="openSheet('progress')">查看进度</view>
|
|
|
109
|
+ <view class="fe-biz-btn" @tap.stop="openProgressOverview">查看进度</view>
|
|
109
|
110
|
</view>
|
|
110
|
111
|
</view>
|
|
111
|
112
|
</view>
|
|
|
@@ -147,6 +148,34 @@
|
|
147
|
148
|
</view>
|
|
148
|
149
|
</view>
|
|
149
|
150
|
|
|
|
151
|
+ <!-- QR card(确认方案后) -->
|
|
|
152
|
+ <view v-else-if="msg.type === 'qr'" class="fe-chat-msg fe-chat-msg--ai" :id="'msg-' + idx">
|
|
|
153
|
+ <view class="fe-chat-avatar fe-chat-avatar--ai">AI</view>
|
|
|
154
|
+ <view class="fe-chat-bubble">
|
|
|
155
|
+ <view class="fe-biz-card fe-biz-card--qr" @tap="openQrByIndex(idx)">
|
|
|
156
|
+ <view class="fe-biz-card__header">
|
|
|
157
|
+ <text class="fe-biz-card__header-title">工人登记二维码</text>
|
|
|
158
|
+ </view>
|
|
|
159
|
+ <text v-if="qrSubtitleByIndex(idx)" class="fe-qr-card__subtitle">{{ qrSubtitleByIndex(idx) }}</text>
|
|
|
160
|
+ <image
|
|
|
161
|
+ v-if="qrImageUrlByIndex(idx)"
|
|
|
162
|
+ class="fe-qr-card__img"
|
|
|
163
|
+ :src="qrImageUrlByIndex(idx)"
|
|
|
164
|
+ mode="aspectFit"
|
|
|
165
|
+ @tap.stop="openQrByIndex(idx)"
|
|
|
166
|
+ />
|
|
|
167
|
+ <view v-else class="fe-qr-card__empty">
|
|
|
168
|
+ <text class="fe-qr-card__empty-text">二维码加载中,可点此刷新</text>
|
|
|
169
|
+ </view>
|
|
|
170
|
+ <text class="fe-qr-card__hint">{{ qrHintByIndex(idx) }}</text>
|
|
|
171
|
+ <view class="fe-biz-card__actions">
|
|
|
172
|
+ <view class="fe-biz-btn" @tap.stop="openProgressByQrIndex(idx)">查看进度</view>
|
|
|
173
|
+ <view class="fe-biz-btn fe-biz-btn--primary" @tap.stop="openQrByIndex(idx)">查看 / 分享</view>
|
|
|
174
|
+ </view>
|
|
|
175
|
+ </view>
|
|
|
176
|
+ </view>
|
|
|
177
|
+ </view>
|
|
|
178
|
+
|
|
150
|
179
|
<!-- Orders -->
|
|
151
|
180
|
<view v-else-if="msg.type === 'orders'" class="fe-chat-msg fe-chat-msg--ai" :id="'msg-' + idx">
|
|
152
|
181
|
<view class="fe-chat-avatar fe-chat-avatar--ai">AI</view>
|
|
|
@@ -211,15 +240,15 @@
|
|
211
|
240
|
<!-- Footer: Quick Actions + Input -->
|
|
212
|
241
|
<view class="chat-footer">
|
|
213
|
242
|
<view class="fe-quick-actions fe-quick-actions--dock guide-target guide-target--quick-bar">
|
|
214
|
|
- <view class="fe-quick-action" @tap="triggerAI('发布需求')">
|
|
|
243
|
+ <view class="fe-quick-action" @tap="triggerAI('新用工需求')">
|
|
215
|
244
|
<view class="fe-quick-action__icon" style="background:#FEF3C7;">➕</view>
|
|
216
|
245
|
<text class="fe-quick-action__label">发布需求</text>
|
|
217
|
246
|
</view>
|
|
218
|
|
- <view class="fe-quick-action" @tap="openSheet('cost')">
|
|
|
247
|
+ <view class="fe-quick-action" @tap="openConversationCost">
|
|
219
|
248
|
<view class="fe-quick-action__icon" style="background:#D1FAE5;">💰</view>
|
|
220
|
249
|
<text class="fe-quick-action__label">成本测算</text>
|
|
221
|
250
|
</view>
|
|
222
|
|
- <view class="fe-quick-action" @tap="openSheet('progress')">
|
|
|
251
|
+ <view class="fe-quick-action" @tap="openProgressOverview">
|
|
223
|
252
|
<view class="fe-quick-action__icon" style="background:#DBEAFE;">📈</view>
|
|
224
|
253
|
<text class="fe-quick-action__label">进度总览</text>
|
|
225
|
254
|
</view>
|
|
|
@@ -264,9 +293,24 @@
|
|
264
|
293
|
@updated="onDraftUpdated"
|
|
265
|
294
|
@view-qr="openDraftQr"
|
|
266
|
295
|
/>
|
|
267
|
|
- <FeCostSheet :active="activeSheet === 'cost'" @confirm="confirmPlan" />
|
|
268
|
|
- <FeReportSheet :active="activeSheet === 'report'" @progress="openSheet('progress')" />
|
|
269
|
|
- <FeProgressSheet :active="activeSheet === 'progress'" :elevated="sheetElevated" />
|
|
|
296
|
+ <FeConversationCostSheet
|
|
|
297
|
+ :active="activeSheet === 'cost'"
|
|
|
298
|
+ :conversation-id="currentConversationId"
|
|
|
299
|
+ :draft-metas="costDraftMetas"
|
|
|
300
|
+ @confirm="onConversationCostConfirm"
|
|
|
301
|
+ @updated="onDraftUpdated($event, { sinkToBottom: false })"
|
|
|
302
|
+ @view-qr="openDraftQr"
|
|
|
303
|
+ />
|
|
|
304
|
+ <FeReportSheet :active="activeSheet === 'report'" @progress="openProgressOverview" />
|
|
|
305
|
+ <FeConversationProgressSheet
|
|
|
306
|
+ :active="activeSheet === 'progressOverview'"
|
|
|
307
|
+ :conversation-id="currentConversationId"
|
|
|
308
|
+ />
|
|
|
309
|
+ <FeProgressSheet
|
|
|
310
|
+ :active="activeSheet === 'progress'"
|
|
|
311
|
+ :elevated="sheetElevated"
|
|
|
312
|
+ :draft-id="progressDraftId"
|
|
|
313
|
+ />
|
|
270
|
314
|
<FeSettlementSheet :active="activeSheet === 'settlement'" @pay="showPayment" />
|
|
271
|
315
|
|
|
272
|
316
|
<!-- Drawer: Message -->
|
|
|
@@ -313,7 +357,13 @@
|
|
313
|
357
|
</view>
|
|
314
|
358
|
</view>
|
|
315
|
359
|
|
|
316
|
|
- <FeBatchQrModal :active="modal === 'qr'" :batch="qrBatch" @close="closeModal" @progress="openQrProgress" />
|
|
|
360
|
+ <FeBatchQrModal
|
|
|
361
|
+ :active="modal === 'qr'"
|
|
|
362
|
+ :batch="qrBatch"
|
|
|
363
|
+ @close="closeModal"
|
|
|
364
|
+ @progress="openQrProgress"
|
|
|
365
|
+ @progress-loaded="onQrProgressLoaded"
|
|
|
366
|
+ />
|
|
317
|
367
|
|
|
318
|
368
|
<!-- Modal Payment -->
|
|
319
|
369
|
<view class="fe-modal" :class="{ 'fe-modal--active': modal === 'payment' }">
|
|
|
@@ -344,12 +394,14 @@
|
|
344
|
394
|
<script>
|
|
345
|
395
|
import EnterpriseHubPanel from '@/packageA/components/EnterpriseHubPanel.vue'
|
|
346
|
396
|
import FeDraftSheet from '@/packageA/components/chat/FeDraftSheet.vue'
|
|
347
|
|
-import FeCostSheet from '@/packageA/components/chat/FeCostSheet.vue'
|
|
|
397
|
+import FeConversationCostSheet from '@/packageA/components/chat/FeConversationCostSheet.vue'
|
|
|
398
|
+import FeConversationProgressSheet from '@/packageA/components/chat/FeConversationProgressSheet.vue'
|
|
348
|
399
|
import FeProgressSheet from '@/packageA/components/chat/FeProgressSheet.vue'
|
|
349
|
400
|
import FeSettlementSheet from '@/packageA/components/chat/FeSettlementSheet.vue'
|
|
350
|
401
|
import FeReportSheet from '@/packageA/components/chat/FeReportSheet.vue'
|
|
351
|
402
|
import FeReportFloat from '@/packageA/components/chat/FeReportFloat.vue'
|
|
352
|
403
|
import FeBatchQrModal from '@/packageA/components/chat/FeBatchQrModal.vue'
|
|
|
404
|
+import FeChatMarkdown from '@/packageA/components/chat/FeChatMarkdown.vue'
|
|
353
|
405
|
import store from '@/common/store.js'
|
|
354
|
406
|
import { MESSAGES, BATCH_QR, showToast } from '@/common/chat-data.js'
|
|
355
|
407
|
import { listConversations, createConversation, streamConversationChat, listConversationMessages } from '@/api/conversation.js'
|
|
|
@@ -363,9 +415,15 @@ import {
|
|
363
|
415
|
} from '@/utils/conversation.js'
|
|
364
|
416
|
import {
|
|
365
|
417
|
shouldFetchDraftCard,
|
|
|
418
|
+ shouldShowOrderQrcode,
|
|
|
419
|
+ isDraftCardContentType,
|
|
366
|
420
|
buildDraftCardMessage,
|
|
367
|
421
|
mapDraftDetailToCard,
|
|
368
|
|
- getDraftStatus
|
|
|
422
|
+ getDraftStatus,
|
|
|
423
|
+ pickDraftQrCodeUrl,
|
|
|
424
|
+ pickDraftQrToken,
|
|
|
425
|
+ parseChatCardPayload,
|
|
|
426
|
+ formatDraftMoney
|
|
369
|
427
|
} from '@/utils/draft.js'
|
|
370
|
428
|
import {
|
|
371
|
429
|
buildJobOfferFromDraft,
|
|
|
@@ -373,6 +431,7 @@ import {
|
|
373
|
431
|
buildJobOfferPageUrl,
|
|
374
|
432
|
buildJobOfferShareMessage
|
|
375
|
433
|
} from '@/utils/job-offer.js'
|
|
|
434
|
+import { resolveApiAssetUrl } from '@/common/config.js'
|
|
376
|
435
|
|
|
377
|
436
|
export default {
|
|
378
|
437
|
name: 'EnterpriseHome',
|
|
|
@@ -385,12 +444,14 @@ export default {
|
|
385
|
444
|
components: {
|
|
386
|
445
|
EnterpriseHubPanel,
|
|
387
|
446
|
FeDraftSheet,
|
|
388
|
|
- FeCostSheet,
|
|
|
447
|
+ FeConversationCostSheet,
|
|
|
448
|
+ FeConversationProgressSheet,
|
|
389
|
449
|
FeProgressSheet,
|
|
390
|
450
|
FeSettlementSheet,
|
|
391
|
451
|
FeReportSheet,
|
|
392
|
452
|
FeReportFloat,
|
|
393
|
|
- FeBatchQrModal
|
|
|
453
|
+ FeBatchQrModal,
|
|
|
454
|
+ FeChatMarkdown
|
|
394
|
455
|
},
|
|
395
|
456
|
data() {
|
|
396
|
457
|
return {
|
|
|
@@ -426,7 +487,9 @@ export default {
|
|
426
|
487
|
inbox: MESSAGES,
|
|
427
|
488
|
reportCardVisible: true,
|
|
428
|
489
|
reportObserver: null,
|
|
429
|
|
- _localMsgSeq: 0
|
|
|
490
|
+ _localMsgSeq: 0,
|
|
|
491
|
+ progressDraftId: null,
|
|
|
492
|
+ costDraftMetas: []
|
|
430
|
493
|
}
|
|
431
|
494
|
},
|
|
432
|
495
|
computed: {
|
|
|
@@ -888,8 +951,13 @@ export default {
|
|
888
|
951
|
} else if (!this.messages[aiIdx].content) {
|
|
889
|
952
|
this.$set(this.messages[aiIdx], 'content', '暂无回复,请稍后重试')
|
|
890
|
953
|
}
|
|
|
954
|
+ // 仅当本轮 SSE 明确提到某草稿 id(card_draft / card_order)时,才将该草稿卡沉底
|
|
891
|
955
|
if (shouldFetchDraftCard(cardMeta)) {
|
|
892
|
|
- await this.appendDraftCardById(cardMeta.relatedDraftId)
|
|
|
956
|
+ await this.appendDraftCardById(cardMeta.relatedDraftId, { sinkToBottom: true })
|
|
|
957
|
+ }
|
|
|
958
|
+ // next_action=show_order_qrcode → 弹出「方案已确认」
|
|
|
959
|
+ if (shouldShowOrderQrcode(cardMeta)) {
|
|
|
960
|
+ await this.showOrderConfirmFromChat(cardMeta)
|
|
893
|
961
|
}
|
|
894
|
962
|
this.ensureChatBottom()
|
|
895
|
963
|
this.stopChatStream()
|
|
|
@@ -945,29 +1013,65 @@ export default {
|
|
945
|
1013
|
if (draft.confirmedPlan) card.confirmedPlan = draft.confirmedPlan
|
|
946
|
1014
|
if (draft.confirmedPlanTitle) card.confirmedPlanTitle = draft.confirmedPlanTitle
|
|
947
|
1015
|
if (draft.orderId && !card.orderId) card.orderId = draft.orderId
|
|
948
|
|
- if (draft.qrCodeUrl && !card.qrCodeUrl) card.qrCodeUrl = draft.qrCodeUrl
|
|
|
1016
|
+ if (draft.qrToken && !card.qrToken) card.qrToken = draft.qrToken
|
|
|
1017
|
+ if (draft.scene && !card.scene) card.scene = draft.scene
|
|
|
1018
|
+ // qrCodeUrl 以详情接口为准;详情暂无时才回退本地
|
|
|
1019
|
+ if (!card.qrCodeUrl && draft.qrCodeUrl) card.qrCodeUrl = draft.qrCodeUrl
|
|
|
1020
|
+ if (card.qrToken && !card.scene) card.scene = card.qrToken
|
|
949
|
1021
|
if (draft.selectedSchemeCode && !card.selectedSchemeCode) {
|
|
950
|
1022
|
card.selectedSchemeCode = draft.selectedSchemeCode
|
|
951
|
1023
|
}
|
|
952
|
|
- this.onDraftUpdated(card)
|
|
|
1024
|
+ this.onDraftUpdated(card, { sinkToBottom: false })
|
|
953
|
1025
|
} catch (e) {
|
|
954
|
1026
|
// 静默失败,沿用本地草稿
|
|
955
|
1027
|
}
|
|
956
|
1028
|
},
|
|
957
|
|
- onDraftUpdated(draftCard) {
|
|
|
1029
|
+ /**
|
|
|
1030
|
+ * 移除会话中指定草稿卡片(保留对话文本)
|
|
|
1031
|
+ */
|
|
|
1032
|
+ removeDraftCardById(draftId) {
|
|
|
1033
|
+ if (draftId == null) return
|
|
|
1034
|
+ const id = Number(draftId)
|
|
|
1035
|
+ if (Number.isNaN(id)) return
|
|
|
1036
|
+ for (let i = this.messages.length - 1; i >= 0; i--) {
|
|
|
1037
|
+ const msg = this.messages[i]
|
|
|
1038
|
+ if (msg && msg.type === 'draft' && msg.draftId === id) {
|
|
|
1039
|
+ this.messages.splice(i, 1)
|
|
|
1040
|
+ }
|
|
|
1041
|
+ }
|
|
|
1042
|
+ },
|
|
|
1043
|
+ /**
|
|
|
1044
|
+ * 更新草稿卡片
|
|
|
1045
|
+ * @param {object} draftCard
|
|
|
1046
|
+ * @param {{ sinkToBottom?: boolean }} [options] sinkToBottom 默认 true:同 id 旧卡移除后沉底
|
|
|
1047
|
+ */
|
|
|
1048
|
+ onDraftUpdated(draftCard, options = {}) {
|
|
958
|
1049
|
if (!draftCard || draftCard.draftId == null) return
|
|
959
|
1050
|
this.activeDraft = draftCard
|
|
960
|
|
- for (let i = 0; i < this.messages.length; i++) {
|
|
961
|
|
- const msg = this.messages[i]
|
|
962
|
|
- if (msg.type === 'draft' && msg.draftId === draftCard.draftId) {
|
|
963
|
|
- this.$set(this.messages[i], 'draft', draftCard)
|
|
964
|
|
- break
|
|
|
1051
|
+ const sinkToBottom = options.sinkToBottom !== false
|
|
|
1052
|
+ if (!sinkToBottom) {
|
|
|
1053
|
+ for (let i = 0; i < this.messages.length; i++) {
|
|
|
1054
|
+ const msg = this.messages[i]
|
|
|
1055
|
+ if (msg.type === 'draft' && msg.draftId === draftCard.draftId) {
|
|
|
1056
|
+ this.$set(this.messages[i], 'draft', draftCard)
|
|
|
1057
|
+ break
|
|
|
1058
|
+ }
|
|
965
|
1059
|
}
|
|
|
1060
|
+ return
|
|
966
|
1061
|
}
|
|
|
1062
|
+ this.removeDraftCardById(draftCard.draftId)
|
|
|
1063
|
+ this.messages.push({
|
|
|
1064
|
+ type: 'draft',
|
|
|
1065
|
+ role: 'ai',
|
|
|
1066
|
+ msgKey: this.nextLocalMsgKey(),
|
|
|
1067
|
+ draftId: draftCard.draftId,
|
|
|
1068
|
+ draft: draftCard
|
|
|
1069
|
+ })
|
|
|
1070
|
+ this.ensureChatBottom()
|
|
967
|
1071
|
},
|
|
968
|
1072
|
/**
|
|
969
|
|
- * 历史消息中 content_type=card_draft 且带 related_draft_id 时,拉详情并插入草稿卡片
|
|
970
|
|
- * @param {Array} [sourceMessages] 仅处理给定列表,默认扫描当前全部消息
|
|
|
1073
|
+ * 历史消息:每个 related_draft_id 对应一张草稿卡,插到「提到该 id」的文本之后;其它草稿互不影响
|
|
|
1074
|
+ * @param {Array} [sourceMessages]
|
|
971
|
1075
|
*/
|
|
972
|
1076
|
async hydrateDraftCardsFromMessages(sourceMessages) {
|
|
973
|
1077
|
const list = Array.isArray(sourceMessages) ? sourceMessages : this.messages
|
|
|
@@ -975,26 +1079,37 @@ export default {
|
|
975
|
1079
|
for (let i = 0; i < list.length; i++) {
|
|
976
|
1080
|
const msg = list[i]
|
|
977
|
1081
|
if (!msg || msg.type !== 'text') continue
|
|
978
|
|
- if (msg.contentType !== 'card_draft' || msg.relatedDraftId == null) continue
|
|
979
|
|
- if (this.messages.some((m) => m.type === 'draft' && m.draftId === msg.relatedDraftId)) continue
|
|
980
|
|
- if (draftIds.indexOf(msg.relatedDraftId) === -1) {
|
|
981
|
|
- draftIds.push(msg.relatedDraftId)
|
|
982
|
|
- }
|
|
|
1082
|
+ if (!isDraftCardContentType(msg.contentType) || msg.relatedDraftId == null) continue
|
|
|
1083
|
+ const id = msg.relatedDraftId
|
|
|
1084
|
+ const prev = draftIds.indexOf(id)
|
|
|
1085
|
+ if (prev >= 0) draftIds.splice(prev, 1)
|
|
|
1086
|
+ draftIds.push(id)
|
|
983
|
1087
|
}
|
|
984
|
1088
|
for (let i = 0; i < draftIds.length; i++) {
|
|
985
|
|
- await this.appendDraftCardById(draftIds[i], { afterRelatedText: true })
|
|
|
1089
|
+ const id = draftIds[i]
|
|
|
1090
|
+ this.removeDraftCardById(id)
|
|
|
1091
|
+ await this.appendDraftCardById(id, { afterRelatedText: true })
|
|
986
|
1092
|
}
|
|
987
|
1093
|
},
|
|
988
|
1094
|
/**
|
|
989
|
1095
|
* 查询草稿详情并插入聊天气泡卡片
|
|
990
|
1096
|
* @param {number} draftId
|
|
991
|
|
- * @param {{ afterRelatedText?: boolean }} [options]
|
|
|
1097
|
+ * @param {{ afterRelatedText?: boolean, sinkToBottom?: boolean }} [options]
|
|
|
1098
|
+ * afterRelatedText:插到提到该草稿 id 的文本后(历史还原)
|
|
|
1099
|
+ * sinkToBottom:本轮对话提到该 id 时,移除同 id 旧卡并沉底(其它草稿卡不动)
|
|
992
|
1100
|
*/
|
|
993
|
1101
|
async appendDraftCardById(draftId, options = {}) {
|
|
994
|
1102
|
if (draftId == null) return null
|
|
995
|
1103
|
const id = Number(draftId)
|
|
996
|
1104
|
if (Number.isNaN(id)) return null
|
|
997
|
|
- if (this.messages.some((m) => m.type === 'draft' && m.draftId === id)) return null
|
|
|
1105
|
+ const exists = this.messages.some((m) => m.type === 'draft' && m.draftId === id)
|
|
|
1106
|
+ if (exists && options.sinkToBottom) {
|
|
|
1107
|
+ this.removeDraftCardById(id)
|
|
|
1108
|
+ } else if (exists && options.afterRelatedText) {
|
|
|
1109
|
+ return null
|
|
|
1110
|
+ } else if (exists) {
|
|
|
1111
|
+ return null
|
|
|
1112
|
+ }
|
|
998
|
1113
|
|
|
999
|
1114
|
try {
|
|
1000
|
1115
|
const detail = await getDraftDetail(id, { showError: false })
|
|
|
@@ -1005,16 +1120,27 @@ export default {
|
|
1005
|
1120
|
let insertAt = -1
|
|
1006
|
1121
|
for (let i = this.messages.length - 1; i >= 0; i--) {
|
|
1007
|
1122
|
const msg = this.messages[i]
|
|
1008
|
|
- if (msg.type === 'text' && msg.relatedDraftId === id) {
|
|
|
1123
|
+ if (
|
|
|
1124
|
+ msg.type === 'text'
|
|
|
1125
|
+ && msg.relatedDraftId === id
|
|
|
1126
|
+ && isDraftCardContentType(msg.contentType)
|
|
|
1127
|
+ ) {
|
|
1009
|
1128
|
insertAt = i + 1
|
|
1010
|
1129
|
break
|
|
1011
|
1130
|
}
|
|
1012
|
1131
|
}
|
|
1013
|
|
- if (insertAt >= 0) {
|
|
1014
|
|
- this.messages.splice(insertAt, 0, cardMsg)
|
|
1015
|
|
- } else {
|
|
1016
|
|
- this.messages.push(cardMsg)
|
|
|
1132
|
+ if (insertAt < 0) {
|
|
|
1133
|
+ for (let i = this.messages.length - 1; i >= 0; i--) {
|
|
|
1134
|
+ const msg = this.messages[i]
|
|
|
1135
|
+ if (msg.type === 'text' && msg.relatedDraftId === id) {
|
|
|
1136
|
+ insertAt = i + 1
|
|
|
1137
|
+ break
|
|
|
1138
|
+ }
|
|
|
1139
|
+ }
|
|
1017
|
1140
|
}
|
|
|
1141
|
+ // 只插到「提到该草稿 id」的消息后面,找不到则不误沉底
|
|
|
1142
|
+ if (insertAt < 0) return null
|
|
|
1143
|
+ this.messages.splice(insertAt, 0, cardMsg)
|
|
1018
|
1144
|
} else {
|
|
1019
|
1145
|
this.messages.push(cardMsg)
|
|
1020
|
1146
|
}
|
|
|
@@ -1079,15 +1205,21 @@ export default {
|
|
1079
|
1205
|
const subtitle = batchId ? `${sceneTitle} ${batchId}` : sceneTitle
|
|
1080
|
1206
|
const enterpriseName = (this.enterprise && this.enterprise.name) || ''
|
|
1081
|
1207
|
const scheme = options.scheme || (draft && draft.confirmedPlan) || null
|
|
1082
|
|
- const qrCodeUrl = options.qrCodeUrl
|
|
1083
|
|
- || (draft && (draft.qrCodeUrl || draft.qr_code_url || draft.ar_code_url))
|
|
|
1208
|
+ const qrCodeUrl = options.qrCodeUrl || pickDraftQrCodeUrl(draft) || ''
|
|
|
1209
|
+ const qrToken = options.qrToken
|
|
|
1210
|
+ || pickDraftQrToken(draft)
|
|
|
1211
|
+ || options.orderId
|
|
|
1212
|
+ || (draft && draft.orderId)
|
|
1084
|
1213
|
|| ''
|
|
1085
|
1214
|
const offer = buildJobOfferFromDraft(draft, {
|
|
1086
|
1215
|
batchId,
|
|
1087
|
1216
|
draftId,
|
|
1088
|
1217
|
scheme,
|
|
1089
|
1218
|
schemeTitle: options.schemeTitle || (scheme && scheme.title),
|
|
1090
|
|
- enterpriseName
|
|
|
1219
|
+ enterpriseName,
|
|
|
1220
|
+ orderId: options.orderId || (draft && draft.orderId) || '',
|
|
|
1221
|
+ qrToken,
|
|
|
1222
|
+ scene: qrToken || options.scene || (draft && draft.scene) || ''
|
|
1091
|
1223
|
})
|
|
1092
|
1224
|
saveJobOffer(offer)
|
|
1093
|
1225
|
return Object.assign({}, BATCH_QR, {
|
|
|
@@ -1095,6 +1227,9 @@ export default {
|
|
1095
|
1227
|
title: sceneTitle,
|
|
1096
|
1228
|
batchId,
|
|
1097
|
1229
|
draftId: offer.draftId,
|
|
|
1230
|
+ orderId: offer.orderId || '',
|
|
|
1231
|
+ qrToken: offer.qrToken || qrToken || '',
|
|
|
1232
|
+ scene: offer.scene || offer.qrToken || qrToken || '',
|
|
1098
|
1233
|
subtitle,
|
|
1099
|
1234
|
qrCodeUrl,
|
|
1100
|
1235
|
total: workerCount > 0 ? workerCount : BATCH_QR.total,
|
|
|
@@ -1103,22 +1238,216 @@ export default {
|
|
1103
|
1238
|
shareLink: buildJobOfferPageUrl(offer)
|
|
1104
|
1239
|
})
|
|
1105
|
1240
|
},
|
|
1106
|
|
- pickConfirmQrUrl(result) {
|
|
1107
|
|
- if (!result || typeof result !== 'object') return ''
|
|
1108
|
|
- return result.qrCodeUrl
|
|
1109
|
|
- || result.qr_code_url
|
|
1110
|
|
- || result.ar_code_url
|
|
1111
|
|
- || result.arCodeUrl
|
|
|
1241
|
+ /**
|
|
|
1242
|
+ * 从草稿详情拉取最新 qrCodeUrl / qrToken,并回写 activeDraft
|
|
|
1243
|
+ */
|
|
|
1244
|
+ async refreshDraftQrFromDetail(draftId) {
|
|
|
1245
|
+ if (draftId == null) return { qrCodeUrl: '', qrToken: '' }
|
|
|
1246
|
+ try {
|
|
|
1247
|
+ const detail = await getDraftDetail(draftId, { showError: false })
|
|
|
1248
|
+ if (!detail || detail.id == null) return { qrCodeUrl: '', qrToken: '' }
|
|
|
1249
|
+ const qrCodeUrl = pickDraftQrCodeUrl(detail)
|
|
|
1250
|
+ const qrToken = pickDraftQrToken(detail)
|
|
|
1251
|
+ const card = mapDraftDetailToCard(detail)
|
|
|
1252
|
+ const prev = this.activeDraft
|
|
|
1253
|
+ if (prev && prev.draftId === detail.id) {
|
|
|
1254
|
+ const merged = Object.assign({}, prev, card, {
|
|
|
1255
|
+ qrCodeUrl,
|
|
|
1256
|
+ qrToken,
|
|
|
1257
|
+ scene: qrToken || prev.scene || '',
|
|
|
1258
|
+ confirmedPlan: prev.confirmedPlan || card.confirmedPlan,
|
|
|
1259
|
+ confirmedPlanTitle: prev.confirmedPlanTitle || card.confirmedPlanTitle,
|
|
|
1260
|
+ costPlans: prev.costPlans || card.costPlans
|
|
|
1261
|
+ })
|
|
|
1262
|
+ this.onDraftUpdated(merged, { sinkToBottom: false })
|
|
|
1263
|
+ }
|
|
|
1264
|
+ return { qrCodeUrl, qrToken }
|
|
|
1265
|
+ } catch (e) {
|
|
|
1266
|
+ return { qrCodeUrl: '', qrToken: '' }
|
|
|
1267
|
+ }
|
|
|
1268
|
+ },
|
|
|
1269
|
+ /**
|
|
|
1270
|
+ * 确认方案后在对话框追加二维码卡片(同 draft 只保留一张)
|
|
|
1271
|
+ */
|
|
|
1272
|
+ appendQrCardMessage(batch) {
|
|
|
1273
|
+ if (!batch) return
|
|
|
1274
|
+ const draftId = batch.draftId
|
|
|
1275
|
+ if (draftId != null) {
|
|
|
1276
|
+ for (let i = this.messages.length - 1; i >= 0; i--) {
|
|
|
1277
|
+ const m = this.messages[i]
|
|
|
1278
|
+ if (m && m.type === 'qr' && m.draftId === draftId) {
|
|
|
1279
|
+ this.messages.splice(i, 1)
|
|
|
1280
|
+ }
|
|
|
1281
|
+ }
|
|
|
1282
|
+ }
|
|
|
1283
|
+ this.messages.push({
|
|
|
1284
|
+ type: 'qr',
|
|
|
1285
|
+ role: 'ai',
|
|
|
1286
|
+ msgKey: this.nextLocalMsgKey(),
|
|
|
1287
|
+ draftId: draftId != null ? draftId : null,
|
|
|
1288
|
+ batch: Object.assign({}, batch)
|
|
|
1289
|
+ })
|
|
|
1290
|
+ this.ensureChatBottom()
|
|
|
1291
|
+ },
|
|
|
1292
|
+ syncQrCardMessage(batch) {
|
|
|
1293
|
+ if (!batch || batch.draftId == null) return
|
|
|
1294
|
+ for (let i = this.messages.length - 1; i >= 0; i--) {
|
|
|
1295
|
+ const m = this.messages[i]
|
|
|
1296
|
+ if (m && m.type === 'qr' && m.draftId === batch.draftId) {
|
|
|
1297
|
+ this.$set(this.messages, i, Object.assign({}, m, {
|
|
|
1298
|
+ batch: Object.assign({}, batch)
|
|
|
1299
|
+ }))
|
|
|
1300
|
+ return
|
|
|
1301
|
+ }
|
|
|
1302
|
+ }
|
|
|
1303
|
+ },
|
|
|
1304
|
+ qrImageUrlByIndex(idx) {
|
|
|
1305
|
+ const msg = this.messages[idx]
|
|
|
1306
|
+ if (!msg || msg.type !== 'qr' || !msg.batch) return ''
|
|
|
1307
|
+ const raw = msg.batch.qrCodeUrl || msg.batch.qr_code_url || ''
|
|
|
1308
|
+ return resolveApiAssetUrl(raw)
|
|
|
1309
|
+ },
|
|
|
1310
|
+ qrSubtitleByIndex(idx) {
|
|
|
1311
|
+ const msg = this.messages[idx]
|
|
|
1312
|
+ if (!msg || !msg.batch) return ''
|
|
|
1313
|
+ return msg.batch.subtitle || msg.batch.title || ''
|
|
|
1314
|
+ },
|
|
|
1315
|
+ qrHintByIndex(idx) {
|
|
|
1316
|
+ const msg = this.messages[idx]
|
|
|
1317
|
+ if (!msg || !msg.batch) return '分享给临时工扫码即可登记'
|
|
|
1318
|
+ return msg.batch.hint || '分享给临时工扫码即可登记'
|
|
|
1319
|
+ },
|
|
|
1320
|
+ openQrByIndex(idx) {
|
|
|
1321
|
+ const msg = this.messages[idx]
|
|
|
1322
|
+ if (!msg || msg.type !== 'qr' || !msg.batch) return
|
|
|
1323
|
+ this.qrBatch = Object.assign({}, msg.batch)
|
|
|
1324
|
+ this.showQR()
|
|
|
1325
|
+ },
|
|
|
1326
|
+ openProgressByQrIndex(idx) {
|
|
|
1327
|
+ const msg = this.messages[idx]
|
|
|
1328
|
+ if (!msg || msg.type !== 'qr') return
|
|
|
1329
|
+ const draftId = msg.draftId
|
|
|
1330
|
+ || (msg.batch && msg.batch.draftId)
|
|
|
1331
|
+ this.openProgressDetail(draftId)
|
|
|
1332
|
+ },
|
|
|
1333
|
+ /**
|
|
|
1334
|
+ * AI 对话 next_action=show_order_qrcode:弹出方案已确认弹框(并可查看二维码)
|
|
|
1335
|
+ */
|
|
|
1336
|
+ async showOrderConfirmFromChat(cardMeta) {
|
|
|
1337
|
+ const payload = parseChatCardPayload(cardMeta && cardMeta.cardPayload)
|
|
|
1338
|
+ const draftId = (cardMeta && cardMeta.relatedDraftId != null)
|
|
|
1339
|
+ ? cardMeta.relatedDraftId
|
|
|
1340
|
+ : (payload && (payload.draft_id != null ? payload.draft_id : payload.draftId))
|
|
|
1341
|
+ let draft = null
|
|
|
1342
|
+ if (this.activeDraft && String(this.activeDraft.draftId) === String(draftId)) {
|
|
|
1343
|
+ draft = this.activeDraft
|
|
|
1344
|
+ } else if (draftId != null) {
|
|
|
1345
|
+ for (let i = this.messages.length - 1; i >= 0; i--) {
|
|
|
1346
|
+ const msg = this.messages[i]
|
|
|
1347
|
+ if (msg && msg.type === 'draft' && String(msg.draftId) === String(draftId) && msg.draft) {
|
|
|
1348
|
+ draft = msg.draft
|
|
|
1349
|
+ break
|
|
|
1350
|
+ }
|
|
|
1351
|
+ }
|
|
|
1352
|
+ }
|
|
|
1353
|
+ if (!draft && draftId != null) {
|
|
|
1354
|
+ try {
|
|
|
1355
|
+ const detail = await getDraftDetail(draftId, { showError: false })
|
|
|
1356
|
+ if (detail) draft = mapDraftDetailToCard(detail)
|
|
|
1357
|
+ } catch (e) {
|
|
|
1358
|
+ // ignore
|
|
|
1359
|
+ }
|
|
|
1360
|
+ }
|
|
|
1361
|
+
|
|
|
1362
|
+ const orderId = (payload && (payload.order_id != null ? payload.order_id : payload.orderId))
|
|
|
1363
|
+ || (draft && draft.orderId)
|
|
|
1364
|
+ || ''
|
|
|
1365
|
+ const title = (payload && payload.title)
|
|
|
1366
|
+ || (draft && draft.title)
|
|
|
1367
|
+ || (draft && draft.confirmedPlanTitle)
|
|
|
1368
|
+ || ''
|
|
|
1369
|
+ let qrCodeUrl = (payload && (payload.qr_code_url || payload.qrCodeUrl))
|
|
|
1370
|
+ || pickDraftQrCodeUrl(draft)
|
|
1112
|
1371
|
|| ''
|
|
|
1372
|
+ let qrToken = (payload && (payload.qr_token || payload.qrToken))
|
|
|
1373
|
+ || pickDraftQrToken(draft)
|
|
|
1374
|
+ || ''
|
|
|
1375
|
+ const totalOutflow = payload && (payload.total_outflow != null ? payload.total_outflow : payload.totalOutflow)
|
|
|
1376
|
+ const totalText = totalOutflow != null && totalOutflow !== ''
|
|
|
1377
|
+ ? formatDraftMoney(totalOutflow)
|
|
|
1378
|
+ : ((draft && draft.estimatedTotalText) || '')
|
|
|
1379
|
+ const workerCount = (payload && (payload.worker_count != null ? payload.worker_count : payload.workerCount))
|
|
|
1380
|
+ || (draft && draft.workerCount)
|
|
|
1381
|
+ let avgCost = ''
|
|
|
1382
|
+ if (totalOutflow != null && workerCount > 0) {
|
|
|
1383
|
+ avgCost = `${formatDraftMoney(Number(totalOutflow) / Number(workerCount))}/人`
|
|
|
1384
|
+ } else if (draft && draft.confirmedPlan && draft.confirmedPlan.avgCost) {
|
|
|
1385
|
+ avgCost = draft.confirmedPlan.avgCost
|
|
|
1386
|
+ }
|
|
|
1387
|
+
|
|
|
1388
|
+ this.confirmInfo = {
|
|
|
1389
|
+ title: title || '方案已确认',
|
|
|
1390
|
+ code: (draft && draft.selectedSchemeCode) || '',
|
|
|
1391
|
+ total: totalText,
|
|
|
1392
|
+ avgCost,
|
|
|
1393
|
+ tagsText: '',
|
|
|
1394
|
+ orderId,
|
|
|
1395
|
+ qrToken,
|
|
|
1396
|
+ qrCodeUrl,
|
|
|
1397
|
+ draftId
|
|
|
1398
|
+ }
|
|
|
1399
|
+
|
|
|
1400
|
+ const scene = qrToken || orderId || ''
|
|
|
1401
|
+ this.qrBatch = this.buildQrBatch(draft, {
|
|
|
1402
|
+ draftId,
|
|
|
1403
|
+ scheme: draft && draft.confirmedPlan,
|
|
|
1404
|
+ schemeTitle: title,
|
|
|
1405
|
+ qrCodeUrl,
|
|
|
1406
|
+ orderId,
|
|
|
1407
|
+ qrToken,
|
|
|
1408
|
+ scene
|
|
|
1409
|
+ })
|
|
|
1410
|
+
|
|
|
1411
|
+ if (draftId != null) {
|
|
|
1412
|
+ const fromDetail = await this.refreshDraftQrFromDetail(draftId)
|
|
|
1413
|
+ if (fromDetail && fromDetail.qrCodeUrl) {
|
|
|
1414
|
+ qrCodeUrl = fromDetail.qrCodeUrl
|
|
|
1415
|
+ this.$set(this.qrBatch, 'qrCodeUrl', fromDetail.qrCodeUrl)
|
|
|
1416
|
+ this.$set(this.confirmInfo, 'qrCodeUrl', fromDetail.qrCodeUrl)
|
|
|
1417
|
+ }
|
|
|
1418
|
+ if (fromDetail && fromDetail.qrToken) {
|
|
|
1419
|
+ qrToken = fromDetail.qrToken
|
|
|
1420
|
+ this.$set(this.qrBatch, 'qrToken', fromDetail.qrToken)
|
|
|
1421
|
+ this.$set(this.qrBatch, 'scene', fromDetail.qrToken)
|
|
|
1422
|
+ this.$set(this.confirmInfo, 'qrToken', fromDetail.qrToken)
|
|
|
1423
|
+ }
|
|
|
1424
|
+ }
|
|
|
1425
|
+
|
|
|
1426
|
+ if (draft && draftId != null) {
|
|
|
1427
|
+ this.onDraftUpdated(Object.assign({}, draft, {
|
|
|
1428
|
+ status: 'confirmed',
|
|
|
1429
|
+ orderId,
|
|
|
1430
|
+ qrToken,
|
|
|
1431
|
+ qrCodeUrl,
|
|
|
1432
|
+ scene: qrToken || orderId || ''
|
|
|
1433
|
+ }), { sinkToBottom: true })
|
|
|
1434
|
+ }
|
|
|
1435
|
+
|
|
|
1436
|
+ this.appendQrCardMessage(this.qrBatch)
|
|
|
1437
|
+ this.closeAll()
|
|
|
1438
|
+ setTimeout(() => { this.modal = 'confirm' }, 300)
|
|
1113
|
1439
|
},
|
|
1114
|
|
- confirmPlan(payload) {
|
|
|
1440
|
+ async confirmPlan(payload) {
|
|
1115
|
1441
|
const scheme = (payload && payload.scheme) || null
|
|
1116
|
1442
|
const result = (payload && payload.result) || {}
|
|
1117
|
1443
|
const draft = this.activeDraft
|
|
1118
|
1444
|
const orderId = result.orderId || result.order_id || ''
|
|
1119
|
|
- const qrCodeUrl = this.pickConfirmQrUrl(result)
|
|
|
1445
|
+ let qrCodeUrl = pickDraftQrCodeUrl(draft)
|
|
|
1446
|
+ let qrToken = pickDraftQrToken(result) || pickDraftQrToken(draft) || ''
|
|
1120
|
1447
|
const tags = (scheme && Array.isArray(scheme.compliance) ? scheme.compliance : [])
|
|
1121
|
1448
|
.filter(Boolean)
|
|
|
1449
|
+ const draftId = draft && draft.draftId
|
|
|
1450
|
+ const scene = qrToken || orderId || ''
|
|
1122
|
1451
|
this.confirmInfo = {
|
|
1123
|
1452
|
title: (scheme && scheme.title) || (payload && payload.schemeCode) || '',
|
|
1124
|
1453
|
code: (payload && payload.schemeCode) || (scheme && scheme.code) || '',
|
|
|
@@ -1126,18 +1455,24 @@ export default {
|
|
1126
|
1455
|
avgCost: (scheme && scheme.avgCost) || '',
|
|
1127
|
1456
|
tagsText: tags.join('、'),
|
|
1128
|
1457
|
orderId,
|
|
1129
|
|
- qrCodeUrl
|
|
|
1458
|
+ qrToken,
|
|
|
1459
|
+ qrCodeUrl,
|
|
|
1460
|
+ draftId
|
|
1130
|
1461
|
}
|
|
1131
|
1462
|
this.qrBatch = this.buildQrBatch(draft, {
|
|
1132
|
1463
|
scheme,
|
|
1133
|
1464
|
schemeTitle: scheme && scheme.title,
|
|
1134
|
|
- qrCodeUrl
|
|
|
1465
|
+ qrCodeUrl,
|
|
|
1466
|
+ orderId,
|
|
|
1467
|
+ qrToken,
|
|
|
1468
|
+ scene
|
|
1135
|
1469
|
})
|
|
1136
|
|
- // 回写状态到气泡草稿,便于再次分享 / 查看二维码
|
|
1137
|
|
- if (draft && draft.draftId != null) {
|
|
|
1470
|
+ if (draft && draftId != null) {
|
|
1138
|
1471
|
this.onDraftUpdated(Object.assign({}, draft, {
|
|
1139
|
1472
|
orderId,
|
|
|
1473
|
+ qrToken,
|
|
1140
|
1474
|
qrCodeUrl,
|
|
|
1475
|
+ scene,
|
|
1141
|
1476
|
status: 'confirmed',
|
|
1142
|
1477
|
confirmedPlan: (scheme && {
|
|
1143
|
1478
|
id: scheme.id || scheme.code,
|
|
|
@@ -1153,35 +1488,228 @@ export default {
|
|
1153
|
1488
|
}))
|
|
1154
|
1489
|
}
|
|
1155
|
1490
|
this.closeAll()
|
|
|
1491
|
+
|
|
|
1492
|
+ // 拉最新二维码 / qrToken 后插入对话
|
|
|
1493
|
+ if (draftId != null) {
|
|
|
1494
|
+ const fromDetail = await this.refreshDraftQrFromDetail(draftId)
|
|
|
1495
|
+ if (fromDetail && fromDetail.qrCodeUrl) {
|
|
|
1496
|
+ qrCodeUrl = fromDetail.qrCodeUrl
|
|
|
1497
|
+ this.$set(this.qrBatch, 'qrCodeUrl', fromDetail.qrCodeUrl)
|
|
|
1498
|
+ this.$set(this.confirmInfo, 'qrCodeUrl', fromDetail.qrCodeUrl)
|
|
|
1499
|
+ }
|
|
|
1500
|
+ if (fromDetail && fromDetail.qrToken) {
|
|
|
1501
|
+ qrToken = fromDetail.qrToken
|
|
|
1502
|
+ this.$set(this.qrBatch, 'qrToken', fromDetail.qrToken)
|
|
|
1503
|
+ this.$set(this.qrBatch, 'scene', fromDetail.qrToken)
|
|
|
1504
|
+ this.$set(this.confirmInfo, 'qrToken', fromDetail.qrToken)
|
|
|
1505
|
+ }
|
|
|
1506
|
+ }
|
|
|
1507
|
+ this.messages.push({
|
|
|
1508
|
+ type: 'text',
|
|
|
1509
|
+ role: 'ai',
|
|
|
1510
|
+ msgKey: this.nextLocalMsgKey(),
|
|
|
1511
|
+ content: '方案已确认。请将下方二维码分享给工人扫码登记。'
|
|
|
1512
|
+ })
|
|
|
1513
|
+ this.appendQrCardMessage(this.qrBatch)
|
|
1156
|
1514
|
setTimeout(() => { this.modal = 'confirm' }, 400)
|
|
1157
|
1515
|
},
|
|
1158
|
|
- showQR() {
|
|
|
1516
|
+ async showQR() {
|
|
|
1517
|
+ const draftId = (this.qrBatch && this.qrBatch.draftId)
|
|
|
1518
|
+ || (this.confirmInfo && this.confirmInfo.draftId)
|
|
|
1519
|
+ || (this.activeDraft && this.activeDraft.draftId)
|
|
|
1520
|
+ let qrCodeUrl = pickDraftQrCodeUrl(this.qrBatch)
|
|
|
1521
|
+ || pickDraftQrCodeUrl(this.activeDraft)
|
|
|
1522
|
+ || (this.confirmInfo && this.confirmInfo.qrCodeUrl)
|
|
|
1523
|
+ || ''
|
|
|
1524
|
+ let qrToken = pickDraftQrToken(this.qrBatch)
|
|
|
1525
|
+ || pickDraftQrToken(this.activeDraft)
|
|
|
1526
|
+ || (this.confirmInfo && this.confirmInfo.qrToken)
|
|
|
1527
|
+ || ''
|
|
|
1528
|
+ if (draftId != null) {
|
|
|
1529
|
+ const fromDetail = await this.refreshDraftQrFromDetail(draftId)
|
|
|
1530
|
+ if (fromDetail && fromDetail.qrCodeUrl) qrCodeUrl = fromDetail.qrCodeUrl
|
|
|
1531
|
+ if (fromDetail && fromDetail.qrToken) qrToken = fromDetail.qrToken
|
|
|
1532
|
+ }
|
|
1159
|
1533
|
if (!this.qrBatch || !this.qrBatch.subtitle) {
|
|
1160
|
|
- this.qrBatch = this.buildQrBatch(null, {
|
|
|
1534
|
+ this.qrBatch = this.buildQrBatch(this.activeDraft, {
|
|
1161
|
1535
|
schemeTitle: this.confirmInfo && this.confirmInfo.title,
|
|
1162
|
|
- qrCodeUrl: this.confirmInfo && this.confirmInfo.qrCodeUrl
|
|
|
1536
|
+ draftId,
|
|
|
1537
|
+ qrCodeUrl,
|
|
|
1538
|
+ qrToken
|
|
1163
|
1539
|
})
|
|
1164
|
|
- } else if (this.confirmInfo && this.confirmInfo.qrCodeUrl && !this.qrBatch.qrCodeUrl) {
|
|
1165
|
|
- this.$set(this.qrBatch, 'qrCodeUrl', this.confirmInfo.qrCodeUrl)
|
|
|
1540
|
+ } else {
|
|
|
1541
|
+ this.$set(this.qrBatch, 'qrCodeUrl', qrCodeUrl)
|
|
|
1542
|
+ if (qrToken) {
|
|
|
1543
|
+ this.$set(this.qrBatch, 'qrToken', qrToken)
|
|
|
1544
|
+ this.$set(this.qrBatch, 'scene', qrToken)
|
|
|
1545
|
+ }
|
|
|
1546
|
+ if (draftId != null && this.qrBatch.draftId == null) {
|
|
|
1547
|
+ this.$set(this.qrBatch, 'draftId', draftId)
|
|
|
1548
|
+ }
|
|
1166
|
1549
|
}
|
|
|
1550
|
+ this.syncQrCardMessage(this.qrBatch)
|
|
1167
|
1551
|
this.modal = 'qr'
|
|
1168
|
1552
|
},
|
|
1169
|
|
- openDraftQr() {
|
|
1170
|
|
- this.qrBatch = this.buildQrBatch(this.activeDraft, {
|
|
1171
|
|
- scheme: this.activeDraft && this.activeDraft.confirmedPlan,
|
|
1172
|
|
- schemeTitle: this.activeDraft && this.activeDraft.confirmedPlanTitle,
|
|
1173
|
|
- qrCodeUrl: this.activeDraft && (this.activeDraft.qrCodeUrl || this.activeDraft.qr_code_url)
|
|
|
1553
|
+ async openDraftQr(payload) {
|
|
|
1554
|
+ let draft = this.activeDraft
|
|
|
1555
|
+ const payloadDraftId = payload && payload.draftId
|
|
|
1556
|
+ if (payloadDraftId != null) {
|
|
|
1557
|
+ if (!draft || draft.draftId !== payloadDraftId) {
|
|
|
1558
|
+ if (this.activeDraft && this.activeDraft.draftId === payloadDraftId) {
|
|
|
1559
|
+ draft = this.activeDraft
|
|
|
1560
|
+ } else {
|
|
|
1561
|
+ for (let i = this.messages.length - 1; i >= 0; i--) {
|
|
|
1562
|
+ const msg = this.messages[i]
|
|
|
1563
|
+ if (msg && msg.type === 'draft' && msg.draftId === payloadDraftId && msg.draft) {
|
|
|
1564
|
+ draft = msg.draft
|
|
|
1565
|
+ break
|
|
|
1566
|
+ }
|
|
|
1567
|
+ }
|
|
|
1568
|
+ }
|
|
|
1569
|
+ if (draft) this.activeDraft = draft
|
|
|
1570
|
+ }
|
|
|
1571
|
+ }
|
|
|
1572
|
+ const draftId = (draft && draft.draftId) || payloadDraftId
|
|
|
1573
|
+ let qrCodeUrl = pickDraftQrCodeUrl(draft)
|
|
|
1574
|
+ let qrToken = pickDraftQrToken(draft)
|
|
|
1575
|
+ if (draftId != null) {
|
|
|
1576
|
+ const fromDetail = await this.refreshDraftQrFromDetail(draftId)
|
|
|
1577
|
+ if (fromDetail && fromDetail.qrCodeUrl) qrCodeUrl = fromDetail.qrCodeUrl
|
|
|
1578
|
+ if (fromDetail && fromDetail.qrToken) qrToken = fromDetail.qrToken
|
|
|
1579
|
+ }
|
|
|
1580
|
+ this.qrBatch = this.buildQrBatch(this.activeDraft || draft, {
|
|
|
1581
|
+ scheme: (this.activeDraft || draft) && (this.activeDraft || draft).confirmedPlan,
|
|
|
1582
|
+ schemeTitle: (this.activeDraft || draft) && (this.activeDraft || draft).confirmedPlanTitle,
|
|
|
1583
|
+ qrCodeUrl,
|
|
|
1584
|
+ qrToken
|
|
1174
|
1585
|
})
|
|
1175
|
1586
|
this.modal = 'qr'
|
|
1176
|
1587
|
},
|
|
1177
|
1588
|
/**
|
|
1178
|
1589
|
* 供首页 onShareAppMessage 读取
|
|
|
1590
|
+ * path 参数名仍为 scene,值为 qrToken
|
|
1179
|
1591
|
*/
|
|
1180
|
1592
|
getShareAppMessage() {
|
|
1181
|
|
- const draftId = (this.qrBatch && this.qrBatch.draftId) || ''
|
|
1182
|
|
- return buildJobOfferShareMessage({ draftId })
|
|
|
1593
|
+ const draftId = (this.qrBatch && this.qrBatch.draftId)
|
|
|
1594
|
+ || (this.activeDraft && this.activeDraft.draftId)
|
|
|
1595
|
+ || ''
|
|
|
1596
|
+ const orderId = (this.qrBatch && this.qrBatch.orderId)
|
|
|
1597
|
+ || (this.activeDraft && this.activeDraft.orderId)
|
|
|
1598
|
+ || (this.confirmInfo && this.confirmInfo.orderId)
|
|
|
1599
|
+ || ''
|
|
|
1600
|
+ const qrToken = (this.qrBatch && this.qrBatch.qrToken)
|
|
|
1601
|
+ || (this.activeDraft && this.activeDraft.qrToken)
|
|
|
1602
|
+ || (this.confirmInfo && this.confirmInfo.qrToken)
|
|
|
1603
|
+ || ''
|
|
|
1604
|
+ const scene = qrToken
|
|
|
1605
|
+ || (this.qrBatch && this.qrBatch.scene)
|
|
|
1606
|
+ || (this.activeDraft && this.activeDraft.scene)
|
|
|
1607
|
+ || orderId
|
|
|
1608
|
+ || ''
|
|
|
1609
|
+ return buildJobOfferShareMessage({ draftId, orderId, scene, qrToken })
|
|
1183
|
1610
|
},
|
|
1184
|
1611
|
openQrProgress() {
|
|
|
1612
|
+ const draftId = (this.qrBatch && this.qrBatch.draftId)
|
|
|
1613
|
+ || (this.activeDraft && this.activeDraft.draftId)
|
|
|
1614
|
+ || (this.confirmInfo && this.confirmInfo.draftId)
|
|
|
1615
|
+ this.openProgressDetail(draftId)
|
|
|
1616
|
+ },
|
|
|
1617
|
+ onQrProgressLoaded(payload) {
|
|
|
1618
|
+ if (!payload || !this.qrBatch) return
|
|
|
1619
|
+ if (payload.registered != null) {
|
|
|
1620
|
+ this.$set(this.qrBatch, 'registered', payload.registered)
|
|
|
1621
|
+ }
|
|
|
1622
|
+ if (payload.total != null) {
|
|
|
1623
|
+ this.$set(this.qrBatch, 'total', payload.total)
|
|
|
1624
|
+ }
|
|
|
1625
|
+ this.syncQrCardMessage(this.qrBatch)
|
|
|
1626
|
+ },
|
|
|
1627
|
+ openProgressOverview() {
|
|
|
1628
|
+ if (!this.currentConversationId) {
|
|
|
1629
|
+ this.toast('请先开启新对话')
|
|
|
1630
|
+ return
|
|
|
1631
|
+ }
|
|
|
1632
|
+ this.openSheet('progressOverview')
|
|
|
1633
|
+ },
|
|
|
1634
|
+ collectCostDraftMetas() {
|
|
|
1635
|
+ const metas = []
|
|
|
1636
|
+ const seen = {}
|
|
|
1637
|
+ const pushMeta = (draftId, title, workerCount) => {
|
|
|
1638
|
+ if (draftId == null || draftId === '') return
|
|
|
1639
|
+ const key = String(draftId)
|
|
|
1640
|
+ if (seen[key]) return
|
|
|
1641
|
+ seen[key] = true
|
|
|
1642
|
+ metas.push({
|
|
|
1643
|
+ draftId,
|
|
|
1644
|
+ title: title || `用工草稿 #${draftId}`,
|
|
|
1645
|
+ workerCount: workerCount != null ? Number(workerCount) : null
|
|
|
1646
|
+ })
|
|
|
1647
|
+ }
|
|
|
1648
|
+ for (let i = 0; i < this.messages.length; i++) {
|
|
|
1649
|
+ const msg = this.messages[i]
|
|
|
1650
|
+ if (!msg || msg.type !== 'draft' || msg.draftId == null) continue
|
|
|
1651
|
+ const d = msg.draft || {}
|
|
|
1652
|
+ pushMeta(msg.draftId, d.title, d.workerCount)
|
|
|
1653
|
+ }
|
|
|
1654
|
+ if (this.activeDraft && this.activeDraft.draftId != null) {
|
|
|
1655
|
+ pushMeta(
|
|
|
1656
|
+ this.activeDraft.draftId,
|
|
|
1657
|
+ this.activeDraft.title,
|
|
|
1658
|
+ this.activeDraft.workerCount
|
|
|
1659
|
+ )
|
|
|
1660
|
+ }
|
|
|
1661
|
+ return metas
|
|
|
1662
|
+ },
|
|
|
1663
|
+ openConversationCost() {
|
|
|
1664
|
+ if (!this.currentConversationId) {
|
|
|
1665
|
+ this.toast('请先开启新对话')
|
|
|
1666
|
+ return
|
|
|
1667
|
+ }
|
|
|
1668
|
+ this.costDraftMetas = this.collectCostDraftMetas()
|
|
|
1669
|
+ this.openSheet('cost')
|
|
|
1670
|
+ },
|
|
|
1671
|
+ async onConversationCostConfirm(payload) {
|
|
|
1672
|
+ const draftId = payload && payload.draftId
|
|
|
1673
|
+ if (draftId == null) {
|
|
|
1674
|
+ this.confirmPlan(payload)
|
|
|
1675
|
+ return
|
|
|
1676
|
+ }
|
|
|
1677
|
+ let draft = null
|
|
|
1678
|
+ if (this.activeDraft && this.activeDraft.draftId === draftId) {
|
|
|
1679
|
+ draft = this.activeDraft
|
|
|
1680
|
+ } else {
|
|
|
1681
|
+ for (let i = this.messages.length - 1; i >= 0; i--) {
|
|
|
1682
|
+ const msg = this.messages[i]
|
|
|
1683
|
+ if (msg && msg.type === 'draft' && msg.draftId === draftId && msg.draft) {
|
|
|
1684
|
+ draft = msg.draft
|
|
|
1685
|
+ break
|
|
|
1686
|
+ }
|
|
|
1687
|
+ }
|
|
|
1688
|
+ }
|
|
|
1689
|
+ if (!draft) {
|
|
|
1690
|
+ try {
|
|
|
1691
|
+ const detail = await getDraftDetail(draftId, { showError: false })
|
|
|
1692
|
+ if (detail) draft = mapDraftDetailToCard(detail)
|
|
|
1693
|
+ } catch (e) {
|
|
|
1694
|
+ // ignore
|
|
|
1695
|
+ }
|
|
|
1696
|
+ }
|
|
|
1697
|
+ if (draft) {
|
|
|
1698
|
+ this.activeDraft = draft
|
|
|
1699
|
+ this.onDraftUpdated(Object.assign({}, draft, {
|
|
|
1700
|
+ status: 'confirmed',
|
|
|
1701
|
+ selectedSchemeCode: (payload && payload.schemeCode) || draft.selectedSchemeCode,
|
|
|
1702
|
+ confirmedPlan: (payload && payload.scheme) || draft.confirmedPlan
|
|
|
1703
|
+ }), { sinkToBottom: false })
|
|
|
1704
|
+ }
|
|
|
1705
|
+ this.confirmPlan(payload)
|
|
|
1706
|
+ },
|
|
|
1707
|
+ openProgressDetail(draftId) {
|
|
|
1708
|
+ if (draftId == null || draftId === '') {
|
|
|
1709
|
+ showToast('缺少草稿信息,无法查看进度')
|
|
|
1710
|
+ return
|
|
|
1711
|
+ }
|
|
|
1712
|
+ this.progressDraftId = draftId
|
|
1185
|
1713
|
this.openSheet('progress')
|
|
1186
|
1714
|
},
|
|
1187
|
1715
|
showPayment() {
|
|
|
@@ -1455,4 +1983,51 @@ export default {
|
|
1455
|
1983
|
top: calc(96rpx + env(safe-area-inset-top));
|
|
1456
|
1984
|
}
|
|
1457
|
1985
|
/* #endif */
|
|
|
1986
|
+
|
|
|
1987
|
+.fe-biz-card--qr {
|
|
|
1988
|
+ border-left: 6rpx solid $fe-primary;
|
|
|
1989
|
+}
|
|
|
1990
|
+
|
|
|
1991
|
+.fe-qr-card__subtitle {
|
|
|
1992
|
+ display: block;
|
|
|
1993
|
+ font-size: 24rpx;
|
|
|
1994
|
+ color: $fe-muted;
|
|
|
1995
|
+ margin-bottom: 20rpx;
|
|
|
1996
|
+ line-height: 1.4;
|
|
|
1997
|
+}
|
|
|
1998
|
+
|
|
|
1999
|
+.fe-qr-card__img {
|
|
|
2000
|
+ display: block;
|
|
|
2001
|
+ width: 360rpx;
|
|
|
2002
|
+ height: 360rpx;
|
|
|
2003
|
+ margin: 0 auto 20rpx;
|
|
|
2004
|
+ background: #fff;
|
|
|
2005
|
+}
|
|
|
2006
|
+
|
|
|
2007
|
+.fe-qr-card__empty {
|
|
|
2008
|
+ display: flex;
|
|
|
2009
|
+ align-items: center;
|
|
|
2010
|
+ justify-content: center;
|
|
|
2011
|
+ width: 360rpx;
|
|
|
2012
|
+ height: 360rpx;
|
|
|
2013
|
+ margin: 0 auto 20rpx;
|
|
|
2014
|
+ background: $fe-primary-bg;
|
|
|
2015
|
+ border-radius: 16rpx;
|
|
|
2016
|
+}
|
|
|
2017
|
+
|
|
|
2018
|
+.fe-qr-card__empty-text {
|
|
|
2019
|
+ font-size: 24rpx;
|
|
|
2020
|
+ color: $fe-muted;
|
|
|
2021
|
+ text-align: center;
|
|
|
2022
|
+ padding: 0 24rpx;
|
|
|
2023
|
+}
|
|
|
2024
|
+
|
|
|
2025
|
+.fe-qr-card__hint {
|
|
|
2026
|
+ display: block;
|
|
|
2027
|
+ font-size: 24rpx;
|
|
|
2028
|
+ color: $fe-muted;
|
|
|
2029
|
+ text-align: center;
|
|
|
2030
|
+ margin-bottom: 20rpx;
|
|
|
2031
|
+ line-height: 1.4;
|
|
|
2032
|
+}
|
|
1458
|
2033
|
</style>
|