mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-09-08 22:57:11 +08:00
refactor: 优化部分代码
This commit is contained in:
@@ -146,6 +146,9 @@ const options: Options = {
|
||||
grid: { cols: 2 },
|
||||
btns: { hide: true },
|
||||
}
|
||||
const { form, resetForm } = useForm({
|
||||
isOverride: false,
|
||||
})
|
||||
const formColumns: Columns = reactive([
|
||||
{
|
||||
label: '作者名称',
|
||||
@@ -198,8 +201,8 @@ const formColumns: Columns = reactive([
|
||||
type: 'switch',
|
||||
props: {
|
||||
type: 'round',
|
||||
checkedValue: 1,
|
||||
uncheckedValue: 2,
|
||||
checkedValue: true,
|
||||
uncheckedValue: false,
|
||||
checkedText: '是',
|
||||
uncheckedText: '否',
|
||||
},
|
||||
@@ -233,10 +236,6 @@ const columns: TableInstanceColumns[] = [
|
||||
{ title: '关联字典', slotName: 'dictCode' },
|
||||
]
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
isOverride: false,
|
||||
})
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.formRef?.resetFields()
|
||||
@@ -281,6 +280,7 @@ const onOpen = async (tableName: string, comment: string) => {
|
||||
// 查询生成配置
|
||||
const { data } = await getGenConfig(tableName)
|
||||
Object.assign(form, data)
|
||||
form.isOverride = form.isOverride || false
|
||||
visible.value = true
|
||||
// 查询字段配置
|
||||
await getDataList(tableName, false)
|
||||
|
@@ -113,7 +113,7 @@ const handleLogin = async () => {
|
||||
})
|
||||
tabsStore.reset()
|
||||
const { redirect, ...othersQuery } = router.currentRoute.value.query
|
||||
router.push({
|
||||
await router.push({
|
||||
path: (redirect as string) || '/',
|
||||
query: {
|
||||
...othersQuery,
|
||||
|
@@ -37,6 +37,10 @@ const options: Options = {
|
||||
btns: { hide: true },
|
||||
}
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
status: 1,
|
||||
})
|
||||
|
||||
const columns: Columns = reactive([
|
||||
{
|
||||
label: '名称',
|
||||
@@ -46,7 +50,7 @@ const columns: Columns = reactive([
|
||||
},
|
||||
{
|
||||
label: '失效时间',
|
||||
field: 'expirationTime',
|
||||
field: 'expireTime',
|
||||
type: 'date-picker',
|
||||
props: {
|
||||
placeholder: '请选择失效时间',
|
||||
@@ -76,10 +80,6 @@ const columns: Columns = reactive([
|
||||
},
|
||||
])
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
status: 1,
|
||||
})
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.formRef?.resetFields()
|
||||
|
@@ -4,7 +4,7 @@
|
||||
:title="title"
|
||||
:mask-closable="false"
|
||||
:esc-to-close="false"
|
||||
:width="width >= 600 ? 600 : '100%'"
|
||||
:width="width >= 700 ? 700 : '100%'"
|
||||
@before-ok="save"
|
||||
@close="reset"
|
||||
>
|
||||
@@ -182,6 +182,7 @@ import { addJob, listGroup, updateJob } from '@/apis/schedule/job'
|
||||
import { useForm } from '@/hooks'
|
||||
import { useDict } from '@/hooks/app'
|
||||
import CronGeneratorModal from '@/components/GenCron/CronModel/index.vue'
|
||||
import type { LabelValueState } from '@/types/global'
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'save-success'): void
|
||||
@@ -196,7 +197,7 @@ const visible = ref(false)
|
||||
const isUpdate = computed(() => !!dataId.value)
|
||||
const title = computed(() => (isUpdate.value ? '修改任务' : '新增任务'))
|
||||
const formRef = ref<FormInstance>()
|
||||
const groupList = ref()
|
||||
const groupList = ref<LabelValueState[]>([])
|
||||
const genModal = ref()
|
||||
const { job_trigger_type_enum, job_task_type_enum, job_route_strategy_enum, job_block_strategy_enum } = useDict(
|
||||
'job_trigger_type_enum',
|
||||
|
@@ -17,17 +17,27 @@
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { updateUserBaseInfo } from '@/apis/system'
|
||||
import { type Columns, GiForm } from '@/components/GiForm'
|
||||
import { type Columns, GiForm, type Options } from '@/components/GiForm'
|
||||
import { useForm } from '@/hooks'
|
||||
import { useUserStore } from '@/stores'
|
||||
|
||||
const { width } = useWindowSize()
|
||||
const userStore = useUserStore()
|
||||
|
||||
const userInfo = computed(() => userStore.userInfo)
|
||||
const visible = ref(false)
|
||||
const formRef = ref<InstanceType<typeof GiForm>>()
|
||||
|
||||
const options: Options = {
|
||||
form: { size: 'large' },
|
||||
btns: { hide: true },
|
||||
}
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
nickname: userInfo.value.nickname,
|
||||
gender: userInfo.value.gender,
|
||||
})
|
||||
|
||||
const columns: Columns = reactive([
|
||||
{
|
||||
label: '昵称',
|
||||
@@ -48,27 +58,12 @@ const columns: Columns = reactive([
|
||||
},
|
||||
])
|
||||
|
||||
const userStore = useUserStore()
|
||||
const userInfo = computed(() => userStore.userInfo)
|
||||
const { form, resetForm } = useForm({
|
||||
nickname: userInfo.value.nickname,
|
||||
gender: userInfo.value.gender,
|
||||
})
|
||||
|
||||
const formRef = ref<InstanceType<typeof GiForm>>()
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.formRef?.resetFields()
|
||||
resetForm()
|
||||
}
|
||||
|
||||
const visible = ref(false)
|
||||
// 修改
|
||||
const onUpdate = async () => {
|
||||
reset()
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
// 保存
|
||||
const save = async () => {
|
||||
const isInvalid = await formRef.value?.formRef?.validate()
|
||||
@@ -84,5 +79,11 @@ const save = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 修改
|
||||
const onUpdate = async () => {
|
||||
reset()
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
defineExpose({ onUpdate })
|
||||
</script>
|
||||
|
@@ -55,6 +55,11 @@ const options: Options = {
|
||||
btns: { hide: true },
|
||||
}
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
sort: 999,
|
||||
status: 1,
|
||||
})
|
||||
|
||||
const columns: Columns = reactive([
|
||||
{
|
||||
label: '上级部门',
|
||||
@@ -118,11 +123,6 @@ const columns: Columns = reactive([
|
||||
},
|
||||
])
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
sort: 999,
|
||||
status: 1,
|
||||
})
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.formRef?.resetFields()
|
||||
|
@@ -23,6 +23,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import { addDictItem, getDictItem, updateDictItem } from '@/apis/system/dict'
|
||||
import { type Columns, GiForm, type Options } from '@/components/GiForm'
|
||||
import { useForm } from '@/hooks'
|
||||
@@ -31,6 +32,8 @@ const emit = defineEmits<{
|
||||
(e: 'save-success'): void
|
||||
}>()
|
||||
|
||||
const { width } = useWindowSize()
|
||||
|
||||
const dataId = ref('')
|
||||
const dictId = ref('')
|
||||
const visible = ref(false)
|
||||
@@ -43,6 +46,12 @@ const options: Options = {
|
||||
btns: { hide: true },
|
||||
}
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
color: 'blue',
|
||||
sort: 999,
|
||||
status: 1,
|
||||
})
|
||||
|
||||
const columns: Columns = reactive([
|
||||
{ label: '标签', field: 'label', type: 'input', rules: [{ required: true, message: '请输入标签' }] },
|
||||
{ label: '值', field: 'value', type: 'input', rules: [{ required: true, message: '请输入值' }] },
|
||||
@@ -79,12 +88,6 @@ const columns: Columns = reactive([
|
||||
},
|
||||
])
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
color: 'blue',
|
||||
sort: 999,
|
||||
status: 1,
|
||||
})
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.formRef?.resetFields()
|
||||
|
@@ -37,6 +37,8 @@ const options: Options = {
|
||||
btns: { hide: true },
|
||||
}
|
||||
|
||||
const { form, resetForm } = useForm({})
|
||||
|
||||
const columns: Columns = reactive([
|
||||
{ label: '名称', field: 'name', type: 'input', rules: [{ required: true, message: '请输入名称' }] },
|
||||
{ label: '编码', field: 'code', type: 'input', disabled: () => isUpdate.value, rules: [{ required: true, message: '请输入编码' }] },
|
||||
@@ -51,8 +53,6 @@ const columns: Columns = reactive([
|
||||
},
|
||||
])
|
||||
|
||||
const { form, resetForm } = useForm({})
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.formRef?.resetFields()
|
||||
|
@@ -11,7 +11,7 @@
|
||||
</a-space>
|
||||
<div v-if="chartData.length > 0">
|
||||
<a-divider />
|
||||
<VCharts :option="option" autoresize :style="{ height: '120px', width: '150px' }" />
|
||||
<VCharts :option="chartOption" autoresize :style="{ height: '120px', width: '150px' }" />
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -38,7 +38,7 @@ const totalData = ref<FileStatisticsResp>({
|
||||
})
|
||||
const chartData = ref<Array<{ name: string, value: number, size: string }>>([])
|
||||
const statisticValueStyle = { 'color': '#5856D6', 'font-size': '18px' }
|
||||
const { option } = useChart(() => {
|
||||
const { chartOption } = useChart(() => {
|
||||
return {
|
||||
grid: {
|
||||
left: 0,
|
||||
|
@@ -2,15 +2,15 @@
|
||||
<div ref="containerRef" class="detail">
|
||||
<div class="detail_header">
|
||||
<a-affix :target="(containerRef as HTMLElement)">
|
||||
<a-page-header title="通知公告" :subtitle="type === 'edit' ? '修改' : '新增'" @back="onBack">
|
||||
<a-page-header title="通知公告" :subtitle="title" @back="onBack">
|
||||
<template #extra>
|
||||
<a-button type="primary" @click="onReleased">
|
||||
<a-button type="primary" @click="save">
|
||||
<template #icon>
|
||||
<icon-save v-if="type === 'edit'" />
|
||||
<icon-save v-if="isUpdate" />
|
||||
<icon-send v-else />
|
||||
</template>
|
||||
<template #default>
|
||||
{{ type === 'edit' ? '保存' : '发布' }}
|
||||
{{ isUpdate ? '保存' : '发布' }}
|
||||
</template>
|
||||
</a-button>
|
||||
</template>
|
||||
@@ -59,21 +59,32 @@
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import AiEditor from './components/index.vue'
|
||||
import { useTabsStore } from '@/stores'
|
||||
import { addNotice, getNotice, updateNotice } from '@/apis/system/notice'
|
||||
import { listUserDict } from '@/apis'
|
||||
import { type Columns, GiForm, type Options } from '@/components/GiForm'
|
||||
import { addNotice, getNotice, updateNotice } from '@/apis/system'
|
||||
import type { LabelValueState } from '@/types/global'
|
||||
import { useTabsStore } from '@/stores'
|
||||
import { useForm } from '@/hooks'
|
||||
import { useDict } from '@/hooks/app'
|
||||
import { listUserDict } from '@/apis'
|
||||
import type { LabelValueState } from '@/types/global'
|
||||
|
||||
const { width } = useWindowSize()
|
||||
const { notice_type } = useDict('notice_type')
|
||||
const containerRef = ref<HTMLElement | null>()
|
||||
const tabsStore = useTabsStore()
|
||||
const route = useRoute()
|
||||
const formRef = ref<InstanceType<typeof GiForm>>()
|
||||
const router = useRouter()
|
||||
const tabsStore = useTabsStore()
|
||||
|
||||
const { id, type } = route.query
|
||||
const isUpdate = computed(() => type === 'update')
|
||||
const title = computed(() => (isUpdate.value ? '修改' : '新增'))
|
||||
const containerRef = ref<HTMLElement | null>()
|
||||
const formRef = ref<InstanceType<typeof GiForm>>()
|
||||
const { notice_type } = useDict('notice_type')
|
||||
|
||||
const options: Options = {
|
||||
form: { size: 'large' },
|
||||
grid: { cols: 2 },
|
||||
btns: { hide: true },
|
||||
}
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
title: '',
|
||||
type: '',
|
||||
@@ -82,11 +93,6 @@ const { form, resetForm } = useForm({
|
||||
content: '',
|
||||
noticeScope: 1,
|
||||
})
|
||||
const options: Options = {
|
||||
form: { size: 'large' },
|
||||
grid: { cols: 2 },
|
||||
btns: { hide: true },
|
||||
}
|
||||
|
||||
const columns: Columns = reactive([
|
||||
{
|
||||
@@ -149,17 +155,18 @@ const onUpdate = async (id: string) => {
|
||||
|
||||
// 返回
|
||||
const onBack = () => {
|
||||
router.back()
|
||||
tabsStore.closeCurrent(route.path)
|
||||
}
|
||||
|
||||
// 发布
|
||||
const onReleased = async () => {
|
||||
// 保存
|
||||
const save = async () => {
|
||||
const isInvalid = await formRef.value?.formRef?.validate()
|
||||
if (isInvalid) return false
|
||||
try {
|
||||
// 通知范围 所有人 去除指定用户
|
||||
form.noticeUsers = form.noticeScope === 1 ? null : form.noticeUsers
|
||||
if (type === 'edit') {
|
||||
if (isUpdate.value) {
|
||||
await updateNotice(form, id as string)
|
||||
Message.success('修改成功')
|
||||
} else {
|
||||
@@ -194,9 +201,9 @@ const onSelectUser = (value: string[]) => {
|
||||
|
||||
const userList = ref<LabelValueState[]>([])
|
||||
onMounted(async () => {
|
||||
// 当id存在与type为edit时,执行修改操作
|
||||
if (id && type === 'edit') {
|
||||
onUpdate(id as string)
|
||||
// 当id存在与type为update时,执行修改操作
|
||||
if (id && isUpdate.value) {
|
||||
await onUpdate(id as string)
|
||||
}
|
||||
// 获取所有用户
|
||||
const { data } = await listUserDict()
|
||||
|
@@ -39,15 +39,16 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import AiEditor from './components/index.vue'
|
||||
import { useTabsStore } from '@/stores'
|
||||
import { getNotice } from '@/apis/system/notice'
|
||||
import { useTabsStore } from '@/stores'
|
||||
import { useForm } from '@/hooks'
|
||||
|
||||
const containerRef = ref<HTMLElement | null>()
|
||||
const tabsStore = useTabsStore()
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const tabsStore = useTabsStore()
|
||||
|
||||
const { id } = route.query
|
||||
const containerRef = ref<HTMLElement | null>()
|
||||
const { form, resetForm } = useForm({
|
||||
title: '',
|
||||
createUserString: '',
|
||||
@@ -56,19 +57,21 @@ const { form, resetForm } = useForm({
|
||||
content: '',
|
||||
})
|
||||
|
||||
// 修改
|
||||
const onDetail = async (id: string) => {
|
||||
resetForm()
|
||||
const res = await getNotice(id)
|
||||
Object.assign(form, res.data)
|
||||
}
|
||||
// 回退
|
||||
const onBack = () => {
|
||||
router.back()
|
||||
tabsStore.closeCurrent(route.path)
|
||||
}
|
||||
|
||||
// 打开
|
||||
const onOpen = async (id: string) => {
|
||||
resetForm()
|
||||
const { data } = await getNotice(id)
|
||||
Object.assign(form, data)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
onDetail(id as string)
|
||||
onOpen(id as string)
|
||||
})
|
||||
</script>
|
||||
|
||||
|
@@ -123,7 +123,7 @@ const onAdd = () => {
|
||||
|
||||
// 修改
|
||||
const onUpdate = (record: NoticeResp) => {
|
||||
router.push({ path: '/system/notice/add', query: { id: record.id, type: 'edit' } })
|
||||
router.push({ path: '/system/notice/add', query: { id: record.id, type: 'update' } })
|
||||
}
|
||||
|
||||
// 详情
|
||||
|
@@ -42,6 +42,11 @@ const options: Options = {
|
||||
btns: { hide: true },
|
||||
}
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
gender: 1 as Gender,
|
||||
status: 1 as Status,
|
||||
})
|
||||
|
||||
const columns: Columns = reactive([
|
||||
{
|
||||
label: '用户名',
|
||||
@@ -160,11 +165,6 @@ const columns: Columns = reactive([
|
||||
},
|
||||
])
|
||||
|
||||
const { form, resetForm } = useForm({
|
||||
gender: 1 as Gender,
|
||||
status: 1 as Status,
|
||||
})
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.formRef?.resetFields()
|
||||
|
@@ -34,12 +34,12 @@ const options: Options = {
|
||||
btns: { hide: true },
|
||||
}
|
||||
|
||||
const { form, resetForm } = useForm({})
|
||||
|
||||
const columns: Columns = reactive([
|
||||
{ label: '密码', field: 'newPassword', type: 'input-password', rules: [{ required: true, message: '请输入密码' }] },
|
||||
])
|
||||
|
||||
const { form, resetForm } = useForm({})
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.formRef?.resetFields()
|
||||
|
@@ -36,6 +36,8 @@ const options: Options = {
|
||||
btns: { hide: true },
|
||||
}
|
||||
|
||||
const { form, resetForm } = useForm({})
|
||||
|
||||
const columns: Columns = reactive([
|
||||
{
|
||||
label: '角色',
|
||||
@@ -52,8 +54,6 @@ const columns: Columns = reactive([
|
||||
},
|
||||
])
|
||||
|
||||
const { form, resetForm } = useForm({})
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
formRef.value?.formRef?.resetFields()
|
||||
|
@@ -101,13 +101,13 @@ import UserImportDrawer from './UserImportDrawer.vue'
|
||||
import UserDetailDrawer from './UserDetailDrawer.vue'
|
||||
import UserResetPwdModal from './UserResetPwdModal.vue'
|
||||
import UserUpdateRoleModal from './UserUpdateRoleModal.vue'
|
||||
import { type UserQuery, type UserResp, deleteUser, exportUser, listUser } from '@/apis/system/user'
|
||||
import { type UserResp, deleteUser, exportUser, listUser } from '@/apis/system/user'
|
||||
import type { Columns, Options } from '@/components/GiForm'
|
||||
import type { TableInstanceColumns } from '@/components/GiTable/type'
|
||||
import { useDownload, useTable } from '@/hooks'
|
||||
import { DisEnableStatusList } from '@/constant/common'
|
||||
import { useDownload, useForm, useTable } from '@/hooks'
|
||||
import { isMobile } from '@/utils'
|
||||
import has from '@/utils/has'
|
||||
import { DisEnableStatusList } from '@/constant/common'
|
||||
|
||||
defineOptions({ name: 'SystemUser' })
|
||||
|
||||
@@ -116,6 +116,9 @@ const options: Options = reactive({
|
||||
grid: { cols: { xs: 1, sm: 1, md: 2, lg: 3, xl: 3, xxl: 3 } },
|
||||
fold: { enable: true, index: 1, defaultCollapsed: true },
|
||||
})
|
||||
const { form: queryForm, resetForm } = useForm({
|
||||
sort: ['t1.id,desc'],
|
||||
})
|
||||
const queryFormColumns: Columns = reactive([
|
||||
{
|
||||
type: 'input',
|
||||
@@ -147,9 +150,6 @@ const queryFormColumns: Columns = reactive([
|
||||
},
|
||||
},
|
||||
])
|
||||
const queryForm = reactive<UserQuery>({
|
||||
sort: ['t1.id,desc'],
|
||||
})
|
||||
|
||||
const {
|
||||
tableData: dataList,
|
||||
@@ -207,9 +207,7 @@ const columns: TableInstanceColumns[] = [
|
||||
|
||||
// 重置
|
||||
const reset = () => {
|
||||
queryForm.description = undefined
|
||||
queryForm.status = undefined
|
||||
queryForm.createTime = []
|
||||
resetForm()
|
||||
search()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user