From bb47af2639c368f2e5ace0c073678e40dc5e1a08 Mon Sep 17 00:00:00 2001 From: "zhonghua.li" Date: Thu, 14 May 2026 22:30:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=BF=9B=E8=B4=A7=E5=8D=95?= =?UTF-8?q?=E6=97=B6=EF=BC=8CAI=E8=87=AA=E5=8A=A8=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E8=87=AA=E7=84=B6=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/lb-purchase-apply.js | 10 ++ .../lb-business/purchase-apply/index.vue | 141 ++++++++++++++++++ 2 files changed, 151 insertions(+) diff --git a/src/api/lb-purchase-apply.js b/src/api/lb-purchase-apply.js index 019bcad..110e0c4 100644 --- a/src/api/lb-purchase-apply.js +++ b/src/api/lb-purchase-apply.js @@ -38,3 +38,13 @@ export function needPrivilegeRecommenders(params) { params }) } + +/** 大模型解析订货信息为进货申请(不落库),请求可能较慢 */ +export function parseLbPurchaseApplyFromOrderInfo(data) { + return request({ + url: '/lbPurchaseApply/parseFromOrderInfo', + method: 'post', + data, + timeout: 120000 + }) +} diff --git a/src/views/lb-business/purchase-apply/index.vue b/src/views/lb-business/purchase-apply/index.vue index a84bc96..0e8be4a 100644 --- a/src/views/lb-business/purchase-apply/index.vue +++ b/src/views/lb-business/purchase-apply/index.vue @@ -85,6 +85,19 @@ + + + + + + AI解析 + + @@ -107,11 +120,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + const payload = res && typeof res === 'object' ? res : {} + const entity = payload.data !== undefined && payload.data !== null && typeof payload.data === 'object' + ? payload.data + : payload + this.applyParsedEntityToForm(entity) + this.$message.success((payload.message) || '解析成功,已填入表单') + }) + .finally(() => { + this.parseAiLoading = false + }) + }, + normalizeApplyDateValue(v) { + if (v == null || v === '') return '' + if (Array.isArray(v) && v.length >= 3) { + const y = v[0] + const m = String(v[1]).padStart(2, '0') + const d = String(v[2]).padStart(2, '0') + return `${y}-${m}-${d}` + } + const s = String(v) + if (s.includes('T')) return s.slice(0, 10) + return s.length >= 10 ? s.slice(0, 10) : s + }, + applyParsedEntityToForm(entity) { + if (!entity || typeof entity !== 'object') return + const keys = [ + 'applyUser', + 'applyPhone', + 'tryDate', + 'age', + 'workExperience', + 'colleagueName', + 'colleaguePhone', + 'teamLeader', + 'applyDate' + ] + keys.forEach((k) => { + const v = entity[k] + if (v === undefined || v === null) return + if (k === 'age') { + this.form.age = v === '' ? '' : v + return + } + if (k === 'applyDate') { + this.form.applyDate = this.normalizeApplyDateValue(v) + return + } + this.form[k] = v + }) + }, handleAdd() { this.dialogTitle = '新增进货申请' this.isEdit = false @@ -333,11 +457,16 @@ export default { handleEdit(row) { this.dialogTitle = '编辑进货申请' this.isEdit = true + this.orderInfo = '' this.form = { id: row.id || '', applyUser: row.applyUser || '', applyPhone: row.applyPhone || '', + tryDate: row.tryDate || '', + age: row.age !== undefined && row.age !== null ? row.age : '', + workExperience: row.workExperience || '', colleagueName: row.colleagueName || '', + colleaguePhone: row.colleaguePhone || '', teamLeader: row.teamLeader || '', applyDate: row.applyDate || '' } @@ -377,10 +506,17 @@ export default { const payload = { applyUser: this.form.applyUser, applyPhone: this.form.applyPhone, + tryDate: this.form.tryDate || undefined, + age: this.form.age === '' || this.form.age === undefined || this.form.age === null + ? undefined + : Number(this.form.age), + workExperience: this.form.workExperience || undefined, colleagueName: this.form.colleagueName || undefined, + colleaguePhone: this.form.colleaguePhone || undefined, teamLeader: this.form.teamLeader || undefined, applyDate: this.form.applyDate || undefined } + if (payload.age !== undefined && Number.isNaN(payload.age)) delete payload.age if (this.isEdit) payload.id = this.form.id Object.keys(payload).forEach((key) => { if (payload[key] === undefined || payload[key] === '') delete payload[key] @@ -392,11 +528,16 @@ export default { this.resetFormData() }, resetFormData() { + this.orderInfo = '' this.form = { id: '', applyUser: '', applyPhone: '', + tryDate: '', + age: '', + workExperience: '', colleagueName: '', + colleaguePhone: '', teamLeader: '', applyDate: '' }