Browse Source

更新ICRUD类型

tongshangming 6 months ago
parent
commit
953e5164c7

+ 4 - 4
.vscode/vue.code-snippets

@@ -26,16 +26,16 @@
       "import { ${0} } from '@/api/'",
       "",
       "const CRUD: ICRUD = {",
-      "\tcreate(data: any) {",
+      "\tcreate(data) {",
       "\t\t",
       "\t},",
-      "\tupdate(data: any) {",
+      "\tupdate(data) {",
       "\t\t",
       "\t},",
-      "\tgetList(data: any) {",
+      "\tgetList(data) {",
       "\t\t",
       "\t},",
-      "\tdelete(data: any) {",
+      "\tdelete(data) {",
       "\t\t",
       "\t}",
       "}",

+ 4 - 4
plop-template/view.hbs

@@ -3,16 +3,16 @@ import { create{{pascalCase name}}, update{{pascalCase name}}, get{{pascalCase n
 import type { BasicForm, ICRUD } from '@/types/form'
 
 const CRUD: ICRUD = {
-  create(data: any) {
+  create(data) {
     return create{{pascalCase name}}(data)
   },
-  update(data: any) {
+  update(data) {
     return update{{pascalCase name}}(data)
   },
-  getList(data: any) {
+  getList(data) {
     return get{{pascalCase name}}List(data)
   },
-  delete(data: any) {
+  delete(data) {
     return del{{pascalCase name}}(data)
   }
 }

+ 7 - 7
src/types/form.ts

@@ -1,4 +1,4 @@
-import type { FormProps, FormItemRule } from 'element-plus'
+import type { FormProps, FormItemRule, dayjs } from 'element-plus'
 
 export type FormSlot = {
   name: string
@@ -49,10 +49,10 @@ export type AdvancedForm = Form & {
 }
 
 export interface ICRUD {
-  create: Function
-  update: Function
-  delete: Function
-  deleteBatch?: Function
-  getList: Function
-  getRecord?: Function
+  create: (data: { [key: string]: any }) => Promise<any>
+  update: (data: { [key: string]: any }) => Promise<any>
+  delete: ({ id }: { id: string }) => Promise<any>
+  deleteBatch?: ({ ids }: { ids: string }) => Promise<any>
+  getList: (data: { pageSize: number; pageNo: number; [key: string]: any }) => Promise<any>
+  getRecord?: ({ id }: { id: string }) => Promise<any>
 }

+ 4 - 4
src/views/list/CardList.vue

@@ -3,10 +3,10 @@ import type { BasicForm, ICRUD } from '@/types/form'
 
 const CRUD: ICRUD = {
   create(data: any) {
-    console.log(data)
+    return new Promise(resolve => console.log(data))
   },
   update(data: any) {
-    console.log(data)
+    return new Promise(resolve => console.log(data))
   },
   getList() {
     return new Promise(resolve => {
@@ -28,10 +28,10 @@ const CRUD: ICRUD = {
     })
   },
   delete(data: any) {
-    console.log(data)
+    return new Promise(resolve => console.log(data))
   },
   deleteBatch(data: any) {
-    console.log(data)
+    return new Promise(resolve => console.log(data))
   }
 }
 

+ 4 - 4
src/views/miniprogram/Banner.vue

@@ -3,16 +3,16 @@ import type { BasicForm, ICRUD } from '@/types/form'
 import { getBannerList, saveBanner, deleteBanner } from '@/api/miniprogram'
 
 const CRUD: ICRUD = {
-  create(data: any) {
+  create(data) {
     return saveBanner(data)
   },
-  update(data: any) {
+  update(data) {
     return saveBanner(data)
   },
-  getList(data: any) {
+  getList(data) {
     return getBannerList(data)
   },
-  delete(data: any) {
+  delete(data) {
     return deleteBanner(data)
   }
 }

+ 4 - 4
src/views/miniprogram/Feedback.vue

@@ -4,16 +4,16 @@ import type { BasicForm, ICRUD } from '@/types/form'
 import { getAdviceList, saveAdvice, deleteAdvice } from '@/api/miniprogram'
 
 const CRUD: ICRUD = {
-  create(data: any) {
+  create(data) {
     return saveAdvice(data)
   },
-  update(data: any) {
+  update(data) {
     return Promise.resolve(data)
   },
-  getList(data: any) {
+  getList(data) {
     return getAdviceList(data)
   },
-  delete(data: any) {
+  delete(data) {
     return deleteAdvice(data)
   }
 }

+ 6 - 6
src/views/miniprogram/Question.vue

@@ -3,20 +3,20 @@ import type { BasicForm, ICRUD } from '@/types/form'
 import { getQuestionList, saveQuestion, deleteQuestion } from '@/api/miniprogram'
 
 const CRUD: ICRUD = {
-  create(data: any) {
+  create(data) {
     return saveQuestion(data)
   },
-  update(data: any) {
+  update(data) {
     return saveQuestion(data)
   },
-  getList(data: any) {
+  getList(data) {
     return getQuestionList(data)
   },
-  delete(data: any) {
+  delete(data) {
     return deleteQuestion({ ids: data.id })
   },
-  deleteBatch(data: any) {
-    return deleteQuestion({ ids: data.id })
+  deleteBatch(data) {
+    return deleteQuestion({ ids: data.ids })
   }
 }
 

+ 4 - 4
src/views/miniprogram/Version.vue

@@ -3,20 +3,20 @@ import type { BasicForm, ICRUD } from '@/types/form'
 import { getVersionList, saveVersion, deleteVersion } from '@/api/miniprogram'
 
 const CRUD: ICRUD = {
-  create(data: any) {
+  create(data) {
     return saveVersion(data)
   },
-  update(data: any) {
+  update(data) {
     return saveVersion(data)
   },
-  getList(data: any) {
+  getList(data) {
     return getVersionList(data).then((res: any) => {
       return {
         list: res
       }
     })
   },
-  delete(data: any) {
+  delete(data) {
     return deleteVersion({
       ids: data.id
     })

+ 8 - 8
src/views/monitor/LogList.vue

@@ -2,11 +2,11 @@
 import type { BasicForm, ICRUD } from '@/types/form'
 
 const CRUD: ICRUD = {
-  create(data: any) {
-    console.log(data)
+  create(data) {
+    return new Promise(resolve => console.log(data))
   },
-  update(data: any) {
-    console.log(data)
+  update(data) {
+    return new Promise(resolve => console.log(data))
   },
   getList() {
     return new Promise(resolve => {
@@ -16,11 +16,11 @@ const CRUD: ICRUD = {
       })
     })
   },
-  delete(data: any) {
-    console.log(data)
+  delete(data) {
+    return new Promise(resolve => console.log(data))
   },
-  deleteBatch(data: any) {
-    console.log(data)
+  deleteBatch(data) {
+    return new Promise(resolve => console.log(data))
   }
 }
 

+ 8 - 8
src/views/monitor/MessageNotif.vue

@@ -2,11 +2,11 @@
 import type { BasicForm, ICRUD } from '@/types/form'
 
 const CRUD: ICRUD = {
-  create(data: any) {
-    console.log(data)
+  create(data) {
+    return new Promise(resolve => console.log(data))
   },
-  update(data: any) {
-    console.log(data)
+  update(data) {
+    return new Promise(resolve => console.log(data))
   },
   getList() {
     return new Promise(resolve => {
@@ -35,11 +35,11 @@ const CRUD: ICRUD = {
       })
     })
   },
-  delete(data: any) {
-    console.log(data)
+  delete(data) {
+    return new Promise(resolve => console.log(data))
   },
-  deleteBatch(data: any) {
-    console.log(data)
+  deleteBatch(data) {
+    return new Promise(resolve => console.log(data))
   }
 }
 

+ 8 - 8
src/views/system/Dict.vue

@@ -3,13 +3,13 @@ import type { BasicForm, ICRUD } from '@/types/form'
 import { getDictList, getDictValue, saveDict, deleteDict, saveDictValue, deleteDictValue } from '@/api/dict'
 
 const CRUD: ICRUD = {
-  create(data: any) {
+  create(data) {
     return saveDict(data)
   },
-  update(data: any) {
+  update(data) {
     return saveDict(data)
   },
-  getList(data: any) {
+  getList(data) {
     return getDictList(data).then((res: any) => {
       if (res.rows.length) {
         curRow.value = res.rows[0]
@@ -20,20 +20,20 @@ const CRUD: ICRUD = {
       }
     })
   },
-  delete(data: any) {
+  delete(data) {
     return deleteDict({ ids: data.id })
   },
-  deleteBatch(data: any) {
+  deleteBatch(data) {
     return deleteDict(data)
   }
 }
 
 const itemCRUD: ICRUD = {
-  create(data: any) {
+  create(data) {
     data['dictType.id'] = curRow.value.id
     return saveDictValue(data)
   },
-  update(data: any) {
+  update(data) {
     data['dictType.id'] = curRow.value.id
     return saveDictValue({
       dictValueId: data.id,
@@ -46,7 +46,7 @@ const itemCRUD: ICRUD = {
   getList() {
     return getDictValue(curRow.value.id)
   },
-  delete(data: any) {
+  delete(data) {
     return deleteDictValue({ dictValueId: data.id, dictTypeId: curRow.value.id })
   }
 }

+ 8 - 9
src/views/system/Menu.vue

@@ -65,7 +65,6 @@ const filterNode = (value: string, data: any) => {
 }
 const menuId = ref('')
 const handleNodeClick = (val: any) => {
-  console.log(val)
   menuId.value = val.id
 }
 const changeType = (val: number) => {
@@ -228,11 +227,11 @@ const setIcon = (val: string) => {
   formData.remark = val
 }
 const CRUD: ICRUD = {
-  create(data: any) {
-    console.log(data)
+  create(data) {
+    return new Promise(resolve => console.log(data))
   },
-  update(data: any) {
-    console.log(data)
+  update(data) {
+    return new Promise(resolve => console.log(data))
   },
   getList() {
     return new Promise(resolve => {
@@ -242,11 +241,11 @@ const CRUD: ICRUD = {
       })
     })
   },
-  delete(data: any) {
-    console.log(data)
+  delete(data) {
+    return new Promise(resolve => console.log(data))
   },
-  deleteBatch(data: any) {
-    console.log(data)
+  deleteBatch(data) {
+    return new Promise(resolve => console.log(data))
   }
 }
 const logtFormConfig = reactive<BasicForm>({

+ 4 - 4
src/views/system/Role.vue

@@ -56,19 +56,19 @@ const handleUser = (row: any) => {
 
 // 用户table
 const UserCRUD: ICRUD = {
-  create(data: any) {
+  create(data) {
     return createRoleUser(data)
   },
-  update(data: any) {
+  update(data) {
     return createRoleUser(data)
   },
-  getList(data: any) {
+  getList(data) {
     return getRoleUserList({ id: curRole.value.id, ...data }).then((res: any) => {
       selectedUser.value = res.rows.map((item: any) => item.id)
       return res
     })
   },
-  delete(data: any) {
+  delete(data) {
     return delRoleUser({ roleId: curRole.value.id, userId: data.id })
   }
 }

+ 6 - 6
src/views/system/User.vue

@@ -6,21 +6,21 @@ import { getRoleList } from '@/api/role'
 const curRow = ref<any>(null)
 
 const CRUD: ICRUD = {
-  create(data: any) {
+  create(data) {
     return createUser(data)
   },
-  update(data: any) {
+  update(data) {
     data.oldLoginName = curRow.value.loginName
     return updateUser(data)
   },
-  getList(data: any) {
+  getList(data) {
     return getUserList(data)
   },
-  delete(data: any) {
+  delete(data) {
     return delUser({ ids: data.id })
   },
-  deleteBatch(data: any) {
-    return delUser({ ids: data.id })
+  deleteBatch(data) {
+    return delUser({ ids: data.ids })
   }
 }
 

+ 8 - 8
src/views/user/UserInfo.vue

@@ -152,11 +152,11 @@ const goCropper = () => {
   dialogVisible.value = true
 }
 const CRUD: ICRUD = {
-  create(data: any) {
-    console.log(data)
+  create(data) {
+    return new Promise(resolve => console.log(data))
   },
-  update(data: any) {
-    console.log(data)
+  update(data) {
+    return new Promise(resolve => console.log(data))
   },
   getList() {
     return new Promise(resolve => {
@@ -166,11 +166,11 @@ const CRUD: ICRUD = {
       })
     })
   },
-  delete(data: any) {
-    console.log(data)
+  delete(data) {
+    return new Promise(resolve => console.log(data))
   },
-  deleteBatch(data: any) {
-    console.log(data)
+  deleteBatch(data) {
+    return new Promise(resolve => console.log(data))
   }
 }