diff --git a/server/resource/template/server/service.go.tpl b/server/resource/template/server/service.go.tpl index 1e55e51c..2137b06e 100644 --- a/server/resource/template/server/service.go.tpl +++ b/server/resource/template/server/service.go.tpl @@ -24,7 +24,7 @@ func Create{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) //@return: err error func Delete{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) { - err = global.GVA_DB.Delete({{.Abbreviation}}).Error + err = global.GVA_DB.Delete(&{{.Abbreviation}}).Error return err } diff --git a/server/resource/template/web/table.vue.tpl b/server/resource/template/web/table.vue.tpl index d107f691..247d3fa6 100644 --- a/server/resource/template/web/table.vue.tpl +++ b/server/resource/template/web/table.vue.tpl @@ -227,6 +227,9 @@ export default { type: 'success', message: '删除成功' }) + if (this.tableData.length == ids.length) { + this.page--; + } this.deleteVisible = false this.getTableData() } @@ -269,6 +272,9 @@ export default { type: "success", message: "删除成功" }); + if (this.tableData.length == 1) { + this.page--; + } this.getTableData(); } }, diff --git a/server/service/exa_customer.go b/server/service/exa_customer.go index f9d1d68f..a304d091 100644 --- a/server/service/exa_customer.go +++ b/server/service/exa_customer.go @@ -24,7 +24,7 @@ func CreateExaCustomer(e model.ExaCustomer) (err error) { //@return: err error func DeleteExaCustomer(e model.ExaCustomer) (err error) { - err = global.GVA_DB.Delete(e).Error + err = global.GVA_DB.Delete(&e).Error return err } diff --git a/server/service/exa_file_upload_download.go b/server/service/exa_file_upload_download.go index 36b521b3..bc4c0904 100644 --- a/server/service/exa_file_upload_download.go +++ b/server/service/exa_file_upload_download.go @@ -42,10 +42,10 @@ func DeleteFile(file model.ExaFileUploadAndDownload) (err error) { var fileFromDb model.ExaFileUploadAndDownload err, fileFromDb = FindFile(file.ID) oss := upload.NewOss() - if err = oss.DeleteFile(fileFromDb.Key); err != nil{ + if err = oss.DeleteFile(fileFromDb.Key); err != nil { return errors.New("文件删除失败") } - err = global.GVA_DB.Where("id = ?", file.ID).Unscoped().Delete(file).Error + err = global.GVA_DB.Where("id = ?", file.ID).Unscoped().Delete(&file).Error return err } diff --git a/server/service/sys_api.go b/server/service/sys_api.go index 40df486d..613876d1 100644 --- a/server/service/sys_api.go +++ b/server/service/sys_api.go @@ -28,7 +28,7 @@ func CreateApi(api model.SysApi) (err error) { //@return: err error func DeleteApi(api model.SysApi) (err error) { - err = global.GVA_DB.Delete(api).Error + err = global.GVA_DB.Delete(&api).Error ClearCasbin(1, api.Path, api.Method) return err } diff --git a/server/service/sys_dictionary.go b/server/service/sys_dictionary.go index 6a0dc0ce..4f7251df 100644 --- a/server/service/sys_dictionary.go +++ b/server/service/sys_dictionary.go @@ -29,7 +29,7 @@ func CreateSysDictionary(sysDictionary model.SysDictionary) (err error) { //@return: err error func DeleteSysDictionary(sysDictionary model.SysDictionary) (err error) { - err = global.GVA_DB.Delete(sysDictionary).Delete(&sysDictionary.SysDictionaryDetails).Error + err = global.GVA_DB.Delete(&sysDictionary).Delete(&sysDictionary.SysDictionaryDetails).Error return err } diff --git a/server/service/sys_dictionary_detail.go b/server/service/sys_dictionary_detail.go index 5d5cd7fd..bbd94d54 100644 --- a/server/service/sys_dictionary_detail.go +++ b/server/service/sys_dictionary_detail.go @@ -24,7 +24,7 @@ func CreateSysDictionaryDetail(sysDictionaryDetail model.SysDictionaryDetail) (e //@return: err error func DeleteSysDictionaryDetail(sysDictionaryDetail model.SysDictionaryDetail) (err error) { - err = global.GVA_DB.Delete(sysDictionaryDetail).Error + err = global.GVA_DB.Delete(&sysDictionaryDetail).Error return err } diff --git a/server/service/sys_operation_record.go b/server/service/sys_operation_record.go index 2e3b53da..8cd85d58 100644 --- a/server/service/sys_operation_record.go +++ b/server/service/sys_operation_record.go @@ -36,7 +36,7 @@ func DeleteSysOperationRecordByIds(ids request.IdsReq) (err error) { //@return: err error func DeleteSysOperationRecord(sysOperationRecord model.SysOperationRecord) (err error) { - err = global.GVA_DB.Delete(sysOperationRecord).Error + err = global.GVA_DB.Delete(&sysOperationRecord).Error return err } diff --git a/server/service/sys_workflow.go b/server/service/sys_workflow.go index d18355de..715eb8ab 100644 --- a/server/service/sys_workflow.go +++ b/server/service/sys_workflow.go @@ -36,12 +36,12 @@ func CreateWorkflowProcess(workflowProcess model.WorkflowProcess) (err error) { func DeleteWorkflowProcess(workflowProcess model.WorkflowProcess) (err error) { err = global.GVA_DB.Transaction(func(tx *gorm.DB) error { var txErr error - txErr = tx.Delete(workflowProcess).Error + txErr = tx.Delete(&workflowProcess).Error if txErr != nil { return txErr } var edges []model.WorkflowEdge - txErr = tx.Delete(model.WorkflowNode{}, "workflow_process_id = ?", workflowProcess.ID).Error + txErr = tx.Delete(&model.WorkflowNode{}, "workflow_process_id = ?", workflowProcess.ID).Error if txErr != nil { return txErr } @@ -86,7 +86,7 @@ func UpdateWorkflowProcess(workflowProcess *model.WorkflowProcess) (err error) { if txErr != nil { return txErr } - txErr = tx.Unscoped().Delete(model.WorkflowNode{}, "workflow_process_id = ?", workflowProcess.ID).Error + txErr = tx.Unscoped().Delete(&model.WorkflowNode{}, "workflow_process_id = ?", workflowProcess.ID).Error if txErr != nil { return txErr } @@ -101,11 +101,11 @@ func UpdateWorkflowProcess(workflowProcess *model.WorkflowProcess) (err error) { for _, v := range edges { edgesIds = append(edgesIds, v.ID) } - txErr = tx.Unscoped().Delete(model.WorkflowStartPoint{}, "workflow_edge_id in ?", edgesIds).Error + txErr = tx.Unscoped().Delete(&model.WorkflowStartPoint{}, "workflow_edge_id in ?", edgesIds).Error if txErr != nil { return txErr } - txErr = tx.Unscoped().Delete(model.WorkflowEndPoint{}, "workflow_edge_id in ?", edgesIds).Error + txErr = tx.Unscoped().Delete(&model.WorkflowEndPoint{}, "workflow_edge_id in ?", edgesIds).Error if txErr != nil { return txErr } diff --git a/web/src/view/example/customer/customer.vue b/web/src/view/example/customer/customer.vue index ea9c3cd6..df0aa501 100644 --- a/web/src/view/example/customer/customer.vue +++ b/web/src/view/example/customer/customer.vue @@ -62,7 +62,7 @@ 确 定 -
在资源权限中将此角色的资源权限清空 或者不包含创建者的角色 即可屏蔽此客户资源的显示
+
在资源权限中将此角色的资源权限清空 或者不包含创建者的角色 即可屏蔽此客户资源的显示
@@ -124,8 +124,11 @@ export default { if (res.code == 0) { this.$message({ type: "success", - message: "删除成功" + message: "" }); + if (this.tableData.length == 1) { + this.page--; + } this.getTableData(); } }, diff --git a/web/src/view/example/upload/upload.vue b/web/src/view/example/upload/upload.vue index 8e7684de..fc06a89c 100644 --- a/web/src/view/example/upload/upload.vue +++ b/web/src/view/example/upload/upload.vue @@ -12,9 +12,7 @@ :show-file-list="false" > 点击上传 -
- 只能上传jpg/png文件,且不超过500kb -
+
只能上传jpg/png文件,且不超过500kb
@@ -35,33 +33,20 @@
{{ scope.row.UpdatedAt | formatDate }}
- - + + @@ -93,7 +78,7 @@ export default { mixins: [infoList], components: { CustomPic, - UploadImage, + UploadImage }, data() { return { @@ -101,43 +86,46 @@ export default { listApi: getFileList, path: path, tableData: [], - imageUrl: "", + imageUrl: "" }; }, computed: { - ...mapGetters("user", ["userInfo", "token"]), + ...mapGetters("user", ["userInfo", "token"]) }, filters: { - formatDate: function (time) { + formatDate: function(time) { if (time != null && time != "") { var date = new Date(time); return formatTimeToStr(date, "yyyy-MM-dd hh:mm:ss"); } else { return ""; } - }, + } }, methods: { async deleteFile(row) { this.$confirm("此操作将永久文件, 是否继续?", "提示", { confirmButtonText: "确定", cancelButtonText: "取消", - type: "warning", + type: "warning" }) .then(async () => { const res = await deleteFile(row); if (res.code == 0) { this.$message({ type: "success", - message: "删除成功!", + message: "删除成功!" }); + if (this.tableData.length == 1) { + this.page--; + } this.getTableData(); } }) .catch(() => { this.$message({ type: "info", - message: "已取消删除", + message: "已取消删除" }); }); }, @@ -161,7 +149,7 @@ export default { if (res.code == 0) { this.$message({ type: "success", - message: "上传成功", + message: "上传成功" }); if (res.code == 0) { this.getTableData(); @@ -169,23 +157,23 @@ export default { } else { this.$message({ type: "warning", - message: res.msg, + message: res.msg }); } }, uploadError() { this.$message({ type: "error", - message: "上传失败", + message: "上传失败" }); this.fullscreenLoading = false; }, downloadFile(row) { downloadImage(row.url, row.name); - }, + } }, created() { this.getTableData(); - }, + } }; diff --git a/web/src/view/superAdmin/api/api.vue b/web/src/view/superAdmin/api/api.vue index 827f4b68..14942513 100644 --- a/web/src/view/superAdmin/api/api.vue +++ b/web/src/view/superAdmin/api/api.vue @@ -52,7 +52,12 @@ @@ -108,194 +113,197 @@ import { createApi, updateApi, deleteApi -} from '@/api/api' -import infoList from '@/mixins/infoList' -import { toSQLLine } from '@/utils/stringFun' +} from "@/api/api"; +import infoList from "@/mixins/infoList"; +import { toSQLLine } from "@/utils/stringFun"; const methodOptions = [ { - value: 'POST', - label: '创建', - type: 'success' + value: "POST", + label: "创建", + type: "success" }, { - value: 'GET', - label: '查看', - type: '' + value: "GET", + label: "查看", + type: "" }, { - value: 'PUT', - label: '更新', - type: 'warning' + value: "PUT", + label: "更新", + type: "warning" }, { - value: 'DELETE', - label: '删除', - type: 'danger' + value: "DELETE", + label: "删除", + type: "danger" } -] +]; export default { - name: 'Api', + name: "Api", mixins: [infoList], data() { return { listApi: getApiList, dialogFormVisible: false, - dialogTitle: '新增Api', + dialogTitle: "新增Api", form: { - path: '', - apiGroup: '', - method: '', - description: '' + path: "", + apiGroup: "", + method: "", + description: "" }, methodOptions: methodOptions, - type: '', + type: "", rules: { - path: [{ required: true, message: '请输入api路径', trigger: 'blur' }], + path: [{ required: true, message: "请输入api路径", trigger: "blur" }], apiGroup: [ - { required: true, message: '请输入组名称', trigger: 'blur' } + { required: true, message: "请输入组名称", trigger: "blur" } ], method: [ - { required: true, message: '请选择请求方式', trigger: 'blur' } + { required: true, message: "请选择请求方式", trigger: "blur" } ], description: [ - { required: true, message: '请输入api介绍', trigger: 'blur' } + { required: true, message: "请输入api介绍", trigger: "blur" } ] } - } + }; }, methods: { // 排序 sortChange({ prop, order }) { if (prop) { - this.searchInfo.orderKey = toSQLLine(prop) - this.searchInfo.desc = order == 'descending' + this.searchInfo.orderKey = toSQLLine(prop); + this.searchInfo.desc = order == "descending"; } - this.getTableData() + this.getTableData(); }, //条件搜索前端看此方法 onSubmit() { - this.page = 1 - this.pageSize = 10 - this.getTableData() + this.page = 1; + this.pageSize = 10; + this.getTableData(); }, initForm() { - this.$refs.apiForm.resetFields() - this.form= { - path: '', - apiGroup: '', - method: '', - description: '' - } + this.$refs.apiForm.resetFields(); + this.form = { + path: "", + apiGroup: "", + method: "", + description: "" + }; }, closeDialog() { - this.initForm() - this.dialogFormVisible = false + this.initForm(); + this.dialogFormVisible = false; }, openDialog(type) { switch (type) { - case 'addApi': - this.dialogTitlethis = '新增Api' - break - case 'edit': - this.dialogTitlethis = '编辑Api' - break + case "addApi": + this.dialogTitlethis = "新增Api"; + break; + case "edit": + this.dialogTitlethis = "编辑Api"; + break; default: - break + break; } - this.type = type - this.dialogFormVisible = true + this.type = type; + this.dialogFormVisible = true; }, async editApi(row) { - const res = await getApiById({ id: row.ID }) - this.form = res.data.api - this.openDialog('edit') + const res = await getApiById({ id: row.ID }); + this.form = res.data.api; + this.openDialog("edit"); }, async deleteApi(row) { - this.$confirm('此操作将永久删除所有角色下该菜单, 是否继续?', '提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning' + this.$confirm("此操作将永久删除所有角色下该api, 是否继续?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning" }) .then(async () => { - const res = await deleteApi(row) + const res = await deleteApi(row); if (res.code == 0) { this.$message({ - type: 'success', - message: '删除成功!' - }) - this.getTableData() + type: "success", + message: "删除成功!" + }); + if (this.tableData.length == 1) { + this.page--; + } + this.getTableData(); } }) .catch(() => { this.$message({ - type: 'info', - message: '已取消删除' - }) - }) + type: "info", + message: "已取消删除" + }); + }); }, async enterDialog() { this.$refs.apiForm.validate(async valid => { if (valid) { switch (this.type) { - case 'addApi': + case "addApi": { - const res = await createApi(this.form) + const res = await createApi(this.form); if (res.code == 0) { this.$message({ - type: 'success', - message: '添加成功', + type: "success", + message: "添加成功", showClose: true - }) + }); } - this.getTableData() - this.closeDialog() + this.getTableData(); + this.closeDialog(); } - break - case 'edit': + break; + case "edit": { - const res = await updateApi(this.form) + const res = await updateApi(this.form); if (res.code == 0) { this.$message({ - type: 'success', - message: '编辑成功', + type: "success", + message: "编辑成功", showClose: true - }) + }); } - this.getTableData() - this.closeDialog() + this.getTableData(); + this.closeDialog(); } - break + break; default: { this.$message({ - type: 'error', - message: '未知操作', + type: "error", + message: "未知操作", showClose: true - }) + }); } - break + break; } } - }) + }); } }, filters: { methodFiletr(value) { - const target = methodOptions.filter(item => item.value === value)[0] + const target = methodOptions.filter(item => item.value === value)[0]; // return target && `${target.label}(${target.value})` - return target && `${target.label}` + return target && `${target.label}`; }, tagTypeFiletr(value) { - const target = methodOptions.filter(item => item.value === value)[0] - return target && `${target.type}` + const target = methodOptions.filter(item => item.value === value)[0]; + return target && `${target.type}`; } }, - created(){ - this.getTableData() + created() { + this.getTableData(); } -} +};