diff --git a/src/views/system/area/editArea.vue b/src/views/system/area/editArea.vue index 11a7868..baadacc 100644 --- a/src/views/system/area/editArea.vue +++ b/src/views/system/area/editArea.vue @@ -16,7 +16,7 @@ - + @@ -45,7 +45,7 @@ @@ -66,6 +66,7 @@ return { dialogFormVisible: false, // 对话框是否显示 dialogStatus: '', // 对话框类型:create,update + isEditMode: true, areaForm: { id: '', // 编号 pid: '', // 父级编号 @@ -81,6 +82,7 @@ update: '编辑', create: '新增' }, // 表头显示标题 + btnLoading: false, // 保存按钮的加载中状态 rules: { id: [{ required: true, message: '区域编号不能为空', trigger: ['blur', 'change'] }], areaName: [{ required: true, message: '区域名称不能为空', trigger: ['blur', 'change'] }], @@ -106,8 +108,10 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() + this.isEditMode = false this.$nextTick(() => { this.$refs['dataForm'].clearValidate() }) @@ -121,6 +125,7 @@ level: '' + row.level, num: row.num // 排序 } + this.isEditMode = true } }, // 获取区域类型 @@ -164,22 +169,26 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.areaForm) if (valid) { + this.btnLoading = true addArea(this.areaForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { confirmButtonText: '是', cancelButtonText: '否', type: 'info' - }).then(() => { + }).then(() => { // 选是 this.resetForm() + this.btnLoading = false this.$nextTick(() => { this.$refs['dataForm'].clearValidate() }) - }).catch(() => { + }).catch(() => { // 选否,关闭窗口,并刷新页面 this.$emit('watchChild') this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -188,6 +197,7 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true updateArea(this.areaForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') @@ -195,6 +205,8 @@ this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/area/editArea.vue b/src/views/system/area/editArea.vue index 11a7868..baadacc 100644 --- a/src/views/system/area/editArea.vue +++ b/src/views/system/area/editArea.vue @@ -16,7 +16,7 @@ - + @@ -45,7 +45,7 @@ @@ -66,6 +66,7 @@ return { dialogFormVisible: false, // 对话框是否显示 dialogStatus: '', // 对话框类型:create,update + isEditMode: true, areaForm: { id: '', // 编号 pid: '', // 父级编号 @@ -81,6 +82,7 @@ update: '编辑', create: '新增' }, // 表头显示标题 + btnLoading: false, // 保存按钮的加载中状态 rules: { id: [{ required: true, message: '区域编号不能为空', trigger: ['blur', 'change'] }], areaName: [{ required: true, message: '区域名称不能为空', trigger: ['blur', 'change'] }], @@ -106,8 +108,10 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() + this.isEditMode = false this.$nextTick(() => { this.$refs['dataForm'].clearValidate() }) @@ -121,6 +125,7 @@ level: '' + row.level, num: row.num // 排序 } + this.isEditMode = true } }, // 获取区域类型 @@ -164,22 +169,26 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.areaForm) if (valid) { + this.btnLoading = true addArea(this.areaForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { confirmButtonText: '是', cancelButtonText: '否', type: 'info' - }).then(() => { + }).then(() => { // 选是 this.resetForm() + this.btnLoading = false this.$nextTick(() => { this.$refs['dataForm'].clearValidate() }) - }).catch(() => { + }).catch(() => { // 选否,关闭窗口,并刷新页面 this.$emit('watchChild') this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -188,6 +197,7 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true updateArea(this.areaForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') @@ -195,6 +205,8 @@ this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/dept/editDept.vue b/src/views/system/dept/editDept.vue index 95123cb..d7a2129 100644 --- a/src/views/system/dept/editDept.vue +++ b/src/views/system/dept/editDept.vue @@ -17,7 +17,7 @@ - + @@ -48,7 +48,7 @@ @@ -94,6 +94,7 @@ value: '04' } ], + btnLoading: false, // 保存按钮的加载中状态 multiData: false, // 组织树是否为多级列表 deptTreeList: [], // 组织树列表数据 textMap: { @@ -124,6 +125,7 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false // this.fetchPcode() if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() @@ -189,6 +191,7 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.deptForm) if (valid) { + this.btnLoading = true addDept(this.deptForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { @@ -196,6 +199,7 @@ cancelButtonText: '否', type: 'info' }).then(() => { + this.btnLoading = false this.resetForm() this.$nextTick(() => { this.$refs['dataForm'].clearValidate() @@ -205,6 +209,8 @@ this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -213,12 +219,16 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true + this.dialogFormVisible = true updateDept(this.deptForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/area/editArea.vue b/src/views/system/area/editArea.vue index 11a7868..baadacc 100644 --- a/src/views/system/area/editArea.vue +++ b/src/views/system/area/editArea.vue @@ -16,7 +16,7 @@ - + @@ -45,7 +45,7 @@ @@ -66,6 +66,7 @@ return { dialogFormVisible: false, // 对话框是否显示 dialogStatus: '', // 对话框类型:create,update + isEditMode: true, areaForm: { id: '', // 编号 pid: '', // 父级编号 @@ -81,6 +82,7 @@ update: '编辑', create: '新增' }, // 表头显示标题 + btnLoading: false, // 保存按钮的加载中状态 rules: { id: [{ required: true, message: '区域编号不能为空', trigger: ['blur', 'change'] }], areaName: [{ required: true, message: '区域名称不能为空', trigger: ['blur', 'change'] }], @@ -106,8 +108,10 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() + this.isEditMode = false this.$nextTick(() => { this.$refs['dataForm'].clearValidate() }) @@ -121,6 +125,7 @@ level: '' + row.level, num: row.num // 排序 } + this.isEditMode = true } }, // 获取区域类型 @@ -164,22 +169,26 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.areaForm) if (valid) { + this.btnLoading = true addArea(this.areaForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { confirmButtonText: '是', cancelButtonText: '否', type: 'info' - }).then(() => { + }).then(() => { // 选是 this.resetForm() + this.btnLoading = false this.$nextTick(() => { this.$refs['dataForm'].clearValidate() }) - }).catch(() => { + }).catch(() => { // 选否,关闭窗口,并刷新页面 this.$emit('watchChild') this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -188,6 +197,7 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true updateArea(this.areaForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') @@ -195,6 +205,8 @@ this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/dept/editDept.vue b/src/views/system/dept/editDept.vue index 95123cb..d7a2129 100644 --- a/src/views/system/dept/editDept.vue +++ b/src/views/system/dept/editDept.vue @@ -17,7 +17,7 @@ - + @@ -48,7 +48,7 @@ @@ -94,6 +94,7 @@ value: '04' } ], + btnLoading: false, // 保存按钮的加载中状态 multiData: false, // 组织树是否为多级列表 deptTreeList: [], // 组织树列表数据 textMap: { @@ -124,6 +125,7 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false // this.fetchPcode() if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() @@ -189,6 +191,7 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.deptForm) if (valid) { + this.btnLoading = true addDept(this.deptForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { @@ -196,6 +199,7 @@ cancelButtonText: '否', type: 'info' }).then(() => { + this.btnLoading = false this.resetForm() this.$nextTick(() => { this.$refs['dataForm'].clearValidate() @@ -205,6 +209,8 @@ this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -213,12 +219,16 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true + this.dialogFormVisible = true updateDept(this.deptForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/dict/editDict.vue b/src/views/system/dict/editDict.vue index 83f92ed..bde4039 100644 --- a/src/views/system/dict/editDict.vue +++ b/src/views/system/dict/editDict.vue @@ -46,7 +46,7 @@ @@ -73,6 +73,7 @@ update: '编辑', create: '新增' }, // 表头显示标题 + btnLoading: false, // 保存按钮的加载中状态 rules: { dictCode: [{ required: true, message: '字典编码不能为空', trigger: ['blur'] }], dictName: [{ required: true, message: '字典名称不能为空', trigger: ['blur'] }], @@ -87,6 +88,7 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false // this.fetchPcode() if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() @@ -149,7 +151,6 @@ // 保存数据 saveData: function() { const flag = this.arrayToString() - debugger if (!flag) { this.$message.warning('请将字典值和名称都填全后再进行保存') } else { @@ -175,6 +176,7 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.dictForm) if (valid) { + this.btnLoading = true addDict(this.dictForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { @@ -182,6 +184,7 @@ cancelButtonText: '否', type: 'info' }).then(() => { + this.btnLoading = false this.resetForm() this.$nextTick(() => { this.$refs['dataForm'].clearValidate() @@ -191,6 +194,8 @@ this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -199,12 +204,15 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true updateDict(this.dictForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/area/editArea.vue b/src/views/system/area/editArea.vue index 11a7868..baadacc 100644 --- a/src/views/system/area/editArea.vue +++ b/src/views/system/area/editArea.vue @@ -16,7 +16,7 @@ - + @@ -45,7 +45,7 @@ @@ -66,6 +66,7 @@ return { dialogFormVisible: false, // 对话框是否显示 dialogStatus: '', // 对话框类型:create,update + isEditMode: true, areaForm: { id: '', // 编号 pid: '', // 父级编号 @@ -81,6 +82,7 @@ update: '编辑', create: '新增' }, // 表头显示标题 + btnLoading: false, // 保存按钮的加载中状态 rules: { id: [{ required: true, message: '区域编号不能为空', trigger: ['blur', 'change'] }], areaName: [{ required: true, message: '区域名称不能为空', trigger: ['blur', 'change'] }], @@ -106,8 +108,10 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() + this.isEditMode = false this.$nextTick(() => { this.$refs['dataForm'].clearValidate() }) @@ -121,6 +125,7 @@ level: '' + row.level, num: row.num // 排序 } + this.isEditMode = true } }, // 获取区域类型 @@ -164,22 +169,26 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.areaForm) if (valid) { + this.btnLoading = true addArea(this.areaForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { confirmButtonText: '是', cancelButtonText: '否', type: 'info' - }).then(() => { + }).then(() => { // 选是 this.resetForm() + this.btnLoading = false this.$nextTick(() => { this.$refs['dataForm'].clearValidate() }) - }).catch(() => { + }).catch(() => { // 选否,关闭窗口,并刷新页面 this.$emit('watchChild') this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -188,6 +197,7 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true updateArea(this.areaForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') @@ -195,6 +205,8 @@ this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/dept/editDept.vue b/src/views/system/dept/editDept.vue index 95123cb..d7a2129 100644 --- a/src/views/system/dept/editDept.vue +++ b/src/views/system/dept/editDept.vue @@ -17,7 +17,7 @@ - + @@ -48,7 +48,7 @@ @@ -94,6 +94,7 @@ value: '04' } ], + btnLoading: false, // 保存按钮的加载中状态 multiData: false, // 组织树是否为多级列表 deptTreeList: [], // 组织树列表数据 textMap: { @@ -124,6 +125,7 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false // this.fetchPcode() if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() @@ -189,6 +191,7 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.deptForm) if (valid) { + this.btnLoading = true addDept(this.deptForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { @@ -196,6 +199,7 @@ cancelButtonText: '否', type: 'info' }).then(() => { + this.btnLoading = false this.resetForm() this.$nextTick(() => { this.$refs['dataForm'].clearValidate() @@ -205,6 +209,8 @@ this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -213,12 +219,16 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true + this.dialogFormVisible = true updateDept(this.deptForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/dict/editDict.vue b/src/views/system/dict/editDict.vue index 83f92ed..bde4039 100644 --- a/src/views/system/dict/editDict.vue +++ b/src/views/system/dict/editDict.vue @@ -46,7 +46,7 @@ @@ -73,6 +73,7 @@ update: '编辑', create: '新增' }, // 表头显示标题 + btnLoading: false, // 保存按钮的加载中状态 rules: { dictCode: [{ required: true, message: '字典编码不能为空', trigger: ['blur'] }], dictName: [{ required: true, message: '字典名称不能为空', trigger: ['blur'] }], @@ -87,6 +88,7 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false // this.fetchPcode() if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() @@ -149,7 +151,6 @@ // 保存数据 saveData: function() { const flag = this.arrayToString() - debugger if (!flag) { this.$message.warning('请将字典值和名称都填全后再进行保存') } else { @@ -175,6 +176,7 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.dictForm) if (valid) { + this.btnLoading = true addDict(this.dictForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { @@ -182,6 +184,7 @@ cancelButtonText: '否', type: 'info' }).then(() => { + this.btnLoading = false this.resetForm() this.$nextTick(() => { this.$refs['dataForm'].clearValidate() @@ -191,6 +194,8 @@ this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -199,12 +204,15 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true updateDict(this.dictForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/role/editRole.vue b/src/views/system/role/editRole.vue index 52f8d62..cc1add3 100644 --- a/src/views/system/role/editRole.vue +++ b/src/views/system/role/editRole.vue @@ -46,7 +46,7 @@ @@ -66,6 +66,7 @@ return { dialogFormVisible: false, // 对话框是否显示 dialogStatus: '', // 对话框类型:create,update + btnLoading: false, // 保存按钮的加载中状态 roleForm: { id: '', // 编号 pid: '', // 父级编号 @@ -111,7 +112,7 @@ return tree } }, - mounted: function() { + created: function() { this.fetchRoleTree() this.fetchDataScopeType() }, @@ -120,6 +121,7 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false this.fetchRoleTree() if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() @@ -150,7 +152,6 @@ // 加载角色树形下拉菜单 fetchRoleTree: function() { getRoleTreeList(this.listQuery).then(response => { - console.log('fetchRoleTree:') console.log(response.data) if (response.data.list) { this.roleTreeList = toTreeList(response.data.list, '0') @@ -184,6 +185,7 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.roleForm) if (valid) { + this.btnLoading = true addRole(this.roleForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { @@ -191,6 +193,7 @@ cancelButtonText: '否', type: 'info' }).then(() => { + this.btnLoading = false this.resetForm() this.$nextTick(() => { this.$refs['dataForm'].clearValidate() @@ -201,6 +204,8 @@ this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -209,12 +214,15 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true updateRole(this.roleForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/area/editArea.vue b/src/views/system/area/editArea.vue index 11a7868..baadacc 100644 --- a/src/views/system/area/editArea.vue +++ b/src/views/system/area/editArea.vue @@ -16,7 +16,7 @@ - + @@ -45,7 +45,7 @@ @@ -66,6 +66,7 @@ return { dialogFormVisible: false, // 对话框是否显示 dialogStatus: '', // 对话框类型:create,update + isEditMode: true, areaForm: { id: '', // 编号 pid: '', // 父级编号 @@ -81,6 +82,7 @@ update: '编辑', create: '新增' }, // 表头显示标题 + btnLoading: false, // 保存按钮的加载中状态 rules: { id: [{ required: true, message: '区域编号不能为空', trigger: ['blur', 'change'] }], areaName: [{ required: true, message: '区域名称不能为空', trigger: ['blur', 'change'] }], @@ -106,8 +108,10 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() + this.isEditMode = false this.$nextTick(() => { this.$refs['dataForm'].clearValidate() }) @@ -121,6 +125,7 @@ level: '' + row.level, num: row.num // 排序 } + this.isEditMode = true } }, // 获取区域类型 @@ -164,22 +169,26 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.areaForm) if (valid) { + this.btnLoading = true addArea(this.areaForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { confirmButtonText: '是', cancelButtonText: '否', type: 'info' - }).then(() => { + }).then(() => { // 选是 this.resetForm() + this.btnLoading = false this.$nextTick(() => { this.$refs['dataForm'].clearValidate() }) - }).catch(() => { + }).catch(() => { // 选否,关闭窗口,并刷新页面 this.$emit('watchChild') this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -188,6 +197,7 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true updateArea(this.areaForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') @@ -195,6 +205,8 @@ this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/dept/editDept.vue b/src/views/system/dept/editDept.vue index 95123cb..d7a2129 100644 --- a/src/views/system/dept/editDept.vue +++ b/src/views/system/dept/editDept.vue @@ -17,7 +17,7 @@ - + @@ -48,7 +48,7 @@ @@ -94,6 +94,7 @@ value: '04' } ], + btnLoading: false, // 保存按钮的加载中状态 multiData: false, // 组织树是否为多级列表 deptTreeList: [], // 组织树列表数据 textMap: { @@ -124,6 +125,7 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false // this.fetchPcode() if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() @@ -189,6 +191,7 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.deptForm) if (valid) { + this.btnLoading = true addDept(this.deptForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { @@ -196,6 +199,7 @@ cancelButtonText: '否', type: 'info' }).then(() => { + this.btnLoading = false this.resetForm() this.$nextTick(() => { this.$refs['dataForm'].clearValidate() @@ -205,6 +209,8 @@ this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -213,12 +219,16 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true + this.dialogFormVisible = true updateDept(this.deptForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/dict/editDict.vue b/src/views/system/dict/editDict.vue index 83f92ed..bde4039 100644 --- a/src/views/system/dict/editDict.vue +++ b/src/views/system/dict/editDict.vue @@ -46,7 +46,7 @@ @@ -73,6 +73,7 @@ update: '编辑', create: '新增' }, // 表头显示标题 + btnLoading: false, // 保存按钮的加载中状态 rules: { dictCode: [{ required: true, message: '字典编码不能为空', trigger: ['blur'] }], dictName: [{ required: true, message: '字典名称不能为空', trigger: ['blur'] }], @@ -87,6 +88,7 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false // this.fetchPcode() if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() @@ -149,7 +151,6 @@ // 保存数据 saveData: function() { const flag = this.arrayToString() - debugger if (!flag) { this.$message.warning('请将字典值和名称都填全后再进行保存') } else { @@ -175,6 +176,7 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.dictForm) if (valid) { + this.btnLoading = true addDict(this.dictForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { @@ -182,6 +184,7 @@ cancelButtonText: '否', type: 'info' }).then(() => { + this.btnLoading = false this.resetForm() this.$nextTick(() => { this.$refs['dataForm'].clearValidate() @@ -191,6 +194,8 @@ this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -199,12 +204,15 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true updateDict(this.dictForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/role/editRole.vue b/src/views/system/role/editRole.vue index 52f8d62..cc1add3 100644 --- a/src/views/system/role/editRole.vue +++ b/src/views/system/role/editRole.vue @@ -46,7 +46,7 @@ @@ -66,6 +66,7 @@ return { dialogFormVisible: false, // 对话框是否显示 dialogStatus: '', // 对话框类型:create,update + btnLoading: false, // 保存按钮的加载中状态 roleForm: { id: '', // 编号 pid: '', // 父级编号 @@ -111,7 +112,7 @@ return tree } }, - mounted: function() { + created: function() { this.fetchRoleTree() this.fetchDataScopeType() }, @@ -120,6 +121,7 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false this.fetchRoleTree() if (dialogStatus === 'create') { // 如果是新增,清除验证 this.resetForm() @@ -150,7 +152,6 @@ // 加载角色树形下拉菜单 fetchRoleTree: function() { getRoleTreeList(this.listQuery).then(response => { - console.log('fetchRoleTree:') console.log(response.data) if (response.data.list) { this.roleTreeList = toTreeList(response.data.list, '0') @@ -184,6 +185,7 @@ this.$refs['dataForm'].validate((valid) => { console.log(this.roleForm) if (valid) { + this.btnLoading = true addRole(this.roleForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { @@ -191,6 +193,7 @@ cancelButtonText: '否', type: 'info' }).then(() => { + this.btnLoading = false this.resetForm() this.$nextTick(() => { this.$refs['dataForm'].clearValidate() @@ -201,6 +204,8 @@ this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -209,12 +214,15 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true updateRole(this.roleForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) diff --git a/src/views/system/user/editUser.vue b/src/views/system/user/editUser.vue index e3405d4..a9ba171 100644 --- a/src/views/system/user/editUser.vue +++ b/src/views/system/user/editUser.vue @@ -79,7 +79,7 @@ @@ -186,7 +186,8 @@ trigger: ['blur', 'change'] }] }, // 前端校验规则 roleName: '', - deptShow: true + deptShow: true, + btnLoading: false // 保存按钮的加载中状态 } }, computed: { @@ -204,6 +205,7 @@ initDialog: function(dialogStatus, dialogFormVisible, row = null) { this.dialogStatus = dialogStatus this.dialogFormVisible = dialogFormVisible + this.btnLoading = false this.fetchRoleTree() if (dialogStatus === 'create') { // 如果是新增,清除验证 this.ifdisabled = false @@ -269,6 +271,7 @@ const userForm = JSON.parse(JSON.stringify(this.userForm)) userForm.password = RSAencrypt(userForm.password) if (valid) { + this.btnLoading = true addUser(userForm).then(response => { if (response.code === 200) { this.$confirm('新增成功,是否继续新增?', '提示', { @@ -276,6 +279,7 @@ cancelButtonText: '否', type: 'info' }).then(() => { + this.btnLoading = false this.resetForm() this.$nextTick(() => { this.$refs['dataForm'].clearValidate() @@ -285,6 +289,8 @@ this.dialogFormVisible = false }) } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } }) @@ -293,12 +299,15 @@ updateData: function() { this.$refs['dataForm'].validate((valid) => { if (valid) { + this.btnLoading = true updateUser(this.userForm).then(response => { if (response.code === 200) { this.$message.success('修改成功') this.$emit('watchChild') this.dialogFormVisible = false } + }).catch(_ => { // 异常情况,loading置为false + this.btnLoading = false }) } })