从Element-plus中导入消息弹出框组件 新建type文件夹,新建baseType.ts文件 定义通用函数类型,新增和编辑的状态数字 在main.ts文件下从myConfirm.ts文件中引入消息弹出框组件,进行全局注册 在api/user/index.ts文件中配置编辑接口put请求 在views/user/AddUser.vue文件中 改写show函数,增加判断, 当row值不为空时,此时调用者为编辑按钮 添加回显数据功能 改写表单提交事件 通过type判断,使新增、编辑功能分别对应各自接口 完成用户编辑功能后端接口的对接pull/31/head
parent
c97cd4c600
commit
d472c8674b
@ -0,0 +1,12 @@
|
||||
import { getCurrentInstance } from "vue";
|
||||
import type { ComponentInternalInstance } from "vue";
|
||||
|
||||
export default function useInstance() {
|
||||
const { appContext, proxy } = getCurrentInstance() as ComponentInternalInstance
|
||||
// 获取全局属性
|
||||
const global = appContext.config.globalProperties
|
||||
return {
|
||||
global,
|
||||
proxy
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
// 通用函数类型
|
||||
export type FuncList = () => any
|
||||
|
||||
// 新增和编辑的状态
|
||||
export enum EditType{
|
||||
ADD = '0', //新增
|
||||
EDIT = '1' //编辑
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
// 从Element-plus中导入消息弹出框组件
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
|
||||
export default function myConfirm(text: string): Promise<boolean> {
|
||||
return ElMessageBox.confirm(text, '系统提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => true)
|
||||
.catch(() => false)
|
||||
}
|
||||
Loading…
Reference in new issue