From 210e5a8a54954efe26a0171f574ce2b4e0adfa60 Mon Sep 17 00:00:00 2001 From: qiuyuan Date: Fri, 7 Nov 2025 10:18:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=AB=99=E7=82=B9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceSites/components/EditDialog.vue | 291 +++++++----------- 1 file changed, 107 insertions(+), 184 deletions(-) diff --git a/src/views/serviceMenu/serviceSites/components/EditDialog.vue b/src/views/serviceMenu/serviceSites/components/EditDialog.vue index d3011f4..88a8bb5 100644 --- a/src/views/serviceMenu/serviceSites/components/EditDialog.vue +++ b/src/views/serviceMenu/serviceSites/components/EditDialog.vue @@ -1,22 +1,8 @@
- + {{ service.label }}
@@ -259,23 +168,20 @@ - + - + - + @@ -303,6 +209,7 @@ const initFormData = () => ({ name: '', parent_id: '', organizationId: '', + organization: '', code: '', type: '', manager: '', @@ -364,6 +271,7 @@ async function fetchNodeOptions() { const res = await apis.serviceMenu.getOrgSelect() if (res.success && Array.isArray(res.data)) { nodeOptions.value = res.data.map((item) => ({ id: item.id, name: item.name })) + console.log('nodeOptions', nodeOptions.value) } else { nodeOptions.value = [] message.warning('未获取到服务站点数据') @@ -389,12 +297,12 @@ function handleCreateChild(record = {}) { async function handleEdit(record = {}) { console.log('handleEdit', record) showModal({ mode: 'edit', title: '编辑服务站点' }) - await loadRecord(record.id,false) + await loadRecord(record.id, false) } async function handleView(record = {}) { showModal({ mode: 'view', title: '查看服务站点' }) - await loadRecord(record.id,true) + await loadRecord(record.id, true) } async function loadRecord(id, forView = false) { @@ -403,6 +311,8 @@ async function loadRecord(id, forView = false) { const record = cloneDeep(data) const org = record.organization || {} + console.log('rdataecord', data) + console.log('org', org) const stationTypeText = record.stationType || '' const typeOption = dicsStore.dictOptions.Station_Type?.find( item => item.introduction === stationTypeText @@ -413,7 +323,8 @@ async function loadRecord(id, forView = false) { ...initFormData(), id: record.id, name: record.name || '', - organizationId: org.organizationId || '', + organizationId: org.id || '', + organization: org.name || '', code: org.orgCode || '', type: stationTypeValue, manager: org.concatName || '', @@ -428,10 +339,11 @@ async function loadRecord(id, forView = false) { description: record.content || '', openTime: record.openAt ? dayjs(`1970-01-01 ${record.openAt}`) : null, closeTime: record.closeAt ? dayjs(`1970-01-01 ${record.closeAt}`) : null, - businessStatus: record.status || '', + + status: record.status || '', services: record.provideServices || [], - qualificationFiles: (record.qualificationAttachment && record.qualificationAttachment.length > 0) ? record.qualificationAttachment.map(item => config('http.apiUpload') + item) : [], - siteImages: (record.stationImgs && record.stationImgs.length > 0) ? record.stationImgs.map(item => config('http.apiUpload') + item) : [], + qualificationFiles: (record.qualificationAttachment && record.qualificationAttachment.length > 0) ? record.qualificationAttachment.map(item => config('http.apiUpload') + item) : [], + siteImages: (record.stationImgs && record.stationImgs.length > 0) ? record.stationImgs.map(item => config('http.apiUpload') + item) : [], latitude: record.latitude || 0, longitude: record.longitude || 0, } @@ -446,61 +358,72 @@ async function loadRecord(id, forView = false) { } } -function handleOk() { +async function handleOk() { if (isViewMode.value) return - formRef.value.validateFields().then(async (values) => { - try { - const params = { - Name: values.name, - organizationId: values.organizationId, - OrgCode: values.code, - StationType: (() => { - const typeItem = dicsStore.dictOptions.Station_Type?.find( - (item) => item.dval === values.type - ) - return typeItem ? typeItem.introduction : values.type || '' - })(), - StationTypeValue: values.type, // 传 dval 给后端 - ConcatName: values.manager, - ConcatPhone: values.phone, - StarLv: values.starLevel || '', - MemberNum: values.staffCount || 0, - AreaLabels: values.address?.length ? values.address : null, - Address: values.detailAddress || '', - Latitude: formData.value.latitude || 0, - Longitude: formData.value.longitude || 0, - CompletionAt: values.buildTime ? values.buildTime.toDate() : null, - Area: values.area || 0, - Content: values.description || '', - OpenAt: values.openTime ? values.openTime.format('HH:mm') : '', - CloseAt: values.closeTime ? values.closeTime.format('HH:mm') : '', - Status: values.businessStatus || '', - ProvideServices: values.services?.length ? values.services : null, - QualificationAttachment: values.qualificationFiles?.map(f => f.url || f.response?.url) || null, - QualificationAttachment:( values.qualificationFiles && values.qualificationFiles.length) > 0 ? values.qualificationFiles.map(item => spliceUrl(item)) : [], - StationImgs:( values.siteImages && values.siteImages.length) > 0 ? values.siteImages.map(item => spliceUrl(item)) : [], - } + try { + formRef.value.validateFields().then(async (values) => { + console.log('values', values) + try { + const params = { + Name: values.name, + organizationId: values.organizationId, + organizationName: nodeOptions.value.find(opt => opt.id === values.organizationId)?.name || '', + OrgCode: values.code, + StationType: (() => { + const typeItem = dicsStore.dictOptions.Station_Type?.find( + (item) => item.dval === values.type + ) + return typeItem ? typeItem.introduction : values.type || '' + })(), + StationTypeValue: values.type, // 传 dval 给后端 + ConcatName: values.manager, + ConcatPhone: values.phone, + StarLv: values.starLevel || '', + MemberNum: values.staffCount || 0, + AreaLabels: values.address?.length ? values.address : null, + Address: values.detailAddress || '', + Latitude: formData.value.latitude || 0, + Longitude: formData.value.longitude || 0, + CompletionAt: values.buildTime ? values.buildTime.toDate() : null, + Area: values.area || 0, + Content: values.description || '', + OpenAt: values.openTime ? values.openTime.format('HH:mm') : '', + CloseAt: values.closeTime ? values.closeTime.format('HH:mm') : '', + Status: '1', + ProvideServices: values.services?.length ? values.services : null, + QualificationAttachment: values.qualificationFiles?.map(f => f.url || f.response?.url) || null, + QualificationAttachment: (values.qualificationFiles && values.qualificationFiles.length) > 0 ? values.qualificationFiles.map(item => spliceUrl(item)) : [], + StationImgs: (values.siteImages && values.siteImages.length) > 0 ? values.siteImages.map(item => spliceUrl(item)) : [], + } - let result - if (modal.value.mode === 'create') { - result = await apis.serviceMenu.createServiceSite(params) - } else if (modal.value.mode === 'edit') { - result = await apis.serviceMenu.updateServiceSite(formData.value.id, params) - } + console.log('params', params) - if (result?.success) { - message.success(modal.value.mode === 'create' ? '新增成功' : '更新成功') - hideModal() - emit('ok') - } else { - message.error(result?.message || '操作失败') + let result + if (modal.value.mode === 'create') { + result = await apis.serviceMenu.createServiceSite(params) + } else if (modal.value.mode === 'edit') { + result = await apis.serviceMenu.updateServiceSite(formData.value.id, params) + } + + if (result?.success) { + message.success(modal.value.mode === 'create' ? '新增成功' : '更新成功') + hideModal() + emit('ok') + } else { + message.error(result?.message || '操作失败') + } + } catch (error) { + console.error('提交失败:', error) + message.error('操作失败,请重试') } - } catch (error) { - console.error('提交失败:', error) - message.error('操作失败,请重试') - } - }) + }) + } catch (error) { + console.error('表单校验失败:', error) + return + } + + } function handleCancel() {