优化日志和移除废弃代码
This commit is contained in:
parent
552914ae9b
commit
3832fdbe53
@ -56,7 +56,29 @@
|
||||
* 定义参数变量
|
||||
*/
|
||||
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({
|
||||
title: '邮件日志详情',
|
||||
subBtuText: '确定',
|
||||
|
@ -51,7 +51,28 @@
|
||||
* 定义参数变量
|
||||
*/
|
||||
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({
|
||||
title: '文件日志详情',
|
||||
subBtuText: '确定',
|
||||
|
@ -55,7 +55,30 @@
|
||||
* 定义参数变量
|
||||
*/
|
||||
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({
|
||||
title: '短信日志详情',
|
||||
subBtuText: '确定',
|
||||
|
@ -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>
|
@ -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',
|
||||
},
|
||||
];
|
@ -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>
|
@ -57,7 +57,27 @@
|
||||
* 定义参数变量
|
||||
*/
|
||||
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({
|
||||
title: '登录日志详情',
|
||||
subBtuText: '确定',
|
||||
|
@ -57,7 +57,27 @@
|
||||
* 定义参数变量
|
||||
*/
|
||||
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({
|
||||
title: '操作日志详情',
|
||||
subBtuText: '确定',
|
||||
|
Loading…
Reference in New Issue
Block a user