generated from Leo_Ding/web-template
代码修改
This commit is contained in:
parent
65caeb0f1a
commit
590a0958e7
@ -11,7 +11,7 @@
|
||||
|
||||
<a-col v-bind="colSpan">
|
||||
<a-form-item :label="'站点类型'" name="type">
|
||||
<a-select v-model:value="searchFormData.type" placeholder="请选择站点类型" allow-clear>
|
||||
<a-select v-model:value="searchFormData.stationType" placeholder="请选择站点类型" allow-clear>
|
||||
<a-select-option v-for="item in dicsStore.dictOptions.Station_Type" :key="item.dval"
|
||||
:value="item.dval">
|
||||
{{ item.introduction }}
|
||||
@ -22,16 +22,13 @@
|
||||
|
||||
<a-col v-bind="colSpan">
|
||||
<a-form-item :label="'所在区域'" name="area">
|
||||
<AreaCascader v-model:value="searchFormData.area" @change="onAreaChange" />
|
||||
<AreaCascader v-model:value="searchFormData.areaCodes" @change="onAreaChange" />
|
||||
</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="lucy">已作废</a-select-option>
|
||||
</a-select>
|
||||
<a-form-item label="组织所在区域" name="areaLabels">
|
||||
<NodeTree v-model:value="searchFormData.areaLabels" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
@ -180,7 +177,7 @@ import ExportRecordsModal from '@/components/ExportRecord/index.vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import storage from '@/utils/storage'
|
||||
import AreaCascader from '@/components/AreaCascader/index.vue'
|
||||
|
||||
import NodeTree from '@/components/NodeTree/index.vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'menu',
|
||||
@ -237,6 +234,7 @@ const { resetForm } = useForm()
|
||||
const editDialogRef = ref()
|
||||
import { useDicsStore } from '@/store'
|
||||
const dicsStore = useDicsStore()
|
||||
const areaCodes = ref([])
|
||||
|
||||
getList()
|
||||
|
||||
@ -248,10 +246,13 @@ async function getList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { pageSize, current } = paginationState
|
||||
console.log("=====searchFormData",searchFormData.value.areaCodes)
|
||||
|
||||
const { success, data, total } = await apis.serviceMenu
|
||||
.getServiceSiteList({
|
||||
pageSize,
|
||||
current: current,
|
||||
// areaCodes:areaCodes,
|
||||
...searchFormData.value,
|
||||
})
|
||||
.catch(() => {
|
||||
@ -267,6 +268,7 @@ async function getList() {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
@ -631,6 +633,14 @@ const handleRetryExport = (record) => {
|
||||
message.error('重新导出失败');
|
||||
});
|
||||
};
|
||||
|
||||
// 选择区域后
|
||||
// 如果你用 <script setup>
|
||||
const onAreaChange = (value, selectedOptions) => {
|
||||
areaCodes.value = value;
|
||||
console.log('value:', value);
|
||||
console.log('selectedOptions:', selectedOptions); // ← 这就是你想要的节点对象数组
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@ -0,0 +1,357 @@
|
||||
<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-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"
|
||||
:disabled="selectedRowKeys.length === 0"
|
||||
@click="handleBatchProcess">
|
||||
批量处理(最多40条)
|
||||
</a-button>
|
||||
</x-action-bar>
|
||||
<a-table
|
||||
rowKey="id"
|
||||
:loading="loading"
|
||||
:pagination="true"
|
||||
:columns="columns"
|
||||
:data-source="listData"
|
||||
:row-selection="rowSelection"
|
||||
>
|
||||
<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.viewDialogRef.handleView(record)">
|
||||
<a-tooltip>
|
||||
<template #title>详情</template>
|
||||
详情
|
||||
</a-tooltip>
|
||||
</x-action-button>
|
||||
|
||||
<x-action-button @click="handleSingleProcess(record)">
|
||||
<a-tooltip>
|
||||
<template #title>处理</template>
|
||||
处理
|
||||
</a-tooltip>
|
||||
</x-action-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 处理弹窗 -->
|
||||
<a-modal
|
||||
v-model:open="processModalVisible"
|
||||
title="处理异常"
|
||||
@ok="handleProcessSubmit"
|
||||
@cancel="processModalVisible = false"
|
||||
:confirm-loading="processSubmitting"
|
||||
>
|
||||
<a-form :model="processForm" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }">
|
||||
<a-form-item label="处理结果" name="processStatus" required>
|
||||
<a-select v-model:value="processForm.processStatus" placeholder="请选择处理结果">
|
||||
<a-select-option value="handled">已处理</a-select-option>
|
||||
<a-select-option value="ignored">忽略</a-select-option>
|
||||
<!-- 可根据实际枚举扩展 -->
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="处理原因" name="processRemark">
|
||||
<a-textarea
|
||||
v-model:value="processForm.processRemark"
|
||||
placeholder="请输入处理原因"
|
||||
:rows="4"
|
||||
allow-clear
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
|
||||
<view-dialog @ok="onOk" ref="viewDialogRef" />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { Modal, message } from 'ant-design-vue'
|
||||
import { ref,reactive } 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 ViewDialog from './components/viewDialog.vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import storage from '@/utils/storage'
|
||||
import AreaCascader from '@/components/AreaCascader/index.vue'
|
||||
defineOptions({
|
||||
// eslint-disable-next-line vue/no-reserved-component-names
|
||||
name: 'menu',
|
||||
})
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const columns = ref([
|
||||
{ title: '工单号', dataIndex: 'orderId', key: 'orderId', width: 180 },
|
||||
{ title: '姓名', dataIndex: 'customerName', key: 'customerName', width: 120 },
|
||||
{ title: '身份证号', dataIndex: 'identityNo', key: 'identityNo', width: 180 },
|
||||
{ title: '异常情况', dataIndex: 'abnormalStatus', key: 'abnormalStatus', width: 120 },
|
||||
{ title: '服务人员', dataIndex: 'serviceUserName', key: 'serviceUserName', width: 120 },
|
||||
{ title: '服务项目', dataIndex: 'itemNames', key: 'itemNames', width: 200 },
|
||||
{ title: '签入时间', dataIndex: 'realStartTime', key: 'realStartTime', width: 160 },
|
||||
{ title: '签出时间', dataIndex: 'realEndTime', key: 'realEndTime', width: 160 },
|
||||
{ title: '处理状态', dataIndex: 'processStatus', key: 'processStatus', width: 120 },
|
||||
{ title: '处理原因', dataIndex: 'processRemark', key: 'processRemark', width: 160 },
|
||||
{ title: '处理人', dataIndex: 'processUserName', key: 'processUserName', width: 120 },
|
||||
{ title: '处理时间', dataIndex: 'processTime', key: 'processTime', width: 160 },
|
||||
{ title: '服务地址', dataIndex: 'serviceAddress', key: 'serviceAddress', width: 200 },
|
||||
{ title: '操作', key: 'action', fixed: 'right', width: 340 },
|
||||
])
|
||||
const { listData, loading, showLoading, hideLoading, searchFormData, paginationState, resetPagination } =
|
||||
usePagination()
|
||||
const { resetForm } = useForm()
|
||||
const viewDialogRef = ref()
|
||||
const selectedRowKeys = ref([]) // 选中的 id 列表
|
||||
const selectedRows = ref([]) // 选中的完整记录
|
||||
const rowSelection = ref({
|
||||
onChange: (keys, rows) => {
|
||||
if (keys.length > 40) {
|
||||
message.warning('最多只能选择40条记录进行批量处理')
|
||||
// 保留前40条
|
||||
selectedRowKeys.value = keys.slice(0, 40)
|
||||
selectedRows.value = rows.slice(0, 40)
|
||||
return
|
||||
}
|
||||
selectedRowKeys.value = keys
|
||||
selectedRows.value = rows
|
||||
},
|
||||
selectedRowKeys: selectedRowKeys,
|
||||
})
|
||||
|
||||
|
||||
|
||||
// 处理弹窗
|
||||
const processModalVisible = ref(false)
|
||||
const processSubmitting = ref(false)
|
||||
const processForm = reactive({
|
||||
processStatus: undefined,
|
||||
processRemark: '',
|
||||
})
|
||||
|
||||
|
||||
let currentProcessRecords = [] // 当前要处理的记录(单条或批量)
|
||||
|
||||
// 打开批量处理
|
||||
function handleBatchProcess() {
|
||||
if (selectedRowKeys.value.length === 0) return
|
||||
if (selectedRowKeys.value.length > 40) {
|
||||
message.warning('最多选择40条')
|
||||
return
|
||||
}
|
||||
currentProcessRecords = [...selectedRows.value]
|
||||
processForm.processStatus = undefined
|
||||
processForm.processRemark = ''
|
||||
processModalVisible.value = true
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
// 打开单条处理
|
||||
function handleSingleProcess(record) {
|
||||
currentProcessRecords = [record]
|
||||
processForm.processStatus = record.processStatus || undefined
|
||||
processForm.processRemark = record.processRemark || ''
|
||||
processModalVisible.value = true
|
||||
}
|
||||
|
||||
// 提交处理
|
||||
async function handleProcessSubmit() {
|
||||
const { processStatus } = processForm
|
||||
if (!processStatus ) {
|
||||
message.warning('请选择处理结果')
|
||||
return
|
||||
}
|
||||
|
||||
processSubmitting.value = true
|
||||
// try {
|
||||
// // 假设你的 API 是批量处理:apis.order.batchProcess({ ids, processStatus, processRemark })
|
||||
// const ids = currentProcessRecords.map(r => r.id)
|
||||
// const { success } = await apis.order.batchProcess({
|
||||
// ids,
|
||||
// processStatus,
|
||||
// processRemark,
|
||||
// })
|
||||
|
||||
// if (config('http.code.success') === success) {
|
||||
// message.success('处理成功')
|
||||
// processModalVisible.value = false
|
||||
// await getOrderList() // 刷新列表
|
||||
// }
|
||||
// } catch (error) {
|
||||
// message.error('处理失败')
|
||||
// } finally {
|
||||
// processSubmitting.value = false
|
||||
// }
|
||||
}
|
||||
|
||||
async function handleView(record = {}) {
|
||||
showModal({
|
||||
type: 'view',
|
||||
title: '查看详情',
|
||||
})
|
||||
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
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
@ -34,7 +34,7 @@
|
||||
|
||||
<a-col v-bind="colSpan">
|
||||
<a-form-item :label="'所在区域'" name="name">
|
||||
<a-input :placeholder="'请选择区域'" v-model:value="searchFormData.name"></a-input>
|
||||
<AreaCascader v-model:value="searchFormData.currentNode" @change="onAreaChange" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
@ -134,6 +134,7 @@ import { formatUtcDateTime } from '@/utils/util'
|
||||
import EditDialog from './components/EditDialog.vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import storage from '@/utils/storage'
|
||||
import AreaCascader from '@/components/AreaCascader/index.vue'
|
||||
defineOptions({
|
||||
// eslint-disable-next-line vue/no-reserved-component-names
|
||||
name: 'menu',
|
||||
|
||||
@ -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>
|
||||
@ -0,0 +1,248 @@
|
||||
<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">
|
||||
<AreaCascader v-model:value="searchFormData.currentNode" @change="onAreaChange" />
|
||||
</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'
|
||||
import AreaCascader from '@/components/AreaCascader/index.vue'
|
||||
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