|
@@ -5,7 +5,6 @@
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<el-table v-loading="loading" height="calc(100vh - 220px)" :data="dataSource" style="width: 100%" border>
|
|
<el-table v-loading="loading" height="calc(100vh - 220px)" :data="dataSource" style="width: 100%" border>
|
|
|
- <!-- <el-table-column prop="id" label="序号" /> -->
|
|
|
|
|
<el-table-column prop="dictName" label="字典名称" />
|
|
<el-table-column prop="dictName" label="字典名称" />
|
|
|
<el-table-column prop="dictCode" label="字典编码" />
|
|
<el-table-column prop="dictCode" label="字典编码" />
|
|
|
<el-table-column prop="description" label="字典描述" show-overflow-tooltip />
|
|
<el-table-column prop="description" label="字典描述" show-overflow-tooltip />
|
|
@@ -28,37 +27,43 @@
|
|
|
</el-table>
|
|
</el-table>
|
|
|
|
|
|
|
|
<div class="pagination-container">
|
|
<div class="pagination-container">
|
|
|
- <el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize" :page-sizes="[10, 20, 50, 100]"
|
|
|
|
|
- :total="totalPage" layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
|
|
|
|
|
- @current-change="handleCurrentChange" />
|
|
|
|
|
|
|
+ <el-pagination
|
|
|
|
|
+ v-model:current-page="currentPage"
|
|
|
|
|
+ v-model:page-size="pageSize"
|
|
|
|
|
+ :page-sizes="[10, 20, 50, 100]"
|
|
|
|
|
+ :total="totalRow"
|
|
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
|
|
+ @size-change="handleSizeChange"
|
|
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <AddDict v-if="dialogVisible" ref="addDictRef" @close="closeAddDialog" @submit="handleSubmit"
|
|
|
|
|
- :dictCode="currentDictCode" />
|
|
|
|
|
|
|
+ <AddDict
|
|
|
|
|
+ v-if="dialogVisible"
|
|
|
|
|
+ ref="addDictRef"
|
|
|
|
|
+ @close="closeAddDialog"
|
|
|
|
|
+ @submit="handleSubmit"
|
|
|
|
|
+ :dictCode="currentDictCode"
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
- import { ref, reactive, onMounted, computed } from 'vue';
|
|
|
|
|
- import { ElMessage, ElMessageBox, FormInstance } from 'element-plus';
|
|
|
|
|
|
|
+ import { ref, onMounted, computed } from 'vue';
|
|
|
|
|
+ import { ElMessage, ElMessageBox } from 'element-plus';
|
|
|
import AddDict from './components/AddDict.vue';
|
|
import AddDict from './components/AddDict.vue';
|
|
|
- import { queryDictPageApi, createDictApi, SaveDictParams, updateDict, deleteDict } from '@/api/dict';
|
|
|
|
|
|
|
+ import { createDictApi, SaveDictParams, updateDict, deleteDict } from '@/api/dict';
|
|
|
import { useDataSource } from './useDataSource';
|
|
import { useDataSource } from './useDataSource';
|
|
|
- import { dictionaryStatusOptions, dictionaryTypeOptions } from './constants'
|
|
|
|
|
-
|
|
|
|
|
|
|
+ import { dictionaryStatusOptions, dictionaryTypeOptions } from './constants';
|
|
|
|
|
+
|
|
|
// 表格数据
|
|
// 表格数据
|
|
|
const loading = ref(false);
|
|
const loading = ref(false);
|
|
|
|
|
|
|
|
- const { dataSource, getDataSource, pageSize, currentPage, totalPage } = useDataSource();
|
|
|
|
|
|
|
+ const { dataSource, getDataSource, pageSize, currentPage, totalRow } = useDataSource();
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
getDataSource();
|
|
getDataSource();
|
|
|
});
|
|
});
|
|
|
- // 搜索
|
|
|
|
|
- function handleSearch() {
|
|
|
|
|
- currentPage.value = 1;
|
|
|
|
|
- getDataSource();
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
// 分页相关
|
|
// 分页相关
|
|
|
function handleSizeChange(val: number) {
|
|
function handleSizeChange(val: number) {
|
|
@@ -77,17 +82,6 @@
|
|
|
const addDictRef = ref<InstanceType<typeof AddDict>>();
|
|
const addDictRef = ref<InstanceType<typeof AddDict>>();
|
|
|
const currentDictCode = ref('');
|
|
const currentDictCode = ref('');
|
|
|
|
|
|
|
|
- const formRules = {
|
|
|
|
|
- name: [
|
|
|
|
|
- { required: true, message: '请输入字典名称', trigger: 'blur' },
|
|
|
|
|
- { min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' },
|
|
|
|
|
- ],
|
|
|
|
|
- code: [
|
|
|
|
|
- { required: true, message: '请输入字典编码', trigger: 'blur' },
|
|
|
|
|
- { min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' },
|
|
|
|
|
- ],
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
// 新增字典
|
|
// 新增字典
|
|
|
function handleAddDialogShow() {
|
|
function handleAddDialogShow() {
|
|
|
dialogVisible.value = true;
|
|
dialogVisible.value = true;
|
|
@@ -114,7 +108,7 @@
|
|
|
await ElMessageBox.confirm('确定要删除这条字典记录吗?', '提示', {
|
|
await ElMessageBox.confirm('确定要删除这条字典记录吗?', '提示', {
|
|
|
type: 'warning',
|
|
type: 'warning',
|
|
|
});
|
|
});
|
|
|
- await deleteDictionary(row.dictId)
|
|
|
|
|
|
|
+ await deleteDictionary(row.dictId);
|
|
|
} catch {
|
|
} catch {
|
|
|
// 用户取消删除
|
|
// 用户取消删除
|
|
|
}
|
|
}
|
|
@@ -124,9 +118,9 @@
|
|
|
async function handleSubmit(formData: SaveDictParams) {
|
|
async function handleSubmit(formData: SaveDictParams) {
|
|
|
if (!addDictRef.value) return;
|
|
if (!addDictRef.value) return;
|
|
|
if (formData.dictId) {
|
|
if (formData.dictId) {
|
|
|
- await updateDictionary(formData)
|
|
|
|
|
|
|
+ await updateDictionary(formData);
|
|
|
} else {
|
|
} else {
|
|
|
- await createDictionary(formData)
|
|
|
|
|
|
|
+ await createDictionary(formData);
|
|
|
}
|
|
}
|
|
|
dialogVisible.value = false;
|
|
dialogVisible.value = false;
|
|
|
getDataSource();
|
|
getDataSource();
|
|
@@ -141,24 +135,23 @@
|
|
|
const updateDictionary = (formData: SaveDictParams) => {
|
|
const updateDictionary = (formData: SaveDictParams) => {
|
|
|
updateDict(formData).then((res) => {
|
|
updateDict(formData).then((res) => {
|
|
|
ElMessage.success('编辑成功');
|
|
ElMessage.success('编辑成功');
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
const deleteDictionary = (id: number) => {
|
|
const deleteDictionary = (id: number) => {
|
|
|
- deleteDict(id).then((res) => {
|
|
|
|
|
|
|
+ deleteDict(id).then(() => {
|
|
|
ElMessage.success('删除成功');
|
|
ElMessage.success('删除成功');
|
|
|
getDataSource();
|
|
getDataSource();
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- const typeLabelMap = computed(() =>
|
|
|
|
|
- Object.fromEntries(dictionaryTypeOptions.map(item => [item.value, item.label]))
|
|
|
|
|
|
|
+ const typeLabelMap = computed(() =>
|
|
|
|
|
+ Object.fromEntries(dictionaryTypeOptions.map((item) => [item.value, item.label])),
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
const statusLabelMap = computed(() =>
|
|
const statusLabelMap = computed(() =>
|
|
|
- Object.fromEntries(dictionaryStatusOptions.map(item => [item.value, item.label]))
|
|
|
|
|
|
|
+ Object.fromEntries(dictionaryStatusOptions.map((item) => [item.value, item.label])),
|
|
|
);
|
|
);
|
|
|
-
|
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|