😎代码优化
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 () => {
|
||||
handleQuery();
|
||||
await handleQuery();
|
||||
});
|
||||
|
||||
// 查询操作
|
||||
@ -109,7 +109,7 @@ const delCache = () => {
|
||||
})
|
||||
.then(async () => {
|
||||
await getAPI(SysCacheApi).apiSysCacheDeleteKeyPost(currentNode.value.id);
|
||||
handleQuery();
|
||||
await handleQuery();
|
||||
state.cacheValue = undefined;
|
||||
state.cacheKey = undefined;
|
||||
ElMessage.success('删除成功');
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<el-row :gutter="10">
|
||||
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
|
||||
<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-col>
|
||||
<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 { VxeGridInstance, VxeGridListeners, VxeGridPropTypes } from 'vxe-table';
|
||||
import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook';
|
||||
import { Local } from '/@/utils/storage';
|
||||
|
||||
import EditConfig from '/@/views/system/config/component/editConfig.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 { SysConfigApi } from '/@/api-services/api';
|
||||
import { SysConfig, PageConfigInput } from '/@/api-services/models';
|
||||
import { Local } from '/@/utils/storage';
|
||||
|
||||
const xGrid = ref<VxeGridInstance>();
|
||||
const editConfigRef = ref<InstanceType<typeof EditConfig>>();
|
||||
const state = reactive({
|
||||
@ -89,7 +90,7 @@ const state = reactive({
|
||||
groupCode: undefined,
|
||||
},
|
||||
localPageParam: {
|
||||
pageSize: 20 as number,
|
||||
pageSize: 50 as number,
|
||||
defaultSort: { field: 'orderNo', order: 'asc', descStr: 'desc' },
|
||||
},
|
||||
visible: false,
|
||||
@ -135,7 +136,7 @@ const options = useVxeTable<SysConfig>(
|
||||
// 页面初始化
|
||||
onMounted(async () => {
|
||||
state.localPageParam = Local.get(localPageParamKey) || state.localPageParam;
|
||||
fetchGroupData();
|
||||
await fetchGroupData();
|
||||
});
|
||||
|
||||
// 查询api
|
||||
@ -149,10 +150,6 @@ const handleQuery = async () => {
|
||||
// 调用vxe-grid的commitProxy(query)方法,触发表格重新加载数据
|
||||
await xGrid.value?.commitProxy('query');
|
||||
};
|
||||
const fetchGroupData = async () => {
|
||||
const res = await getAPI(SysConfigApi).apiSysConfigGroupListGet();
|
||||
state.groupList = res.data.result ?? [];
|
||||
};
|
||||
|
||||
// 重置操作
|
||||
const resetQuery = async () => {
|
||||
@ -163,19 +160,6 @@ const resetQuery = async () => {
|
||||
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 = () => {
|
||||
state.title = '添加配置';
|
||||
@ -188,12 +172,6 @@ const handleEdit = (row: any) => {
|
||||
editConfigRef.value?.openDialog(row);
|
||||
};
|
||||
|
||||
// 更新数据
|
||||
const updateData = async () => {
|
||||
await handleQuery();
|
||||
fetchGroupData();
|
||||
};
|
||||
|
||||
// 删除
|
||||
const handleDelete = (row: any) => {
|
||||
ElMessageBox.confirm(`确定删除配置:【${row.name}】?`, '提示', {
|
||||
@ -209,24 +187,46 @@ const handleDelete = (row: any) => {
|
||||
.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 = () => {
|
||||
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(() => {});
|
||||
// 获取分组
|
||||
const fetchGroupData = async () => {
|
||||
const res = await getAPI(SysConfigApi).apiSysConfigGroupListGet();
|
||||
state.groupList = res.data.result ?? [];
|
||||
};
|
||||
|
||||
// 更新数据
|
||||
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>
|
||||
|
||||
@ -142,7 +142,7 @@ import VueOfficePdf from '@vue-office/pdf';
|
||||
import '@vue-office/docx/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 { SysFileApi } from '/@/api-services/api';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user