From 546696d86afc88faf6ea966a2b058a771c3ae490 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Thu, 31 Oct 2024 19:48:38 +0800 Subject: [PATCH 1/7] =?UTF-8?q?dictData=E6=9C=AA=E6=8B=86=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/system/dictionary/dictData/index.ts | 28 +++ frontend/src/views/system/dictionary/data.vue | 223 ++++++++---------- .../dictData/components/dataPopup.vue | 6 + .../system/dictionary/dictData/index.vue | 9 + .../dictType/components/typePopup.vue | 12 + .../system/dictionary/dictType/index.vue | 25 +- 6 files changed, 157 insertions(+), 146 deletions(-) create mode 100644 frontend/src/views/system/dictionary/dictData/components/dataPopup.vue diff --git a/frontend/src/api/system/dictionary/dictData/index.ts b/frontend/src/api/system/dictionary/dictData/index.ts index e69de29..bee0146 100644 --- a/frontend/src/api/system/dictionary/dictData/index.ts +++ b/frontend/src/api/system/dictionary/dictData/index.ts @@ -0,0 +1,28 @@ +import http from '@/api' +import {type Dict} from '@/api/system/dictionary/interface' + +//获取字典数据 +export const getDictDataListByTypeId = (params: Dict.ReqDictDataParams) => { + return http.post(`/dictData/listByTypeId`, params) +} + +//添加字典数据 +export const addDictData = (params: Dict.ResDictData) => { + return http.post(`/dictData/add`, params) +} + +//编辑字典数据 +export const updateDictData = (params: Dict.ResDictData) => { + return http.post(`/dictData/update`, params) +} + +//删除字典数据 +export const deleteDictData = (params: string[]) => { + return http.post(`/dictData/delete`, params) +} + +export const getDicDataById = (params: string) => { + return http.post('/dictData/getDicDataById', params) +} + + diff --git a/frontend/src/views/system/dictionary/data.vue b/frontend/src/views/system/dictionary/data.vue index 2546342..873fbe3 100644 --- a/frontend/src/views/system/dictionary/data.vue +++ b/frontend/src/views/system/dictionary/data.vue @@ -1,14 +1,15 @@ - - - + + +
- + - + - + - + - + - +
@@ -52,25 +54,24 @@ \ No newline at end of file diff --git a/frontend/src/views/system/dictionary/dictData/index.vue b/frontend/src/views/system/dictionary/dictData/index.vue index e69de29..7a7423f 100644 --- a/frontend/src/views/system/dictionary/dictData/index.vue +++ b/frontend/src/views/system/dictionary/dictData/index.vue @@ -0,0 +1,9 @@ + + \ No newline at end of file diff --git a/frontend/src/views/system/dictionary/dictType/components/typePopup.vue b/frontend/src/views/system/dictionary/dictType/components/typePopup.vue index ea60098..f6364e5 100644 --- a/frontend/src/views/system/dictionary/dictType/components/typePopup.vue +++ b/frontend/src/views/system/dictionary/dictType/components/typePopup.vue @@ -8,6 +8,18 @@ + + + + + + + + + + + + diff --git a/frontend/src/views/system/dictionary/dictType/index.vue b/frontend/src/views/system/dictionary/dictType/index.vue index 29aed39..d97df93 100644 --- a/frontend/src/views/system/dictionary/dictType/index.vue +++ b/frontend/src/views/system/dictionary/dictType/index.vue @@ -68,35 +68,12 @@ const columns = reactive[]>([ { prop: 'remark', label: '描述', - width: 340, - }, - { - prop: 'state', - label: '状态', - enum: dictStore.getDictData('status'), - search: { - el: 'tree-select', - props: { filterable: true }, - }, - fieldNames: { label: 'label', value: 'code' }, - render: scope => { - return ( - <> - { - {scope.row.state ? '正常' : '禁用'} - } - - ) - }, + minWidth: 300, }, { prop: 'createTime', label: '创建时间', width: 180, - search: { - el: 'date-picker', - props: { type: 'daterange', valueFormat: 'YYYY-MM-DD' }, - }, }, { prop: 'operation', From 998b30d153c67e6465ddf6dbd606562ef1f66abf Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Fri, 1 Nov 2024 09:10:37 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ProTable/components/Pagination.vue | 8 +++++++- frontend/src/components/ProTable/index.vue | 9 +++++---- frontend/src/hooks/interface/index.ts | 8 ++++++++ frontend/src/hooks/useTable.ts | 15 ++++++++++++--- frontend/src/views/system/dictionary/data.vue | 6 +++++- 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/ProTable/components/Pagination.vue b/frontend/src/components/ProTable/components/Pagination.vue index 3bd67fe..5dafd73 100644 --- a/frontend/src/components/ProTable/components/Pagination.vue +++ b/frontend/src/components/ProTable/components/Pagination.vue @@ -23,8 +23,14 @@ interface Pageable { total: number; } +interface ResPageable { + current: number; + size: number; + total: number; +} + interface PaginationProps { - pageable: Pageable; + pageable: ResPageable; handleSizeChange: (size: number) => void; handleCurrentChange: (currentPage: number) => void; } diff --git a/frontend/src/components/ProTable/index.vue b/frontend/src/components/ProTable/index.vue index 5c30c26..f556b79 100644 --- a/frontend/src/components/ProTable/index.vue +++ b/frontend/src/components/ProTable/index.vue @@ -94,7 +94,7 @@ @@ -173,6 +173,7 @@ const { selectionChange, selectedList, selectedListIds, isSelected } = useSelect const { tableData, pageable, + resPageable, searchParam, searchInitParam, getTableList, @@ -190,7 +191,7 @@ const clearSelection = () => tableRef.value!.clearSelection() onMounted(() => { dragSort() props.requestAuto && getTableList() - props.data && (pageable.value.total = props.data.length) + props.data && (resPageable.value.total = props.data.length) }) // 处理表格数据 @@ -198,8 +199,8 @@ const processTableData = computed(() => { if (!props.data) return tableData.value if (!props.pagination) return props.data return props.data.slice( - (pageable.value.pageNum - 1) * pageable.value.pageSize, - pageable.value.pageSize * pageable.value.pageNum, + (resPageable.value.current - 1) * resPageable.value.size, + resPageable.value.size * resPageable.value.current, ) }) diff --git a/frontend/src/hooks/interface/index.ts b/frontend/src/hooks/interface/index.ts index ac5a300..55b12a2 100644 --- a/frontend/src/hooks/interface/index.ts +++ b/frontend/src/hooks/interface/index.ts @@ -4,9 +4,17 @@ export namespace Table { pageSize: number; total: number; } + + export interface ResPageable { + current: number; + size: number; + total: number; + } + export interface StateProps { tableData: any[]; pageable: Pageable; + resPageable: ResPageable; searchParam: { [key: string]: any; }; diff --git a/frontend/src/hooks/useTable.ts b/frontend/src/hooks/useTable.ts index 49aa741..c64c5c8 100644 --- a/frontend/src/hooks/useTable.ts +++ b/frontend/src/hooks/useTable.ts @@ -20,6 +20,15 @@ export const useTable = ( tableData: [], // 分页数据 pageable: { + // 当前页数 + pageNum: 1, + // 每页显示条数 + pageSize: 10, + // 总条数 + total: 0, + }, + // 响应分页 + resPageable: { // 当前页数 current: 1, // 每页显示条数 @@ -71,9 +80,9 @@ export const useTable = ( state.tableData = isPageable ? data.records : data; // 解构后台返回的分页数据 (如果有分页更新分页信息) if (isPageable) { - state.pageable.total = data.total; - state.pageable.current = data.current; - state.pageable.size = data.size; + state.resPageable.total = data.total; + state.resPageable.current = data.current; + state.resPageable.size = data.size; } } catch (error) { requestError && requestError(error); diff --git a/frontend/src/views/system/dictionary/data.vue b/frontend/src/views/system/dictionary/data.vue index 2546342..5051101 100644 --- a/frontend/src/views/system/dictionary/data.vue +++ b/frontend/src/views/system/dictionary/data.vue @@ -2,7 +2,11 @@
- + From 3b1b8d36e2417dfb2d1de29046591e6f22bc2f49 Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Fri, 1 Nov 2024 13:53:50 +0800 Subject: [PATCH 5/7] weitiao --- frontend/src/views/authority/role/index.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/views/authority/role/index.vue b/frontend/src/views/authority/role/index.vue index d8a5067..dd0692f 100644 --- a/frontend/src/views/authority/role/index.vue +++ b/frontend/src/views/authority/role/index.vue @@ -88,7 +88,7 @@ const proTable = ref() // 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行 const dataCallback = (data: any) => { return { - recoards: data.list, + records: data.list, total: data.total, current: data.pageNum, size: data.pageSize, From 22868b887b3cb69a2db3aa9b6fd6a2dbc55ccd77 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Fri, 1 Nov 2024 14:25:25 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/.env.development | 5 +++-- .../dictionary/dictData/components/dataPopup.vue | 14 +++++++------- .../src/views/system/dictionary/dictData/index.vue | 6 +++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/frontend/.env.development b/frontend/.env.development index 345f0f4..e4424ec 100644 --- a/frontend/.env.development +++ b/frontend/.env.development @@ -18,5 +18,6 @@ VITE_PWA=false VITE_API_URL=/api # 开发环境跨域代理,支持配置多个 -# VITE_PROXY=[["/api","http://192.168.1.125:18092/"]] -VITE_PROXY=[["/api","http://192.168.1.138:8080/"]] \ No newline at end of file +VITE_PROXY=[["/api","http://192.168.1.122:18092/"]] +# VITE_PROXY=[["/api","http://192.168.1.125:18092/"]] +# VITE_PROXY=[["/api","http://192.168.1.138:8080/"]] \ No newline at end of file diff --git a/frontend/src/views/system/dictionary/dictData/components/dataPopup.vue b/frontend/src/views/system/dictionary/dictData/components/dataPopup.vue index ff78606..09127cd 100644 --- a/frontend/src/views/system/dictionary/dictData/components/dataPopup.vue +++ b/frontend/src/views/system/dictionary/dictData/components/dataPopup.vue @@ -3,8 +3,8 @@ v-bind="dialogSmall">
- - + + @@ -44,12 +44,12 @@ const rules: Ref>> = ref({ }) const dialogFormRef = ref() -const {dialogVisible, titleType, formContent, dictTypeCode} = useMetaInfo(); +const {dialogVisible, titleType, formContent, dictTypeName} = useMetaInfo(); function useMetaInfo() { const dialogVisible = ref(false) const titleType = ref('add') - const dictTypeCode = ref('') + const dictTypeName = ref('') const formContent = ref({ id: "", @@ -62,7 +62,7 @@ function useMetaInfo() { state: 1, }) - return {dialogVisible, titleType, formContent, dictTypeCode}; + return {dialogVisible, titleType, formContent, dictTypeName}; } let dialogTitle = computed(() => { @@ -86,12 +86,12 @@ const close = () => { resetFormContent() dialogFormRef.value?.resetFields() } -const open = (sign: string, typeId: string, code: string, data: Dict.ResDictData) => { +const open = (sign: string, typeId: string, name: string, data: Dict.ResDictData) => { resetFormContent() titleType.value = sign formContent.value.typeId = typeId - dictTypeCode.value = code + dictTypeName.value = name dialogVisible.value = true if (data.id) { formContent.value = {...data} diff --git a/frontend/src/views/system/dictionary/dictData/index.vue b/frontend/src/views/system/dictionary/dictData/index.vue index ba5c5a7..c1e59e6 100644 --- a/frontend/src/views/system/dictionary/dictData/index.vue +++ b/frontend/src/views/system/dictionary/dictData/index.vue @@ -38,7 +38,7 @@ const proTable = ref() const dialogVisible = ref(false) //字典数据所属的字典类型Id const dictTypeId = ref('') -const dictTypeCode = ref('') +const dictTypeName = ref('') const initParam = reactive({typeId: ''}) @@ -113,7 +113,7 @@ const columns = reactive[]>([ const open = (row: Dict.ResDictType) => { dialogVisible.value = true dictTypeId.value = row.id - dictTypeCode.value = row.code + dictTypeName.value = row.name initParam.typeId = row.id } @@ -121,7 +121,7 @@ defineExpose({open}) // 打开 dialog(新增、查看、编辑) const openDialog = (titleType: string, row: Partial = {}) => { - dataPopup.value?.open(titleType, dictTypeId.value, dictTypeCode.value, row) + dataPopup.value?.open(titleType, dictTypeId.value, dictTypeName.value, row) } // 批量删除字典数据 From f530c482284b6467c1622c662cff93f264ac67ed Mon Sep 17 00:00:00 2001 From: hongawen <83944980@qq.com> Date: Fri, 1 Nov 2024 15:17:18 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/system/dictionary/dictData/components/dataPopup.vue | 2 -- .../views/system/dictionary/dictType/components/typePopup.vue | 2 -- 2 files changed, 4 deletions(-) diff --git a/frontend/src/views/system/dictionary/dictData/components/dataPopup.vue b/frontend/src/views/system/dictionary/dictData/components/dataPopup.vue index 09127cd..63faa99 100644 --- a/frontend/src/views/system/dictionary/dictData/components/dataPopup.vue +++ b/frontend/src/views/system/dictionary/dictData/components/dataPopup.vue @@ -113,8 +113,6 @@ const save = () => { ElMessage.success({message: `${dialogTitle.value}成功!`}) close() await props.refreshTable!() - } else { - ElMessage.error('表单验证失败!') } }) } catch (err) { diff --git a/frontend/src/views/system/dictionary/dictType/components/typePopup.vue b/frontend/src/views/system/dictionary/dictType/components/typePopup.vue index f6364e5..7c089c8 100644 --- a/frontend/src/views/system/dictionary/dictType/components/typePopup.vue +++ b/frontend/src/views/system/dictionary/dictType/components/typePopup.vue @@ -115,8 +115,6 @@ const save = () => { close() // 刷新表格 await props.refreshTable!() - } else { - ElMessage.error('表单验证失败!') } }) } catch (err) {