优化(sys): 用户/角色/部门/权限页提交按钮启用loading,响应成功后关闭动画
CI/CD Deploy (Web) / 构建前端镜像并部署 (push) Successful in 18s

This commit is contained in:
张家训
2026-10-23 10:36:45 +08:00
parent 65c37d3b4a
commit 10660209f2
4 changed files with 715 additions and 714 deletions
+64 -65
View File
@@ -116,13 +116,13 @@
</template> </template>
<script> <script>
import { getTreeList, getTreeSelectList, getDataList, add, update, remove, getExcelTemplate} from '@/api/sys/sys-dept' import { getTreeList, getTreeSelectList, getDataList, add, update, remove } from '@/api/sys/sys-dept'
import { objectUtil, utils, exportExcel } from "@/common/js/util" import { objectUtil } from '@/common/js/util'
import Treeselect from '@riophae/vue-treeselect' import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css' import '@riophae/vue-treeselect/dist/vue-treeselect.css'
export default { export default {
name: "sso-dept", name: 'sso-dept',
components: { components: {
Treeselect Treeselect
}, },
@@ -141,33 +141,33 @@
}, },
listColumns: [ listColumns: [
{ {
title: "#", title: '#',
type: 'index', type: 'index',
width: 60, width: 60,
align: 'center', align: 'center',
indexMethod: (row) => { indexMethod: (row) => {
return (row._index + 1) + ((this.pageParam.pageNum - 1) * this.pageParam.pageSize); return (row._index + 1) + ((this.pageParam.pageNum - 1) * this.pageParam.pageSize)
} }
}, },
{ {
title: '部门名称', title: '部门名称',
key: 'deptName', key: 'deptName',
width: 300, width: 300
}, },
{ {
title: '部门编码', title: '部门编码',
key: 'deptCode', key: 'deptCode',
width: 100, width: 100
}, },
{ {
title: '上级部门', title: '上级部门',
key: 'pDeptName', key: 'pDeptName',
width: 300, width: 300
}, },
{ {
title: '部门描述', title: '部门描述',
key: 'deptDesc', key: 'deptDesc',
width: 300, width: 300
}, },
{ {
title: '操作区', title: '操作区',
@@ -184,12 +184,12 @@
}, },
{ {
title: '部门编码', title: '部门编码',
key: 'deptCode', key: 'deptCode'
}, },
{ {
title: '部门描述', title: '部门描述',
key: 'deptDesc' key: 'deptDesc'
}, }
], ],
pDeptList: [], // 父级部门列表 pDeptList: [], // 父级部门列表
dataList: [], dataList: [],
@@ -213,7 +213,7 @@
deptCode: '', deptCode: '',
level: 0, level: 0,
deptDesc: '', deptDesc: '',
sort: 0, sort: 0
}, },
ruleCustom: { ruleCustom: {
parentId: [{ parentId: [{
@@ -224,8 +224,8 @@
}], }],
deptCode: [{ deptCode: [{
required: true, message: '请输入部门编码', trigger: 'blur' required: true, message: '请输入部门编码', trigger: 'blur'
}], }]
}, }
} }
}, },
methods: { methods: {
@@ -240,15 +240,15 @@
return return
} }
const wrapStyle = window.getComputedStyle(wrap) const wrapStyle = window.getComputedStyle(wrap)
const avail = wrap.clientHeight const avail = wrap.clientHeight -
- (parseFloat(wrapStyle.paddingTop) || 0) (parseFloat(wrapStyle.paddingTop) || 0) -
- (parseFloat(wrapStyle.paddingBottom) || 0) (parseFloat(wrapStyle.paddingBottom) || 0)
const pageStyle = window.getComputedStyle(page) const pageStyle = window.getComputedStyle(page)
const pageMarginTop = parseFloat(pageStyle.marginTop) || 0 const pageMarginTop = parseFloat(pageStyle.marginTop) || 0
const pageMarginBottom = parseFloat(pageStyle.marginBottom) || 0 const pageMarginBottom = parseFloat(pageStyle.marginBottom) || 0
// 除表格外的固定块:查询区 + 按钮区 + 分页区(含上下外边距) // 除表格外的固定块:查询区 + 按钮区 + 分页区(含上下外边距)
const fixed = option.offsetHeight + btn.offsetHeight const fixed = option.offsetHeight + btn.offsetHeight +
+ page.offsetHeight + pageMarginTop + pageMarginBottom page.offsetHeight + pageMarginTop + pageMarginBottom
this.autoHeight = Math.max(200, avail - fixed) this.autoHeight = Math.max(200, avail - fixed)
// 等表格按新高度重排后再量底边,避免拿到上一帧的位置 // 等表格按新高度重排后再量底边,避免拿到上一帧的位置
this.$nextTick(() => { this.$nextTick(() => {
@@ -263,7 +263,7 @@
}, },
getTreeChoose () { getTreeChoose () {
// 获取选中的节点信息 // 获取选中的节点信息
let choose = this.$refs.tree.getSelectedNodes(); let choose = this.$refs.tree.getSelectedNodes()
if (choose.length > 0) { if (choose.length > 0) {
this.formItem.parentId = choose[0].id this.formItem.parentId = choose[0].id
this.formItem.level = choose[0].level + 1 this.formItem.level = choose[0].level + 1
@@ -299,14 +299,14 @@
}) })
}, },
toAdd () { toAdd () {
this.modalTitle = "添加" this.modalTitle = '添加'
this.modal = true this.modal = true
this.addModal = true this.addModal = true
this.editModal = false this.editModal = false
}, },
toEdit (index) { toEdit (index) {
this.modalTitle = "编辑" this.modalTitle = '编辑'
let temp = this.dataList[index] let temp = this.dataList[index]
this.addModal = false this.addModal = false
@@ -331,31 +331,30 @@
// modal 提交 // modal 提交
this.$refs[formItem].validate((valid) => { this.$refs[formItem].validate((valid) => {
if (valid) { if (valid) {
if (this.addModal) {//添加 // 点击即转圈,等请求响应成功后再关闭,同时防重复提交
add(this.formItem).then(res => { this.submitLoading = true
const isAdd = this.addModal
const req = isAdd ? add(this.formItem) : update(this.formItem)
req.then(res => {
this.refresh() this.refresh()
this.getTreeSelectList() this.getTreeSelectList()
this.getTreeList() this.getTreeList()
this.getDataList() this.getDataList()
this.$Message.success("添加成功!") this.$Message.success(isAdd ? '添加成功!' : '编辑成功!')
})
} else {//编辑
update(this.formItem).then(res => {
this.refresh()
this.getTreeSelectList()
this.getTreeList()
this.getDataList()
this.$Message.success("编辑成功!")
})
}
this.cancel() this.cancel()
this.submitLoading = false
}).catch(() => {
// 失败保持弹窗打开,方便直接重试
this.submitLoading = false
this.$Message.error(isAdd ? '添加失败,请重试' : '编辑失败,请重试')
})
} }
}) })
}, },
cancel () { cancel () {
// Modal cancel // Modal cancel
this.modal = false; this.modal = false
this.refresh(); this.refresh()
}, },
toDelete (index) { toDelete (index) {
let temp = this.dataList[index] let temp = this.dataList[index]
@@ -366,18 +365,18 @@
remove(data).then(res => { remove(data).then(res => {
this.refresh() this.refresh()
this.getDataList() this.getDataList()
this.$Message.success("删除成功!") this.$Message.success('删除成功!')
}) })
}, },
refresh () { refresh () {
this.pageParam = { this.pageParam = {
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 10
}; }
this.search = { this.search = {
deptName: '', deptName: '',
parentId: this.search.parentId parentId: this.search.parentId
}; }
this.formItem = { this.formItem = {
id: '', id: '',
parentId: '0', parentId: '0',
@@ -385,63 +384,63 @@
deptCode: '', deptCode: '',
level: 0, level: 0,
deptDesc: '', deptDesc: '',
sort: 0, sort: 0
}; }
}, },
changePage (index) { changePage (index) {
// 需要显示开始数据的index,(因为数据是从0开始的,页码是从1开始的,需要-1) // 需要显示开始数据的index,(因为数据是从0开始的,页码是从1开始的,需要-1)
this.pageParam.pageNum = index; this.pageParam.pageNum = index
this.getDataList(); this.getDataList()
}, },
changePageSize (page) { changePageSize (page) {
// 切换分页条数 // 切换分页条数
this.pageParam.pageNum = 1; this.pageParam.pageNum = 1
this.pageParam.pageSize = page; this.pageParam.pageSize = page
this.getDataList(); this.getDataList()
}, },
renderContent (h, { root, node, data }) { renderContent (h, { root, node, data }) {
let icon = ""; let icon = ''
if (data.level === 0) { if (data.level === 0) {
icon = "ios-navigate"; icon = 'ios-navigate'
} else if (data.level === 1) { } else if (data.level === 1) {
icon = "md-planet"; icon = 'md-planet'
} else if (data.level === 2) { } else if (data.level === 2) {
icon = "ios-paper-plane"; icon = 'ios-paper-plane'
} else if (data.level === 3) { } else if (data.level === 3) {
icon = "md-radio"; icon = 'md-radio'
} else { } else {
icon = "md-radio-button-off"; icon = 'md-radio-button-off'
} }
return h( return h(
"span", 'span',
{ {
style: { style: {
display: "inline-block", display: 'inline-block',
cursor: "pointer" cursor: 'pointer'
}, },
on: { on: {
click: () => { click: () => {
data.checked = !data.checked; data.checked = !data.checked
} }
} }
}, },
[ [
h("span", [ h('span', [
h("Icon", { h('Icon', {
props: { props: {
type: icon, type: icon,
size: "16" size: '16'
}, },
style: { style: {
"margin-right": "8px", 'margin-right': '8px',
"margin-bottom": "3px" 'margin-bottom': '3px'
} }
}), }),
h("span", { class: "ivu-tree-title" }, data.title) h('span', { class: 'ivu-tree-title' }, data.title)
]) ])
] ]
); )
}, }
}, },
created () { created () {
+57 -58
View File
@@ -134,13 +134,13 @@
<script> <script>
import { getTreeList, getTreeSelectList, getDataList, add, update, remove } from '@/api/sys/sys-permission' import { getTreeList, getTreeSelectList, getDataList, add, update, remove } from '@/api/sys/sys-permission'
import {objectUtil, utils, exportExcel} from "@/common/js/util" import { objectUtil } from '@/common/js/util'
import IconChoose from "@/components/my-components/icon-choose" import IconChoose from '@/components/my-components/icon-choose'
import Treeselect from '@riophae/vue-treeselect' import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css' import '@riophae/vue-treeselect/dist/vue-treeselect.css'
export default { export default {
name: "sso-menu", name: 'sso-menu',
components: { components: {
IconChoose, IconChoose,
Treeselect Treeselect
@@ -160,12 +160,12 @@
}, },
listColumns: [ listColumns: [
{ {
title: "#", title: '#',
type: 'index', type: 'index',
width: 60, width: 60,
align: 'center', align: 'center',
indexMethod: (row) => { indexMethod: (row) => {
return (row._index + 1) + ((this.pageParam.pageNum - 1) * this.pageParam.pageSize); return (row._index + 1) + ((this.pageParam.pageNum - 1) * this.pageParam.pageSize)
} }
}, },
{ {
@@ -174,7 +174,7 @@
}, },
{ {
title: '菜单编码', title: '菜单编码',
key: 'permissionCode', key: 'permissionCode'
}, },
{ {
title: '上级菜单', title: '上级菜单',
@@ -199,12 +199,12 @@
}, },
{ {
title: '菜单编码', title: '菜单编码',
key: 'permissionCode', key: 'permissionCode'
}, },
{ {
title: '菜单描述', title: '菜单描述',
key: 'permissionDesc' key: 'permissionDesc'
}, }
], ],
pMenuList: [], // 父级菜单列表 pMenuList: [], // 父级菜单列表
dataList: [], dataList: [],
@@ -232,7 +232,7 @@
url: '', url: '',
component: '', component: '',
status: '1', status: '1',
sort: 0, sort: 0
}, },
ruleCustom: { ruleCustom: {
parentId: [{ parentId: [{
@@ -252,8 +252,8 @@
}], }],
component: [{ component: [{
required: true, message: '请输入组件地址', trigger: 'blur' required: true, message: '请输入组件地址', trigger: 'blur'
}], }]
}, }
} }
}, },
methods: { methods: {
@@ -268,15 +268,15 @@
return return
} }
const wrapStyle = window.getComputedStyle(wrap) const wrapStyle = window.getComputedStyle(wrap)
const avail = wrap.clientHeight const avail = wrap.clientHeight -
- (parseFloat(wrapStyle.paddingTop) || 0) (parseFloat(wrapStyle.paddingTop) || 0) -
- (parseFloat(wrapStyle.paddingBottom) || 0) (parseFloat(wrapStyle.paddingBottom) || 0)
const pageStyle = window.getComputedStyle(page) const pageStyle = window.getComputedStyle(page)
const pageMarginTop = parseFloat(pageStyle.marginTop) || 0 const pageMarginTop = parseFloat(pageStyle.marginTop) || 0
const pageMarginBottom = parseFloat(pageStyle.marginBottom) || 0 const pageMarginBottom = parseFloat(pageStyle.marginBottom) || 0
// 除表格外的固定块:查询区 + 按钮区 + 分页区(含上下外边距) // 除表格外的固定块:查询区 + 按钮区 + 分页区(含上下外边距)
const fixed = option.offsetHeight + btn.offsetHeight const fixed = option.offsetHeight + btn.offsetHeight +
+ page.offsetHeight + pageMarginTop + pageMarginBottom page.offsetHeight + pageMarginTop + pageMarginBottom
this.autoHeight = Math.max(200, avail - fixed) this.autoHeight = Math.max(200, avail - fixed)
// 等表格按新高度重排后再量底边,避免拿到上一帧的位置 // 等表格按新高度重排后再量底边,避免拿到上一帧的位置
this.$nextTick(() => { this.$nextTick(() => {
@@ -291,7 +291,7 @@
}, },
getTreeChoose () { getTreeChoose () {
// 获取选中的节点信息 // 获取选中的节点信息
let choose = this.$refs.tree.getSelectedNodes(); let choose = this.$refs.tree.getSelectedNodes()
if (choose.length > 0) { if (choose.length > 0) {
this.formItem.parentId = choose[0].id this.formItem.parentId = choose[0].id
this.formItem.level = choose[0].level + 1 this.formItem.level = choose[0].level + 1
@@ -325,11 +325,11 @@
}, },
toAdd () { toAdd () {
if (this.formItem.level === 3) { if (this.formItem.level === 3) {
this.$Message.warning("不可以添加子菜单!") this.$Message.warning('不可以添加子菜单!')
return return
} }
this.modalTitle = "添加" this.modalTitle = '添加'
this.addModal = true this.addModal = true
this.editModal = false this.editModal = false
this.modal = true this.modal = true
@@ -341,7 +341,7 @@
}) })
}, },
toEdit (index) { toEdit (index) {
this.modalTitle = "编辑" this.modalTitle = '编辑'
let temp = this.dataList[index] let temp = this.dataList[index]
this.addModal = false this.addModal = false
@@ -369,31 +369,30 @@
// modal 提交 // modal 提交
this.$refs[formItem].validate((valid) => { this.$refs[formItem].validate((valid) => {
if (valid) { if (valid) {
if (this.addModal) {//添加 // 点击即转圈,等请求响应成功后再关闭,同时防重复提交
add(this.formItem).then(res => { this.submitLoading = true
const isAdd = this.addModal
const req = isAdd ? add(this.formItem) : update(this.formItem)
req.then(res => {
this.refresh() this.refresh()
this.getTreeSelectList() this.getTreeSelectList()
this.getTreeList() this.getTreeList()
this.getDataList() this.getDataList()
this.$Message.success("添加成功!") this.$Message.success(isAdd ? '添加成功!' : '编辑成功!')
})
} else {//编辑
update(this.formItem).then(res => {
this.refresh()
this.getTreeSelectList()
this.getTreeList()
this.getDataList()
this.$Message.success("编辑成功!")
})
}
this.cancel() this.cancel()
this.submitLoading = false
}).catch(() => {
// 失败保持弹窗打开,方便直接重试
this.submitLoading = false
this.$Message.error(isAdd ? '添加失败,请重试' : '编辑失败,请重试')
})
} }
}) })
}, },
cancel () { cancel () {
// Modal cancel // Modal cancel
this.modal = false; this.modal = false
this.refresh(); this.refresh()
}, },
toDelete (index) { toDelete (index) {
let temp = this.dataList[index] let temp = this.dataList[index]
@@ -406,18 +405,18 @@
this.getTreeSelectList() this.getTreeSelectList()
this.getTreeList() this.getTreeList()
this.getDataList() this.getDataList()
this.$Message.success("删除成功!") this.$Message.success('删除成功!')
}) })
}, },
refresh () { refresh () {
this.pageParam = { this.pageParam = {
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: 10
}; }
this.search = { this.search = {
permissionName: '', permissionName: '',
parentId: this.search.parentId parentId: this.search.parentId
}; }
this.formItem = { this.formItem = {
id: '', id: '',
parentId: '0', parentId: '0',
@@ -428,52 +427,52 @@
permissionDesc: '', permissionDesc: '',
url: '', url: '',
component: '', component: '',
sort: 0, sort: 0
}; }
}, },
changePage (index) { changePage (index) {
// 需要显示开始数据的index,(因为数据是从0开始的,页码是从1开始的,需要-1) // 需要显示开始数据的index,(因为数据是从0开始的,页码是从1开始的,需要-1)
this.pageParam.pageNum = index; this.pageParam.pageNum = index
this.getDataList(); this.getDataList()
}, },
changePageSize (page) { changePageSize (page) {
// 切换分页条数 // 切换分页条数
this.pageParam.pageNum = 1; this.pageParam.pageNum = 1
this.pageParam.pageSize = page; this.pageParam.pageSize = page
this.getDataList(); this.getDataList()
}, },
renderContent (h, { root, node, data }) { renderContent (h, { root, node, data }) {
let icon = data.icon; let icon = data.icon
return h( return h(
"span", 'span',
{ {
style: { style: {
display: "inline-block", display: 'inline-block',
cursor: "pointer" cursor: 'pointer'
}, },
on: { on: {
click: () => { click: () => {
data.checked = !data.checked; data.checked = !data.checked
} }
} }
}, },
[ [
h("span", [ h('span', [
h("Icon", { h('Icon', {
props: { props: {
type: icon, type: icon,
size: "16" size: '16'
}, },
style: { style: {
"margin-right": "8px", 'margin-right': '8px',
"margin-bottom": "3px" 'margin-bottom': '3px'
} }
}), }),
h("span", {class: "ivu-tree-title"}, data.title) h('span', { class: 'ivu-tree-title' }, data.title)
]) ])
] ]
); )
}, }
}, },
created () { created () {
this.getTreeList() this.getTreeList()
+13 -12
View File
@@ -142,7 +142,7 @@
import { getTreeListByRoleId } from '@/api/sys/sys-permission' import { getTreeListByRoleId } from '@/api/sys/sys-permission'
import { getDataList, add, update, remove, addRolePermission } from '@/api/sys/sys-role' import { getDataList, add, update, remove, addRolePermission } from '@/api/sys/sys-role'
import { getTreeSelectList } from '@/api/sys/sys-dept' import { getTreeSelectList } from '@/api/sys/sys-dept'
import { objectUtil, utils, exportExcel } from '@/common/js/util' import { objectUtil } from '@/common/js/util'
import Treeselect from '@riophae/vue-treeselect' import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css' import '@riophae/vue-treeselect/dist/vue-treeselect.css'
@@ -313,20 +313,21 @@ export default {
// modal 提交 // modal 提交
this.$refs[formItem].validate((valid) => { this.$refs[formItem].validate((valid) => {
if (valid) { if (valid) {
if (this.addModal) { // 添加 // 点击即转圈,等请求响应成功后再关闭,避免无反馈像卡住,同时防重复提交
add(this.formItem).then(res => { this.submitLoading = true
const isAdd = this.addModal
const req = isAdd ? add(this.formItem) : update(this.formItem)
req.then(res => {
this.refresh() this.refresh()
this.getDataList() this.getDataList()
this.$Message.success('添加成功!') this.$Message.success(isAdd ? '添加成功!' : '编辑成功!')
})
} else { // 编辑
update(this.formItem).then(res => {
this.refresh()
this.getDataList()
this.$Message.success('编辑成功!')
})
}
this.cancel() this.cancel()
this.submitLoading = false
}).catch(() => {
// 失败保持弹窗打开,方便直接重试
this.submitLoading = false
this.$Message.error(isAdd ? '添加失败,请重试' : '编辑失败,请重试')
})
} }
}) })
}, },
+12 -10
View File
@@ -372,18 +372,20 @@ export default {
userRoleStr: JSON.stringify(userAndRoleArr).toString() userRoleStr: JSON.stringify(userAndRoleArr).toString()
}) })
if (this.addModal) { // 添加 // 点击即转圈,等请求响应成功后再关闭,同时防重复提交
add(data).then(res => { this.submitLoading = true
const isAdd = this.addModal
const req = isAdd ? add(data) : update(data)
req.then(res => {
this.getDataList() this.getDataList()
this.$Message.success('添加成功!') this.$Message.success(isAdd ? '添加成功!' : '编辑成功!')
})
} else { // 编辑
update(data).then(res => {
this.getDataList()
this.$Message.success('编辑成功!')
})
}
this.cancel() this.cancel()
this.submitLoading = false
}).catch(() => {
// 失败保持弹窗打开,方便直接重试
this.submitLoading = false
this.$Message.error(isAdd ? '添加失败,请重试' : '编辑失败,请重试')
})
} }
}) })
}, },