Browse Source

联系人管理增加 人工/AI 模式切换

boweniac 3 months ago
parent
commit
1696d312f0

+ 1 - 0
.gitignore

@@ -41,3 +41,4 @@ pnpm-lock.yaml
 .vscode/launch.json
 
 *.log
+dist

+ 7 - 0
src/api/model/baseModel.ts

@@ -62,6 +62,13 @@ export interface BaseIDsReq {
   updateType?: number;//1 批量追加标签 -1 批量移除标签
 }
 
+export interface ChangeBlockListReq {
+  ownerWxid: string;
+  wxid: string;
+  type: number;
+  ai: boolean;
+}
+
 export interface BaseUUIDReq {
   id: string;
 }

+ 19 - 1
src/api/wechat/contact.ts

@@ -1,6 +1,13 @@
 import { defHttp } from '@/utils/http/axios';
 import { ErrorMessageMode } from '/#/axios';
-import { BaseDataResp, BaseListReq, BaseResp, BaseIDsReq, BaseIDReq } from '@/api/model/baseModel';
+import {
+  BaseDataResp,
+  BaseListReq,
+  BaseResp,
+  BaseIDsReq,
+  BaseIDReq,
+  ChangeBlockListReq
+} from '@/api/model/baseModel';
 import { ContactInfo, ContactListResp, AddNewFriendInfo } from './model/contactModel';
 
 enum Api {
@@ -8,6 +15,7 @@ enum Api {
   UpdateContact = '/wechat-api/contact/update',
   GetContactList = '/wechat-api/contact/list',
   DeleteContact = '/wechat-api/contact/delete',
+  ChangeBlockList = '/wechat-api/contact/changeBlockList',
   GetContactById = '/wechat-api/contact',
   AddNewFriend = '/wechat-api/contact/addNewFriend',
   UpdateContactLabels = '/wechat-api/label_relationship/batch_update_contact_labels'
@@ -63,6 +71,16 @@ export const deleteContact = (params: BaseIDsReq, mode: ErrorMessageMode = 'noti
   );
 };
 
+export const changeBlockList = (params: ChangeBlockListReq, mode: ErrorMessageMode = 'notice') => {
+  return defHttp.post<BaseResp>(
+    { url: Api.ChangeBlockList, params: params },
+    {
+      errorMessageMode: mode,
+      successMessageMode: mode,
+    },
+  );
+};
+
 /**
  *  @description: Get contact By ID
  */

+ 2 - 1
src/locales/lang/zh-CN/wechat.ts

@@ -31,7 +31,7 @@ export default {
     type: '类型',
     wxid: '微信ID',
     account: '微信账号',
-    nickname: '称',
+    nickname: '称',
     markname: '备注',
     headimg: '头像',
     sex: '性别',
@@ -46,6 +46,7 @@ export default {
     addContact: '添加 Contact',
     editContact: '编辑 Contact',
     contactList: 'Contact 列表',
+    isInBlockList: '模式',
   },
   label: {
     status: 'Status',

+ 19 - 2
src/views/wechat/contact/contact.data.ts

@@ -4,15 +4,23 @@ import {getLabelSelectList} from "@/api/wechat/label";
 const { t } = useI18n();
 
 export const columns: BasicColumn[] = [
+  // {
+  //   title: t('wechat.contact.wxWxid'),
+  //   dataIndex: 'wxWxid',
+  //   width: 100,
+  // },
   {
     title: t('wechat.contact.wxWxid'),
-    dataIndex: 'wxWxid',
+    dataIndex: 'wxWxidNickname',
     width: 100,
   },
   {
     title: t('wechat.contact.type'),
     dataIndex: 'type',
     width: 50,
+    customRender: ({ record }) => {
+      return record.type == 1 ? '联系人' : '群组'
+    },
   },
   {
     title: t('wechat.contact.wxid'),
@@ -27,9 +35,18 @@ export const columns: BasicColumn[] = [
     align: 'left',
   },
   {
+    title: t('wechat.contact.isInBlockList'),
+    dataIndex: 'isInBlockList',
+    width: 100,
+    align: 'left',
+    customRender: ({ record }) => {
+      return record.isInBlockList == true ? '人工' : 'AI'
+    },
+  },
+  {
     title: t('wechat.contact.lag'),
     dataIndex: 'labelRelationships',
-    width: 200,
+    width: 100,
     customRender: ({ text }) => {
       return text.map(label => label.label).join(', ');
     },

+ 19 - 2
src/views/wechat/contact/index.vue

@@ -37,6 +37,10 @@
           <TableAction
             :actions="[
               {
+                label: record.isInBlockList == true ? '转 AI' : '转人工',
+                onClick: handleIsInBlockList.bind(null, record),
+              },
+              {
                 label: '发信息',
                 onClick: handleMsg.bind(null, record),
               },
@@ -101,7 +105,12 @@
   import { useI18n } from 'vue-i18n';
 
   import { columns, searchFormSchema } from './contact.data';
-  import { getContactList, deleteContact, updateContactLabels } from '@/api/wechat/contact';
+  import {
+    getContactList,
+    deleteContact,
+    updateContactLabels,
+    changeBlockList
+  } from '@/api/wechat/contact';
 
   export default defineComponent({
     name: 'ContactManagement',
@@ -204,6 +213,13 @@
         });
       }
 
+      async function handleIsInBlockList(record: Recordable) {
+        const result = await changeBlockList({ ownerWxid: record.wxWxid, wxid: record.wxid, type: record.type, ai: record.isInBlockList });
+        if (result.code === 0) {
+          await reload();
+        }
+      }
+
       async function handleDelete(record: Recordable) {
         const result = await deleteContact({ ids: [record.id] });
         if (result.code === 0) {
@@ -287,6 +303,7 @@
         registerDrawerMsg,
         handleCreate,
         handleMsg,
+        handleIsInBlockList,
         handleEdit,
         handleDelete,
         handleSuccess,
@@ -314,4 +331,4 @@
     justify-content: center;
     align-items: center;
   }
-</style>
+</style>