代码修改

This commit is contained in:
qiuyuan 2025-10-10 14:41:43 +08:00
parent 6537e6f919
commit abf0748855
4 changed files with 1148 additions and 863 deletions

View File

@ -4,13 +4,25 @@
<a-form :label-col="{ style: { width: '100px' } }" :model="searchFormData" layout="inline"> <a-form :label-col="{ style: { width: '100px' } }" :model="searchFormData" layout="inline">
<a-row :gutter="gutter"> <a-row :gutter="gutter">
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item :label="'站点名称'" name="name"> <a-form-item :label="'所在区域'" name="area">
<a-input :placeholder="'请输入站点名称'" v-model:value="searchFormData.name"></a-input> <a-input :placeholder="'请选择区域'" v-model:value="searchFormData.area"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item :label="'站点类型'" name="type"> <a-form-item :label="'组织名称'" name="name">
<a-input :placeholder="'请输组织名称'" v-model:value="searchFormData.name"></a-input>
</a-form-item>
</a-col>
<a-col v-bind="colSpan">
<a-form-item :label="'负责人'" name="name">
<a-input :placeholder="'请输负责人'" v-model:value="searchFormData.name"></a-input>
</a-form-item>
</a-col>
<a-col v-bind="colSpan">
<a-form-item :label="'等级'" name="type">
<a-select v-model:value="searchFormData.type" @change="handleChange"> <a-select v-model:value="searchFormData.type" @change="handleChange">
<a-select-option value="jack">已结单</a-select-option> <a-select-option value="jack">已结单</a-select-option>
<a-select-option value="lucy">已作废</a-select-option> <a-select-option value="lucy">已作废</a-select-option>
@ -19,21 +31,26 @@
</a-col> </a-col>
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item :label="'所在区域'" name="area"> <a-form-item :label="'可用钱包'" name="type">
<a-input :placeholder="'请选择区域'" v-model:value="searchFormData.area"></a-input> <a-select v-model:value="searchFormData.type" @change="handleChange">
</a-form-item>
</a-col>
<a-col v-bind="colSpan">
<a-form-item :label="'所在节点'" name="node">
<a-select v-model:value="searchFormData.node" @change="handleChange">
<a-select-option value="jack">已结单</a-select-option> <a-select-option value="jack">已结单</a-select-option>
<a-select-option value="lucy">已作废</a-select-option> <a-select-option value="lucy">已作废</a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col v-bind="colSpan" style="text-align: right;"> <a-col v-bind="colSpan">
<a-form-item :label="'收否中标'" name="type">
<a-select v-model:value="searchFormData.type" @change="handleChange">
<a-select-option value="jack">已结单</a-select-option>
<a-select-option value="lucy">已作废</a-select-option>
</a-select>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="gutter" justify="end" style="margin-top: 20px;">
<a-col>
<a-space> <a-space>
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button> <a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
<a-button ghost type="primary" @click="handleSearch"> <a-button ghost type="primary" @click="handleSearch">
@ -50,42 +67,10 @@
<a-card> <a-card>
<!-- 添加标题和横线 --> <!-- 添加标题和横线 -->
<div class="title-container"> <div class="title-container">
<h3>服务站点列表</h3> <h3>服务组织列表</h3>
<div class="title-line"></div> <div class="title-line"></div>
</div> </div>
<x-action-bar class="mb-8-2">
<!-- 增加按钮之间的间距 -->
<a-space :size="12">
<a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()">
新建
</a-button>
<!-- 修改导入按钮的点击事件 -->
<a-button v-action="'add'" type="primary" @click="showImportModal = true">
导入
</a-button>
<a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()">
<template #icon>
<UnorderedListOutlined />
</template>
导入记录
</a-button>
<a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()">
导出
</a-button>
<a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()">
<template #icon>
<UnorderedListOutlined />
</template>
导出记录
</a-button>
</a-space>
</x-action-bar>
<a-table rowKey="id" :loading="loading" :pagination="true" :columns="columns" :data-source="listData"> <a-table rowKey="id" :loading="loading" :pagination="true" :columns="columns" :data-source="listData">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="'menuType' === column.key"> <template v-if="'menuType' === column.key">
@ -114,43 +99,28 @@
</a-tag> </a-tag>
</template> </template>
<template v-if="'action' === column.key"> <template v-if="'actions' === column.key">
<x-action-button @click="$refs.editDialogRef.handleEdit(record)"> <span class="action-buttons">
<a-tooltip> <a-button type="link" size="small" @click="handleEdit(record)">编辑</a-button>
<template #title>{{ $t('pages.system.menu.edit') }}</template> <a-divider type="vertical" />
<edit-outlined /> <a-button type="link" size="small" @click="handleDetail(record)">详情</a-button>
</a-tooltip> <a-divider type="vertical" />
</x-action-button> <a-button type="link" size="small" @click="handleToggleStatus(record)">
{{ record.status === 'active' ? '停用' : '启用' }}
<x-action-button @click="$refs.editDialogRef.handleCreateChild(record)"> </a-button>
<a-tooltip> <a-divider type="vertical" />
<template #title>{{ $t('pages.system.menu.button.addChild') }}</template> <a-button type="link" size="small" @click="handleDeviceManagement(record)">设备管理</a-button>
<plus-circle-outlined /> </span>
</a-tooltip>
</x-action-button>
<x-action-button @click="handleDelete(record)">
<a-tooltip>
<template #title>{{ $t('pages.system.delete') }}</template>
<delete-outlined style="color: #ff4d4f" />
</a-tooltip>
</x-action-button>
</template> </template>
</template> </template>
</a-table> </a-table>
</a-card> </a-card>
<edit-dialog @ok="onOk" ref="editDialogRef" /> <edit-dialog @ok="onOk" ref="editDialogRef" />
<!-- 导入弹框组件 -->
<import-modal
v-model:visible="showImportModal"
@download="handleDownloadTemplate"
@upload="handleFileUpload"
/>
</template> </template>
<script setup> <script setup>
import { Modal, message } from 'ant-design-vue' import { Modal, message, Divider } from 'ant-design-vue'
import { ref } from 'vue' import { ref } from 'vue'
import { UnorderedListOutlined, EditOutlined, PlusCircleOutlined, DeleteOutlined } from '@ant-design/icons-vue' import { UnorderedListOutlined, EditOutlined, PlusCircleOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import apis from '@/apis' import apis from '@/apis'
@ -160,7 +130,6 @@ import { usePagination, useForm } from '@/hooks'
import { formatUtcDateTime } from '@/utils/util' import { formatUtcDateTime } from '@/utils/util'
import EditDialog from './components/EditDialog.vue' import EditDialog from './components/EditDialog.vue'
// //
import ImportModal from '@/components/Import/index.vue' //
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import storage from '@/utils/storage' import storage from '@/utils/storage'
@ -173,21 +142,22 @@ const { t } = useI18n() // 解构出t方法
const showImportModal = ref(false) const showImportModal = ref(false)
const columns = ref([ const columns = ref([
{ title: '工单号', dataIndex: 'name', key: 'name', fixed: true, width: 280 }, { title: '序号', dataIndex: 'serialNumber', key: 'serialNumber', fixed: true, width: 180 },
{ title: '服务对象', dataIndex: 'code', key: 'code', width: 240 }, { title: '机构编号', dataIndex: 'orgCode', key: 'orgCode', width: 240 },
{ title: '身份证号', dataIndex: 'type', key: 'menuType', width: 240 }, { title: '节点编号', dataIndex: 'nodeCode', key: 'nodeCode', width: 240 },
{ title: '联系方式1', dataIndex: 'status', key: 'statusType', width: 240 }, { title: '机构名称', dataIndex: 'orgName', key: 'orgName', width: 240 },
{ title: '联系方式2', dataIndex: 'sequence', width: 240 }, { title: '联系人', dataIndex: 'contactPerson', key: 'contactPerson', width: 240 },
{ title: '计划服务时间', dataIndex: 'created_at', key: 'createAt', width: 240 }, { title: '联系电话', dataIndex: 'contactPhone', key: 'contactPhone', width: 240 },
{ title: '计划服务时常(分钟)', dataIndex: 'created_at', key: 'createAt', width: 240 }, { title: '机构类型', dataIndex: 'orgType', key: 'orgType', width: 240 },
{ title: '服务项目', dataIndex: 'created_at', key: 'createAt', width: 240 }, { title: '机构性质', dataIndex: 'orgNature', key: 'orgNature', width: 240 },
{ title: '所属区域', dataIndex: 'created_at', key: 'createAt', width: 240 }, { title: '状态', dataIndex: 'status', key: 'status', width: 240 },
{ title: '服务地址', dataIndex: 'created_at', key: 'createAt', width: 240 }, { title: '等级', dataIndex: 'level', key: 'level', width: 240 },
{ title: '服务组织', dataIndex: 'created_at', key: 'createAt', width: 240 }, { title: '营业执照注册号', dataIndex: 'businessLicenseNo', key: 'businessLicenseNo', width: 240 },
{ title: '服务人员', dataIndex: 'created_at', key: 'createAt', width: 240 }, { title: '所在区域', dataIndex: 'region', key: 'region', width: 240 },
{ title: '下单员', dataIndex: 'created_at', key: 'createAt', width: 240 }, { title: '详细地址', dataIndex: 'addressDetail', key: 'addressDetail', width: 240 },
{ title: '下单时间', dataIndex: 'created_at', key: 'createAt', width: 240 }, { title: '操作', dataIndex: 'actions', key: 'actions', width: 320 },
]) ])
const { listData, loading, showLoading, hideLoading, searchFormData, paginationState, resetPagination } = const { listData, loading, showLoading, hideLoading, searchFormData, paginationState, resetPagination } =
usePagination() usePagination()
const { resetForm } = useForm() const { resetForm } = useForm()
@ -223,6 +193,7 @@ async function getMenuList() {
hideLoading() hideLoading()
} }
} }
/** /**
* 搜索 * 搜索
*/ */
@ -230,6 +201,7 @@ function handleSearch() {
resetPagination() resetPagination()
getMenuList() getMenuList()
} }
/** /**
* 重置 * 重置
*/ */
@ -238,6 +210,7 @@ function handleResetSearch() {
resetPagination() resetPagination()
getMenuList() getMenuList()
} }
/** /**
* 删除 * 删除
* @param id * @param id
@ -275,8 +248,6 @@ async function onOk() {
await getMenuList() await getMenuList()
} }
/** /**
* 处理下载模板 * 处理下载模板
*/ */
@ -323,6 +294,28 @@ function handleChange() {
// //
} }
//
function handleEdit(record) {
editDialogRef.value.open({ record, mode: 'edit' })
}
function handleDetail(record) {
//
editDialogRef.value.open({ record, mode: 'view' })
}
function handleToggleStatus(record) {
// /
const newStatus = record.status === 'active' ? 'inactive' : 'active'
console.log(`切换状态为: ${newStatus}`, record)
message.info(`${record.status === 'active' ? '停用' : '启用'}功能待实现`)
}
function handleDeviceManagement(record) {
//
console.log('设备管理', record)
message.info('设备管理功能待实现')
}
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
@ -337,4 +330,20 @@ function handleChange() {
background-color: #e8e8e8; // 线 background-color: #e8e8e8; // 线
margin-top: 8px; margin-top: 8px;
} }
//
.action-buttons {
.ant-btn-link {
padding: 0 4px;
height: auto;
line-height: inherit;
}
.ant-divider {
margin: 0 2px;
}
}
</style> </style>

View File

@ -1,152 +1,482 @@
<template> <template>
<a-modal :width="640" :open="modal.open" :title="modal.title" :confirm-loading="modal.confirmLoading" <a-modal
:after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel"> :width="800"
:open="modal.open"
:title="modal.title"
:confirm-loading="modal.confirmLoading"
:after-close="onAfterClose"
:cancel-text="cancelText"
:ok-text="okText"
@ok="handleOk"
@cancel="handleCancel"
>
<a-form layout="vertical" ref="formRef" :model="formData" :rules="formRules"> <a-form layout="vertical" ref="formRef" :model="formData" :rules="formRules">
<a-card class="mb-8-2"> <a-card class="mb-4">
<a-row :gutter="12"> <a-row :gutter="16">
<!-- 基本信息区域 -->
<a-col :span="12"> <a-col :span="12">
<a-form-item :label="$t('pages.system.menu.form.parent_name')" name="parent_id"> <a-form-item :label="'站点名称'" name="name" :required="true">
<a-tree-select v-model:value="formData.parent_id" tree-default-expand-all></a-tree-select>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="$t('pages.system.menu.form.type')" name="type">
<a-radio-group v-model:value="formData.type"
:options="menuTypeEnum.getOptions()"></a-radio-group>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="$t('pages.system.menu.form.name')" name="name">
<a-input v-model:value="formData.name"></a-input> <a-input v-model:value="formData.name"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item :label="$t('pages.system.menu.resource.form.path')" name="path"> <a-form-item :label="'所在节点'" name="nodeType" :required="true">
<a-input v-model:value="formData.path"></a-input> <a-select v-model:value="formData.nodeType" @change="handleChange">
<a-select-option value="jack">已结单</a-select-option>
<a-select-option value="lucy">已作废</a-select-option>
</a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item name="code"> <a-form-item :label="'机构代码'" name="code" :required="true">
<template #label>
<span class="mr-4-1">{{ $t('pages.system.menu.form.code') }}</span>
<a-tooltip :title="$t('pages.system.menu.form.code')">
<question-circle-outlined class="color-secondary"></question-circle-outlined>
</a-tooltip>
</template>
<a-input v-model:value="formData.code"></a-input> <a-input v-model:value="formData.code"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item :label="$t('pages.system.menu.form.status')" name="status"> <a-form-item :label="'站点类型'" name="type" :required="true">
<a-radio-group v-model:value="formData.status" <a-select v-model:value="formData.type" @change="handleChange">
:options="statusTypeEnum.getOptions()"></a-radio-group> <a-select-option value="type1">社区服务中心</a-select-option>
<a-select-option value="type2">养老服务站</a-select-option>
<a-select-option value="type3">综合服务中心</a-select-option>
</a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item style="width: 200px" :label="$t('pages.system.menu.form.sequence')" <a-form-item :label="'负责人姓名'" name="manager" :required="true">
name="sequence"> <a-input v-model:value="formData.manager"></a-input>
<a-input :defaultValue="0" type="number" v-model:value="formData.sequence"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="12">
<a-form-item :label="$t('pages.system.menu.form.description')" name="description"> <a-form-item :label="'联系电话'" name="phone" :required="true">
<a-input v-model:value="formData.description"></a-input> <a-input v-model:value="formData.phone" placeholder="请输入联系电话"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12">
<a-col :span="24"> <a-form-item :label="'星级等级'" name="starLevel">
<a-form-item :label="$t('pages.system.menu.form.properties')" name="properties"> <a-select v-model:value="formData.starLevel">
<a-textarea v-model:value="formData.properties"></a-textarea> <a-select-option value="1">一星</a-select-option>
<a-select-option value="2">二星</a-select-option>
<a-select-option value="3">三星</a-select-option>
<a-select-option value="4">四星</a-select-option>
<a-select-option value="5">五星</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="'人员编制(个)'" name="staffCount">
<a-input-number v-model:value="formData.staffCount" min="0" style="width: 100%"></a-input-number>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
</a-card> </a-card>
<a-card :title="$t('pages.system.menu.resource.form.title')">
<a-table :columns="columns" :data-source="formData.resources" :pagination="false" row-key="id">
<template #bodyCell="{ column, record, index }">
<template v-if="column.key === 'types'">
<a-form-item :label="$t('pages.system.menu.resource.form.method')">
<a-input-group style="display: inline-block; vertical-align: middle" :compact="true">
<a-form-item-rest>
<a-select v-model:value="record.method" :default-value="record.method || 'GET'"
style="width: 100px">
<a-select-option v-for="item of reqType" :key="item" :value="item">{{ item
}}</a-select-option>
</a-select>
</a-form-item-rest>
<a-input v-model:value="record.path" :style="{ width: 'calc(100% - 100px)' }" />
</a-input-group>
</a-form-item>
</template>
<template v-if="column.key === 'action'">
<x-action-button @click="handleDelete(index)"> {{ $t('button.delete') }}</x-action-button>
</template>
</template>
</a-table>
<a-button @click="handleAddApi" block class="mt-8-2" type="dashed"> <!-- 地址信息区域 -->
<template #icon> <a-card class="mb-4" title="地址信息">
<plus-outlined></plus-outlined> <a-row :gutter="16">
</template> <a-col :span="24">
{{ $t('button.add') }} <a-form-item :label="'服务中心地址'" name="address">
</a-button> <a-cascader
v-model:value="formData.address"
:options="addressOptions"
placeholder="请选择省/市/区"
style="width: 100%"
></a-cascader>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'详细地址'" name="detailAddress">
<a-input v-model:value="formData.detailAddress" placeholder="请输入详细地址"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'地图定位地址'" name="location">
<a-row :gutter="8">
<a-col :span="18">
<a-input
v-model:value="formData.location"
placeholder="请选择地图位置"
readonly
></a-input>
</a-col>
<a-col :span="6">
<a-button type="primary" block @click="openMapSelector">选择地图位置</a-button>
</a-col>
</a-row>
</a-form-item>
</a-col>
</a-row>
</a-card> </a-card>
<template v-if="menuTypeEnum.is('menu', formData.type)"> </template>
<template v-if="statusTypeEnum.is('enabled', formData.status)"> </template> <!-- 站点信息区域 -->
<a-card class="mb-4" title="站点信息">
<a-row :gutter="16">
<a-col :span="12">
<a-form-item :label="'建成时间'" name="buildTime">
<a-date-picker
v-model:value="formData.buildTime"
format="YYYY-MM-DD"
placeholder="请选择建成时间"
></a-date-picker>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="'建筑面积(平方米)'" name="area">
<a-input-number
v-model:value="formData.area"
min="0"
style="width: 100%"
placeholder="请输入建筑面积"
></a-input-number>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'服务介绍'" name="description">
<a-textarea
v-model:value="formData.description"
rows="4"
placeholder="请输入服务介绍"
></a-textarea>
</a-form-item>
</a-col>
</a-row>
</a-card>
<!-- 服务信息区域 -->
<a-card class="mb-4" title="服务信息">
<a-row :gutter="16">
<a-col :span="12">
<a-form-item :label="'开始营业时间'" name="openTime">
<a-time-picker
v-model:value="formData.openTime"
format="HH:mm"
placeholder="请选择开始营业时间"
></a-time-picker>
<a-time-picker
v-model:value="formData.closeTime"
format="HH:mm"
placeholder="请选择结束营业时间"
></a-time-picker>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="'营业状态'" name="businessStatus">
<a-select v-model:value="formData.businessStatus">
<a-select-option value="open">营业中</a-select-option>
<a-select-option value="closed">已关闭</a-select-option>
<a-select-option value="suspended">暂停营业</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item name="services">
<template #label>
<span>
提供服务
<a-tooltip>
<template #title>
勾选以下服务类型在小程序可见
</template>
<question-circle-outlined class="info-icon" />
</a-tooltip>
</span>
</template>
<div class="service-tags">
<a-tag
v-for="service in allServices"
:key="service.value"
:checked="formData.services?.includes(service.value)"
@click="handleServiceClick(service.value)"
:class="{'ant-tag-checkable-checked': formData.services?.includes(service.value)}"
class="service-tag"
>
{{ service.label }}
</a-tag>
</div>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="'是否有厨房'" name="hasKitchen">
<a-select v-model:value="formData.hasKitchen">
<a-select-option value="yes"></a-select-option>
<a-select-option value="no"></a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="'提供餐饮'" name="provideMeal">
<a-select v-model:value="formData.provideMeal">
<a-select-option value="yes"></a-select-option>
<a-select-option value="no"></a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="'支持送餐'" name="supportDelivery">
<a-select v-model:value="formData.supportDelivery">
<a-select-option value="yes"></a-select-option>
<a-select-option value="no"></a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="'助餐点名称'" name="mealPointName">
<a-input v-model:value="formData.mealPointName" placeholder="请输入助餐点名称"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="'床位数'" name="bedCount" :required="true">
<a-input-number v-model:value="formData.bedCount" placeholder="请输入床位数" min="0" style="width: 100%"></a-input-number>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="'日间照料中心名称'" name="daycareCenterName">
<a-input v-model:value="formData.daycareCenterName" placeholder="请输入日间照料中心名称"></a-input>
</a-form-item>
</a-col>
</a-row>
</a-card>
<!-- 图片上传区域 -->
<a-card class="mb-4" title="图片上传">
<a-row :gutter="16">
<a-col :span="12">
<a-form-item :label="'资质附件'" name="qualificationFiles">
<a-upload
list-type="picture-card"
v-model:file-list="formData.qualificationFiles"
:before-upload="beforeUpload"
>
<div v-if="formData.qualificationFiles.length < 5">
<plus-outlined />
<div class="ant-upload-text">上传</div>
</div>
</a-upload>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item :label="'站点图片'" name="siteImages">
<a-upload
list-type="picture-card"
v-model:file-list="formData.siteImages"
:before-upload="beforeUpload"
>
<div v-if="formData.siteImages.length < 5">
<plus-outlined />
<div class="ant-upload-text">上传</div>
</div>
</a-upload>
</a-form-item>
</a-col>
</a-row>
</a-card>
</a-form> </a-form>
</a-modal> </a-modal>
</template> </template>
<script setup> <script setup>
import { cloneDeep } from 'lodash-es' import { cloneDeep } from 'lodash-es'
import { QuestionCircleOutlined } from '@ant-design/icons-vue' import { QuestionCircleOutlined, PlusOutlined } from '@ant-design/icons-vue'
import apis from '@/apis' import apis from '@/apis'
import { useModal, useForm } from '@/hooks' import { useModal, useForm } from '@/hooks'
import { menuTypeEnum, statusTypeEnum } from '@/enums/system' import { menuTypeEnum, statusTypeEnum } from '@/enums/system'
import { ref } from 'vue' import { ref, reactive } from 'vue'
import { config } from '@/config' import { config } from '@/config'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import storage from '@/utils/storage' import storage from '@/utils/storage'
import { message } from 'ant-design-vue'
const emit = defineEmits(['ok']) const emit = defineEmits(['ok'])
const { t } = useI18n() // t const { t } = useI18n() // t
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal() const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
const { formData, formRef, formRules, resetForm } = useForm() const { formData, formRef, formRules, resetForm } = useForm()
formRules.value = { //
name: { required: true, message: t('pages.system.menu.form.name.placeholder') }, formData.value = {
code: { required: true, message: t('pages.system.menu.form.code.placeholder') }, name: '', //
parent_id: '',
nodeType: '',
code: '',
type: '',
manager: '',
phone: '',
starLevel: '',
staffCount: 0,
address: [], //
detailAddress: '',
location: '', //
buildTime: null, //
area: 0, //
description: '', //
openTime: null, //
closeTime: null, //
businessStatus: '', //
services: [], //
hasKitchen: '', //
provideMeal: '', //
supportDelivery: '', //
mealPointName: '', //
bedCount: 0, //
daycareCenterName: '', //
qualificationFiles: [], //
siteImages: [], //
resources: []
} }
//
formRules.value = {
name: [
{ required: true, message: '请输入站点名称' }
],
nodeType: [
{ required: true, message: '请选择所在节点' }
],
code: [
{ required: true, message: '请输入机构代码' }
],
type: [
{ required: true, message: '请选择站点类型' }
],
manager: [
{ required: true, message: '请输入负责人姓名' }
],
phone: [
{ required: true, message: '请输入联系电话' },
{
pattern: /^1[3-9]\d{9}$/,
message: '请输入正确的联系电话'
}
],
bedCount: [
{ required: true, message: '请输入床位数' },
{
validator: (_, value) => {
if (value !== null && value !== undefined && value !== '') {
if (typeof value === 'number' && value >= 0) {
return Promise.resolve();
}
return Promise.reject(new Error('床位数必须为非负数'));
}
return Promise.reject(new Error('请输入床位数'));
}
}
],
address: { required: true, message: '请选择省市区' },
detailAddress: { required: true, message: '请输入详细地址' },
buildTime: { required: true, message: '请选择建成时间' },
area: {
required: true,
validator: (_, value) => {
if (value && value > 0) {
return Promise.resolve();
}
return Promise.reject(new Error('请输入有效的建筑面积'));
}
},
openTime: { required: true, message: '请选择开始营业时间' },
closeTime: { required: true, message: '请选择结束营业时间' },
businessStatus: { required: true, message: '请选择营业状态' },
services: {
required: true,
validator: (_, value) => {
if (value && value.length > 0) {
return Promise.resolve();
}
return Promise.reject(new Error('请至少选择一项服务'));
}
},
hasKitchen: { required: true, message: '请选择是否有厨房' },
provideMeal: { required: true, message: '请选择是否提供餐饮' }
}
//
const columns = [ const columns = [
{ title: t('pages.system.menu.form.path'), dataIndex: 'types', key: 'types' }, { title: t('pages.system.menu.form.path'), dataIndex: 'types', key: 'types' },
{ title: t('button.action'), dataIndex: 'action', key: 'action' }, { title: t('button.action'), dataIndex: 'action', key: 'action' }
] ]
//
const reqType = ['GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE'] const reqType = ['GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE']
//
const cancelText = ref(t('button.cancel')) const cancelText = ref(t('button.cancel'))
const okText = ref(t('button.confirm')) const okText = ref(t('button.confirm'))
const platform=ref('') const platform = ref('')
// -
const addressOptions = ref([
{
value: 'beijing',
label: '北京',
children: [
{
value: 'haidian',
label: '海淀区',
children: [
{ value: 'zhongguancun', label: '中关村' },
{ value: 'wudaokou', label: '五道口' }
]
},
{
value: 'chaoyang',
label: '朝阳区',
children: [
{ value: 'cbd', label: 'CBD' },
{ value: 'sanlitun', label: '三里屯' }
]
}
]
},
{
value: 'shanghai',
label: '上海',
children: [
{
value: 'pudong',
label: '浦东新区',
children: [
{ value: 'lujiazui', label: '陆家嘴' },
{ value: 'zhangjiang', label: '张江' }
]
}
]
}
])
//
const allServices = [
{ value: 'meal', label: '助餐' },
{ value: 'daycare', label: '日间照料' },
{ value: 'equipment', label: '辅具租赁' },
{ value: 'entertainment', label: '休闲/娱乐' },
{ value: 'health', label: '健康管理' }
]
/** /**
* 新建 * 新建
*/ */
function handleCreate() { function handleCreate() {
formData.value.resources = [] formData.value.resources = []
formData.value.qualificationFiles = []
formData.value.siteImages = []
showModal({ showModal({
type: 'create', type: 'create',
title: t('pages.system.menu.add'), title: '新增服务站点',
}) })
} }
/** /**
* 添加下级 * 添加下级
* handleCreateChild
*/ */
function handleCreateChild(record = {}) { function handleCreateChild(record = {}) {
formData.value.resources = [] formData.value.resources = []
formData.value.qualificationFiles = []
formData.value.siteImages = []
showModal({ showModal({
type: 'create', type: 'create',
title: t('pages.system.menu.button.addChild'), title: '新增服务站点',
}) })
formData.value.parent_id = record.id formData.value.parent_id = record.id
} }
@ -164,12 +494,14 @@ async function handleEdit(record = {}) {
}) })
formData.value = cloneDeep(data) formData.value = cloneDeep(data)
formData.value.properties = formData.value.properties ? JSON.parse(formData.value.properties) : '' formData.value.properties = formData.value.properties ? JSON.parse(formData.value.properties) : ''
formData.value.resources = formData.value.resources || (formData.value.resources = []) formData.value.resources = formData.value.resources || []
platform.value=data.platform formData.value.qualificationFiles = formData.value.qualificationFiles || []
formData.value.siteImages = formData.value.siteImages || []
platform.value = data.platform
} }
/** /**
* 确定 * 确定提交
*/ */
function handleOk() { function handleOk() {
formRef.value formRef.value
@ -182,19 +514,24 @@ function handleOk() {
} }
params.sequence = Number.parseInt(params.sequence) || 0 params.sequence = Number.parseInt(params.sequence) || 0
params.properties = JSON.stringify(params.properties) params.properties = JSON.stringify(params.properties)
//
params.province = params.address[0]
params.city = params.address[1]
params.district = params.address[2]
let result = null let result = null
switch (modal.value.type) { switch (modal.value.type) {
case 'create': case 'create':
params.platform=storage.local.getItem('platform') params.platform = storage.local.getItem('platform')
result = await apis.menu.createMenu(params).catch(() => { result = await apis.menu.createMenu(params).catch(() => {
throw new Error() throw new Error()
}) })
break break
case 'edit': case 'edit':
newApiData() newApiData()
params.resources = formData.value.resources params.resources = formData.value.resources
params.platform=platform.value params.platform = platform.value
result = await apis.menu.updateMenu(formData.value.id, params).catch(() => { result = await apis.menu.updateMenu(formData.value.id, params).catch(() => {
throw new Error() throw new Error()
}) })
@ -222,7 +559,7 @@ function handleCancel() {
} }
/** /**
* 针对API 做一次 menu_id * 处理API数据
*/ */
function newApiData() { function newApiData() {
if (formData.value.resources) if (formData.value.resources)
@ -232,7 +569,7 @@ function newApiData() {
} }
/** /**
* 关闭后 * 关闭后重置
*/ */
function onAfterClose() { function onAfterClose() {
resetForm() resetForm()
@ -242,20 +579,64 @@ function onAfterClose() {
/** /**
* 添加API * 添加API
*/ */
function handleAddApi() { function handleAddApi() {
formData.value.resources.push({ formData.value.resources.push({
method: 'GET', method: 'GET',
path: '', path: '',
}) })
} /** }
/**
* 删除API * 删除API
*/ */
function handleDelete(index) { function handleDelete(index) {
formData.value.resources.splice(index, 1) formData.value.resources.splice(index, 1)
} }
/**
* 处理服务点击事件
*/
function handleServiceClick(value) {
if (!formData.value.services) {
formData.value.services = []
}
const index = formData.value.services.indexOf(value)
if (index > -1) {
//
formData.value.services.splice(index, 1)
} else {
//
formData.value.services.push(value)
}
}
/**
* 打开地图选择器
*/
function openMapSelector() {
//
// 使
formData.value.location = '北京市海淀区中关村大街1号 (经纬度: 39.9847, 116.3055)'
}
/**
* 上传前处理
*/
function beforeUpload(file) {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'
if (!isJpgOrPng) {
message.error('只能上传JPG/PNG格式的图片!')
return false
}
const isLt2M = file.size / 1024 / 1024 < 2
if (!isLt2M) {
message.error('图片大小不能超过2MB!')
return false
}
return true
}
defineExpose({ defineExpose({
handleCreate, handleCreate,
handleCreateChild, handleCreateChild,
@ -263,4 +644,44 @@ defineExpose({
}) })
</script> </script>
<style lang="less" scoped></style> <style lang="less" scoped>
.service-tags {
display: flex;
flex-wrap: wrap;
gap: 8px;
padding: 8px 0;
}
//
.service-tag {
cursor: pointer;
&.ant-tag-checkable-checked {
background-color: #1890ff; //
color: #fff; //
border-color: #1890ff;
&:hover {
background-color: #40a9ff;
border-color: #40a9ff;
}
}
&:not(.ant-tag-checkable-checked) {
&:hover {
border-color: #1890ff;
}
}
}
//
.info-icon {
margin-left: 4px;
color: #1890ff;
cursor: pointer;
}
.ant-upload-list {
margin-top: 8px;
}
</style>

View File

@ -4,28 +4,14 @@
<a-form :label-col="{ style: { width: '100px' } }" :model="searchFormData" layout="inline"> <a-form :label-col="{ style: { width: '100px' } }" :model="searchFormData" layout="inline">
<a-row :gutter="gutter"> <a-row :gutter="gutter">
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item :label="'姓名'" name="name"> <a-form-item :label="'站点名称'" name="name">
<a-input :placeholder="'请选择姓名'" v-model:value="searchFormData.name"></a-input> <a-input :placeholder="'请输入站点名称'" v-model:value="searchFormData.name"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item name="code"> <a-form-item :label="'站点类型'" name="type">
<template #label> <a-select v-model:value="searchFormData.type" @change="handleChange">
{{ '身份证号' }}
<a-tooltip :title="'身份证号'">
<question-circle-outlined class="ml-4-1 color-placeholder" />
</a-tooltip>
</template>
<a-input :placeholder="'请输入身份证号'" v-model:value="searchFormData.code"></a-input>
</a-form-item>
</a-col>
<a-col v-bind="colSpan">
<a-form-item :label="'工单状态'" name="name">
<!-- <a-input :placeholder="'请选择工作状态'" v-model:value="searchFormData.name"></a-input> -->
<a-select ref="select" v-model:value="searchFormData.name" @focus="focus"
@change="handleChange">
<a-select-option value="jack">已结单</a-select-option> <a-select-option value="jack">已结单</a-select-option>
<a-select-option value="lucy">已作废</a-select-option> <a-select-option value="lucy">已作废</a-select-option>
</a-select> </a-select>
@ -33,19 +19,21 @@
</a-col> </a-col>
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item :label="'所在区域'" name="name"> <a-form-item :label="'所在区域'" name="area">
<a-input :placeholder="'请选择区域'" v-model:value="searchFormData.name"></a-input> <a-input :placeholder="'请选择区域'" v-model:value="searchFormData.area"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item :label="'服务时间'" name="name"> <a-form-item :label="'所在节点'" name="node">
<a-range-picker v-model:value="searchFormData.date" /> <a-select v-model:value="searchFormData.node" @change="handleChange">
<a-select-option value="jack">已结单</a-select-option>
<a-select-option value="lucy">已作废</a-select-option>
</a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row>
<a-row :gutter="gutter" style="margin-top: 16px;"> <a-col v-bind="colSpan" style="text-align: right;">
<a-col :span="24" style="text-align: right;">
<a-space> <a-space>
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button> <a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
<a-button ghost type="primary" @click="handleSearch"> <a-button ghost type="primary" @click="handleSearch">
@ -54,18 +42,50 @@
</a-space> </a-space>
</a-col> </a-col>
</a-row> </a-row>
</a-form> </a-form>
</template> </template>
</x-search-bar> </x-search-bar>
<a-card> <a-card>
<!-- 添加标题和横线 -->
<div class="title-container">
<h3>服务站点列表</h3>
<div class="title-line"></div>
</div>
<x-action-bar class="mb-8-2"> <x-action-bar class="mb-8-2">
<a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()"> <!-- 增加按钮之间的间距 -->
<template #icon> <a-space :size="12">
<plus-outlined></plus-outlined> <a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()">
</template> 新建
{{ $t('pages.system.menu.add') }} </a-button>
</a-button>
<!-- 修改导入按钮的点击事件 -->
<a-button v-action="'add'" type="primary" @click="showImportModal = true">
导入
</a-button>
<a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()">
<template #icon>
<UnorderedListOutlined />
</template>
导入记录
</a-button>
<a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()">
导出
</a-button>
<a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()">
<template #icon>
<UnorderedListOutlined />
</template>
导出记录
</a-button>
</a-space>
</x-action-bar> </x-action-bar>
<a-table rowKey="id" :loading="loading" :pagination="true" :columns="columns" :data-source="listData"> <a-table rowKey="id" :loading="loading" :pagination="true" :columns="columns" :data-source="listData">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="'menuType' === column.key"> <template v-if="'menuType' === column.key">
@ -120,25 +140,38 @@
</a-card> </a-card>
<edit-dialog @ok="onOk" ref="editDialogRef" /> <edit-dialog @ok="onOk" ref="editDialogRef" />
<!-- 导入弹框组件 -->
<import-modal
v-model:visible="showImportModal"
@download="handleDownloadTemplate"
@upload="handleFileUpload"
/>
</template> </template>
<script setup> <script setup>
import { Modal, message } from 'ant-design-vue' import { Modal, message } from 'ant-design-vue'
import { ref } from 'vue' import { ref } from 'vue'
import { PlusOutlined, EditOutlined, DeleteOutlined, PlusCircleOutlined } from '@ant-design/icons-vue' import { UnorderedListOutlined, EditOutlined, PlusCircleOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import apis from '@/apis' import apis from '@/apis'
import { config } from '@/config' import { config } from '@/config'
import { menuTypeEnum, statusTypeEnum } from '@/enums/system' import { menuTypeEnum, statusTypeEnum } from '@/enums/system'
import { usePagination, useForm } from '@/hooks' import { usePagination, useForm } from '@/hooks'
import { formatUtcDateTime } from '@/utils/util' import { formatUtcDateTime } from '@/utils/util'
import EditDialog from './components/EditDialog.vue' import EditDialog from './components/EditDialog.vue'
//
import ImportModal from '@/components/Import/index.vue' //
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import storage from '@/utils/storage' import storage from '@/utils/storage'
defineOptions({ defineOptions({
// eslint-disable-next-line vue/no-reserved-component-names
name: 'menu', name: 'menu',
}) })
const { t } = useI18n() // t const { t } = useI18n() // t
// /
const showImportModal = ref(false)
const columns = ref([ const columns = ref([
{ title: '工单号', dataIndex: 'name', key: 'name', fixed: true, width: 280 }, { title: '工单号', dataIndex: 'name', key: 'name', fixed: true, width: 280 },
{ title: '服务对象', dataIndex: 'code', key: 'code', width: 240 }, { title: '服务对象', dataIndex: 'code', key: 'code', width: 240 },
@ -169,7 +202,6 @@ getMenuList()
async function getMenuList() { async function getMenuList() {
try { try {
showLoading() showLoading()
// const { current } = paginationState
const platform = storage.local.getItem('platform') const platform = storage.local.getItem('platform')
const { data, success, total } = await apis.menu const { data, success, total } = await apis.menu
.getMenuList({ .getMenuList({
@ -195,7 +227,6 @@ async function getMenuList() {
* 搜索 * 搜索
*/ */
function handleSearch() { function handleSearch() {
// resetForm()
resetPagination() resetPagination()
getMenuList() getMenuList()
} }
@ -236,12 +267,74 @@ function handleDelete({ id }) {
}, },
}) })
} }
/** /**
* 编辑完成 * 编辑完成
*/ */
async function onOk() { async function onOk() {
await getMenuList() await getMenuList()
} }
/**
* 处理下载模板
*/
function handleDownloadTemplate() {
// API
apis.downloadTemplate().then(() => {
message.success('模板下载成功')
}).catch(() => {
message.error('模板下载失败')
})
}
/**
* 处理文件上传
* @param file 选中的文件
*/
async function handleFileUpload(file) {
try {
showLoading()
// FormData
const formData = new FormData()
formData.append('file', file)
// API
const { success } = await apis.uploadServiceSite(formData)
hideLoading()
if (config('http.code.success') === success) {
message.success('文件上传成功')
showImportModal.value = false
//
await getMenuList()
} else {
message.error('文件上传失败')
}
} catch (error) {
hideLoading()
message.error('文件上传失败,请重试')
}
}
//
function handleChange() {
//
}
</script> </script>
<style lang="less" scoped></style> <style lang="less" scoped>
// 线
.title-container {
margin-bottom: 16px;
}
.title-line {
height: 1px;
width: 100%;
background-color: #e8e8e8; // 线
margin-top: 8px;
}
</style>