huangbin 4 лет назад
Родитель
Сommit
78bec9b2fb

+ 1 - 1
public/config/app.config.json

@@ -1,3 +1,3 @@
 {
-    "apiUrl": "http://192.168.31.174:8080/cfg?key=test_174"
+    "apiUrl": "http://192.168.31.139:8080/cfg?key=test_139"
 }

+ 1 - 1
src/layout/components/header.vue

@@ -29,7 +29,7 @@
       <!-- <a-icon type="search" /> -->
     </div>
     <div>
-      <a-popover trigger="hover"
+      <a-popover trigger="click"
                  placement="bottom">
         <template #content>
           <Friend />

+ 4 - 3
src/services/go/wrtrade/index.ts

@@ -362,12 +362,13 @@ export function queryQueryWrTradeBargainApply(param: QueryWrTradeBargainApplyReq
 }
 
 /**
- * /WrTrade2/QueryWrFriendApply 查询好友申请记录
+ * /WrTrade2/QueryWrUserFriend 查询查询我的朋友
  * @param QueryWrFriendApply
  */
-export function queryQueryWrFriendApply(): Promise<QueryWrFriendApplyRsp[]> {
+export function queryQueryWrFriend(newuserid?: string): Promise<QueryWrFriendApplyRsp[]> {
     const userid = getUsrId()
-    return commonSearch_go('/WrTrade2/QueryWrFriendApply', { userid }).catch((err) => {
+    const param = newuserid ? { userid, newuserid } : { userid }
+    return commonSearch_go('/WrTrade2/QueryWrUserFriend', param).catch((err) => {
         throw new Error(`查询议价单: ${err}`);
     });
 }

+ 2 - 13
src/services/go/wrtrade/interface.ts

@@ -1109,19 +1109,8 @@ export interface QueryWrTradeBargainApplyQsp {
 }
 
 export interface QueryWrFriendApplyRsp {
-    applicantid: number;//申请人
-    applyname: string;//申请人名称
-    applysrc: number;//申请来源 - 1:管理端 2:终端
-    applystatus: number;//申请状态 - 1:待审核 2:审核通过 3:审核拒绝 4:处理失败 5:已撤回
-    applytime: string;//申请时间
-    auditname: string;//审核人名称
-    auditorid: number;//审核人
-    auditremark: string;//审核备注
-    auditsrc: number;//审核来源 - 1:管理端 2:终端
-    audittime: string;//审核时间
-    friendapplyid: string;//申请ID(SEQ_FRIENDAPPLY)
     friendname: string;//好友名字(已脱敏)
     frienduserid: string;//好友用户ID
-    remark: string;//备注
-    userid: number;//申请人用户ID
+    isfriend: number; // 是否好友 0-不是 1-是
+    userid: number;//用户ID
 }

+ 76 - 24
src/views/setting/friends/index.vue

@@ -1,16 +1,24 @@
 <template>
   <!-- 我的好友 -->
   <a-spin :spinning="loading">
-    <div>
-      <a-auto-complete placeholder="输入好友代码进行搜索"
-                       @search="handleSearch">
-        <template #dataSource>
-          <a-select-option v-for="(item, index) in friendsList"
-                           :key="index + '11'">
-            {{ item.friendname }}
-          </a-select-option>
-        </template>
-      </a-auto-complete>
+    <div class="my-friend">
+      <a-input-search placeholder="输入好友代码进行搜索"
+                      enter-button
+                      @search="handleSearch" />
+      <div v-for="(item, index) in searchFriend"
+           :key="index + '11'">
+        <a-row type="flex">
+          <a-col :span="12">
+            <span>{{item.frienduserid}} {{ item.friendname }}</span>
+          </a-col>
+          <a-col :span="6"
+                 @click="operate(item)">
+            <span v-if="item.isfriend">删除</span>
+            <span v-else>添加</span>
+          </a-col>
+        </a-row>
+        <a-divider />
+      </div>
     </div>
   </a-spin>
 </template>
@@ -19,51 +27,95 @@
 import { defineComponent, ref } from 'vue';
 import { initData } from '@/common/methods';
 import { QueryWrFriendApplyRsp } from '@/services/go/wrtrade/interface';
-import { queryQueryWrFriendApply } from '@/services/go/wrtrade';
+import { queryQueryWrFriend } from '@/services/go/wrtrade';
 import { friendOperate } from '@/services/proto/accountinfo';
 import { getUsrId } from '@/services/bus/user';
 import { queryResultLoadingAndInfo, requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
+import { message } from 'ant-design-vue';
+import { Modal } from 'ant-design-vue';
+import { getLongTypeLoginID } from '@/services/bus/login';
 
 export default defineComponent({
     name: 'friend',
     setup() {
+        const myFriends = ref<QueryWrFriendApplyRsp[]>([]);
+        const searchFriend = ref<QueryWrFriendApplyRsp[]>([]);
         const loading = ref<boolean>(false);
-        const friendsList = ref<QueryWrFriendApplyRsp[]>([]);
         // 设置 新增和删除好友 公共请求参数
         // operatetype: number; // 操作类型-1:申请 2:审核通过 3:审核拒绝 4: 删除
-        function getParam(operatetype: 1 | 2 | 3 | 4, frienduserid: number) {
+        function getParam(operatetype: 1 | 2 | 3 | 4, frienduserid: string) {
             return {
                 operatetype,
                 userid: getUsrId(),
                 frienduserid,
                 applysrc: 2,
+                applicantid: getLongTypeLoginID(),
             };
         }
         // 删除好友
-        function deleteFriend(frienduserid: number) {
-            const param = getParam(4, frienduserid);
-            requestResultLoadingAndInfo(friendOperate, param, loading, ['删除好友成功', '删除好友失败:']);
+        function deleteFriend(frienduserid: string) {
+            Modal.confirm({
+                title: '删除好友',
+                content: '确定删除好友?',
+                onOk() {
+                    const param = getParam(4, frienduserid);
+                    requestResultLoadingAndInfo(friendOperate, param, loading, ['删除好友成功', '删除好友失败:']).then(() => {
+                        queryMyFriend();
+                    });
+                },
+            });
         }
 
         // 添加好友
-        function addFriend(frienduserid: number) {
+        function addFriend(frienduserid: string) {
             const param = getParam(1, frienduserid);
-            requestResultLoadingAndInfo(friendOperate, param, loading, ['删除好友成功', '删除好友失败:']);
-        }
-        // 查询我的好友列表
-        function queryMyFriend() {
-            queryResultLoadingAndInfo(queryQueryWrFriendApply, loading).then((res) => {
-                friendsList.value = res;
+            requestResultLoadingAndInfo(friendOperate, param, loading, ['添加好友成功', '添加好友失败:']).then(() => {
+                queryMyFriend();
             });
         }
+        function operate({ frienduserid, isfriend }: QueryWrFriendApplyRsp) {
+            if (isfriend) {
+                deleteFriend(frienduserid);
+            } else {
+                addFriend(frienduserid);
+            }
+        }
+        // 查询好友列表
+        function queryMyFriend(value?: string) {
+            loading.value = true;
+            queryQueryWrFriend(value)
+                .then((res) => {
+                    if (!value) {
+                        myFriends.value = res; // 我的朋友
+                    }
+                    searchFriend.value = res;
+                })
+                .catch((err: string) => message.error(err))
+                .finally(() => {
+                    loading.value = false;
+                });
+        }
+        function handleSearch(value: string) {
+            const findResult = myFriends.value.find((e) => String(e.frienduserid).includes(value));
+            if (findResult) {
+                searchFriend.value = [findResult];
+            } else {
+                queryMyFriend(value);
+            }
+        }
+
         initData(() => {
             queryMyFriend();
         });
-        return { deleteFriend, addFriend, friendsList };
+        return { operate, myFriends, loading, handleSearch, searchFriend };
     },
 });
 </script>
 
 <style lang="less">
+.my-friend {
+    height: 340px;
+    width: 260px;
+}
 </style
 >;