|
@@ -1,37 +1,7 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <BasicTable @register="registerTable">
|
|
|
+ <BasicTable @register="registerTable" :loading="loading">
|
|
|
<template #toolbar>
|
|
|
- <!-- 筛选表单 -->
|
|
|
- <!-- <Form
|
|
|
- :model="filterForm"
|
|
|
- layout="inline"
|
|
|
- @submit.prevent="handleFilterSubmit"
|
|
|
- style="margin-bottom: 16px"
|
|
|
- >
|
|
|
- <FormItem label="服务器名称" name="serverId">
|
|
|
- <Select
|
|
|
- v-model:value="filterForm.serverId"
|
|
|
- :options="options"
|
|
|
- style="width: 200px"
|
|
|
- placeholder="请选择服务器"
|
|
|
- allowClear
|
|
|
- ></Select>
|
|
|
- </FormItem>
|
|
|
- <FormItem label="端口" name="port">
|
|
|
- <Input v-model:value="filterForm.port" style="width: 200px" allowClear />
|
|
|
- </FormItem>
|
|
|
- <FormItem label="进程ID" name="processId">
|
|
|
- <Input v-model:value="filterForm.processId" style="width: 200px" allowClear />
|
|
|
- </FormItem>
|
|
|
- <FormItem label="租户名称" name="organizationName" v-if="permCode === '001'">
|
|
|
- <Input v-model:value="filterForm.organizationName" style="width: 200px" allowClear />
|
|
|
- </FormItem>
|
|
|
- <FormItem>
|
|
|
- <a-button type="primary" html-type="submit">筛选</a-button>
|
|
|
- </FormItem>
|
|
|
- </Form> -->
|
|
|
- <!-- <a-button @click="handleEditMode">编辑模式</a-button> -->
|
|
|
<a-button type="primary" v-if="permCode === '001'" @click="handleCreate">
|
|
|
{{ t('wechat.wx.addWx') }}
|
|
|
</a-button>
|
|
@@ -49,10 +19,10 @@
|
|
|
label: '编辑模式',
|
|
|
onClick: handleEditMode.bind(null, record),
|
|
|
},
|
|
|
- // {
|
|
|
- // label: '黑白名单',
|
|
|
- // onClick: handleBlackWhiteList.bind(null, record),
|
|
|
- // },
|
|
|
+ {
|
|
|
+ label: '黑白名单',
|
|
|
+ onClick: handleBlackWhiteList.bind(null, record),
|
|
|
+ },
|
|
|
{
|
|
|
label: '登录',
|
|
|
onClick: handleLogin.bind(null, record),
|
|
@@ -116,7 +86,6 @@
|
|
|
</FormItem>
|
|
|
</Form>
|
|
|
</Modal>
|
|
|
-
|
|
|
<!-- 编辑黑白名单 -->
|
|
|
<Modal
|
|
|
width="700px"
|
|
@@ -128,108 +97,139 @@
|
|
|
>
|
|
|
<Form :model="blackWhiteForm" layout="inline" style="height: 500px">
|
|
|
<FormItem name="allowList" label="客户白名单" style="margin-left: 30px">
|
|
|
- <Switch v-model:checked="blackWhiteForm.isAllowListEnabled" @change="handleSwitchChange" />
|
|
|
- <div v-if="blackWhiteForm.isAllowListEnabled" style="foon-size: 12px; margin-top: 10px; color: #9a9a9a">
|
|
|
+ <Switch
|
|
|
+ v-model:checked="blackWhiteForm.isAllowListEnabled"
|
|
|
+ @change="handleSwitchChange"
|
|
|
+ />
|
|
|
+ <div
|
|
|
+ v-if="blackWhiteForm.isAllowListEnabled"
|
|
|
+ style="foon-size: 12px; margin-top: 10px; color: #9a9a9a"
|
|
|
+ >
|
|
|
开启白名单表示仅向白名单内的客户发送消息
|
|
|
</div>
|
|
|
<div v-else style="foon-size: 12px; margin-top: 10px; color: #9a9a9a">
|
|
|
关闭白名单表示允许向所有客户发送消息
|
|
|
</div>
|
|
|
<FormItem v-if="blackWhiteForm.isAllowListEnabled" name="nickname" label="">
|
|
|
+ <!-- <Select
|
|
|
+ v-model:value="blackWhiteForm.allowWxid"
|
|
|
+ :options="listOptions"
|
|
|
+ show-search
|
|
|
+ @search="handleSearchAllow"
|
|
|
+ allowClear
|
|
|
+ size="middle"
|
|
|
+ placeholder="请选择"
|
|
|
+ mode="multiple"
|
|
|
+ :max-tag-count="2"
|
|
|
+ :style="{ width: '330px', margin: '0 5px' }"
|
|
|
+ ></Select> -->
|
|
|
<Select
|
|
|
- v-model:value="blackWhiteForm.wxid"
|
|
|
+ v-model:value="blackWhiteForm.allowWxid"
|
|
|
:options="listOptions"
|
|
|
show-search
|
|
|
- @search="handleSearch"
|
|
|
+ :filter-option="filterAllowOption"
|
|
|
allowClear
|
|
|
size="middle"
|
|
|
placeholder="请选择"
|
|
|
mode="multiple"
|
|
|
:max-tag-count="2"
|
|
|
:style="{ width: '330px', margin: '0 5px' }"
|
|
|
+ virtual
|
|
|
></Select>
|
|
|
- <!-- <a-select
|
|
|
- v-model:value="value"
|
|
|
- show-search
|
|
|
- placeholder="Select a person"
|
|
|
- style="width: 200px"
|
|
|
- :options="options"
|
|
|
- :filter-option="filterOption"
|
|
|
- @focus="handleFocus"
|
|
|
- @blur="handleBlur"
|
|
|
- @change="handleChange"
|
|
|
- ></a-select> -->
|
|
|
</FormItem>
|
|
|
</FormItem>
|
|
|
-
|
|
|
<FormItem name="groupAllowList" label="客群白名单" style="margin-left: 30px">
|
|
|
- <Switch v-model:checked="isGroupAllowListEnabled" />
|
|
|
- <div v-if="isGroupAllowListEnabled" style="foon-size: 12px; margin-top: 10px; color: #9a9a9a">
|
|
|
+ <Switch v-model:checked="blackWhiteForm.isGroupAllowListEnabled" />
|
|
|
+ <div
|
|
|
+ v-if="blackWhiteForm.isGroupAllowListEnabled"
|
|
|
+ style="foon-size: 12px; margin-top: 10px; color: #9a9a9a"
|
|
|
+ >
|
|
|
开启白名单表示仅向白名单内的客群发送消息
|
|
|
</div>
|
|
|
<div v-else style="foon-size: 12px; margin-top: 10px; color: #9a9a9a">
|
|
|
关闭白名单表示允许向所有客群发送消息
|
|
|
</div>
|
|
|
- <FormItem v-if="isGroupAllowListEnabled" name="nickname" label="">
|
|
|
+ <FormItem v-if="blackWhiteForm.isGroupAllowListEnabled" name="nickname" label="">
|
|
|
<Select
|
|
|
- v-model:value="blackWhiteForm.wxid"
|
|
|
- :options="groupAllowListOptions"
|
|
|
+ v-model:value="blackWhiteForm.groupAllowWxid"
|
|
|
+ :options="groupListOptions"
|
|
|
+ show-search
|
|
|
+ :filter-option="filterAllowOption"
|
|
|
allowClear
|
|
|
size="middle"
|
|
|
placeholder="请选择"
|
|
|
+ mode="multiple"
|
|
|
+ :max-tag-count="2"
|
|
|
:style="{ width: '330px', margin: '0 5px' }"
|
|
|
+ virtual
|
|
|
></Select>
|
|
|
</FormItem>
|
|
|
</FormItem>
|
|
|
|
|
|
<FormItem name="blockList" label="客户黑名单" style="margin-left: 30px">
|
|
|
- <Switch v-model:checked="isBlockListEnabledt" />
|
|
|
- <div v-if="isBlockListEnabledt" style="foon-size: 12px; margin-top: 10px; color: #9a9a9a">
|
|
|
+ <Switch v-model:checked="blackWhiteForm.isBlockListEnabledt" />
|
|
|
+ <div
|
|
|
+ v-if="blackWhiteForm.isBlockListEnabledt"
|
|
|
+ style="foon-size: 12px; margin-top: 10px; color: #9a9a9a"
|
|
|
+ >
|
|
|
黑名单优先级高于白名单
|
|
|
</div>
|
|
|
<div v-else style="foon-size: 12px; margin-top: 10px; color: #9a9a9a">
|
|
|
关闭黑名单表示允许向所有客户发送消息
|
|
|
</div>
|
|
|
- <FormItem v-if="isBlockListEnabledt" name="groupBlockList" label="">
|
|
|
- <RadioGroup v-model:value="type" style="margin-bottom: 16px">
|
|
|
+ <FormItem v-if="blackWhiteForm.isBlockListEnabledt" name="groupBlockList" label="">
|
|
|
+ <RadioGroup v-model:value="blockType" style="margin-bottom: 16px">
|
|
|
<RadioButton value="all">全部客户</RadioButton>
|
|
|
<RadioButton value="part">部分客户</RadioButton>
|
|
|
</RadioGroup>
|
|
|
</FormItem>
|
|
|
- <FormItem v-if="isBlockListEnabledt" name="nickname" label="">
|
|
|
+ <FormItem v-if="blackWhiteForm.isBlockListEnabledt" name="nickname" label="">
|
|
|
<Select
|
|
|
- v-model:value="blackWhiteForm.wxid"
|
|
|
- :options="blockListOptions"
|
|
|
+ v-model:value="blackWhiteForm.blackWxid"
|
|
|
+ :options="listOptions"
|
|
|
+ show-search
|
|
|
allowClear
|
|
|
size="middle"
|
|
|
placeholder="请选择"
|
|
|
:style="{ width: '330px', margin: '0 5px' }"
|
|
|
+ :filter-option="filterAllowOption"
|
|
|
+ mode="multiple"
|
|
|
+ :max-tag-count="2"
|
|
|
+ virtual
|
|
|
></Select>
|
|
|
</FormItem>
|
|
|
</FormItem>
|
|
|
|
|
|
<FormItem name="groupBlockList" label="客群黑名单" style="margin-left: 30px">
|
|
|
- <Switch v-model:checked="isGroupBlockListEnabled" />
|
|
|
- <div v-if="isGroupBlockListEnabled" style="foon-size: 12px; margin-top: 10px; color: #9a9a9a">
|
|
|
+ <Switch v-model:checked="blackWhiteForm.isGroupBlockListEnabled" />
|
|
|
+ <div
|
|
|
+ v-if="blackWhiteForm.isGroupBlockListEnabled"
|
|
|
+ style="foon-size: 12px; margin-top: 10px; color: #9a9a9a"
|
|
|
+ >
|
|
|
黑名单优先级高于白名单
|
|
|
</div>
|
|
|
<div v-else style="foon-size: 12px; margin-top: 10px; color: #9a9a9a">
|
|
|
关闭黑名单表示允许向所有客群发送消息
|
|
|
</div>
|
|
|
- <FormItem v-if="isGroupBlockListEnabled" name="groupBlockList" label="">
|
|
|
- <RadioGroup v-model:value="type" style="margin-bottom: 16px">
|
|
|
+ <FormItem v-if="blackWhiteForm.isGroupBlockListEnabled" name="groupBlockList" label="">
|
|
|
+ <RadioGroup v-model:value="blockGroupType" style="margin-bottom: 16px">
|
|
|
<RadioButton value="all">全部客群</RadioButton>
|
|
|
<RadioButton value="part">部分客群</RadioButton>
|
|
|
</RadioGroup>
|
|
|
</FormItem>
|
|
|
- <FormItem v-if="isGroupBlockListEnabled" name="groupBlockList" label="">
|
|
|
+ <FormItem v-if="blackWhiteForm.isGroupBlockListEnabled" name="groupBlockList" label="">
|
|
|
<Select
|
|
|
- v-model:value="blackWhiteForm.id"
|
|
|
- :options="modeList"
|
|
|
+ v-model:value="blackWhiteForm.groupBlackWxid"
|
|
|
+ :options="groupListOptions"
|
|
|
allowClear
|
|
|
size="middle"
|
|
|
placeholder="请选择"
|
|
|
:style="{ width: '330px', margin: '0 5px' }"
|
|
|
+ show-search
|
|
|
+ :filter-option="filterAllowOption"
|
|
|
+ mode="multiple"
|
|
|
+ :max-tag-count="2"
|
|
|
+ virtual
|
|
|
></Select>
|
|
|
</FormItem>
|
|
|
</FormItem>
|
|
@@ -260,7 +260,7 @@
|
|
|
import WxDrawer from './WxDrawer.vue';
|
|
|
import { getAgentList } from '@/api/wechat/agent';
|
|
|
import { getServerList } from '@/api/wechat/server';
|
|
|
- import {getContactList} from '@/api/wechat/contact';
|
|
|
+ import { getContactList } from '@/api/wechat/contact';
|
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
|
|
import { columns } from './wx.data';
|
|
@@ -271,10 +271,12 @@
|
|
|
updateWx,
|
|
|
checkWx,
|
|
|
getBlackWhiteList,
|
|
|
+ updataBlackWhiteList,
|
|
|
} from '@/api/wechat/wx';
|
|
|
import { getFriendsAndGroupsApi, logoutApi } from '@/api/wechat/wxhook';
|
|
|
import type { TabsProps } from 'ant-design-vue';
|
|
|
- const type = ref<TabsProps['all']>('part');
|
|
|
+ const blockType = ref<TabsProps['all']>('part');
|
|
|
+ const blockGroupType = ref<TabsProps['all']>('part');
|
|
|
const searchFormSchema = ref<FormSchema[]>([]);
|
|
|
const { t } = useI18n();
|
|
|
const selectedIds = ref<number[] | string[]>();
|
|
@@ -282,71 +284,40 @@
|
|
|
let modeList = ref([]);
|
|
|
const modalVisible = ref(false);
|
|
|
const blackWhiteModalVisible = ref(false);
|
|
|
+ const loading = ref(false); // 添加 loading 状态
|
|
|
+ const recordId = ref(undefined);
|
|
|
const blackWhiteForm = reactive({
|
|
|
allowList: [],
|
|
|
groupAllowList: [],
|
|
|
blockList: [],
|
|
|
groupBlockList: [],
|
|
|
- wxid: '',
|
|
|
+ groupAllowWxid: [], //客群白名单ID
|
|
|
+ allowWxid: [], //客户白名单id
|
|
|
+ blackWxid: [], //客户黑名单id
|
|
|
+ groupBlackWxid: [], //客群黑名单id
|
|
|
id: '',
|
|
|
isAllowListEnabled: false,
|
|
|
isGroupAllowListEnabled: false,
|
|
|
+ isBlockListEnabledt: false,
|
|
|
+ isGroupBlockListEnabled: false,
|
|
|
});
|
|
|
- // const isAllowListEnabled = ref(false);
|
|
|
- // const isGroupAllowListEnabled = ref(false);
|
|
|
- const listOptions = ref([]);
|
|
|
- // 计算属性来确定 Switch 的状态
|
|
|
- // const isAllowListEnabled = computed(() => {
|
|
|
- // return blackWhiteForm.allowList.length > 0 && blackWhiteForm.allowList[0].wxid !== 'ALL';
|
|
|
- // });
|
|
|
- // const isGroupAllowListEnabled = computed(() => {
|
|
|
- // return blackWhiteForm.groupAllowList.length > 0 && blackWhiteForm.groupAllowList[0].wxid !== 'ALL';
|
|
|
- // });
|
|
|
- // 计算属性来生成 Select 的选项
|
|
|
- const allowListOptions = computed(() => {
|
|
|
- return blackWhiteForm.allowList.map((item) => ({
|
|
|
- label: item.nickname,
|
|
|
- value: item.wxid,
|
|
|
- }));
|
|
|
- });
|
|
|
- const groupAllowListOptions = computed(() => {
|
|
|
- return blackWhiteForm.groupAllowList.map((item) => ({
|
|
|
- label: item.nickname,
|
|
|
- value: item.wxid,
|
|
|
- }));
|
|
|
+ const initialBlackWhiteForm = reactive({
|
|
|
+ allowList: [],
|
|
|
+ groupAllowList: [],
|
|
|
+ blockList: [],
|
|
|
+ groupBlockList: [],
|
|
|
+ groupAllowWxid: [], //客群白名单ID
|
|
|
+ allowWxid: [], //客户白名单id
|
|
|
+ blackWxid: [], //客户黑名单id
|
|
|
+ groupBlackWxid: [], //客群黑名单id
|
|
|
+ id: '',
|
|
|
+ isAllowListEnabled: false,
|
|
|
+ isGroupAllowListEnabled: false,
|
|
|
+ isBlockListEnabledt: false,
|
|
|
+ isGroupBlockListEnabled: false,
|
|
|
});
|
|
|
- // 计算属性来确定 blockList Switch 的状态
|
|
|
-// const isBlockListEnabled = computed(() => {
|
|
|
-// return blackWhiteForm.blockList.length > 0;
|
|
|
-// });
|
|
|
-
|
|
|
-// 计算属性来确定 groupBlockList Switch 的状态
|
|
|
-// const isGroupBlockListEnabled = computed(() => {
|
|
|
-// return blackWhiteForm.groupBlockList.length > 0;
|
|
|
-// });
|
|
|
-
|
|
|
-// 控制是否显示 RadioGroup
|
|
|
-// const showRadioGroup = computed(() => {
|
|
|
-// return blackWhiteForm.blockList.length > 0;
|
|
|
-// });
|
|
|
-
|
|
|
-// 控制是否显示 groupBlockList 的 RadioGroup
|
|
|
-const showGroupRadioGroup = computed(() => {
|
|
|
- return blackWhiteForm.groupBlockList.length > 0;
|
|
|
-});
|
|
|
-const blockListOptions = computed(() => {
|
|
|
- return blackWhiteForm.blockList.map(item => ({
|
|
|
- label: item.nickname,
|
|
|
- value: item.wxid,
|
|
|
- }));
|
|
|
-});
|
|
|
-// 生成 Select 的选项
|
|
|
-const groupBlockListOptions = computed(() => {
|
|
|
- return blackWhiteForm.groupBlockList.map(item => ({
|
|
|
- label: item.nickname,
|
|
|
- value: item.wxid,
|
|
|
- }));
|
|
|
-});
|
|
|
+ const listOptions = ref([]);
|
|
|
+ const groupListOptions = ref([]);
|
|
|
|
|
|
const form = reactive({
|
|
|
name: '',
|
|
@@ -391,8 +362,8 @@ const groupBlockListOptions = computed(() => {
|
|
|
rowKey: 'id',
|
|
|
});
|
|
|
const filterOption = (input: string, option: any) => {
|
|
|
- return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
|
-};
|
|
|
+ return option.value.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
|
+ };
|
|
|
onMounted(async () => {
|
|
|
let res = await getPermCode();
|
|
|
permCode.value = res.data[0];
|
|
@@ -452,68 +423,135 @@ const groupBlockListOptions = computed(() => {
|
|
|
isUpdate: !isUpdate.value,
|
|
|
});
|
|
|
}
|
|
|
- function handleSwitchChange (checked){
|
|
|
- // isAllowListEnabled.value = checked;
|
|
|
- // console.log(blackWhiteForm.allowList,'allowList')
|
|
|
- // // 根据开关状态更新 blackWhiteForm 的 allowList
|
|
|
- // if (checked) {
|
|
|
- // blackWhiteForm.allowList = [{ wxid: 'SOME_ID' }]; // 示例:需要替换为实际的逻辑
|
|
|
- // } else {
|
|
|
- // blackWhiteForm.allowList = [{ wxid: 'ALL' }];
|
|
|
- // }
|
|
|
+ function handleSwitchChange(checked) {}
|
|
|
+
|
|
|
+ async function getListOptions(id) {
|
|
|
+ let resCustomer = await getContactList({ page: 1, pageSize: 10000, type: 1, id: id });
|
|
|
+ const data = resCustomer.data.data.map((item) => ({
|
|
|
+ label: item.nickname,
|
|
|
+ value: item.wxid,
|
|
|
+ }));
|
|
|
+ listOptions.value = [...data]; // 初始化时显示所有数据
|
|
|
+ }
|
|
|
+ function filterAllowOption(input: string, option: any) {
|
|
|
+ return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
|
+ }
|
|
|
+ async function getgroupListOptions(id) {
|
|
|
+ let resGroup = await getContactList({ page: 1, pageSize: 5000, type: 2, id: id });
|
|
|
+ groupListOptions.value = resGroup.data.data.map((item) => ({
|
|
|
+ label: item.nickname,
|
|
|
+ value: item.wxid,
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ function handleblackWhiteCancel() {
|
|
|
+ Object.assign(blackWhiteForm, initialBlackWhiteForm);
|
|
|
+ }
|
|
|
+ async function handleblackWhiteOk() {
|
|
|
+ let allowList;
|
|
|
+ let groupBlockList;
|
|
|
+ let blockList;
|
|
|
+ let groupAllowList;
|
|
|
+ if (blackWhiteForm.allowWxid.length == listOptions.value.length) {
|
|
|
+ console.log(blackWhiteForm.allowWxid.length, listOptions.value.length);
|
|
|
+ allowList = ['ALL'];
|
|
|
+ } else {
|
|
|
+ allowList = blackWhiteForm.allowWxid;
|
|
|
+ }
|
|
|
+ if (blackWhiteForm.blackWxid.length == listOptions.value.length) {
|
|
|
+ blockList = ['ALL'];
|
|
|
+ } else {
|
|
|
+ blockList = blackWhiteForm.blackWxid;
|
|
|
+ }
|
|
|
+ if (blackWhiteForm.groupAllowWxid.length == groupListOptions.value.length) {
|
|
|
+ groupAllowList = ['ALL'];
|
|
|
+ } else {
|
|
|
+ groupAllowList = blackWhiteForm.groupAllowWxid;
|
|
|
+ }
|
|
|
+ if (blackWhiteForm.groupBlackWxid.length == groupListOptions.value.length) {
|
|
|
+ groupBlockList = ['ALL'];
|
|
|
+ } else {
|
|
|
+ groupBlockList = blackWhiteForm.groupBlackWxid;
|
|
|
+ }
|
|
|
+ console.log(allowList,groupBlockList,blockList,groupAllowList,'recordId')
|
|
|
+ let res = await updataBlackWhiteList({
|
|
|
+ id: recordId.value,
|
|
|
+ allowList,
|
|
|
+ blockList,
|
|
|
+ groupAllowList,
|
|
|
+ groupBlockList,
|
|
|
+ });
|
|
|
+ if (res.code == 0) {
|
|
|
+ message.success('success');
|
|
|
+ blackWhiteModalVisible.value = false;
|
|
|
+ await reload();
|
|
|
+ } else {
|
|
|
+ blackWhiteModalVisible.value = false;
|
|
|
}
|
|
|
+ }
|
|
|
//打开黑白名单
|
|
|
async function handleBlackWhiteList(record: Recordable) {
|
|
|
- let res1 = await getContactList({ page: 1, pageSize: 50, type: 1 , id:record.id});
|
|
|
- // console.log(res1)
|
|
|
- listOptions.value = res1.data.data.map((item: any)=>{
|
|
|
- return {
|
|
|
- label: item.nickname,
|
|
|
- value: item.wxid,
|
|
|
- }
|
|
|
- });
|
|
|
- blackWhiteModalVisible.value = true;
|
|
|
+ recordId.value = record.id;
|
|
|
+ loading.value = true; // 开始加载
|
|
|
try {
|
|
|
+ await getListOptions(record.id);
|
|
|
+ await getgroupListOptions(record.id);
|
|
|
let res = await getBlackWhiteList({ id: record.id });
|
|
|
- // console.log(res.data, 'getBlackWhiteList');
|
|
|
-
|
|
|
// 使用解构赋值和默认值
|
|
|
if (res && res.data) {
|
|
|
- const {allowList = [], groupAllowList = [], blockList = [], groupBlockList = [] } = res.data;
|
|
|
- if(Array.isArray(allowList) && allowList.length == 0 || allowList[0].wxid == 'ALL'){
|
|
|
+ const { allowList = [], groupAllowList = [], blockList = [], groupBlockList = [] } = res.data;
|
|
|
+ if ((Array.isArray(allowList) && allowList.length == 0) || allowList[0].wxid == 'ALL') {
|
|
|
blackWhiteForm.isAllowListEnabled = true;
|
|
|
// blackWhiteForm.allowList = listOptions.value;
|
|
|
- Object.assign(blackWhiteForm, { allowList: listOptions.value });
|
|
|
- // console.log('first,',blackWhiteForm.allowList)
|
|
|
- }else{
|
|
|
+ Object.assign(blackWhiteForm, { allowWxid: listOptions.value });
|
|
|
+ // console.log(blackWhiteForm.allowList,listOptions.value);
|
|
|
+ } else {
|
|
|
blackWhiteForm.isAllowListEnabled = false;
|
|
|
- // blackWhiteForm.allowList = allowList;
|
|
|
+ Object.assign(blackWhiteForm, { allowWxid: allowList });
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ (Array.isArray(groupAllowList) && groupAllowList.length == 0) ||
|
|
|
+ groupAllowList[0].wxid == 'ALL'
|
|
|
+ ) {
|
|
|
+ blackWhiteForm.isGroupAllowListEnabled = true;
|
|
|
+ Object.assign(blackWhiteForm, { groupAllowWxid: groupListOptions.value });
|
|
|
+ } else {
|
|
|
+ blackWhiteForm.isGroupAllowListEnabled = false;
|
|
|
+ Object.assign(blackWhiteForm, { groupAllowWxid: groupAllowList });
|
|
|
+ }
|
|
|
+ if (Array.isArray(blockList) && blockList.length == 0) {
|
|
|
+ blackWhiteForm.isBlockListEnabledt = false;
|
|
|
+ } else if (Array.isArray(blockList) && blockList[0].wxid == 'ALL') {
|
|
|
+ blackWhiteForm.isBlockListEnabledt = true;
|
|
|
+ blockType.value = 'all';
|
|
|
+ Object.assign(blackWhiteForm, { blackWxid: listOptions.value });
|
|
|
+ } else {
|
|
|
+ blackWhiteForm.isBlockListEnabledt = true;
|
|
|
+ blockType.value = 'part';
|
|
|
+ let data = blockList.map((item) =>
|
|
|
+ item.wxid,
|
|
|
+ );
|
|
|
+ Object.assign(blackWhiteForm, { blackWxid: data });
|
|
|
+ }
|
|
|
+ if (Array.isArray(groupBlockList) && groupBlockList.length == 0) {
|
|
|
+ blackWhiteForm.isGroupBlockListEnabled = false;
|
|
|
+ } else if (Array.isArray(groupBlockList) && groupBlockList[0].wxid == 'ALL') {
|
|
|
+ blackWhiteForm.isGroupBlockListEnabled = true;
|
|
|
+ blockGroupType.value = 'all';
|
|
|
+ Object.assign(blackWhiteForm, { groupBlackWxid: groupListOptions.value });
|
|
|
+ } else {
|
|
|
+ blackWhiteForm.isGroupBlockListEnabled = true;
|
|
|
+ blockGroupType.value = 'part';
|
|
|
+ Object.assign(blackWhiteForm, { groupBlackWxid: groupBlockList });
|
|
|
}
|
|
|
- // 检查数据类型,确保是数组
|
|
|
- // blackWhiteForm.allowList = Array.isArray(allowList) ? allowList : [];
|
|
|
- blackWhiteForm.groupAllowList = Array.isArray(groupAllowList) ? groupAllowList : [];
|
|
|
- blackWhiteForm.blockList = Array.isArray(blockList) ? blockList : [];
|
|
|
- blackWhiteForm.groupBlockList = Array.isArray(groupBlockList) ? groupBlockList : [];
|
|
|
}
|
|
|
-
|
|
|
- console.log(blackWhiteForm.allowList, 'getBlackWhiteList');
|
|
|
} catch (error) {
|
|
|
console.error('Failed to fetch black-white list:', error);
|
|
|
+ } finally {
|
|
|
+ loading.value = false; // 请求结束
|
|
|
+ blackWhiteModalVisible.value = true;
|
|
|
}
|
|
|
}
|
|
|
- async function handleSearch(value){
|
|
|
- if (value) {
|
|
|
- // 触发远程请求
|
|
|
- let res1 = await getContactList({ page: 1, pageSize: 50, type: 1, search: value });
|
|
|
- console.log(res1);
|
|
|
- listOptions.value = res1.data.data.map((item) => ({
|
|
|
- label: item.nickname,
|
|
|
- value: item.wxWxid,
|
|
|
- }));
|
|
|
- } else {
|
|
|
- listOptions.value = []; // 如果没有输入,清空列表
|
|
|
- }
|
|
|
-}
|
|
|
+
|
|
|
//编辑模式
|
|
|
function handleEditMode(record: Recordable) {
|
|
|
accountId.value = record.id;
|
|
@@ -527,7 +565,6 @@ const groupBlockListOptions = computed(() => {
|
|
|
}
|
|
|
async function handleOk() {
|
|
|
let res = await updateWx({ agentId: form.id, id: accountId.value });
|
|
|
- console.log(res);
|
|
|
message.success('success');
|
|
|
modalVisible.value = false;
|
|
|
await reload();
|