优化字典、配置

This commit is contained in:
zjl 2024-12-18 11:28:42 +08:00
parent 1eede00c20
commit c56d32bd54
2 changed files with 275 additions and 234 deletions

View File

@ -14,24 +14,43 @@
</el-input>
<el-button type="primary" @click="reloadTable" icon="Search"> 查询 </el-button>
</el-space>
<div style="margin-top:15px;">
<div style="margin-top: 15px">
<el-button type="primary" @click="addConfig" icon="Plus">新建</el-button>
<el-button type="danger" :disabled="!selectionData.length" @click="handleDelete()" icon="Delete">删除</el-button>
<el-button
type="danger"
:disabled="!selectionData.length"
@click="handleDelete()"
icon="Delete"
>删除</el-button
>
</div>
</template>
<BasicTable :columns="columns" :showTableSetting="false" :request="loadDataTable" :row-key="(row) => row.id"
ref="tableRef" :actionColumn="actionColumn" @selection-change="onSelectionChange" highlight-current-row
@row-click="onCheckedRow" :pagination="{ small: true, layout: 'total,prev, pager, next,jumper' }"/>
<BasicTable
:columns="columns"
:showTableSetting="false"
:request="loadDataTable"
:row-key="(row) => row.id"
ref="tableRef"
:actionColumn="actionColumn"
@selection-change="onSelectionChange"
highlight-current-row
@row-click="onCheckedRow"
:pagination="{ small: true, layout: 'total,prev, pager, next,jumper' }"
/>
</el-card>
</el-col>
<el-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16" class="mb-4">
<el-card shadow="hover" class="mb-4 border-0 proCard">
<configItem :configId="configId" v-if="configItemShow"></configItem>
<configItem :configId="configId" v-if="configItemShow" />
</el-card>
</el-col>
</el-row>
<editDialog v-if="editVisible" :configId="configId" v-model:visible="editVisible" @success="reloadTable">
</editDialog>
<editDialog
v-if="editVisible"
:configId="configId"
v-model:visible="editVisible"
@success="reloadTable"
/>
</PageWrapper>
</template>
@ -42,15 +61,13 @@ import { TableAction } from '@/components/Table';
import { getConfigList, configDelete, configBatchDelete } from '@/api/data/config';
import { columns } from './columns';
import configItem from './configItem.vue';
import { message, confirm } from "@/utils/auth";
const editDialog = defineAsyncComponent(() =>
import('./edit.vue')
)
const configId = ref(0)
const configItemShow = ref(false)
import { message, confirm } from '@/utils/auth';
const editDialog = defineAsyncComponent(() => import('./edit.vue'));
const configId = ref(0);
const configItemShow = ref(false);
const tableRef = ref();
const editVisible = ref(false)
const selectionData = ref([])
const editVisible = ref(false);
const selectionData = ref([]);
const params = ref({
name: '',
});
@ -75,28 +92,27 @@ const actionColumn = reactive({
icon: 'Delete',
type: 'danger',
onClick: handleDelete.bind(null, record),
}
},
],
});
},
});
//
const addConfig = async () => {
configId.value=0
configId.value = 0;
await nextTick();
editVisible.value=true
editVisible.value = true;
};
//
const handleEdit = async (record: Recordable) => {
configId.value=record.row.id
configId.value = record.row.id;
await nextTick();
editVisible.value=true
editVisible.value = true;
};
//
function onCheckedRow(row) {
configId.value = row.id
configId.value = row.id;
}
//
@ -107,28 +123,28 @@ function reloadTable() {
//;
const loadDataTable = async (res) => {
const result = await getConfigList({ ...params.value, ...res });
configId.value = result?.records[0]?.id
configItemShow.value = true
configId.value = result?.records[0]?.id;
configItemShow.value = true;
nextTick(() => {
const tables = tableRef.value.getTableRef();
tables.setCurrentRow(result?.records[0])
})
tables.setCurrentRow(result?.records[0]);
});
return result;
};
//
async function handleDelete(record: Recordable) {
let ids = []
let ids = [];
if (!record) {
ids = selectionData.value.map(({ id }) => id);
}
await confirm('确定要删除?');
record ? await configDelete(record.row.id) : await configBatchDelete(ids);
message("删除成功");
reloadTable()
message('删除成功');
reloadTable();
}
function onSelectionChange(value) {
selectionData.value = value
selectionData.value = value;
}
</script>
<style lang="scss" scoped>

View File

@ -14,25 +14,53 @@
</el-input>
<el-button type="primary" icon="Search" @click="reloadTable"> 查询 </el-button>
</el-space>
<div style="margin-top:15px;">
<el-button type="primary" @click="dictRefresh" icon="RefreshRight" v-perm="['sys:dict:cache']">刷新缓存</el-button>
<el-button type="primary" @click="addDict" icon="Plus" v-perm="['sys:dict:add']">新建</el-button>
<el-button type="danger" v-perm="['sys:dict:delete']" icon="Delete" :disabled="!selectionData.length" @click="handleDelete()">删除</el-button>
<div style="margin-top: 15px">
<el-button
type="primary"
@click="dictRefresh"
icon="RefreshRight"
v-perm="['sys:dict:cache']"
>刷新缓存</el-button
>
<el-button type="primary" @click="addDict" icon="Plus" v-perm="['sys:dict:add']"
>新建</el-button
>
<el-button
type="danger"
v-perm="['sys:dict:delete']"
icon="Delete"
:disabled="!selectionData.length"
@click="handleDelete()"
>删除</el-button
>
</div>
</template>
<BasicTable :columns="columns" :showTableSetting="false" :request="loadDataTable" :row-key="(row) => row.id"
ref="tableRef" :actionColumn="actionColumn" @selection-change="onSelectionChange" highlight-current-row
@row-click="onCheckedRow" :pagination="{ small: true, layout: 'total,prev, pager, next,jumper' }" />
<BasicTable
:columns="columns"
:showTableSetting="false"
:request="loadDataTable"
:row-key="(row) => row.id"
ref="tableRef"
:actionColumn="actionColumn"
@selection-change="onSelectionChange"
highlight-current-row
@row-click="onCheckedRow"
:pagination="{ small: true, layout: 'total,prev, pager, next,jumper' }"
/>
</el-card>
</el-col>
<el-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16" class="mb-4">
<el-card shadow="hover" class="mb-4 border-0 proCard">
<dictItem :dictId="dictId" v-if="dictItemShow"></dictItem>
<dictItem :dictId="dictId" v-if="dictItemShow" />
</el-card>
</el-col>
</el-row>
<editDialog v-if="editVisible" :dictId="dictId" v-model:visible="editVisible" @success="reloadTable">
</editDialog>
<editDialog
v-if="editVisible"
:dictId="dictId"
v-model:visible="editVisible"
@success="reloadTable"
/>
</PageWrapper>
</template>
@ -43,18 +71,16 @@ import { TableAction } from '@/components/Table';
import { getDictList, refreshCache, dictDelete, dictBatchDelete } from '@/api/data/dictionary';
import { columns } from './columns';
import dictItem from './dictItem.vue';
import { message, confirm } from "@/utils/auth";
const editDialog = defineAsyncComponent(() =>
import('./edit.vue')
)
const dictId = ref(0)
const dictItemShow = ref(false)
import { message, confirm } from '@/utils/auth';
const editDialog = defineAsyncComponent(() => import('./edit.vue'));
const dictId = ref(0);
const dictItemShow = ref(false);
const tableRef = ref();
const selectedKey = ref('');
const rowKeysName = ref('');
const currentRow = ref();
const editVisible = ref(false)
const selectionData = ref([])
const editVisible = ref(false);
const selectionData = ref([]);
const params = ref({
name: '',
});
@ -79,28 +105,27 @@ const actionColumn = reactive({
icon: 'Delete',
type: 'danger',
onClick: handleDelete.bind(null, record),
}
},
],
});
},
});
//
const addDict = async () => {
dictId.value=0
dictId.value = 0;
await nextTick();
editVisible.value=true
editVisible.value = true;
};
//
const handleEdit = async (record: Recordable) => {
dictId.value=record.row.id
dictId.value = record.row.id;
await nextTick();
editVisible.value=true
editVisible.value = true;
};
//
function onCheckedRow(row) {
dictId.value = row.id
dictId.value = row.id;
}
//
@ -111,33 +136,33 @@ function reloadTable() {
//;
const loadDataTable = async (res) => {
const result = await getDictList({ ...params.value, ...res });
dictId.value = result?.records[0]?.id
dictItemShow.value = true
dictId.value = result?.records[0]?.id;
dictItemShow.value = true;
nextTick(() => {
const tables = tableRef.value.getTableRef();
tables.setCurrentRow(result?.records[0])
})
tables.setCurrentRow(result?.records[0]);
});
return result;
};
//
async function dictRefresh() {
await refreshCache();
message("刷新成功");
message('刷新成功');
}
//
async function handleDelete(record: Recordable) {
let ids = []
let ids = [];
if (!record) {
ids = selectionData.value.map(({ id }) => id);
}
await confirm('确定要删除?');
record ? await dictDelete(record.row.id) : await dictBatchDelete(ids);
message("删除成功");
reloadTable()
message('删除成功');
reloadTable();
}
function onSelectionChange(value) {
selectionData.value = value
selectionData.value = value;
}
</script>
<style lang="scss" scoped>