服务站点代码修改

This commit is contained in:
qiuyuan 2025-11-07 10:18:53 +08:00
parent 1eaf10502b
commit 210e5a8a54

View File

@ -1,22 +1,8 @@
<template> <template>
<a-modal <a-modal :width="800" :open="modal.open" :title="modal.title" :confirm-loading="modal.confirmLoading"
:width="800" :after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" :ok-button-props="{ disabled: isViewMode }"
:open="modal.open" @ok="handleOk" @cancel="handleCancel">
:title="modal.title" <a-form layout="vertical" ref="formRef" :model="formData" :rules="isViewMode ? {} : rules">
:confirm-loading="modal.confirmLoading"
:after-close="onAfterClose"
:cancel-text="cancelText"
:ok-text="okText"
:ok-button-props="{ disabled: isViewMode }"
@ok="handleOk"
@cancel="handleCancel"
>
<a-form
layout="vertical"
ref="formRef"
:model="formData"
:rules="isViewMode ? {} : rules"
>
<!-- 基本信息区域 --> <!-- 基本信息区域 -->
<a-card class="mb-4"> <a-card class="mb-4">
<a-row :gutter="16"> <a-row :gutter="16">
@ -28,11 +14,7 @@
<a-col :span="12"> <a-col :span="12">
<a-form-item label="所在机构" name="organizationId" required> <a-form-item label="所在机构" name="organizationId" required>
<a-select v-model:value="formData.organizationId" :disabled="isViewMode"> <a-select v-model:value="formData.organizationId" :disabled="isViewMode">
<a-select-option <a-select-option v-for="item in nodeOptions" :key="item.id" :value="item.id">
v-for="item in nodeOptions"
:key="item.id"
:value="item.id"
>
{{ item.name }} {{ item.name }}
</a-select-option> </a-select-option>
</a-select> </a-select>
@ -45,16 +27,8 @@
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item label="站点类型" name="type" required> <a-form-item label="站点类型" name="type" required>
<a-select <a-select v-model:value="formData.type" :disabled="isViewMode" @change="handleChange">
v-model:value="formData.type" <a-select-option v-for="item in dicsStore.dictOptions.Station_Type" :key="item.dval" :value="item.dval">
:disabled="isViewMode"
@change="handleChange"
>
<a-select-option
v-for="item in dicsStore.dictOptions.Station_Type"
:key="item.dval"
:value="item.dval"
>
{{ item.introduction }} {{ item.introduction }}
</a-select-option> </a-select-option>
</a-select> </a-select>
@ -67,21 +41,13 @@
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item label="联系电话" name="phone" required> <a-form-item label="联系电话" name="phone" required>
<a-input <a-input v-model:value="formData.phone" :disabled="isViewMode" placeholder="请输入联系电话" />
v-model:value="formData.phone"
:disabled="isViewMode"
placeholder="请输入联系电话"
/>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item label="星级等级" name="starLevel"> <a-form-item label="星级等级" name="starLevel">
<a-select v-model:value="formData.starLevel" :disabled="isViewMode"> <a-select v-model:value="formData.starLevel" :disabled="isViewMode">
<a-select-option <a-select-option v-for="item in dicsStore.dictOptions.Level" :key="item.dval" :value="item.dval">
v-for="item in dicsStore.dictOptions.Level"
:key="item.dval"
:value="item.dval"
>
{{ item.introduction }} {{ item.introduction }}
</a-select-option> </a-select-option>
</a-select> </a-select>
@ -89,12 +55,7 @@
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item label="人员编制(个)" name="staffCount"> <a-form-item label="人员编制(个)" name="staffCount">
<a-input-number <a-input-number v-model:value="formData.staffCount" :disabled="isViewMode" min="0" style="width: 100%" />
v-model:value="formData.staffCount"
:disabled="isViewMode"
min="0"
style="width: 100%"
/>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
@ -105,40 +66,22 @@
<a-row :gutter="16"> <a-row :gutter="16">
<a-col :span="24"> <a-col :span="24">
<a-form-item label="服务中心地址" name="address"> <a-form-item label="服务中心地址" name="address">
<AreaCascader <AreaCascader v-model:value="formData.address" :disabled="isViewMode" @change="onAreaChange" />
v-model:value="formData.address"
:disabled="isViewMode"
@change="onAreaChange"
/>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item label="详细地址" name="detailAddress"> <a-form-item label="详细地址" name="detailAddress">
<a-input <a-input v-model:value="formData.detailAddress" :disabled="isViewMode" placeholder="请输入详细地址" />
v-model:value="formData.detailAddress"
:disabled="isViewMode"
placeholder="请输入详细地址"
/>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item label="地图定位地址" name="location"> <a-form-item label="地图定位地址" name="location">
<a-row :gutter="8"> <a-row :gutter="8">
<a-col :span="18"> <a-col :span="18">
<a-input <a-input v-model:value="formData.location" placeholder="请选择地图位置" readonly :disabled="isViewMode" />
v-model:value="formData.location"
placeholder="请选择地图位置"
readonly
:disabled="isViewMode"
/>
</a-col> </a-col>
<a-col :span="6"> <a-col :span="6">
<a-button <a-button type="primary" block :disabled="isViewMode" @click="openMapSelector">
type="primary"
block
:disabled="isViewMode"
@click="openMapSelector"
>
选择地图位置 选择地图位置
</a-button> </a-button>
</a-col> </a-col>
@ -153,33 +96,19 @@
<a-row :gutter="16"> <a-row :gutter="16">
<a-col :span="12"> <a-col :span="12">
<a-form-item label="建成时间" name="buildTime"> <a-form-item label="建成时间" name="buildTime">
<a-date-picker <a-date-picker v-model:value="formData.buildTime" format="YYYY-MM-DD" placeholder="请选择建成时间"
v-model:value="formData.buildTime" :disabled="isViewMode" />
format="YYYY-MM-DD"
placeholder="请选择建成时间"
:disabled="isViewMode"
/>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item label="建筑面积(平方米)" name="area"> <a-form-item label="建筑面积(平方米)" name="area">
<a-input-number <a-input-number v-model:value="formData.area" :disabled="isViewMode" min="0" style="width: 100%"
v-model:value="formData.area" placeholder="请输入建筑面积" />
:disabled="isViewMode"
min="0"
style="width: 100%"
placeholder="请输入建筑面积"
/>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24"> <a-col :span="24">
<a-form-item label="服务介绍" name="description"> <a-form-item label="服务介绍" name="description">
<a-textarea <a-textarea v-model:value="formData.description" :disabled="isViewMode" rows="4" placeholder="请输入服务介绍" />
v-model:value="formData.description"
:disabled="isViewMode"
rows="4"
placeholder="请输入服务介绍"
/>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
@ -191,33 +120,19 @@
<a-col :span="12"> <a-col :span="12">
<a-form-item label="营业时间" name="openTime"> <a-form-item label="营业时间" name="openTime">
<div style="display: flex; gap: 8px"> <div style="display: flex; gap: 8px">
<a-time-picker <a-time-picker v-model:value="formData.openTime" format="HH:mm" placeholder="开始时间"
v-model:value="formData.openTime" :disabled="isViewMode" />
format="HH:mm" <a-time-picker v-model:value="formData.closeTime" format="HH:mm" placeholder="结束时间"
placeholder="开始时间" :disabled="isViewMode" />
:disabled="isViewMode"
/>
<a-time-picker
v-model:value="formData.closeTime"
format="HH:mm"
placeholder="结束时间"
:disabled="isViewMode"
/>
</div> </div>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item label="营业状态" name="businessStatus"> <a-form-item label="营业状态" name="businessStatus">
<a-select <a-select v-model:value="formData.businessStatus" :disabled="isViewMode">
v-model:value="formData.businessStatus" <a-select-option v-for="item in dicsStore.dictOptions.Business_Status" :key="item.dval"
:disabled="isViewMode" :value="item.dval">
>
<a-select-option
v-for="item in dicsStore.dictOptions.Business_Status"
:key="item.dval"
:value="item.dval"
>
{{ item.introduction }} {{ item.introduction }}
</a-select-option> </a-select-option>
</a-select> </a-select>
@ -236,16 +151,10 @@
</span> </span>
</template> </template>
<div class="service-tags"> <div class="service-tags">
<a-tag <a-tag v-for="service in allServices" :key="service.value" :class="{
v-for="service in allServices" 'ant-tag-checkable-checked': formData.services?.includes(service.value),
:key="service.value" }" class="service-tag" :style="{ cursor: isViewMode ? 'default' : 'pointer' }"
:class="{ @click="isViewMode ? null : handleServiceClick(service.value)">
'ant-tag-checkable-checked': formData.services?.includes(service.value),
}"
class="service-tag"
:style="{ cursor: isViewMode ? 'default' : 'pointer' }"
@click="isViewMode ? null : handleServiceClick(service.value)"
>
{{ service.label }} {{ service.label }}
</a-tag> </a-tag>
</div> </div>
@ -259,23 +168,20 @@
<a-row :gutter="16"> <a-row :gutter="16">
<a-col :span="12"> <a-col :span="12">
<a-form-item label="资质附件" name="qualificationFiles"> <a-form-item label="资质附件" name="qualificationFiles">
<UploadInput v-model="formData.qualificationFiles"/> <UploadInput v-model="formData.qualificationFiles" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item label="站点图片" name="siteImages"> <a-form-item label="站点图片" name="siteImages">
<gx-upload v-model="formData.siteImages" :fileNumber="1" accept-types=".jpg,.png,.webp" /> <gx-upload v-model="formData.siteImages" :fileNumber="1" accept-types=".jpg,.png,.webp" />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
</a-card> </a-card>
</a-form> </a-form>
<MapPickerModal <MapPickerModal :open="showMapPicker" @update:open="(val) => (showMapPicker = val)"
:open="showMapPicker" @select="handleLocationSelect" />
@update:open="(val) => (showMapPicker = val)"
@select="handleLocationSelect"
/>
</a-modal> </a-modal>
</template> </template>
@ -303,6 +209,7 @@ const initFormData = () => ({
name: '', name: '',
parent_id: '', parent_id: '',
organizationId: '', organizationId: '',
organization: '',
code: '', code: '',
type: '', type: '',
manager: '', manager: '',
@ -364,6 +271,7 @@ async function fetchNodeOptions() {
const res = await apis.serviceMenu.getOrgSelect() const res = await apis.serviceMenu.getOrgSelect()
if (res.success && Array.isArray(res.data)) { if (res.success && Array.isArray(res.data)) {
nodeOptions.value = res.data.map((item) => ({ id: item.id, name: item.name })) nodeOptions.value = res.data.map((item) => ({ id: item.id, name: item.name }))
console.log('nodeOptions', nodeOptions.value)
} else { } else {
nodeOptions.value = [] nodeOptions.value = []
message.warning('未获取到服务站点数据') message.warning('未获取到服务站点数据')
@ -389,12 +297,12 @@ function handleCreateChild(record = {}) {
async function handleEdit(record = {}) { async function handleEdit(record = {}) {
console.log('handleEdit', record) console.log('handleEdit', record)
showModal({ mode: 'edit', title: '编辑服务站点' }) showModal({ mode: 'edit', title: '编辑服务站点' })
await loadRecord(record.id,false) await loadRecord(record.id, false)
} }
async function handleView(record = {}) { async function handleView(record = {}) {
showModal({ mode: 'view', title: '查看服务站点' }) showModal({ mode: 'view', title: '查看服务站点' })
await loadRecord(record.id,true) await loadRecord(record.id, true)
} }
async function loadRecord(id, forView = false) { async function loadRecord(id, forView = false) {
@ -403,6 +311,8 @@ async function loadRecord(id, forView = false) {
const record = cloneDeep(data) const record = cloneDeep(data)
const org = record.organization || {} const org = record.organization || {}
console.log('rdataecord', data)
console.log('org', org)
const stationTypeText = record.stationType || '' const stationTypeText = record.stationType || ''
const typeOption = dicsStore.dictOptions.Station_Type?.find( const typeOption = dicsStore.dictOptions.Station_Type?.find(
item => item.introduction === stationTypeText item => item.introduction === stationTypeText
@ -413,7 +323,8 @@ async function loadRecord(id, forView = false) {
...initFormData(), ...initFormData(),
id: record.id, id: record.id,
name: record.name || '', name: record.name || '',
organizationId: org.organizationId || '', organizationId: org.id || '',
organization: org.name || '',
code: org.orgCode || '', code: org.orgCode || '',
type: stationTypeValue, type: stationTypeValue,
manager: org.concatName || '', manager: org.concatName || '',
@ -428,10 +339,11 @@ async function loadRecord(id, forView = false) {
description: record.content || '', description: record.content || '',
openTime: record.openAt ? dayjs(`1970-01-01 ${record.openAt}`) : null, openTime: record.openAt ? dayjs(`1970-01-01 ${record.openAt}`) : null,
closeTime: record.closeAt ? dayjs(`1970-01-01 ${record.closeAt}`) : null, closeTime: record.closeAt ? dayjs(`1970-01-01 ${record.closeAt}`) : null,
businessStatus: record.status || '',
status: record.status || '',
services: record.provideServices || [], services: record.provideServices || [],
qualificationFiles: (record.qualificationAttachment && record.qualificationAttachment.length > 0) ? record.qualificationAttachment.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) : [], siteImages: (record.stationImgs && record.stationImgs.length > 0) ? record.stationImgs.map(item => config('http.apiUpload') + item) : [],
latitude: record.latitude || 0, latitude: record.latitude || 0,
longitude: record.longitude || 0, longitude: record.longitude || 0,
} }
@ -446,61 +358,72 @@ async function loadRecord(id, forView = false) {
} }
} }
function handleOk() { async function handleOk() {
if (isViewMode.value) return if (isViewMode.value) return
formRef.value.validateFields().then(async (values) => { try {
try { formRef.value.validateFields().then(async (values) => {
const params = { console.log('values', values)
Name: values.name, try {
organizationId: values.organizationId, const params = {
OrgCode: values.code, Name: values.name,
StationType: (() => { organizationId: values.organizationId,
const typeItem = dicsStore.dictOptions.Station_Type?.find( organizationName: nodeOptions.value.find(opt => opt.id === values.organizationId)?.name || '',
(item) => item.dval === values.type OrgCode: values.code,
) StationType: (() => {
return typeItem ? typeItem.introduction : values.type || '' const typeItem = dicsStore.dictOptions.Station_Type?.find(
})(), (item) => item.dval === values.type
StationTypeValue: values.type, // dval )
ConcatName: values.manager, return typeItem ? typeItem.introduction : values.type || ''
ConcatPhone: values.phone, })(),
StarLv: values.starLevel || '', StationTypeValue: values.type, // dval
MemberNum: values.staffCount || 0, ConcatName: values.manager,
AreaLabels: values.address?.length ? values.address : null, ConcatPhone: values.phone,
Address: values.detailAddress || '', StarLv: values.starLevel || '',
Latitude: formData.value.latitude || 0, MemberNum: values.staffCount || 0,
Longitude: formData.value.longitude || 0, AreaLabels: values.address?.length ? values.address : null,
CompletionAt: values.buildTime ? values.buildTime.toDate() : null, Address: values.detailAddress || '',
Area: values.area || 0, Latitude: formData.value.latitude || 0,
Content: values.description || '', Longitude: formData.value.longitude || 0,
OpenAt: values.openTime ? values.openTime.format('HH:mm') : '', CompletionAt: values.buildTime ? values.buildTime.toDate() : null,
CloseAt: values.closeTime ? values.closeTime.format('HH:mm') : '', Area: values.area || 0,
Status: values.businessStatus || '', Content: values.description || '',
ProvideServices: values.services?.length ? values.services : null, OpenAt: values.openTime ? values.openTime.format('HH:mm') : '',
QualificationAttachment: values.qualificationFiles?.map(f => f.url || f.response?.url) || null, CloseAt: values.closeTime ? values.closeTime.format('HH:mm') : '',
QualificationAttachment:( values.qualificationFiles && values.qualificationFiles.length) > 0 ? values.qualificationFiles.map(item => spliceUrl(item)) : [], Status: '1',
StationImgs:( values.siteImages && values.siteImages.length) > 0 ? values.siteImages.map(item => spliceUrl(item)) : [], 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 console.log('params', params)
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) { let result
message.success(modal.value.mode === 'create' ? '新增成功' : '更新成功') if (modal.value.mode === 'create') {
hideModal() result = await apis.serviceMenu.createServiceSite(params)
emit('ok') } else if (modal.value.mode === 'edit') {
} else { result = await apis.serviceMenu.updateServiceSite(formData.value.id, params)
message.error(result?.message || '操作失败') }
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) } catch (error) {
message.error('操作失败,请重试') console.error('表单校验失败:', error)
} return
}) }
} }
function handleCancel() { function handleCancel() {