服务对象节点代码修改

This commit is contained in:
qiuyuan 2025-10-09 15:07:57 +08:00
parent 249f1d2e55
commit 5316616a3c
7 changed files with 1058 additions and 7 deletions

View File

@ -36,7 +36,7 @@ export default {
'dict-detail': '字典数据', 'dict-detail': '字典数据',
workorderMenu: '工单管理', workorderMenu: '工单管理',
mineWorderOrder: '我下的工单', mineWorderOrder: '我下的工单',
invalidWWzorkOrder: '无效工单', invalidWzorkOrder: '无效工单',
abnormalWorkOrder: '异常工单', abnormalWorkOrder: '异常工单',
serviceWorkOrder: '服务工单' serviceWorkOrder: '服务工单'
} }

View File

@ -16,7 +16,7 @@ export default [
{ {
path: 'mineWorderOrder/index.vue', path: 'mineWorderOrder/index.vue',
name: 'mineWorderOrder', name: 'mineWorderOrder',
component: '/pages/workorderMenu/mineWorderOrder/index.vue', component: 'workorderMenu/mineWorderOrder/index.vue',
meta: { meta: {
title: '我的工单', title: '我的工单',
isMenu: true, isMenu: true,
@ -25,9 +25,9 @@ export default [
}, },
}, },
{ {
path: 'invalidWWzorkOrder/index.vue', path: 'invalidWzorkOrder/index.vue',
name: 'invalidWWzorkOrder', name: 'invalidWzorkOrder',
component: '/pages/workorderMenu/invalidWWzorkOrder/index.vue', component: 'workorderMenu/invalidWzorkOrder/index.vue',
meta: { meta: {
title: '无效工单', title: '无效工单',
isMenu: true, isMenu: true,
@ -38,7 +38,7 @@ export default [
{ {
path: 'abnormalWorkOrder/index.vue', path: 'abnormalWorkOrder/index.vue',
name: 'abnormalWorkOrder', name: 'abnormalWorkOrder',
component: '/pages/workorderMenu/abnormalWorkOrder/index.vue', component: 'workorderMenu/abnormalWorkOrder/index.vue',
meta: { meta: {
title: '异常工单', title: '异常工单',
isMenu: true, isMenu: true,
@ -49,7 +49,7 @@ export default [
{ {
path: 'serviceWorkOrder/index.vue', path: 'serviceWorkOrder/index.vue',
name: 'serviceWorkOrder', name: 'serviceWorkOrder',
component: '/pages/workorderMenu/serviceWorkOrder/index.vue', component: 'workorderMenu/serviceWorkOrder/index.vue',
meta: { meta: {
title: '服务工单', title: '服务工单',
isMenu: true, isMenu: true,

View 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>

View 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>

View File

@ -0,0 +1,42 @@
export default {
welcome: '欢迎',
home: '首页',
system: '系统设置',
menu: '菜单管理',
user: '用户管理',
setting: '信息设置',
role: '角色管理',
logger: '日志管理',
'menu.account.settings': '个人设置',
add: '添加',
edit: '修改',
delete: '删除',
search: '搜索',
login: '登录',
register: '注册',
dashboard: 'Dashboard',
'dashboard.analysis': '分析页',
'dashboard.monitor': '监控页',
'dashboard.workplace': '工作台',
'exception.403': '403',
'exception.404': '404',
'exception.500': '500',
result: '结果页',
'result.success': '成功页',
'result.fail': '失败页',
exception: '异常页',
'exception.not-permission': '403',
'exception.not-find': '404',
'exception.server-error': '500',
'exception.trigger': '触发错误',
account: '个人页',
'account.trigger': '触发报错',
'account.logout': '退出登录',
'dict': '字典管理',
'dict-detail': '字典数据',
workorderMenu: '工单管理',
mineWorderOrder: '我下的工单',
invalidWzorkOrder: '无效工单',
abnormalWorkOrder: '异常工单',
serviceWorkOrder: '服务工单'
}

View 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>

View File

@ -0,0 +1,230 @@
<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-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-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>