优化日志和移除废弃代码

This commit is contained in:
zjl 2024-12-14 14:08:20 +08:00
parent 552914ae9b
commit 3832fdbe53
8 changed files with 111 additions and 478 deletions

View File

@ -56,7 +56,29 @@
* 定义参数变量 * 定义参数变量
*/ */
const emit = defineEmits(['success', 'update:visible']); const emit = defineEmits(['success', 'update:visible']);
const formData = ref({});
/**
* 定义表单参数
*/
const formData = ref({
title: '',
type: '',
code: '',
receiveEmail: '',
receiveType: '',
consumeTime: '',
bizType: 0,
bizId: 0,
status: 0,
bizContent: '',
param: '',
result: '',
error: '',
});
/**
* 定义模态
*/
const [modalRegister, { openModal }] = useModal({ const [modalRegister, { openModal }] = useModal({
title: '邮件日志详情', title: '邮件日志详情',
subBtuText: '确定', subBtuText: '确定',

View File

@ -51,7 +51,28 @@
* 定义参数变量 * 定义参数变量
*/ */
const emit = defineEmits(['success', 'update:visible']); const emit = defineEmits(['success', 'update:visible']);
const formData = ref({});
/**
* 定义表单参数
*/
const formData = ref({
filePath: '',
originalName: '',
fileType: '',
fileSize: '',
consumeTime: '',
bizType: 0,
bizId: 0,
bizContent: '',
status: 0,
param: '',
result: '',
error: '',
});
/**
* 定义模态
*/
const [modalRegister, { openModal }] = useModal({ const [modalRegister, { openModal }] = useModal({
title: '文件日志详情', title: '文件日志详情',
subBtuText: '确定', subBtuText: '确定',

View File

@ -55,7 +55,30 @@
* 定义参数变量 * 定义参数变量
*/ */
const emit = defineEmits(['success', 'update:visible']); const emit = defineEmits(['success', 'update:visible']);
const formData = ref({});
/**
* 定义表单参数
*/
const formData = ref({
title: '',
type: '',
typeText: '',
number: '',
receiveMobile: '',
receiveType: '',
consumeTime: '',
bizType: 0,
bizId: 0,
status: 0,
bizContent: '',
param: '',
result: '',
error: '',
});
/**
* 定义模态
*/
const [modalRegister, { openModal }] = useModal({ const [modalRegister, { openModal }] = useModal({
title: '短信日志详情', title: '短信日志详情',
subBtuText: '确定', subBtuText: '确定',

View File

@ -1,142 +0,0 @@
<template>
<basicModal
@register="modalRegister"
ref="modalRef"
class="basicModal basicFormModal"
@on-ok="okModal"
>
<template #default>
<BasicForm @register="registerForm" class="pt-6 basicForm">
<template #passwordSlot="{ model, field }">
<Password ref="passwordRef" v-model:value="model[field]" :required="false" block />
</template>
<template #rePasswordSlot="{ model, field }">
<Password ref="passwordRef" v-model:value="model[field]" :required="false" block />
</template>
</BasicForm>
</template>
</basicModal>
</template>
<script lang="ts" setup>
import { ref, reactive, computed } from 'vue';
import { BasicForm, FormSchema, useForm } from '@/components/Form/index';
import { basicModal, useModal } from '@/components/Modal';
import { Password } from '@/components/Password';
import { useMessage } from 'naive-ui';
const message = useMessage();
const props = defineProps({
title: {
type: String,
default: '添加字典',
},
isEdit: {
type: Boolean,
default: false,
},
createType: {
type: Number,
default: 1,
},
});
const typeName = computed(() => {
return props.createType === 1 ? '' : '项';
});
//
const schemas: FormSchema[] = reactive([
{
field: 'label',
component: 'NInput',
label: `字典${typeName.value}名称`,
componentProps: {
placeholder: `请输入字典${typeName.value}名称`,
},
rules: [
{
required: true,
message: `请输入字典${typeName.value}名称`,
trigger: ['blur'],
},
],
},
{
field: 'value',
component: 'NInput',
label: `字典${typeName.value}`,
componentProps: {
placeholder: `请输入字典${typeName.value}`,
},
rules: [
{
required: true,
message: `请输入字典${typeName.value}`,
trigger: ['blur'],
},
],
},
{
field: 'order',
component: 'NInputNumber',
label: '排序',
componentProps: {
placeholder: '请输入排序',
},
rules: [{ required: true, type: 'number', message: '请输入排序', trigger: ['blur'] }],
},
{
field: 'remark',
component: 'NInput',
label: '备注',
componentProps: {
placeholder: '请输入备注',
type: 'textarea',
},
},
]);
const title = ref(props.title);
//form
const [registerForm, { submit, setFieldsValue }] = useForm({
gridProps: { cols: 1 },
collapsed: false,
labelWidth: 100,
layout: 'horizontal',
submitButtonText: '确定',
showActionButtonGroup: false,
schemas,
});
//
const [modalRegister, { openModal, closeModal, setSubLoading, setProps }] = useModal({
title,
subBtuText: '确定',
width: 450,
});
//
async function okModal() {
const formRes = await submit();
if (formRes) {
// const { isEdit } = props;
message.error('抱歉,您没有操作权限');
//message.success(isEdit ? '' : '');
closeModal();
} else {
message.error('验证失败,请填写完整信息');
setSubLoading(false);
}
}
//
defineExpose({
openModal,
closeModal,
setFieldsValue,
setProps,
});
</script>

View File

@ -1,23 +0,0 @@
import { BasicColumn } from '@/components/Table';
export const columns: BasicColumn[] = [
{
type: 'selection',
},
{
title: '字典名称',
key: 'label',
},
{
title: '字典值',
key: 'value',
},
{
title: '排序',
key: 'order',
},
{
title: '创建时间',
key: 'create_date',
},
];

View File

@ -1,308 +0,0 @@
<template>
<div>
<div class="n-layout-page-header">
<n-card :bordered="false" title="字典管理">
可代替后台管理系统设置的大量枚举值和配置统一标准化管理随时修改或增加
</n-card>
</div>
<n-grid class="mt-3" cols="1 s:1 m:1 l:3 xl:3 2xl:3" responsive="screen" :x-gap="12">
<n-gi span="1" class="mb-4">
<n-card :segmented="{ content: true }" :bordered="false" size="small">
<template #header>
<n-space>
<n-button type="primary" @click="addDictionary">新建</n-button>
<n-button type="primary" @click="editDictionary" :disabled="!selectedKey"
>编辑</n-button
>
<n-button type="error" @click="removeDictionary" :disabled="!selectedKey"
>删除</n-button
>
</n-space>
</template>
<template #header-extra>
<n-input type="text" v-model:value="pattern">
<template #prefix>
<n-icon>
<SearchOutlined />
</n-icon>
</template>
</n-input>
</template>
<n-table :bordered="false" :single-line="false">
<thead>
<tr>
<th width="60">ID</th>
<th>字典名称</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>
<div class="w-full">
<div class="text-center" v-if="loading">
<n-spin size="medium" style="margin-left: auto" />
</div>
<n-tree
v-else
block-line
draggable
:data="treeData"
:pattern="pattern"
@update:selected-keys="selectedTree"
selectable
/>
</div>
</td>
</tr>
</tbody>
</n-table>
</n-card>
</n-gi>
<n-gi span="2">
<n-card :bordered="false" class="mb-4 proCard">
<BasicTable
:columns="columns"
:request="loadDataTable"
:row-key="(row) => row.id"
ref="tableRef"
:actionColumn="actionColumn"
@update:checked-row-keys="onCheckedRow"
:scroll-x="1090"
>
<template #tableTitle>
<n-space>
<n-input type="text" v-model:value="params.keywords">
<template #prefix>
<n-icon>
<SearchOutlined />
</n-icon>
</template>
</n-input>
<n-button type="primary" @click="reloadTable"> 查询 </n-button>
<n-button type="primary" :disabled="!selectedKey" @click="addDictionaryValue"
>新建</n-button
>
<n-button type="error" :disabled="!rowKeys.length" @click="removeDictionaryValues"
>删除</n-button
>
</n-space>
</template>
</BasicTable>
</n-card>
</n-gi>
</n-grid>
<basicModal
@register="lightModalRegister"
class="basicModalLight"
ref="modalRef"
@on-ok="removeOkModal"
>
<template #default>
<p class="text-gray-600" style="padding-left: 35px"
>您确认要删除<n-text strong>{{ rowKeysName }} ?</n-text></p
>
</template>
</basicModal>
<CreateModal ref="createModalRef" :createType="createType" :isEdit="isEdit" />
</div>
</template>
<script lang="ts" setup>
import { ref, reactive, h, onMounted, nextTick, unref } from 'vue';
import { SearchOutlined } from '@vicons/antd';
import { BasicColumn, BasicTable, TableAction } from '@/components/Table';
import { getDictionary, getDictionaryInfo } from '@/api/system/dictionary';
import { basicModal, useModal } from '@/components/Modal';
import CreateModal from './CreateModal.vue';
import { columns } from './columns';
import { getTreeItem } from '@/utils';
import { useMessage } from 'naive-ui';
const message = useMessage();
const createModalRef = ref();
const tableRef = ref();
const loading = ref(true);
const selectedKey = ref('');
const treeData = ref<any[]>([]);
const dictionaryValues = ref<any[]>([]);
const rowKeys = ref<any[]>([]);
const rowKeysName = ref('');
const createType = ref(1);
const isEdit = ref(false);
const pattern = ref('');
const params = ref({
pageSize: 10,
name: 'xiaoMa',
keywords: '',
});
const actionColumn: BasicColumn = reactive({
width: 150,
title: '操作',
key: 'action',
fixed: 'right',
render(record) {
return h(TableAction as any, {
style: 'text',
actions: [
{
label: '删除',
onClick: removeDictionaryValueOne.bind(null, record),
},
{
label: '编辑',
onClick: editDictionaryValue.bind(null, record),
},
],
});
},
});
//
const [
lightModalRegister,
{ openModal: lightOpenModal, closeModal: lightCloseModal, setSubLoading: lightSetSubLoading },
] = useModal({
title: '删除确认',
showIcon: true,
type: 'warning',
closable: false,
maskClosable: true,
width: 380,
});
//
function addDictionary() {
createType.value = 1;
createModalRef.value.setProps({ title: '添加字典' });
createModalRef.value.openModal();
}
//
function addDictionaryValue() {
createType.value = 2;
createModalRef.value.setProps({ title: '添加字典项' });
createModalRef.value.openModal();
}
//
function removeOkModal() {
lightCloseModal();
lightSetSubLoading();
message.error('抱歉,您没有操作权限');
}
//
function onCheckedRow(keys) {
rowKeys.value = keys;
}
//
function reloadTable() {
tableRef.value.reload();
}
//
function openRemoveModal() {
lightOpenModal();
}
//
const loadDataTable = async (res) => {
const key = selectedKey.value.length ? selectedKey.value[0] : '';
const result = await getDictionaryInfo({ ...params.value, key, ...res });
dictionaryValues.value = result.list;
return result;
};
//
function removeDictionaryValues() {
//
rowKeysName.value = dictionaryValues.value
.filter((item) => {
return rowKeys.value.includes(item.id as number);
})
.map((item) => {
return item.label;
})
.join('');
openRemoveModal();
}
//
function removeDictionaryValueOne(record: Recordable) {
console.log('点击了删除', record);
rowKeysName.value = record.label;
openRemoveModal();
}
//
function removeDictionary() {
//
if (!selectedKey.value.length) return;
const treeItem = getTreeItem(treeData.value, unref(selectedKey)[0]);
rowKeysName.value = treeItem.label;
openRemoveModal();
}
//
function selectedTree(key: string) {
selectedKey.value = key.length ? key : '';
rowKeysName.value = getLabelStr(treeData.value, key);
reloadTable();
}
//label
function getLabelStr(data: any[], key: string): string {
return data
.filter((item) => {
return key.includes(item.key);
})
.map((item) => {
return item.label;
})
.join('');
}
//
function editDictionaryValue(record: Recordable) {
console.log('点击了编辑', record);
createModalRef.value.openModal();
nextTick(() => {
isEdit.value = true;
createModalRef.value.setProps({ title: '编辑字典项' });
createModalRef.value.setFieldsValue({
...unref(record),
});
});
}
//
function editDictionary() {
if (!selectedKey.value.length) return;
const treeItem = getTreeItem(treeData.value, unref(selectedKey)[0]);
createModalRef.value.openModal();
nextTick(() => {
isEdit.value = true;
createModalRef.value.setProps({ title: '编辑字典' });
createModalRef.value.setFieldsValue({
...unref(treeItem),
});
});
}
//
async function init() {
const res = await getDictionary();
treeData.value = res;
loading.value = false;
}
onMounted(() => {
init();
});
</script>

View File

@ -57,7 +57,27 @@
* 定义参数变量 * 定义参数变量
*/ */
const emit = defineEmits(['success', 'update:visible']); const emit = defineEmits(['success', 'update:visible']);
const formData = ref({});
/**
* 定义表单参数
*/
const formData = ref({
createUser: '',
ip: '',
os: '',
browser: '',
consumeTime: '',
location: '',
requestMethod: '',
status: '',
method: '',
param: '',
result: '',
});
/**
* 定义模态
*/
const [modalRegister, { openModal, setSubLoading }] = useModal({ const [modalRegister, { openModal, setSubLoading }] = useModal({
title: '登录日志详情', title: '登录日志详情',
subBtuText: '确定', subBtuText: '确定',

View File

@ -57,7 +57,27 @@
* 定义参数变量 * 定义参数变量
*/ */
const emit = defineEmits(['success', 'update:visible']); const emit = defineEmits(['success', 'update:visible']);
const formData = ref({});
/**
* 定义表单参数
*/
const formData = ref({
title: '',
createUser: '',
ip: '',
os: '',
browser: '',
consumeTime: '',
requestMethod: '',
status: '',
method: '',
param: '',
result: '',
});
/**
* 定义模态
*/
const [modalRegister, { openModal, setSubLoading }] = useModal({ const [modalRegister, { openModal, setSubLoading }] = useModal({
title: '操作日志详情', title: '操作日志详情',
subBtuText: '确定', subBtuText: '确定',