generated from Leo_Ding/web-template
代码修改
This commit is contained in:
parent
cfc751a3ec
commit
b1160117c2
15
src/apis/modules/announcement.js
Normal file
15
src/apis/modules/announcement.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* 消息公告
|
||||||
|
*/
|
||||||
|
|
||||||
|
import request from '@/utils/request'
|
||||||
|
// 获取公告列表
|
||||||
|
export const getNoticesList = (params) => request.basic.get('/api/v1/notices', params)
|
||||||
|
// 获取条目
|
||||||
|
export const getNotices = (id) => request.basic.get(`/api/v1/notices/${id}`)
|
||||||
|
// 添加公告
|
||||||
|
export const createNotices = (params) => request.basic.post('/api/v1/notices', params)
|
||||||
|
// 更新公告
|
||||||
|
export const updateNotices = (id, params) => request.basic.put(`/api/v1/notices/${id}`, params)
|
||||||
|
// 删除公告
|
||||||
|
export const delNotices = (id) => request.basic.delete(`/api/v1/notices/${id}`)
|
||||||
@ -1,19 +1,15 @@
|
|||||||
|
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
export default () => {
|
export default () => {
|
||||||
const spining = ref(false) // 直接使用基本类型ref
|
const spining = ref(false) // 直接使用基本类型ref
|
||||||
|
|
||||||
const showSpining = () => {
|
const showSpining = () => {
|
||||||
spining.value = true
|
spining.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const hideSpining = () => {
|
const hideSpining = () => {
|
||||||
spining.value = false
|
spining.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
spining, // 直接暴露ref
|
spining, // 直接暴露ref
|
||||||
showSpining,
|
showSpining,
|
||||||
hideSpining
|
hideSpining,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,7 @@ export default {
|
|||||||
projectList: '项目列表',
|
projectList: '项目列表',
|
||||||
hoseBookList: '房刊列表',
|
hoseBookList: '房刊列表',
|
||||||
houseList: '房源列表',
|
houseList: '房源列表',
|
||||||
|
announcement: '消息公告',
|
||||||
announcementList: '公告列表',
|
announcementList: '公告列表',
|
||||||
bannberTypeList: '轮播图分类列表',
|
bannberTypeList: '轮播图分类列表',
|
||||||
bannberList: '轮播图列表',
|
bannberList: '轮播图列表',
|
||||||
|
|||||||
@ -122,7 +122,7 @@ export default {
|
|||||||
'pages.user.profile.tab.security.form.confirm_password.required': '确认密码是必填项!',
|
'pages.user.profile.tab.security.form.confirm_password.required': '确认密码是必填项!',
|
||||||
'pages.user.profile.tab.security.form.confirm_password.validator': '两次输入的密码不匹配!',
|
'pages.user.profile.tab.security.form.confirm_password.validator': '两次输入的密码不匹配!',
|
||||||
|
|
||||||
// userManagement
|
// userManagement 客户管理
|
||||||
'pages.system.userManagement.form.id': '用户编码',
|
'pages.system.userManagement.form.id': '用户编码',
|
||||||
'pages.system.userManagement.form.name': '用户名',
|
'pages.system.userManagement.form.name': '用户名',
|
||||||
'pages.system.userManagement.form.phone': '联系方式',
|
'pages.system.userManagement.form.phone': '联系方式',
|
||||||
@ -132,4 +132,17 @@ export default {
|
|||||||
'pages.system.userManagement.form.grade': '等级',
|
'pages.system.userManagement.form.grade': '等级',
|
||||||
'pages.system.userManagement.form.balance': '余额',
|
'pages.system.userManagement.form.balance': '余额',
|
||||||
'pages.system.userManagement.form.status': '状态',
|
'pages.system.userManagement.form.status': '状态',
|
||||||
|
|
||||||
|
// announcement 消息公告
|
||||||
|
'pages.system.announcement.form.id': '编号ID',
|
||||||
|
'pages.system.announcement.form.createdAt': '创建时间',
|
||||||
|
'pages.system.announcement.form.title': '标题',
|
||||||
|
'pages.system.announcement.form.content': '内容',
|
||||||
|
'pages.system.announcement.form.status': '状态',
|
||||||
|
'pages.system.announcement.form.areaId': '区域',
|
||||||
|
'pages.system.announcement.form.name': '标题名称',
|
||||||
|
'pages.system.announcement.add': '添加公告',
|
||||||
|
'pages.system.announcement.form.title.placeholder': '编辑公告标题',
|
||||||
|
'pages.system.announcement.form.content.placeholder': '编辑公告内容',
|
||||||
|
'pages.system.announcement.form.createdAt.placeholder': '创建公告时间',
|
||||||
}
|
}
|
||||||
|
|||||||
30
src/router/routes/announcement.js
Normal file
30
src/router/routes/announcement.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import { TableOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
path: 'announcement',
|
||||||
|
name: 'announcement',
|
||||||
|
component: 'RouteViewLayout',
|
||||||
|
meta: {
|
||||||
|
icon: TableOutlined,
|
||||||
|
title: '消息公告',
|
||||||
|
isMenu: true,
|
||||||
|
keepAlive: true,
|
||||||
|
permission: '*',
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'announcementList',
|
||||||
|
name: 'announcementList',
|
||||||
|
component: 'announcement/announcementList/index.vue',
|
||||||
|
|
||||||
|
meta: {
|
||||||
|
title: '消息公告列表',
|
||||||
|
isMenu: true,
|
||||||
|
keepAlive: true,
|
||||||
|
permission: '*',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
@ -12,6 +12,7 @@ import other from './other'
|
|||||||
import userManagement from './userManagement'
|
import userManagement from './userManagement'
|
||||||
import integral from './integral'
|
import integral from './integral'
|
||||||
import regional from './regional'
|
import regional from './regional'
|
||||||
|
import announcement from './announcement'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
...home,
|
...home,
|
||||||
@ -28,4 +29,5 @@ export default [
|
|||||||
...userManagement,
|
...userManagement,
|
||||||
...integral,
|
...integral,
|
||||||
...regional,
|
...regional,
|
||||||
|
...announcement,
|
||||||
]
|
]
|
||||||
|
|||||||
220
src/views/announcement/announcementList/components/AddDialog.vue
Normal file
220
src/views/announcement/announcementList/components/AddDialog.vue
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
<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-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
:label-col="{ style: { width: '90px' } }">
|
||||||
|
<a-card class="mb-8-2">
|
||||||
|
<a-row :gutter="24">
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item
|
||||||
|
:label="$t('pages.system.announcement.form.title')"
|
||||||
|
name="title">
|
||||||
|
<a-input
|
||||||
|
:placeholder="$t('pages.system.announcement.form.title.placeholder')"
|
||||||
|
v-model:value="formData.title"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item
|
||||||
|
:label="$t('pages.system.announcement.form.content')"
|
||||||
|
name="content">
|
||||||
|
<a-textarea
|
||||||
|
v-model:value="formData.content"
|
||||||
|
:placeholder="$t('pages.system.announcement.form.content.placeholder')" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<!-- <a-col :span="24">
|
||||||
|
<a-form-item
|
||||||
|
:label="$t('pages.system.announcement.form.createdAt')"
|
||||||
|
name="createdAt">
|
||||||
|
<a-input
|
||||||
|
v-model:value="formData.createdAt"
|
||||||
|
:placeholder="$t('pages.system.announcement.form.createdAt.placeholder')" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col> -->
|
||||||
|
</a-row>
|
||||||
|
</a-card>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { cloneDeep } from 'lodash-es'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { config } from '@/config'
|
||||||
|
import apis from '@/apis'
|
||||||
|
import { useForm, useModal } from '@/hooks'
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
const emit = defineEmits(['ok'])
|
||||||
|
const { t } = useI18n() // 解构出t方法
|
||||||
|
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||||
|
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||||
|
const cancelText = ref(t('button.cancel'))
|
||||||
|
const okText = ref(t('button.confirm'))
|
||||||
|
const rolesValue = ref([])
|
||||||
|
const roles = ref([])
|
||||||
|
|
||||||
|
formRules.value = {
|
||||||
|
title: { required: true, message: t('pages.system.announcement.form.title.placeholder') },
|
||||||
|
content: { required: true, message: t('pages.system.announcement.form.content.placeholder') },
|
||||||
|
// createdAt: { required: true, message: t('pages.system.announcement.form.createdAt.placeholder') },
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求角色
|
||||||
|
*/
|
||||||
|
getRole()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新建
|
||||||
|
*/
|
||||||
|
function handleCreate() {
|
||||||
|
showModal({
|
||||||
|
type: 'create',
|
||||||
|
title: t('pages.system.announcement.add'),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
async function getRole() {
|
||||||
|
const { success, data } = await apis.role.getRoleList().catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
if (!success) {
|
||||||
|
return message.error('当前角色信息错误')
|
||||||
|
}
|
||||||
|
let roleArr = []
|
||||||
|
if (data.length) {
|
||||||
|
data.forEach((item) => {
|
||||||
|
roleArr.push({
|
||||||
|
label: item.name,
|
||||||
|
value: item.id,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
roles.value = roleArr
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*/
|
||||||
|
async function handleEdit(record = {}) {
|
||||||
|
showModal({
|
||||||
|
type: 'edit',
|
||||||
|
title: '修改公告信息',
|
||||||
|
})
|
||||||
|
const { data, success } = await apis.announcement.getNotices(record.id).catch()
|
||||||
|
if (!success) {
|
||||||
|
hideModal()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let roles = []
|
||||||
|
if (data.roles) {
|
||||||
|
roles = formatArr(data.roles, 'edit')
|
||||||
|
}
|
||||||
|
|
||||||
|
data.roles = roles
|
||||||
|
formRecord.value = data
|
||||||
|
formData.value = cloneDeep(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确定
|
||||||
|
*/
|
||||||
|
function handleOk() {
|
||||||
|
formRef.value
|
||||||
|
.validateFields()
|
||||||
|
.then(async (values) => {
|
||||||
|
try {
|
||||||
|
showLoading()
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
...values,
|
||||||
|
roles: formatArr(rolesValue.value),
|
||||||
|
}
|
||||||
|
let result = null
|
||||||
|
switch (modal.value.type) {
|
||||||
|
case 'create':
|
||||||
|
result = await apis.announcement.createNotices(params).catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case 'edit':
|
||||||
|
result = await apis.announcement.updateNotices(formData.value.id, params).catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
hideLoading()
|
||||||
|
if (config('http.code.success') === result?.success) {
|
||||||
|
hideModal()
|
||||||
|
emit('ok')
|
||||||
|
message.success(modal.value.type === 'create' ? '创建成功' : '更新成功')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
hideLoading()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对权限组 过数据格式
|
||||||
|
*/
|
||||||
|
function formatArr(data, type = '') {
|
||||||
|
const rolesArr = []
|
||||||
|
data.forEach((item) => {
|
||||||
|
roles.value.forEach((r) => {
|
||||||
|
if (type === 'edit') {
|
||||||
|
if (item.role_id === r.value) {
|
||||||
|
rolesArr.push({
|
||||||
|
value: item.role_id,
|
||||||
|
label: r.label,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else if (r.value === item) {
|
||||||
|
rolesArr.push({
|
||||||
|
role_id: item,
|
||||||
|
role_name: r.label,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return rolesArr
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消
|
||||||
|
*/
|
||||||
|
function handleCancel() {
|
||||||
|
hideModal()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭后
|
||||||
|
*/
|
||||||
|
function onAfterClose() {
|
||||||
|
resetForm()
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
handleCreate,
|
||||||
|
handleEdit,
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
||||||
259
src/views/announcement/announcementList/index.vue
Normal file
259
src/views/announcement/announcementList/index.vue
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
<template>
|
||||||
|
<x-search-bar class="mb-8-2">
|
||||||
|
<template #default="{ gutter }">
|
||||||
|
<a-form
|
||||||
|
:model="searchFormData"
|
||||||
|
layout="inline">
|
||||||
|
<a-row :gutter="gutter">
|
||||||
|
<a-col :span="6">
|
||||||
|
<a-form-item
|
||||||
|
:label="$t('pages.system.announcement.form.name')"
|
||||||
|
name="title">
|
||||||
|
<a-input
|
||||||
|
:placeholder="$t('pages.system.role.form.code.placeholder')"
|
||||||
|
v-model:value="searchFormData.title"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
|
||||||
|
<a-col :span="6">
|
||||||
|
<a-form-item
|
||||||
|
:label="'状态'"
|
||||||
|
name="status">
|
||||||
|
<a-input
|
||||||
|
:placeholder="'请输入状态'"
|
||||||
|
v-model:value="searchFormData.status"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
|
||||||
|
<a-col :span="6">
|
||||||
|
<a-form-item
|
||||||
|
:label="'地区'"
|
||||||
|
name="areaId">
|
||||||
|
<a-input
|
||||||
|
:placeholder="'请输入地区'"
|
||||||
|
v-model:value="searchFormData.areaId"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
|
||||||
|
<!-- <a-col v-bind="colSpan">
|
||||||
|
<a-form-item name="id">
|
||||||
|
<template #label>
|
||||||
|
{{ $t('pages.system.role.form.code') }}
|
||||||
|
<a-tooltip :title="$t('pages.system.announcement.form.id')">
|
||||||
|
<question-circle-outlined class="ml-4-1 color-placeholder" />
|
||||||
|
</a-tooltip>
|
||||||
|
</template>
|
||||||
|
<a-input
|
||||||
|
:placeholder="$t('pages.system.role.form.code.placeholder')"
|
||||||
|
v-model:value="searchFormData.code"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col> -->
|
||||||
|
|
||||||
|
<a-col
|
||||||
|
class="align-right"
|
||||||
|
:span="6">
|
||||||
|
<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-row
|
||||||
|
:gutter="8"
|
||||||
|
:wrap="false">
|
||||||
|
<a-col flex="auto">
|
||||||
|
<a-card type="flex">
|
||||||
|
<x-action-bar class="mb-8-2">
|
||||||
|
<a-button
|
||||||
|
v-action="'add'"
|
||||||
|
type="primary"
|
||||||
|
@click="$refs.addDialogRef.handleCreate()">
|
||||||
|
<template #icon>
|
||||||
|
<plus-outlined></plus-outlined>
|
||||||
|
</template>
|
||||||
|
{{ $t('pages.system.announcement.add') }}
|
||||||
|
</a-button>
|
||||||
|
</x-action-bar>
|
||||||
|
<a-table
|
||||||
|
:columns="columns"
|
||||||
|
:data-source="listData"
|
||||||
|
:loading="loading"
|
||||||
|
:pagination="paginationState"
|
||||||
|
:scroll="{ x: 1000 }"
|
||||||
|
@change="onTableChange">
|
||||||
|
<template #bodyCell="{ column, record }">
|
||||||
|
<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="'createdAt' === column.dataIndex">
|
||||||
|
{{ dayjs(record.createdAt).format('YYYY-MM-DD HH:mm:ss') }}
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-if="'action' === column.key">
|
||||||
|
<x-action-button @click="$refs.addDialogRef.handleEdit(record)">
|
||||||
|
<a-tooltip>
|
||||||
|
<template #title> {{ '编辑公告' }}</template>
|
||||||
|
<edit-outlined />
|
||||||
|
</a-tooltip>
|
||||||
|
</x-action-button>
|
||||||
|
<x-action-button @click="handleRemove(record)">
|
||||||
|
<a-tooltip>
|
||||||
|
<template #title> {{ '删除公告' }}</template>
|
||||||
|
<delete-outlined style="color: #ff4d4f" />
|
||||||
|
</a-tooltip>
|
||||||
|
</x-action-button>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
|
</a-card>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
|
||||||
|
<add-dialog
|
||||||
|
ref="addDialogRef"
|
||||||
|
@ok="onOk"></add-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { message, Modal } from 'ant-design-vue'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import apis from '@/apis'
|
||||||
|
import { config } from '@/config'
|
||||||
|
import { statusTypeEnum } from '@/enums/system'
|
||||||
|
import { usePagination } from '@/hooks'
|
||||||
|
import AddDialog from './components/AddDialog.vue'
|
||||||
|
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'systemRole',
|
||||||
|
})
|
||||||
|
const { t } = useI18n() // 解构出t方法
|
||||||
|
const columns = [
|
||||||
|
{ title: t('pages.system.announcement.form.id'), dataIndex: 'id', width: 100 },
|
||||||
|
{ title: t('pages.system.announcement.form.createdAt'), dataIndex: 'createdAt', width: 200 },
|
||||||
|
{ title: t('pages.system.announcement.form.title'), dataIndex: 'title', key: 'title', width: 240 },
|
||||||
|
{ title: t('pages.system.announcement.form.content'), dataIndex: 'content', width: 240 },
|
||||||
|
{ title: t('pages.system.announcement.form.status'), key: 'status', width: 120 },
|
||||||
|
{ title: t('pages.system.announcement.form.areaId'), key: 'areaId', width: 120 },
|
||||||
|
{ title: t('button.action'), key: 'action', fixed: 'right', width: 120 },
|
||||||
|
]
|
||||||
|
|
||||||
|
const { listData, loading, showLoading, hideLoading, paginationState, searchFormData, resetPagination } =
|
||||||
|
usePagination()
|
||||||
|
// const { resetForm } = useForm()
|
||||||
|
const addDialogRef = ref()
|
||||||
|
|
||||||
|
getPageList()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取公公告列表
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async function getPageList() {
|
||||||
|
try {
|
||||||
|
showLoading()
|
||||||
|
const { pageSize, current } = paginationState
|
||||||
|
const { success, data, total } = await apis.announcement
|
||||||
|
.getNoticesList({
|
||||||
|
pageSize,
|
||||||
|
current: current,
|
||||||
|
...searchFormData.value,
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
hideLoading()
|
||||||
|
if (config('http.code.success') === success) {
|
||||||
|
listData.value = data
|
||||||
|
paginationState.total = total
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除
|
||||||
|
*/
|
||||||
|
function handleRemove({ id }) {
|
||||||
|
Modal.confirm({
|
||||||
|
title: t('pages.system.role.delTip'),
|
||||||
|
content: t('button.confirm'),
|
||||||
|
okText: t('button.confirm'),
|
||||||
|
onOk: () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
;(async () => {
|
||||||
|
try {
|
||||||
|
const { success } = await apis.role.delRole(id).catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
if (config('http.code.success') === success) {
|
||||||
|
resolve()
|
||||||
|
message.success(t('component.message.success.delete'))
|
||||||
|
await getPageList()
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
reject()
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*/
|
||||||
|
function onTableChange({ current, pageSize }) {
|
||||||
|
paginationState.current = current
|
||||||
|
paginationState.pageSize = pageSize
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置
|
||||||
|
*/
|
||||||
|
function handleResetSearch() {
|
||||||
|
searchFormData.value = {}
|
||||||
|
resetPagination()
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 搜索
|
||||||
|
*/
|
||||||
|
function handleSearch() {
|
||||||
|
resetPagination()
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑完成
|
||||||
|
*/
|
||||||
|
async function onOk() {
|
||||||
|
await getPageList()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
||||||
Loading…
x
Reference in New Issue
Block a user