feat: errorcode style
parent
43d34d5d94
commit
ddb73432d0
|
@ -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="ErrorCodeModal">
|
<script lang="ts" setup name="ErrorCodeModal">
|
||||||
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 './errorCode.data'
|
import { formSchema } from './errorCode.data'
|
||||||
|
@ -12,7 +12,6 @@ import { createErrorCode, getErrorCode, updateErrorCode } from '@/api/system/err
|
||||||
|
|
||||||
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: 100,
|
||||||
|
@ -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 getErrorCode(data.record.id)
|
const res = await getErrorCode(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,18 +2,23 @@
|
||||||
<div>
|
<div>
|
||||||
<BasicTable @register="registerTable">
|
<BasicTable @register="registerTable">
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
<a-button type="primary" :preIcon="IconEnum.ADD" @click="handleCreate"> {{ t('action.create') }} </a-button>
|
<a-button type="primary" v-auth="['system:error-code:create']" :preIcon="IconEnum.ADD" @click="handleCreate">
|
||||||
<a-button type="warning" :preIcon="IconEnum.EXPORT" @click="handleExport"> {{ t('action.export') }} </a-button>
|
{{ t('action.create') }}
|
||||||
|
</a-button>
|
||||||
|
<a-button type="warning" v-auth="['system:error-code:export']" :preIcon="IconEnum.EXPORT" @click="handleExport">
|
||||||
|
{{ t('action.export') }}
|
||||||
|
</a-button>
|
||||||
</template>
|
</template>
|
||||||
<template #bodyCell="{ column, record }">
|
<template #bodyCell="{ column, record }">
|
||||||
<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:error-code:edit', 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:error-code:delete',
|
||||||
popConfirm: {
|
popConfirm: {
|
||||||
title: t('common.delMessage'),
|
title: t('common.delMessage'),
|
||||||
placement: 'left',
|
placement: 'left',
|
||||||
|
@ -61,16 +66,11 @@ const [registerTable, { getForm, reload }] = useTable({
|
||||||
})
|
})
|
||||||
|
|
||||||
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 handleExport() {
|
async function handleExport() {
|
||||||
|
|
Loading…
Reference in New Issue