generated from Leo_Ding/web-template
服务设施代码提交
This commit is contained in:
parent
5316616a3c
commit
9fe02d0c3c
@ -38,5 +38,8 @@ export default {
|
||||
mineWorderOrder: '我下的工单',
|
||||
invalidWzorkOrder: '无效工单',
|
||||
abnormalWorkOrder: '异常工单',
|
||||
serviceWorkOrder: '服务工单'
|
||||
serviceWorkOrder: '服务工单',
|
||||
serviceMenu: '服务设施',
|
||||
serviceSites: '服务站点',
|
||||
serviceOrganization: '服务组织',
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import platform from './platform'
|
||||
// import iframe from './iframe'
|
||||
// import other from './other'
|
||||
import workorder from './workorder'
|
||||
import service from './service'
|
||||
|
||||
export default [
|
||||
...home,
|
||||
@ -26,4 +27,5 @@ export default [
|
||||
// ...iframe,
|
||||
// ...other,
|
||||
...workorder,
|
||||
...service,
|
||||
]
|
||||
|
||||
51
src/router/routes/service.js
Normal file
51
src/router/routes/service.js
Normal file
@ -0,0 +1,51 @@
|
||||
import { ProfileOutlined } from '@ant-design/icons-vue'
|
||||
|
||||
export default [
|
||||
{
|
||||
path: 'serviceMenu',
|
||||
name: 'serviceMenu',
|
||||
component: 'RouteViewLayout',
|
||||
meta: {
|
||||
icon: ProfileOutlined,
|
||||
title: '服务设施',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'serviceSites/index.vue',
|
||||
name: 'serviceSites',
|
||||
component: 'serviceMenu/serviceSites/index.vue',
|
||||
meta: {
|
||||
title: '服务站点',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'serviceOrganization/index.vue',
|
||||
name: 'serviceOrganization',
|
||||
component: 'serviceMenu/serviceOrganization/index.vue',
|
||||
meta: {
|
||||
title: '服务组织',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'add/index.vue',
|
||||
name: 'serviceOrganizationAdd',
|
||||
component: 'serviceMenu/serviceOrganization/pages/index.vue',
|
||||
meta: {
|
||||
title: '新建',
|
||||
isMenu: false,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
@ -0,0 +1,687 @@
|
||||
<template>
|
||||
<a-modal
|
||||
: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-card class="mb-4">
|
||||
<a-row :gutter="16">
|
||||
<!-- 基本信息区域 -->
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="'站点名称'" name="name" :required="true">
|
||||
<a-input v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="'所在节点'" name="nodeType" :required="true">
|
||||
<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-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="'机构代码'" name="code" :required="true">
|
||||
<a-input v-model:value="formData.code"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="'站点类型'" name="type" :required="true">
|
||||
<a-select v-model:value="formData.type" @change="handleChange">
|
||||
<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-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="'负责人姓名'" name="manager" :required="true">
|
||||
<a-input v-model:value="formData.manager"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="'联系电话'" name="phone" :required="true">
|
||||
<a-input v-model:value="formData.phone" placeholder="请输入联系电话"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="'星级等级'" name="starLevel">
|
||||
<a-select v-model:value="formData.starLevel">
|
||||
<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-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
|
||||
<!-- 地址信息区域 -->
|
||||
<a-card class="mb-4" title="地址信息">
|
||||
<a-row :gutter="16">
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'服务中心地址'" name="address">
|
||||
<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 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-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { QuestionCircleOutlined, PlusOutlined } from '@ant-design/icons-vue'
|
||||
import apis from '@/apis'
|
||||
import { useModal, useForm } from '@/hooks'
|
||||
import { menuTypeEnum, statusTypeEnum } from '@/enums/system'
|
||||
import { ref, reactive } from 'vue'
|
||||
import { config } from '@/config'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import storage from '@/utils/storage'
|
||||
import { message } from 'ant-design-vue'
|
||||
const emit = defineEmits(['ok'])
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
const { formData, formRef, formRules, resetForm } = useForm()
|
||||
|
||||
// 初始化表单数据
|
||||
formData.value = {
|
||||
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 = [
|
||||
{ title: t('pages.system.menu.form.path'), dataIndex: 'types', key: 'types' },
|
||||
{ title: t('button.action'), dataIndex: 'action', key: 'action' }
|
||||
]
|
||||
|
||||
// 请求类型
|
||||
const reqType = ['GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE']
|
||||
|
||||
// 取消和确认按钮文本
|
||||
const cancelText = ref(t('button.cancel'))
|
||||
const okText = ref(t('button.confirm'))
|
||||
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() {
|
||||
formData.value.resources = []
|
||||
formData.value.qualificationFiles = []
|
||||
formData.value.siteImages = []
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: '新增服务站点',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加下级
|
||||
*/
|
||||
function handleCreateChild(record = {}) {
|
||||
formData.value.resources = []
|
||||
formData.value.qualificationFiles = []
|
||||
formData.value.siteImages = []
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: '新增服务站点',
|
||||
})
|
||||
formData.value.parent_id = record.id
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
async function handleEdit(record = {}) {
|
||||
showModal({
|
||||
type: 'edit',
|
||||
title: t('pages.system.menu.edit'),
|
||||
})
|
||||
const { data } = await apis.menu.getMenu(record.id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
formData.value = cloneDeep(data)
|
||||
formData.value.properties = formData.value.properties ? JSON.parse(formData.value.properties) : ''
|
||||
formData.value.resources = formData.value.resources || []
|
||||
formData.value.qualificationFiles = formData.value.qualificationFiles || []
|
||||
formData.value.siteImages = formData.value.siteImages || []
|
||||
platform.value = data.platform
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定提交
|
||||
*/
|
||||
function handleOk() {
|
||||
formRef.value
|
||||
.validateFields()
|
||||
.then(async (values) => {
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
...values,
|
||||
}
|
||||
params.sequence = Number.parseInt(params.sequence) || 0
|
||||
params.properties = JSON.stringify(params.properties)
|
||||
|
||||
// 处理地址数据
|
||||
params.province = params.address[0]
|
||||
params.city = params.address[1]
|
||||
params.district = params.address[2]
|
||||
|
||||
let result = null
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
params.platform = storage.local.getItem('platform')
|
||||
result = await apis.menu.createMenu(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
newApiData()
|
||||
params.resources = formData.value.resources
|
||||
params.platform = platform.value
|
||||
result = await apis.menu.updateMenu(formData.value.id, params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.success) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理API数据
|
||||
*/
|
||||
function newApiData() {
|
||||
if (formData.value.resources)
|
||||
formData.value.resources.forEach((item) => {
|
||||
item.menu_id = formData.value.id
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后重置
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加API
|
||||
*/
|
||||
function handleAddApi() {
|
||||
formData.value.resources.push({
|
||||
method: 'GET',
|
||||
path: '',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除API
|
||||
*/
|
||||
function handleDelete(index) {
|
||||
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({
|
||||
handleCreate,
|
||||
handleCreateChild,
|
||||
handleEdit,
|
||||
})
|
||||
</script>
|
||||
|
||||
<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>
|
||||
292
src/views/serviceMenu/serviceOrganization/index.vue
Normal file
292
src/views/serviceMenu/serviceOrganization/index.vue
Normal file
@ -0,0 +1,292 @@
|
||||
<template>
|
||||
<x-search-bar class="mb-8-2">
|
||||
<template #default="{ gutter, colSpan }">
|
||||
<a-form :label-col="{ style: { width: '100px' } }" :model="searchFormData" layout="inline">
|
||||
<a-row :gutter="gutter">
|
||||
<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="name">
|
||||
<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="lucy">已作废</a-select-option>
|
||||
</a-select>
|
||||
</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="name">
|
||||
<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="lucy">已作废</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col v-bind="colSpan" style="text-align: right;">
|
||||
<a-space>
|
||||
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
||||
<a-button ghost type="primary" @click="handleSearch">
|
||||
{{ $t('button.search') }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
</a-form>
|
||||
</template>
|
||||
</x-search-bar>
|
||||
|
||||
<a-card>
|
||||
<!-- 添加标题和横线 -->
|
||||
<div class="title-container">
|
||||
<h3>服务站点列表</h3>
|
||||
<div class="title-line"></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="$refs.editDialogRef.handleCreate()">
|
||||
导入
|
||||
</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">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="'menuType' === column.key">
|
||||
<!--菜单-->
|
||||
<a-tag v-if="menuTypeEnum.is('page', record.type)" color="processing">
|
||||
{{ menuTypeEnum.getDesc(record.type) }}
|
||||
</a-tag>
|
||||
<!--按钮-->
|
||||
<a-tag v-if="menuTypeEnum.is('button', record.type)" color="success">
|
||||
{{ menuTypeEnum.getDesc(record.type) }}
|
||||
</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="'createAt' === column.key">
|
||||
{{ formatUtcDateTime(record.created_at) }}
|
||||
</template>
|
||||
|
||||
<template v-if="'statusType' === column.key">
|
||||
<!--状态-->
|
||||
<a-tag v-if="statusTypeEnum.is('enabled', record.status)" color="processing">
|
||||
{{ statusTypeEnum.getDesc(record.status) }}
|
||||
</a-tag>
|
||||
<!--状态-->
|
||||
<a-tag v-if="statusTypeEnum.is('disabled', record.status)" color="processing">
|
||||
{{ statusTypeEnum.getDesc(record.status) }}
|
||||
</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="'action' === column.key">
|
||||
<x-action-button @click="$refs.editDialogRef.handleEdit(record)">
|
||||
<a-tooltip>
|
||||
<template #title>{{ $t('pages.system.menu.edit') }}</template>
|
||||
<edit-outlined />
|
||||
</a-tooltip>
|
||||
</x-action-button>
|
||||
|
||||
<x-action-button @click="$refs.editDialogRef.handleCreateChild(record)">
|
||||
<a-tooltip>
|
||||
<template #title>{{ $t('pages.system.menu.button.addChild') }}</template>
|
||||
<plus-circle-outlined />
|
||||
</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>
|
||||
</a-table>
|
||||
</a-card>
|
||||
|
||||
<edit-dialog @ok="onOk" ref="editDialogRef" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Modal, message } from 'ant-design-vue'
|
||||
import { ref } from 'vue'
|
||||
import { UnorderedListOutlined } from '@ant-design/icons-vue'
|
||||
import apis from '@/apis'
|
||||
import { config } from '@/config'
|
||||
import { menuTypeEnum, statusTypeEnum } from '@/enums/system'
|
||||
import { usePagination, useForm } from '@/hooks'
|
||||
import { formatUtcDateTime } from '@/utils/util'
|
||||
import EditDialog from './components/EditDialog.vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import storage from '@/utils/storage'
|
||||
|
||||
defineOptions({
|
||||
// eslint-disable-next-line vue/no-reserved-component-names
|
||||
name: 'menu',
|
||||
})
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const columns = ref([
|
||||
{ title: '工单号', dataIndex: 'name', key: 'name', fixed: true, width: 280 },
|
||||
{ title: '服务对象', dataIndex: 'code', key: 'code', width: 240 },
|
||||
{ title: '身份证号', dataIndex: 'type', key: 'menuType', width: 240 },
|
||||
{ title: '联系方式1', dataIndex: 'status', key: 'statusType', width: 240 },
|
||||
{ title: '联系方式2', dataIndex: 'sequence', width: 240 },
|
||||
{ title: '计划服务时间', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '计划服务时常(分钟)', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '服务项目', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '所属区域', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '服务地址', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '服务组织', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '服务人员', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '下单员', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '下单时间', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
])
|
||||
const { listData, loading, showLoading, hideLoading, searchFormData, paginationState, resetPagination } =
|
||||
usePagination()
|
||||
const { resetForm } = useForm()
|
||||
const editDialogRef = ref()
|
||||
|
||||
getMenuList()
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async function getMenuList() {
|
||||
try {
|
||||
showLoading()
|
||||
// const { current } = paginationState
|
||||
const platform = storage.local.getItem('platform')
|
||||
const { data, success, total } = await apis.menu
|
||||
.getMenuList({
|
||||
...searchFormData.value,
|
||||
platform
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
data.forEach((item) => {
|
||||
item.name = t(item.code) || item.name
|
||||
})
|
||||
listData.value = data
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
function handleSearch() {
|
||||
// resetForm()
|
||||
resetPagination()
|
||||
getMenuList()
|
||||
}
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function handleResetSearch() {
|
||||
searchFormData.value = {}
|
||||
resetPagination()
|
||||
getMenuList()
|
||||
}
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
*/
|
||||
function handleDelete({ id }) {
|
||||
Modal.confirm({
|
||||
title: t('pages.system.menu.delTip'),
|
||||
content: t('button.confirm'),
|
||||
okText: t('button.confirm'),
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.menu.delMenu(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
resolve()
|
||||
message.success(t('component.message.success.delete'))
|
||||
await getMenuList()
|
||||
}
|
||||
} catch (error) {
|
||||
reject()
|
||||
}
|
||||
})()
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑完成
|
||||
*/
|
||||
async function onOk() {
|
||||
await getMenuList()
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
// 标题和横线样式
|
||||
.title-container {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.title-line {
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
background-color: #e8e8e8; // 灰色横线
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
// 按钮间距已经通过a-space的size属性设置,这里可以作为备选方案
|
||||
// :deep(.ant-btn) {
|
||||
// margin-right: 8px;
|
||||
// &:last-child {
|
||||
// margin-right: 0;
|
||||
// }
|
||||
// }
|
||||
</style>
|
||||
266
src/views/serviceMenu/serviceSites/components/EditDialog.vue
Normal file
266
src/views/serviceMenu/serviceSites/components/EditDialog.vue
Normal file
@ -0,0 +1,266 @@
|
||||
<template>
|
||||
<a-modal :width="640" :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-card class="mb-8-2">
|
||||
<a-row :gutter="12">
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="$t('pages.system.menu.form.parent_name')" name="parent_id">
|
||||
<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-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="$t('pages.system.menu.resource.form.path')" name="path">
|
||||
<a-input v-model:value="formData.path"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item name="code">
|
||||
<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-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="$t('pages.system.menu.form.status')" name="status">
|
||||
<a-radio-group v-model:value="formData.status"
|
||||
:options="statusTypeEnum.getOptions()"></a-radio-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item style="width: 200px" :label="$t('pages.system.menu.form.sequence')"
|
||||
name="sequence">
|
||||
<a-input :defaultValue="0" type="number" v-model:value="formData.sequence"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="$t('pages.system.menu.form.description')" name="description">
|
||||
<a-input v-model:value="formData.description"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="$t('pages.system.menu.form.properties')" name="properties">
|
||||
<a-textarea v-model:value="formData.properties"></a-textarea>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</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>
|
||||
<plus-outlined></plus-outlined>
|
||||
</template>
|
||||
{{ $t('button.add') }}
|
||||
</a-button>
|
||||
</a-card>
|
||||
<template v-if="menuTypeEnum.is('menu', formData.type)"> </template>
|
||||
<template v-if="statusTypeEnum.is('enabled', formData.status)"> </template>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { QuestionCircleOutlined } from '@ant-design/icons-vue'
|
||||
import apis from '@/apis'
|
||||
import { useModal, useForm } from '@/hooks'
|
||||
import { menuTypeEnum, statusTypeEnum } from '@/enums/system'
|
||||
import { ref } from 'vue'
|
||||
import { config } from '@/config'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import storage from '@/utils/storage'
|
||||
const emit = defineEmits(['ok'])
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
const { formData, formRef, formRules, resetForm } = useForm()
|
||||
|
||||
formRules.value = {
|
||||
name: { required: true, message: t('pages.system.menu.form.name.placeholder') },
|
||||
code: { required: true, message: t('pages.system.menu.form.code.placeholder') },
|
||||
}
|
||||
|
||||
const columns = [
|
||||
{ title: t('pages.system.menu.form.path'), dataIndex: 'types', key: 'types' },
|
||||
{ title: t('button.action'), dataIndex: 'action', key: 'action' },
|
||||
]
|
||||
const reqType = ['GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE']
|
||||
const cancelText = ref(t('button.cancel'))
|
||||
const okText = ref(t('button.confirm'))
|
||||
const platform=ref('')
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
formData.value.resources = []
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: t('pages.system.menu.add'),
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加下级
|
||||
* handleCreateChild
|
||||
*/
|
||||
|
||||
function handleCreateChild(record = {}) {
|
||||
formData.value.resources = []
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: t('pages.system.menu.button.addChild'),
|
||||
})
|
||||
formData.value.parent_id = record.id
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
async function handleEdit(record = {}) {
|
||||
showModal({
|
||||
type: 'edit',
|
||||
title: t('pages.system.menu.edit'),
|
||||
})
|
||||
const { data } = await apis.menu.getMenu(record.id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
formData.value = cloneDeep(data)
|
||||
formData.value.properties = formData.value.properties ? JSON.parse(formData.value.properties) : ''
|
||||
formData.value.resources = formData.value.resources || (formData.value.resources = [])
|
||||
platform.value=data.platform
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
function handleOk() {
|
||||
formRef.value
|
||||
.validateFields()
|
||||
.then(async (values) => {
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
...values,
|
||||
}
|
||||
params.sequence = Number.parseInt(params.sequence) || 0
|
||||
params.properties = JSON.stringify(params.properties)
|
||||
let result = null
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
params.platform=storage.local.getItem('platform')
|
||||
result = await apis.menu.createMenu(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
|
||||
break
|
||||
case 'edit':
|
||||
newApiData()
|
||||
params.resources = formData.value.resources
|
||||
params.platform=platform.value
|
||||
result = await apis.menu.updateMenu(formData.value.id, params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.success) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对API 做一次 menu_id
|
||||
*/
|
||||
function newApiData() {
|
||||
if (formData.value.resources)
|
||||
formData.value.resources.forEach((item) => {
|
||||
item.menu_id = formData.value.id
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加API
|
||||
*/
|
||||
|
||||
function handleAddApi() {
|
||||
formData.value.resources.push({
|
||||
method: 'GET',
|
||||
path: '',
|
||||
})
|
||||
} /**
|
||||
* 删除API
|
||||
*/
|
||||
|
||||
function handleDelete(index) {
|
||||
formData.value.resources.splice(index, 1)
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
handleCreateChild,
|
||||
handleEdit,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
247
src/views/serviceMenu/serviceSites/index.vue
Normal file
247
src/views/serviceMenu/serviceSites/index.vue
Normal file
@ -0,0 +1,247 @@
|
||||
<template>
|
||||
<x-search-bar class="mb-8-2">
|
||||
<template #default="{ gutter, colSpan }">
|
||||
<a-form :label-col="{ style: { width: '100px' } }" :model="searchFormData" layout="inline">
|
||||
<a-row :gutter="gutter">
|
||||
<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 name="code">
|
||||
<template #label>
|
||||
{{ '身份证号' }}
|
||||
<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="lucy">已作废</a-select-option>
|
||||
</a-select>
|
||||
</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="name">
|
||||
<a-range-picker v-model:value="searchFormData.date" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="gutter" style="margin-top: 16px;">
|
||||
<a-col :span="24" style="text-align: right;">
|
||||
<a-space>
|
||||
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
||||
<a-button ghost type="primary" @click="handleSearch">
|
||||
{{ $t('button.search') }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
</x-search-bar>
|
||||
<a-card>
|
||||
<x-action-bar class="mb-8-2">
|
||||
<a-button v-action="'add'" type="primary" @click="$refs.editDialogRef.handleCreate()">
|
||||
<template #icon>
|
||||
<plus-outlined></plus-outlined>
|
||||
</template>
|
||||
{{ $t('pages.system.menu.add') }}
|
||||
</a-button>
|
||||
</x-action-bar>
|
||||
<a-table rowKey="id" :loading="loading" :pagination="true" :columns="columns" :data-source="listData">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="'menuType' === column.key">
|
||||
<!--菜单-->
|
||||
<a-tag v-if="menuTypeEnum.is('page', record.type)" color="processing">
|
||||
{{ menuTypeEnum.getDesc(record.type) }}
|
||||
</a-tag>
|
||||
<!--按钮-->
|
||||
<a-tag v-if="menuTypeEnum.is('button', record.type)" color="success">
|
||||
{{ menuTypeEnum.getDesc(record.type) }}
|
||||
</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="'createAt' === column.key">
|
||||
{{ formatUtcDateTime(record.created_at) }}
|
||||
</template>
|
||||
|
||||
<template v-if="'statusType' === column.key">
|
||||
<!--状态-->
|
||||
<a-tag v-if="statusTypeEnum.is('enabled', record.status)" color="processing">
|
||||
{{ statusTypeEnum.getDesc(record.status) }}
|
||||
</a-tag>
|
||||
<!--状态-->
|
||||
<a-tag v-if="statusTypeEnum.is('disabled', record.status)" color="processing">
|
||||
{{ statusTypeEnum.getDesc(record.status) }}
|
||||
</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="'action' === column.key">
|
||||
<x-action-button @click="$refs.editDialogRef.handleEdit(record)">
|
||||
<a-tooltip>
|
||||
<template #title>{{ $t('pages.system.menu.edit') }}</template>
|
||||
<edit-outlined />
|
||||
</a-tooltip>
|
||||
</x-action-button>
|
||||
|
||||
<x-action-button @click="$refs.editDialogRef.handleCreateChild(record)">
|
||||
<a-tooltip>
|
||||
<template #title>{{ $t('pages.system.menu.button.addChild') }}</template>
|
||||
<plus-circle-outlined />
|
||||
</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>
|
||||
</a-table>
|
||||
</a-card>
|
||||
|
||||
<edit-dialog @ok="onOk" ref="editDialogRef" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Modal, message } from 'ant-design-vue'
|
||||
import { ref } from 'vue'
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined, PlusCircleOutlined } from '@ant-design/icons-vue'
|
||||
import apis from '@/apis'
|
||||
import { config } from '@/config'
|
||||
import { menuTypeEnum, statusTypeEnum } from '@/enums/system'
|
||||
import { usePagination, useForm } from '@/hooks'
|
||||
import { formatUtcDateTime } from '@/utils/util'
|
||||
import EditDialog from './components/EditDialog.vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import storage from '@/utils/storage'
|
||||
defineOptions({
|
||||
// eslint-disable-next-line vue/no-reserved-component-names
|
||||
name: 'menu',
|
||||
})
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const columns = ref([
|
||||
{ title: '工单号', dataIndex: 'name', key: 'name', fixed: true, width: 280 },
|
||||
{ title: '服务对象', dataIndex: 'code', key: 'code', width: 240 },
|
||||
{ title: '身份证号', dataIndex: 'type', key: 'menuType', width: 240 },
|
||||
{ title: '联系方式1', dataIndex: 'status', key: 'statusType', width: 240 },
|
||||
{ title: '联系方式2', dataIndex: 'sequence', width: 240 },
|
||||
{ title: '计划服务时间', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '计划服务时常(分钟)', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '服务项目', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '所属区域', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '服务地址', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '服务组织', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '服务人员', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '下单员', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
{ title: '下单时间', dataIndex: 'created_at', key: 'createAt', width: 240 },
|
||||
])
|
||||
const { listData, loading, showLoading, hideLoading, searchFormData, paginationState, resetPagination } =
|
||||
usePagination()
|
||||
const { resetForm } = useForm()
|
||||
const editDialogRef = ref()
|
||||
|
||||
getMenuList()
|
||||
|
||||
/**
|
||||
* 获取菜单列表
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async function getMenuList() {
|
||||
try {
|
||||
showLoading()
|
||||
// const { current } = paginationState
|
||||
const platform = storage.local.getItem('platform')
|
||||
const { data, success, total } = await apis.menu
|
||||
.getMenuList({
|
||||
...searchFormData.value,
|
||||
platform
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
data.forEach((item) => {
|
||||
item.name = t(item.code) || item.name
|
||||
})
|
||||
listData.value = data
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
function handleSearch() {
|
||||
// resetForm()
|
||||
resetPagination()
|
||||
getMenuList()
|
||||
}
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function handleResetSearch() {
|
||||
searchFormData.value = {}
|
||||
resetPagination()
|
||||
getMenuList()
|
||||
}
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
*/
|
||||
function handleDelete({ id }) {
|
||||
Modal.confirm({
|
||||
title: t('pages.system.menu.delTip'),
|
||||
content: t('button.confirm'),
|
||||
okText: t('button.confirm'),
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.menu.delMenu(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
resolve()
|
||||
message.success(t('component.message.success.delete'))
|
||||
await getMenuList()
|
||||
}
|
||||
} catch (error) {
|
||||
reject()
|
||||
}
|
||||
})()
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 编辑完成
|
||||
*/
|
||||
async function onOk() {
|
||||
await getMenuList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
Loading…
x
Reference in New Issue
Block a user