generated from Leo_Ding/web-template
1
This commit is contained in:
parent
3fb319bb7b
commit
7956f87572
14
src/apis/modules/orderArea.js
Normal file
14
src/apis/modules/orderArea.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* 图片管理接口
|
||||||
|
*/
|
||||||
|
import request from '@/utils/request'
|
||||||
|
// 获取列表
|
||||||
|
export const getDataList = (params) => request.basic.get('/api/v1/order-areas', params)
|
||||||
|
// 获取菜单条数据
|
||||||
|
export const getMenu = (id) => request.basic.get(`/api/v1/order-areas/${id}`)
|
||||||
|
// 添加菜单
|
||||||
|
export const createMenu = (params) => request.basic.post('/api/v1/order-areas', params)
|
||||||
|
// 更新菜单
|
||||||
|
export const updateMenu = (id, params) => request.basic.put(`/api/v1/order-areas/${id}`, params)
|
||||||
|
// 删除菜单
|
||||||
|
export const delMenu = (id) => request.basic.delete(`/api/v1/order-areas/${id}`)
|
||||||
@ -50,5 +50,6 @@ export default {
|
|||||||
mettingYuYue:'预约记录',
|
mettingYuYue:'预约记录',
|
||||||
customer:'用户管理',
|
customer:'用户管理',
|
||||||
aiHelper:'AI助手',
|
aiHelper:'AI助手',
|
||||||
abbreviation:'活动报名'
|
abbreviation:'活动报名',
|
||||||
|
orderArea:'工单区域管理'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -135,6 +135,18 @@ export default [
|
|||||||
permission: '*',
|
permission: '*',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'workOrder/orderArea',
|
||||||
|
name: 'orderArea',
|
||||||
|
component: 'pages/workOrder/orderArea/index.vue',
|
||||||
|
meta: {
|
||||||
|
icon: '',
|
||||||
|
title: '工单区域管理',
|
||||||
|
isMenu: true,
|
||||||
|
keepAlive: true,
|
||||||
|
permission: '*',
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
176
src/views/pages/workOrder/orderArea/components/EditDialog.vue
Normal file
176
src/views/pages/workOrder/orderArea/components/EditDialog.vue
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
<template>
|
||||||
|
<a-modal :open="modal.open" :title="modal.title" :width="640" :confirm-loading="modal.confirmLoading"
|
||||||
|
:after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
|
||||||
|
<a-spin :spinning="spining">
|
||||||
|
<a-form ref="formRef" :model="formData" :rules="formRules">
|
||||||
|
<a-card class="mb-8-2">
|
||||||
|
<a-row :gutter="12">
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'区域名称'" name="title">
|
||||||
|
<a-input :placeholder="'请输入区域名称'" v-model:value="formData.title"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'区域排序'" name="sequence">
|
||||||
|
<a-input-number :placeholder="'请输入排序'" v-model:value="formData.sequence"
|
||||||
|
style="width: 100%;"></a-input-number>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'区域联系人'" name="concatName">
|
||||||
|
<a-input :placeholder="'请输区域联系人'" v-model:value="formData.concatName"
|
||||||
|
style="width: 100%;"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'联系电话'" name="concatPhone">
|
||||||
|
<a-input :placeholder="'请输入联系电话'" v-model:value="formData.concatPhone"
|
||||||
|
@input="formData.concatPhone = formData.concatPhone.replace(/[^0-9]/g, '')"
|
||||||
|
style="width: 100%;" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'备注'" name="remark">
|
||||||
|
<a-textarea :placeholder="'请输备注'" v-model:value="formData.remark"
|
||||||
|
style="width: 100%;"></a-textarea>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'状态'" name="status">
|
||||||
|
<a-radio-group v-model:value="formData.status" :options="workTypeStatus.getAll()"
|
||||||
|
disabled></a-radio-group>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-card>
|
||||||
|
</a-form>
|
||||||
|
</a-spin>
|
||||||
|
|
||||||
|
</a-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { cloneDeep } from 'lodash-es'
|
||||||
|
import { ref, onBeforeMount } from 'vue'
|
||||||
|
import { config } from '@/config'
|
||||||
|
import apis from '@/apis'
|
||||||
|
import { useForm, useModal, useSpining } from '@/hooks'
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { workTypeStatus } from '@/enums/index.js'
|
||||||
|
import { spliceUrl } from '@/utils/util'
|
||||||
|
const areaFormRef = ref()
|
||||||
|
const emit = defineEmits(['ok'])
|
||||||
|
const { t } = useI18n() // 解构出t方法
|
||||||
|
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||||
|
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||||
|
const { spining, showSpining, hideSpining } = useSpining()
|
||||||
|
const cancelText = ref(t('button.cancel'))
|
||||||
|
const okText = ref(t('button.confirm'))
|
||||||
|
const treeData = ref([])
|
||||||
|
formRules.value = {
|
||||||
|
title: { required: true, message: '请输入区域名称' },
|
||||||
|
sequence: { required: true, message: '请输入排序' },
|
||||||
|
concatName: { required: true, message: '请输入联系人' },
|
||||||
|
concatPhone: { required: true, message: '请输入联系电话' },
|
||||||
|
status: { required: true, message: '请选择状态', trigger: 'change' }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新建
|
||||||
|
*/
|
||||||
|
function handleCreate() {
|
||||||
|
showModal({
|
||||||
|
type: 'create',
|
||||||
|
title: '新增区域',
|
||||||
|
})
|
||||||
|
formData.value.status = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*/
|
||||||
|
async function handleEdit(record = {}) {
|
||||||
|
showModal({
|
||||||
|
type: 'edit',
|
||||||
|
title: '编辑分类',
|
||||||
|
})
|
||||||
|
try {
|
||||||
|
showSpining()
|
||||||
|
const { data, success } = await apis.orderArea.getMenu(record.id).catch()
|
||||||
|
if (!success) {
|
||||||
|
hideModal()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
hideSpining()
|
||||||
|
formData.value = { ...data }
|
||||||
|
} catch (error) {
|
||||||
|
message.error({ content: error.message })
|
||||||
|
hideSpining()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 确定
|
||||||
|
*/
|
||||||
|
function handleOk() {
|
||||||
|
formRef.value.validateFields().then(async (values) => {
|
||||||
|
try {
|
||||||
|
showLoading()
|
||||||
|
const params = {
|
||||||
|
...values,
|
||||||
|
status: 1
|
||||||
|
}
|
||||||
|
let result = null
|
||||||
|
switch (modal.value.type) {
|
||||||
|
case 'create':
|
||||||
|
result = await apis.orderArea.createMenu(params).catch((error) => {
|
||||||
|
throw new Error(error)
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case 'edit':
|
||||||
|
result = await apis.orderArea.updateMenu(formData.value.id, params).catch(() => {
|
||||||
|
throw new Error(error)
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
hideLoading()
|
||||||
|
if (config('http.code.success') === result?.success) {
|
||||||
|
hideModal()
|
||||||
|
emit('ok')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error({ content: error.message })
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
hideLoading()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消
|
||||||
|
*/
|
||||||
|
function handleCancel() {
|
||||||
|
hideModal()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭后
|
||||||
|
*/
|
||||||
|
function onAfterClose() {
|
||||||
|
resetForm()
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
handleCreate,
|
||||||
|
handleEdit,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
||||||
206
src/views/pages/workOrder/orderArea/index.vue
Normal file
206
src/views/pages/workOrder/orderArea/index.vue
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
<template>
|
||||||
|
<a-row :gutter="8" :wrap="false">
|
||||||
|
<a-col flex="auto">
|
||||||
|
<a-card type="flex">
|
||||||
|
<x-action-bar class="mb-8-2">
|
||||||
|
<a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
|
||||||
|
<template #icon>
|
||||||
|
<plus-outlined></plus-outlined>
|
||||||
|
</template>
|
||||||
|
新增区域
|
||||||
|
</a-button>
|
||||||
|
</x-action-bar>
|
||||||
|
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
||||||
|
:pagination="paginationState" @change="onTableChange">
|
||||||
|
<template #bodyCell="{ column, record }">
|
||||||
|
<template v-if="'status' === column.dataIndex">
|
||||||
|
<a-tag :color="workTypeStatus.getColor(record.status)">{{
|
||||||
|
workTypeStatus.getName(record.status) }}</a-tag>
|
||||||
|
</template>
|
||||||
|
<template v-if="'action' === column.key">
|
||||||
|
<x-action-button @click="$refs.editDialogRef.handleEdit(record)">
|
||||||
|
<a-tooltip>
|
||||||
|
<template #title>编辑区域</template>
|
||||||
|
<edit-outlined />
|
||||||
|
</a-tooltip>
|
||||||
|
</x-action-button>
|
||||||
|
<x-action-button @click="auditHandleEdit(record)" v-if="record.status === 1">
|
||||||
|
<a-tooltip>
|
||||||
|
<template #title>审核</template>
|
||||||
|
<i class='iconfont icon-shenhe' style='font-size:14px;color:#faad14'></i>
|
||||||
|
</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>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
<a-modal :open="open" :title="'审核'" :width="640" title="审核" ok-text="确认" cancel-text="取消" @ok="handleAuditEdit"
|
||||||
|
@cancel="open = false">
|
||||||
|
<a-card class="mb-8-2">
|
||||||
|
<a-form-item :label="'审核'" name="">
|
||||||
|
<a-radio-group v-model:value="auditStatus"
|
||||||
|
:options="[{ value: 2, label: '通过' }, { value: 99, label: '不通过' }]"></a-radio-group>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :label="'备注'" name="">
|
||||||
|
<a-textarea v-model:value="remark"></a-textarea>
|
||||||
|
</a-form-item>
|
||||||
|
</a-card>
|
||||||
|
</a-modal>
|
||||||
|
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { message, Modal } from 'ant-design-vue'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import apis from '@/apis'
|
||||||
|
import { config } from '@/config'
|
||||||
|
import { usePagination } from '@/hooks'
|
||||||
|
import EditDialog from './components/EditDialog.vue'
|
||||||
|
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { workTypeStatus } from '@/enums/index.js'
|
||||||
|
defineOptions({
|
||||||
|
name: 'orderArea',
|
||||||
|
})
|
||||||
|
const currentForm = ref({})
|
||||||
|
const open = ref(false)
|
||||||
|
const auditStatus = ref(2)
|
||||||
|
const remark = ref('')
|
||||||
|
const { t } = useI18n() // 解构出t方法
|
||||||
|
const columns = [
|
||||||
|
{ title: '区域名称', dataIndex: 'title' },
|
||||||
|
// { title: '分类排序', dataIndex: 'sequence' },
|
||||||
|
{ title: '区域联系人', dataIndex: 'concatName' },
|
||||||
|
{ title: '联系电话', dataIndex: 'concatPhone' },
|
||||||
|
{ title: '备注', dataIndex: 'remark' },
|
||||||
|
{ title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
||||||
|
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
||||||
|
]
|
||||||
|
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
||||||
|
usePagination()
|
||||||
|
|
||||||
|
const editDialogRef = ref()
|
||||||
|
getPageList()
|
||||||
|
/**
|
||||||
|
* 获取区域列表
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async function getPageList() {
|
||||||
|
try {
|
||||||
|
showLoading()
|
||||||
|
const { pageSize, current } = paginationState
|
||||||
|
const { success, data, total } = await apis.orderArea
|
||||||
|
.getDataList({
|
||||||
|
pageSize,
|
||||||
|
current: current,
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
hideLoading()
|
||||||
|
if (config('http.code.success') === success) {
|
||||||
|
listData.value = data.map(item => ({
|
||||||
|
...item,
|
||||||
|
key: item.value
|
||||||
|
}))
|
||||||
|
paginationState.total = total
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const auditHandleEdit = (params) => {
|
||||||
|
currentForm.value = params
|
||||||
|
open.value = true
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 审核
|
||||||
|
*/
|
||||||
|
const handleAuditEdit = async () => {
|
||||||
|
try {
|
||||||
|
const params = {
|
||||||
|
...currentForm.value,
|
||||||
|
status: auditStatus.value,
|
||||||
|
remark: remark.value
|
||||||
|
}
|
||||||
|
const result = await apis.orderArea.updateMenu(currentForm.value.id, params).catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
if (config('http.code.success') === result?.success) {
|
||||||
|
getPageList()
|
||||||
|
open.value = false
|
||||||
|
message.success('审核成功')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error(error.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*/
|
||||||
|
function onTableChange({ current, pageSize }) {
|
||||||
|
paginationState.current = current
|
||||||
|
paginationState.pageSize = pageSize
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索
|
||||||
|
*/
|
||||||
|
function handleSearch() {
|
||||||
|
resetPagination()
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 重置
|
||||||
|
*/
|
||||||
|
function handleResetSearch() {
|
||||||
|
searchFormData.value = {}
|
||||||
|
resetPagination()
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 编辑完成
|
||||||
|
*/
|
||||||
|
async function onOk() {
|
||||||
|
await getPageList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
function handleDelete({ id }) {
|
||||||
|
Modal.confirm({
|
||||||
|
title: t('pages.system.user.delTip'),
|
||||||
|
content: t('button.confirm'),
|
||||||
|
okText: t('button.confirm'),
|
||||||
|
onOk: () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
; (async () => {
|
||||||
|
try {
|
||||||
|
const { success } = await apis.orderArea.delMenu(id).catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
if (config('http.code.success') === success) {
|
||||||
|
resolve()
|
||||||
|
message.success(t('component.message.success.delete'))
|
||||||
|
await getPageList()
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
reject()
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
||||||
Loading…
x
Reference in New Issue
Block a user