generated from Leo_Ding/web-template
科研成果-菜单
This commit is contained in:
parent
8e32d15d1e
commit
8727e0b1f9
@ -34,5 +34,6 @@ export default {
|
||||
'account.logout': '退出登录',
|
||||
imgMgt:'图片管理',
|
||||
homeBanner:'首页轮播图',
|
||||
about:'关于海邻'
|
||||
about:'关于海邻',
|
||||
researchHonor:'科研成果'
|
||||
}
|
||||
|
||||
@ -36,11 +36,11 @@ export default [
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'menu',
|
||||
name: 'menu',
|
||||
component: 'system/menu/index.vue',
|
||||
path: 'researchHonor',
|
||||
name: 'researchHonor',
|
||||
component: 'imgMgt/researchHonor/index.vue',
|
||||
meta: {
|
||||
title: '菜单管理',
|
||||
title: '科研成果',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
|
||||
169
src/views/imgMgt/researchHonor/components/Department.vue
Normal file
169
src/views/imgMgt/researchHonor/components/Department.vue
Normal file
@ -0,0 +1,169 @@
|
||||
<template>
|
||||
<a-card
|
||||
:body-style="{ height: 'calc(100% - 56px - 47px)', padding: 0 }"
|
||||
:style="{
|
||||
position: 'sticky',
|
||||
top: appStore.mainOffsetTop,
|
||||
height: appStore.mainHeight,
|
||||
}">
|
||||
<template #title>
|
||||
<a-input-search placeholder="搜索部门"></a-input-search>
|
||||
</template>
|
||||
<x-scrollbar class="pa-8-2">
|
||||
<a-spin :spinning="loading">
|
||||
<a-tree
|
||||
block-node
|
||||
:selected-keys="selectedKeys"
|
||||
:tree-data="listData"
|
||||
:field-names="{ key: 'id', children: 'children' }"
|
||||
@select="onSelect">
|
||||
<template #title="{ title }">
|
||||
<span class="ant-tree-title__name">{{ title }}</span>
|
||||
<span class="ant-tree-title__actions">
|
||||
<a-dropdown
|
||||
:trigger="['click']"
|
||||
@click.stop>
|
||||
<x-action-button>
|
||||
<more-outlined></more-outlined>
|
||||
</x-action-button>
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
|
||||
添加子部门
|
||||
</a-menu-item>
|
||||
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
|
||||
编辑
|
||||
</a-menu-item>
|
||||
<a-menu-item @click="handleDelete">删除</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</span>
|
||||
</template>
|
||||
</a-tree>
|
||||
<empty
|
||||
v-if="!listData.length"
|
||||
:image="Empty.PRESENTED_IMAGE_SIMPLE"></empty>
|
||||
</a-spin>
|
||||
</x-scrollbar>
|
||||
<template #actions>
|
||||
<span @click="$refs.editDepartmentDialogRef.handleCreate()">
|
||||
<plus-outlined></plus-outlined>
|
||||
新建部门
|
||||
</span>
|
||||
</template>
|
||||
</a-card>
|
||||
|
||||
<edit-department-dialog
|
||||
ref="editDepartmentDialogRef"
|
||||
@ok="onOk"></edit-department-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useAppStore } from '@/store'
|
||||
import { ref, watch } from 'vue'
|
||||
import { usePagination } from '@/hooks'
|
||||
import apis from '@/apis'
|
||||
import { Empty, Modal, message } from 'ant-design-vue'
|
||||
import { config } from '@/config'
|
||||
import { head, get, find } from 'lodash-es'
|
||||
import { MoreOutlined, PlusOutlined } from '@ant-design/icons-vue'
|
||||
import EditDepartmentDialog from './EditDepartmentDialog.vue'
|
||||
|
||||
const props = defineProps({
|
||||
value: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['change', 'update:value'])
|
||||
|
||||
const appStore = useAppStore()
|
||||
const { listData, loading, showLoading, hideLoading } = usePagination()
|
||||
|
||||
const editDepartmentDialogRef = ref()
|
||||
const selectedKeys = ref([props.value])
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
(val) => {
|
||||
if (val === selectedKeys.value?.[0]) return
|
||||
selectedKeys.value = [val]
|
||||
}
|
||||
)
|
||||
|
||||
getList()
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function getList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { code, data } = await apis.common.getPageList().catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === code) {
|
||||
const { records } = data
|
||||
listData.value = records
|
||||
if (listData.value.length) {
|
||||
selectedKeys.value = [get(head(listData.value), 'id')]
|
||||
trigger()
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function handleDelete({ id }) {
|
||||
Modal.confirm({
|
||||
title: '删除提示',
|
||||
content: '确认删除?',
|
||||
okText: '确认',
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
;(async () => {
|
||||
try {
|
||||
const { code } = await apis.common.del(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === code) {
|
||||
resolve()
|
||||
message.success('删除成功')
|
||||
await getList()
|
||||
}
|
||||
} catch (error) {
|
||||
reject()
|
||||
}
|
||||
})()
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function onSelect(keys) {
|
||||
if (!keys.length) return
|
||||
selectedKeys.value = keys
|
||||
trigger()
|
||||
}
|
||||
|
||||
async function onOk() {
|
||||
await getList()
|
||||
}
|
||||
|
||||
function trigger() {
|
||||
const value = head(selectedKeys.value)
|
||||
const record = find(listData.value, { id: value })
|
||||
emit('update:value', value)
|
||||
emit('change', record)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:open="modal.open"
|
||||
:title="modal.title"
|
||||
:width="480"
|
||||
:confirm-loading="modal.confirmLoading"
|
||||
:after-close="onAfterClose"
|
||||
:cancel-text="cancelText"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
:label-col="{ style: { width: '90px' } }">
|
||||
<a-form-item
|
||||
label="部门名称"
|
||||
name="name">
|
||||
<a-input v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="上级部门"
|
||||
name="parent_id">
|
||||
<a-tree-select v-model:value="formData.parent_id"></a-tree-select>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="部门负责人"
|
||||
name="name">
|
||||
<a-input v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
</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'
|
||||
|
||||
const emit = defineEmits(['ok'])
|
||||
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||
const cancelText = ref('取消')
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: '新建部门',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
function handleEdit(record = {}) {
|
||||
showModal({
|
||||
type: 'edit',
|
||||
title: '编辑部门',
|
||||
})
|
||||
formRecord.value = record
|
||||
formData.value = cloneDeep(record)
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
function handleOk() {
|
||||
formRef.value
|
||||
.validateFields()
|
||||
.then(async (values) => {
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
...values,
|
||||
}
|
||||
let result = null
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.common.create(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.common.update(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.code) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
cancelText.value = '取消'
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
handleEdit,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
293
src/views/imgMgt/researchHonor/components/EditDialog.vue
Normal file
293
src/views/imgMgt/researchHonor/components/EditDialog.vue
Normal file
@ -0,0 +1,293 @@
|
||||
<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="12">
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.user.form.username')"
|
||||
name="username">
|
||||
<a-input
|
||||
:placeholder="$t('pages.system.user.form.username.placeholder')"
|
||||
v-model:value="formData.username"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.user.form.password')"
|
||||
name="password">
|
||||
<a-input-password
|
||||
v-model:value="formData.password"
|
||||
:placeholder="$t('pages.system.user.form.password.placeholder')" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="12">
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.user.form.name')"
|
||||
name="name">
|
||||
<a-input
|
||||
:placeholder="$t('pages.system.user.form.name.placeholder')"
|
||||
v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.user.form.roles')"
|
||||
name="roles">
|
||||
<a-select
|
||||
v-model:value="formData.roles"
|
||||
mode="multiple"
|
||||
style="width: 100%"
|
||||
:placeholder="$t('pages.system.user.form.roles.placeholder')"
|
||||
:options="roles"
|
||||
@change="handleChange"></a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-row :gutter="12">
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.user.form.phone')"
|
||||
type="tel"
|
||||
name="phone">
|
||||
<a-input
|
||||
:placeholder="$t('pages.system.user.form.phone.placeholder')"
|
||||
type="tel"
|
||||
v-model:value="formData.phone"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.user.form.email')"
|
||||
type="email"
|
||||
name="email">
|
||||
<a-input
|
||||
:placeholder="$t('pages.system.user.form.email.placeholder')"
|
||||
type="email"
|
||||
v-model:value="formData.email"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<a-row :gutter="12">
|
||||
<a-col :span="24">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.user.form.remark')"
|
||||
name="remark">
|
||||
<a-textarea
|
||||
:placeholder="$t('pages.system.user.form.remark.placeholder')"
|
||||
v-model:value="formData.remark"></a-textarea>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="12">
|
||||
<a-col :span="24">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.user.form.status')"
|
||||
name="status">
|
||||
<a-radio-group
|
||||
v-model:value="formData.status"
|
||||
:options="[
|
||||
{ label: $t('pages.system.user.form.status.activated'), value: 'activated' },
|
||||
{ label: $t('pages.system.user.form.status.freezed'), value: 'freezed' },
|
||||
]"></a-radio-group>
|
||||
</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 = {
|
||||
name: { required: true, message: t('pages.system.user.form.username.placeholder') },
|
||||
username: { required: true, message: t('pages.system.user.form.code.placeholder') },
|
||||
status: { required: true, message: t('pages.system.user.form.status') },
|
||||
roles: [{ required: true, message: t('pages.system.user.form.roles.placeholder'), trigger: 'change' }],
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求角色
|
||||
*/
|
||||
getRole()
|
||||
|
||||
/**
|
||||
* select 选择框
|
||||
*/
|
||||
const handleChange = (value) => {
|
||||
rolesValue.value = value
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: t('pages.system.user.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: t('pages.system.user.edit'),
|
||||
})
|
||||
const { data, success } = await apis.users.getUsers(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.users.createUsers(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.users.updateUsers(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 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>
|
||||
234
src/views/imgMgt/researchHonor/index.vue
Normal file
234
src/views/imgMgt/researchHonor/index.vue
Normal file
@ -0,0 +1,234 @@
|
||||
<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="$t('pages.system.user.form.username')"
|
||||
name="username">
|
||||
<a-input
|
||||
:placeholder="$t('pages.system.user.form.username.placeholder')"
|
||||
v-model:value="searchFormData.username"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col v-bind="colSpan">
|
||||
<a-form-item name="name">
|
||||
<template #label>
|
||||
{{ $t('pages.system.user.form.name') }}
|
||||
<a-tooltip :title="$t('pages.system.user.form.name')">
|
||||
<question-circle-outlined class="ml-4-1 color-placeholder" />
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<a-input
|
||||
:placeholder="$t('pages.system.user.form.name.placeholder')"
|
||||
v-model:value="searchFormData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col
|
||||
class="align-right"
|
||||
v-bind="colSpan">
|
||||
<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
|
||||
type="primary"
|
||||
@click="$refs.editDialogRef.handleCreate()">
|
||||
<template #icon>
|
||||
<plus-outlined></plus-outlined>
|
||||
</template>
|
||||
{{ $t('pages.system.user.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="statusUserTypeEnum.is('activated', record.status)"
|
||||
color="processing">
|
||||
{{ statusUserTypeEnum.getDesc(record.status) }}
|
||||
</a-tag>
|
||||
<!--状态-->
|
||||
<a-tag
|
||||
v-if="statusUserTypeEnum.is('freezed', record.status)"
|
||||
color="processing">
|
||||
{{ statusUserTypeEnum.getDesc(record.status) }}
|
||||
</a-tag>
|
||||
</template>
|
||||
|
||||
<template v-if="'createAt' === column.key">
|
||||
{{ formatUtcDateTime(record.created_at) }}
|
||||
</template>
|
||||
<template v-if="'action' === column.key">
|
||||
<x-action-button @click="$refs.editDialogRef.handleEdit(record)">
|
||||
<a-tooltip>
|
||||
<template #title> {{ $t('pages.system.user.edit') }}</template>
|
||||
<edit-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>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<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 { formatUtcDateTime } from '@/utils/util'
|
||||
import { config } from '@/config'
|
||||
import { statusUserTypeEnum } from '@/enums/system'
|
||||
import { usePagination } from '@/hooks'
|
||||
|
||||
import EditDialog from './components/EditDialog.vue'
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
defineOptions({
|
||||
name: 'researchHonor',
|
||||
})
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const columns = [
|
||||
{ title: t('pages.system.user.form.username'), dataIndex: 'username', width: 120 },
|
||||
{ title: t('pages.system.user.form.name'), dataIndex: 'name', key: 'name', width: 100 },
|
||||
{ title: t('pages.system.user.form.phone'), dataIndex: 'phone', width: 120 },
|
||||
{ title: t('pages.system.user.form.email'), dataIndex: 'email', width: 100 },
|
||||
{ title: t('pages.system.user.form.status'), dataIndex: 'status', key: 'statusType', width: 60 },
|
||||
{ title: t('pages.system.user.form.created_at'), key: 'createAt', fixed: 'right', width: 120 },
|
||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100 },
|
||||
]
|
||||
|
||||
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.users
|
||||
.getUsersList({
|
||||
pageSize,
|
||||
page: current,
|
||||
...searchFormData.value,
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
listData.value = data
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
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.users.delUsers(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 handleSearch() {
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function handleResetSearch() {
|
||||
searchFormData.value = {}
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 编辑完成
|
||||
*/
|
||||
async function onOk() {
|
||||
message.success(t('component.message.success.delete'))
|
||||
await getPageList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
Loading…
x
Reference in New Issue
Block a user