feat: dept style
parent
af3f998374
commit
bf7d05b71c
|
@ -1,10 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
|
<BasicModal v-bind="$attrs" @register="registerModal" :title="isUpdate ? '编辑' : '新增'" @ok="handleSubmit">
|
||||||
<BasicForm @register="registerForm" />
|
<BasicForm @register="registerForm" />
|
||||||
</BasicModal>
|
</BasicModal>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup name="DeptModal">
|
<script lang="ts" setup name="DeptModal">
|
||||||
import { ref, computed, unref } from 'vue'
|
import { ref, unref } from 'vue'
|
||||||
import { BasicModal, useModalInner } from '@/components/Modal'
|
import { BasicModal, useModalInner } from '@/components/Modal'
|
||||||
import { BasicForm, useForm } from '@/components/Form'
|
import { BasicForm, useForm } from '@/components/Form'
|
||||||
import { formSchema } from './dept.data'
|
import { formSchema } from './dept.data'
|
||||||
|
@ -12,10 +12,9 @@ import { createDept, getDept, updateDept } from '@/api/system/dept'
|
||||||
|
|
||||||
const emit = defineEmits(['success', 'register'])
|
const emit = defineEmits(['success', 'register'])
|
||||||
const isUpdate = ref(true)
|
const isUpdate = ref(true)
|
||||||
const rowId = ref()
|
|
||||||
|
|
||||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
||||||
labelWidth: 100,
|
labelWidth: 120,
|
||||||
baseColProps: { span: 24 },
|
baseColProps: { span: 24 },
|
||||||
schemas: formSchema,
|
schemas: formSchema,
|
||||||
showActionButtonGroup: false,
|
showActionButtonGroup: false,
|
||||||
|
@ -26,16 +25,12 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
|
||||||
resetFields()
|
resetFields()
|
||||||
setModalProps({ confirmLoading: false })
|
setModalProps({ confirmLoading: false })
|
||||||
isUpdate.value = !!data?.isUpdate
|
isUpdate.value = !!data?.isUpdate
|
||||||
|
|
||||||
if (unref(isUpdate)) {
|
if (unref(isUpdate)) {
|
||||||
const res = await getDept(data.record.id)
|
const res = await getDept(data.record.id)
|
||||||
rowId.value = res.id
|
|
||||||
setFieldsValue({ ...res })
|
setFieldsValue({ ...res })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const getTitle = computed(() => (!unref(isUpdate) ? '新增部门' : '编辑部门'))
|
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
try {
|
try {
|
||||||
const values = await validate()
|
const values = await validate()
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
<div>
|
<div>
|
||||||
<BasicTable @register="register" @fetch-success="onFetchSuccess">
|
<BasicTable @register="register" @fetch-success="onFetchSuccess">
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
<a-button type="primary" :preIcon="IconEnum.ADD" @click="handleCreate"> {{ t('action.create') }} </a-button>
|
<a-button type="primary" :preIcon="IconEnum.ADD" v-auth="['system:dept:create']" @click="handleCreate">
|
||||||
|
{{ t('action.create') }}
|
||||||
|
</a-button>
|
||||||
<a-button type="info" @click="expandAll">{{ t('component.tree.expandAll') }}</a-button>
|
<a-button type="info" @click="expandAll">{{ t('component.tree.expandAll') }}</a-button>
|
||||||
<a-button type="info" @click="collapseAll">{{ t('component.tree.unExpandAll') }}</a-button>
|
<a-button type="info" @click="collapseAll">{{ t('component.tree.unExpandAll') }}</a-button>
|
||||||
</template>
|
</template>
|
||||||
|
@ -13,11 +15,12 @@
|
||||||
<template v-if="column.key === 'action'">
|
<template v-if="column.key === 'action'">
|
||||||
<TableAction
|
<TableAction
|
||||||
:actions="[
|
:actions="[
|
||||||
{ icon: IconEnum.EDIT, label: t('action.edit'), onClick: handleEdit.bind(null, record) },
|
{ icon: IconEnum.EDIT, label: t('action.edit'), auth: 'system:dept:update', onClick: handleEdit.bind(null, record) },
|
||||||
{
|
{
|
||||||
icon: IconEnum.DELETE,
|
icon: IconEnum.DELETE,
|
||||||
color: 'error',
|
color: 'error',
|
||||||
label: t('action.delete'),
|
label: t('action.delete'),
|
||||||
|
auth: 'system:dept:delete',
|
||||||
popConfirm: {
|
popConfirm: {
|
||||||
title: t('common.delMessage'),
|
title: t('common.delMessage'),
|
||||||
placement: 'left',
|
placement: 'left',
|
||||||
|
@ -60,12 +63,9 @@ const [register, { expandAll, collapseAll, getForm, reload }] = useTable({
|
||||||
},
|
},
|
||||||
isTreeTable: true,
|
isTreeTable: true,
|
||||||
pagination: false,
|
pagination: false,
|
||||||
striped: false,
|
|
||||||
useSearchForm: true,
|
useSearchForm: true,
|
||||||
showTableSetting: true,
|
showTableSetting: true,
|
||||||
bordered: true,
|
|
||||||
showIndexColumn: false,
|
showIndexColumn: false,
|
||||||
canResize: false,
|
|
||||||
actionColumn: {
|
actionColumn: {
|
||||||
width: 140,
|
width: 140,
|
||||||
title: t('common.action'),
|
title: t('common.action'),
|
||||||
|
@ -86,29 +86,12 @@ async function getUserList() {
|
||||||
users.value = res
|
users.value = res
|
||||||
}
|
}
|
||||||
|
|
||||||
function userNicknameFormat(row) {
|
|
||||||
if (!row.leaderUserId) {
|
|
||||||
return '未设置'
|
|
||||||
}
|
|
||||||
for (const user of users.value) {
|
|
||||||
if (row.leaderUserId === user.id) {
|
|
||||||
return user.nickname
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return '未知【' + row.leaderUserId + '】'
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleCreate() {
|
function handleCreate() {
|
||||||
openModal(true, {
|
openModal(true, { isUpdate: false })
|
||||||
isUpdate: false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleEdit(record: Recordable) {
|
function handleEdit(record: Recordable) {
|
||||||
openModal(true, {
|
openModal(true, { record, isUpdate: true })
|
||||||
record,
|
|
||||||
isUpdate: true
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDelete(record: Recordable) {
|
async function handleDelete(record: Recordable) {
|
||||||
|
@ -121,6 +104,18 @@ function onFetchSuccess() {
|
||||||
nextTick(expandAll)
|
nextTick(expandAll)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function userNicknameFormat(row) {
|
||||||
|
if (!row.leaderUserId) {
|
||||||
|
return '未设置'
|
||||||
|
}
|
||||||
|
for (const user of users.value) {
|
||||||
|
if (row.leaderUserId === user.id) {
|
||||||
|
return user.nickname
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '未知【' + row.leaderUserId + '】'
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getUserList()
|
await getUserList()
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue