Browse Source

refactor(myselectrequest.vu组件): 删除选择框组件的DTO和API的TS文件

使用框架已经封装号的Dict.ts API接口,删除原先使用的API和DTO
wyoujia 1 year ago
parent
commit
8beeb840bb

+ 5 - 6
admin.ui.plus-master/src/components/my-select-request/index.vue

@@ -6,9 +6,9 @@
 
 <script setup lang="ts" name="my-select-request">
 import {onMounted, reactive, ref, watch} from "vue";
-  import  type {selectDto} from "/@/components/my-select-request/mySelectRequestDto";
-  import {localStorageSet} from "/@/utils/localStorageSet";
-  import {MySelectRequest} from "/@/components/my-select-request/mySelectRequest";
+import {localStorageSet} from "/@/utils/localStorageSet";
+import {DictApi} from "/@/api/admin/Dict";
+import {DictGetListDto} from "/@/api/admin/data-contracts";
   /**
    * 接受父组件中传过来的数据字典id,
    * 根据id去查询
@@ -34,12 +34,11 @@ import {onMounted, reactive, ref, watch} from "vue";
 
   const state = reactive({
     /**选择选择值*/
-    selectDto: <selectDto>[],
+    selectDto: <DictGetListDto>[],
   })
 
   const onChange = () =>{
     emits('search',localSelect)
-    console.log(localSelect)
   }
   /**
    * 获取缓存,缓存不存在就发送请求
@@ -47,7 +46,7 @@ import {onMounted, reactive, ref, watch} from "vue";
   const init = async () => {
     state.selectDto = localStorageSet.getItemWithExpiration(props.code as string)
     if (!state.selectDto){
-      const res = await new MySelectRequest().getCodeDict([props.code])
+      const res = await new DictApi().getList([props.code] as string[])
       /**存一天的缓存*/
       localStorageSet.setItemWithExpiration(props.code as string, res?.data,1)
       state.selectDto = localStorageSet.getItemWithExpiration(props.code as string)

+ 0 - 21
admin.ui.plus-master/src/components/my-select-request/mySelectRequest.ts

@@ -1,21 +0,0 @@
-/**
- * 选择框获取值请求
- * */
-import {ContentType, HttpClient} from "/@/api/admin/http-client";
-import {AxiosResponse} from "axios";
-
-export class MySelectRequest<SecurityDataType = unknown> extends HttpClient<SecurityDataType>{
-
-  /**
-   * 根据编码获取字典
-   */
-  getCodeDict = (data:any) =>
-    this.request<AxiosResponse,any>({
-      path:'/api/admin/dict/get-list',
-      method: 'POST',
-      body: data,
-      secure: true,
-      type: ContentType.Json,
-      format: 'json',
-    })
-}

+ 0 - 7
admin.ui.plus-master/src/components/my-select-request/mySelectRequestDto.ts

@@ -1,7 +0,0 @@
-/**下拉框对象*/
-export interface selectDto {
-  id?: number,
-  name?: string,
-  code?: string,
-  value?: string
-}