😎代码优化
This commit is contained in:
parent
1d12c06676
commit
3eb2fe86f3
4
Web/src/views/system/cache/index.vue
vendored
4
Web/src/views/system/cache/index.vue
vendored
@ -61,7 +61,7 @@ const state = reactive({
|
|||||||
|
|
||||||
// 页面初始化
|
// 页面初始化
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
handleQuery();
|
await handleQuery();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 查询操作
|
// 查询操作
|
||||||
@ -109,7 +109,7 @@ const delCache = () => {
|
|||||||
})
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
await getAPI(SysCacheApi).apiSysCacheDeleteKeyPost(currentNode.value.id);
|
await getAPI(SysCacheApi).apiSysCacheDeleteKeyPost(currentNode.value.id);
|
||||||
handleQuery();
|
await handleQuery();
|
||||||
state.cacheValue = undefined;
|
state.cacheValue = undefined;
|
||||||
state.cacheKey = undefined;
|
state.cacheKey = undefined;
|
||||||
ElMessage.success('删除成功');
|
ElMessage.success('删除成功');
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<el-row :gutter="10">
|
<el-row :gutter="10">
|
||||||
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||||
<el-form-item label="配置名称" prop="name">
|
<el-form-item label="配置名称" prop="name">
|
||||||
<el-input v-model="state.queryParams.name" placeholder="配置名称" clearable @keyup.enter.native="handleQuery()" />
|
<el-input v-model="state.queryParams.name" placeholder="配置名称" clearable @keyup.enter.native="handleQuery" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||||
@ -72,6 +72,7 @@ import { onMounted, reactive, ref } from 'vue';
|
|||||||
import { ElMessageBox, ElMessage } from 'element-plus';
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
||||||
import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
|
import { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
|
||||||
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
|
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
|
||||||
|
import { Local } from '/@/utils/storage';
|
||||||
|
|
||||||
import EditConfig from '/@/views/system/config/component/editConfig.vue';
|
import EditConfig from '/@/views/system/config/component/editConfig.vue';
|
||||||
import ModifyRecord from '/@/components/table/modifyRecord.vue';
|
import ModifyRecord from '/@/components/table/modifyRecord.vue';
|
||||||
@ -79,7 +80,7 @@ import ModifyRecord from '/@/components/table/modifyRecord.vue';
|
|||||||
import { getAPI } from '/@/utils/axios-utils';
|
import { getAPI } from '/@/utils/axios-utils';
|
||||||
import { SysConfigApi } from '/@/api-services/api';
|
import { SysConfigApi } from '/@/api-services/api';
|
||||||
import { SysConfig, PageConfigInput } from '/@/api-services/models';
|
import { SysConfig, PageConfigInput } from '/@/api-services/models';
|
||||||
import { Local } from '/@/utils/storage';
|
|
||||||
const xGrid = ref<VxeGridInstance>();
|
const xGrid = ref<VxeGridInstance>();
|
||||||
const editConfigRef = ref<InstanceType<typeof EditConfig>>();
|
const editConfigRef = ref<InstanceType<typeof EditConfig>>();
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
@ -89,7 +90,7 @@ const state = reactive({
|
|||||||
groupCode: undefined,
|
groupCode: undefined,
|
||||||
},
|
},
|
||||||
localPageParam: {
|
localPageParam: {
|
||||||
pageSize: 20 as number,
|
pageSize: 50 as number,
|
||||||
defaultSort: { field: 'orderNo', order: 'asc', descStr: 'desc' },
|
defaultSort: { field: 'orderNo', order: 'asc', descStr: 'desc' },
|
||||||
},
|
},
|
||||||
visible: false,
|
visible: false,
|
||||||
@ -135,7 +136,7 @@ const options = useVxeTable<SysConfig>(
|
|||||||
// 页面初始化
|
// 页面初始化
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
state.localPageParam = Local.get(localPageParamKey) || state.localPageParam;
|
state.localPageParam = Local.get(localPageParamKey) || state.localPageParam;
|
||||||
fetchGroupData();
|
await fetchGroupData();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 查询api
|
// 查询api
|
||||||
@ -149,10 +150,6 @@ const handleQuery = async () => {
|
|||||||
// 调用vxe-grid的commitProxy(query)方法,触发表格重新加载数据
|
// 调用vxe-grid的commitProxy(query)方法,触发表格重新加载数据
|
||||||
await xGrid.value?.commitProxy('query');
|
await xGrid.value?.commitProxy('query');
|
||||||
};
|
};
|
||||||
const fetchGroupData = async () => {
|
|
||||||
const res = await getAPI(SysConfigApi).apiSysConfigGroupListGet();
|
|
||||||
state.groupList = res.data.result ?? [];
|
|
||||||
};
|
|
||||||
|
|
||||||
// 重置操作
|
// 重置操作
|
||||||
const resetQuery = async () => {
|
const resetQuery = async () => {
|
||||||
@ -163,19 +160,6 @@ const resetQuery = async () => {
|
|||||||
await xGrid.value?.commitProxy('reload');
|
await xGrid.value?.commitProxy('reload');
|
||||||
};
|
};
|
||||||
|
|
||||||
// 表格事件
|
|
||||||
const gridEvents: VxeGridListeners<SysConfig> = {
|
|
||||||
// 只对 pager-config 配置时有效,分页发生改变时会触发该事件
|
|
||||||
async pageChange({ pageSize }) {
|
|
||||||
state.localPageParam.pageSize = pageSize;
|
|
||||||
Local.set(localPageParamKey, state.localPageParam);
|
|
||||||
},
|
|
||||||
// 当排序条件发生变化时会触发该事件
|
|
||||||
async sortChange({ field, order }) {
|
|
||||||
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
|
|
||||||
Local.set(localPageParamKey, state.localPageParam);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
// 打开新增页面
|
// 打开新增页面
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
state.title = '添加配置';
|
state.title = '添加配置';
|
||||||
@ -188,12 +172,6 @@ const handleEdit = (row: any) => {
|
|||||||
editConfigRef.value?.openDialog(row);
|
editConfigRef.value?.openDialog(row);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 更新数据
|
|
||||||
const updateData = async () => {
|
|
||||||
await handleQuery();
|
|
||||||
fetchGroupData();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
const handleDelete = (row: any) => {
|
const handleDelete = (row: any) => {
|
||||||
ElMessageBox.confirm(`确定删除配置:【${row.name}】?`, '提示', {
|
ElMessageBox.confirm(`确定删除配置:【${row.name}】?`, '提示', {
|
||||||
@ -209,24 +187,46 @@ const handleDelete = (row: any) => {
|
|||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSelectChange = () => {
|
// 表格事件
|
||||||
state.selectList = xGrid.value?.getCheckboxRecords() ?? [];
|
const gridEvents: VxeGridListeners<SysConfig> = {
|
||||||
|
// 只对 pager-config 配置时有效,分页发生改变时会触发该事件
|
||||||
|
async pageChange({ pageSize }) {
|
||||||
|
state.localPageParam.pageSize = pageSize;
|
||||||
|
Local.set(localPageParamKey, state.localPageParam);
|
||||||
|
},
|
||||||
|
// 当排序条件发生变化时会触发该事件
|
||||||
|
async sortChange({ field, order }) {
|
||||||
|
state.localPageParam.defaultSort = { field: field, order: order!, descStr: 'desc' };
|
||||||
|
Local.set(localPageParamKey, state.localPageParam);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// 批量删除
|
// 获取分组
|
||||||
const handleBacthDelete = () => {
|
const fetchGroupData = async () => {
|
||||||
if (state.selectList.length == 0) return false;
|
const res = await getAPI(SysConfigApi).apiSysConfigGroupListGet();
|
||||||
ElMessageBox.confirm(`确定批量删除【${state.selectList[0].name}】等${state.selectList.length}个配置?`, '提示', {
|
state.groupList = res.data.result ?? [];
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
.then(async () => {
|
|
||||||
const ids = state.selectList.map((item: any) => item.id);
|
|
||||||
var res = await getAPI(SysConfigApi).apiSysConfigBatchDeletePost(ids);
|
|
||||||
handleQuery();
|
|
||||||
ElMessage.success('删除成功');
|
|
||||||
})
|
|
||||||
.catch(() => {});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 更新数据
|
||||||
|
const updateData = async () => {
|
||||||
|
await handleQuery();
|
||||||
|
fetchGroupData();
|
||||||
|
};
|
||||||
|
|
||||||
|
// // 批量删除
|
||||||
|
// const handleBacthDelete = () => {
|
||||||
|
// if (state.selectList.length == 0) return false;
|
||||||
|
// ElMessageBox.confirm(`确定批量删除【${state.selectList[0].name}】等${state.selectList.length}个配置?`, '提示', {
|
||||||
|
// confirmButtonText: '确定',
|
||||||
|
// cancelButtonText: '取消',
|
||||||
|
// type: 'warning',
|
||||||
|
// })
|
||||||
|
// .then(async () => {
|
||||||
|
// const ids = state.selectList.map((item: any) => item.id);
|
||||||
|
// var res = await getAPI(SysConfigApi).apiSysConfigBatchDeletePost(ids);
|
||||||
|
// handleQuery();
|
||||||
|
// ElMessage.success('删除成功');
|
||||||
|
// })
|
||||||
|
// .catch(() => {});
|
||||||
|
// };
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -142,7 +142,7 @@ import VueOfficePdf from '@vue-office/pdf';
|
|||||||
import '@vue-office/docx/lib/index.css';
|
import '@vue-office/docx/lib/index.css';
|
||||||
import '@vue-office/excel/lib/index.css';
|
import '@vue-office/excel/lib/index.css';
|
||||||
|
|
||||||
import EditFile from '/@/views/system/file/component/editSysfile.vue';
|
import EditFile from '/@/views/system/file/component/editFile.vue';
|
||||||
|
|
||||||
import { getAPI } from '/@/utils/axios-utils';
|
import { getAPI } from '/@/utils/axios-utils';
|
||||||
import { SysFileApi } from '/@/api-services/api';
|
import { SysFileApi } from '/@/api-services/api';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user