shenwu há 7 meses atrás
pai
commit
8a35a4d014

+ 28 - 3
src/models/global.tsx

@@ -39,12 +39,37 @@ export default (): { state: State, init: () => void, getEnum: (enumName: string,
         isLoding = true
         let enumData: any = await enumDictList().then((res) => res.data).catch((err) => { console.log(err) })
         let authList = await queryAuthList().then((res) => res.data).catch((err) => { console.log(err) })
-        let enumList: { [key: string]: any[] } = {}
+        let enumList: { [key: string]: any } = {}
         if (enumData) {
             Object.values(enumData.enums).map((item: any) => {
                 enumList[item.name] = item
             })
         }
+        // 企业类型美剧
+        enumList["SUBJECTTYPE"] = {
+            values: [
+                { value: 1, description: "企业" },
+                { value: 2, description: "政府以及事业单位" },
+                { value: 3, description: "其他组织" },
+                { value: 4, description: "团队号" }
+            ]
+        }
+        //授权方企业类型
+        enumList["CORPTYPE"] = {
+            values: [
+                { value: "verified", description: "认证号" },
+                { value: "unverified", description: "注册号" },
+            ]
+        }
+         //企微通讯录状态
+         enumList["CORPSTATE"] = {
+            values: [
+                { value: 1, description: "已激活" },
+                { value: 2, description: "已禁用" },
+                { value: 4, description: "未激活" },
+                { value: 5, description: "退出企业" },
+            ]
+        }
         dispatch({ type: "setAll", params: { enumList, authList } })
         isLoding = false
     }
@@ -65,12 +90,12 @@ export default (): { state: State, init: () => void, getEnum: (enumName: string,
             case "map":
                 return new Map(arr?.map(({ value, description }: any) => [value, description]))
             case "arr":
-                return arr?.map(({ value, description }: any) => ({ value, key: value, label: description,disabled:false }))
+                return arr?.map(({ value, description }: any) => ({ value, key: value, label: description, disabled: false }))
             case "obj":
                 let obj: any = {}
                 if (arr) {
                     for (let item of arr) {
-                        obj[item?.value] = { text: item?.description,disabled:false }
+                        obj[item?.value] = { text: item?.description, disabled: false }
                     }
                 }
                 return obj

+ 0 - 1
src/pages/Distributor/AppManage/index.tsx

@@ -37,7 +37,6 @@ const Page: React.FC = () => {
             }
         })
     }
-    console.log(getEnum("ADVERTISING_CHANNEL", "arr"))
     return <PageContainer
         tabList={getEnum("APP_TYPE", "arr")}
         tabProps={{

+ 18 - 22
src/pages/Distributor/CorpManage/index.tsx

@@ -1,10 +1,9 @@
-import { miniAppList } from "@/services/distributor/miniApp"
-import { PageContainer, ProTable } from "@ant-design/pro-components"
-import { Button, Modal, QRCode, Table } from "antd"
-import { columns, childrenColumns } from "./tableConfig"
+import { ActionType, PageContainer, ProTable } from "@ant-design/pro-components"
+import { Button, message, Modal, QRCode, Table } from "antd"
+import { columns } from "./tableConfig"
 import { useAjax } from "@/Hook/useAjax"
-import { corpListOfPage, corpPreAuth } from "@/services/distributor/corpManage"
-import { useEffect, useRef, useState } from "react"
+import { corpListOfPage, corpPreAuth, corpSyncAll } from "@/services/distributor/corpManage"
+import { useRef, useState } from "react"
 import { PlusOutlined } from "@ant-design/icons"
 
 const Page: React.FC = () => {
@@ -12,6 +11,8 @@ const Page: React.FC = () => {
     let [codeOpen, setCodeOpen] = useState<string>("")
     let [codeState, setCodeState] = useState<"active" | "loading" | "expired" | "scanned">("active")
     let CorpPreAuth = useAjax(() => corpPreAuth())
+    let CorpSyncAll = useAjax((corpId) => corpSyncAll(corpId))
+    const actionRef = useRef<ActionType>();
     let timeRef = useRef<any>()
     const auth = () => {
         CorpPreAuth.run().then(res => {
@@ -30,8 +31,17 @@ const Page: React.FC = () => {
             setCodeState("expired")
         }, 1000 * 60 * 10)
     }
-    return <PageContainer>
+    const sync = (corpId: any) => {
+        CorpSyncAll.run(corpId).then(res => {
+            if (res.code === 200) {
+                message.success("同步成功!")
+                actionRef?.current?.reload()
+            }
+        })
+    }
+    return <PageContainer >
         <ProTable<any, any>
+            actionRef={actionRef}
             headerTitle={"企微列表"}
             rowKey={(r) => r.id}
             search={{
@@ -41,24 +51,10 @@ const Page: React.FC = () => {
             request={async (params) => {
                 return await getList.run(params)
             }}
-            columns={columns()}
+            columns={columns(sync)}
             toolBarRender={() => [
                 <Button type="primary" onClick={auth} ><PlusOutlined />新增企微</Button>,
             ]}
-            expandable={{
-                rowExpandable: (record) => record?.appCarrierList?.length > 0,
-                expandRowByClick: true,
-                expandedRowRender: (record) => {
-                    return <Table
-                        columns={childrenColumns}
-                        dataSource={record.appCarrierList}
-                        rowKey={(r) => r.id}
-                        pagination={false}
-                        size='small'
-                        bordered
-                    />
-                },
-            }}
         />
         <Modal
             footer={null}

+ 177 - 0
src/pages/Distributor/CorpManage/popUp.tsx

@@ -0,0 +1,177 @@
+import { ActionType, BetaSchemaForm, PageContainer, ProFormInstance, ProTable } from "@ant-design/pro-components"
+import { Button, Drawer, message, Modal, QRCode, Space, Table, Tag } from "antd"
+import { columns, PopUpColumns } from "./tableConfig"
+import { useAjax } from "@/Hook/useAjax"
+import { corpUserSyncAll, corpUserConfigUser, corpUserListOfPage } from "@/services/distributor/corpManage"
+import { useEffect, useRef, useState } from "react"
+import { SyncOutlined, UserAddOutlined } from "@ant-design/icons"
+import { distributorAccountAll } from "@/services/distributor/account"
+type Props = {
+    corpId: string,//企微ID
+    corpName: string,//企微名称
+}
+const PopUp: React.FC<Props> = (props) => {
+    let { corpId, corpName } = props
+    let [open, SetOpen] = useState(false)
+    let [openForm, setOpenForm] = useState(false)
+    const [editSelectedRow, setEditSelectedRow] = useState<any[]>([]); //选择
+    let getList = useAjax((params) => corpUserListOfPage(params), { type: 'table' })
+    let CorpUserConfigUser = useAjax((params) => corpUserConfigUser(params))
+    let CorpSyncAll = useAjax((corpId) => corpUserSyncAll(corpId))
+    let allList = useAjax(() => distributorAccountAll())
+    const actionRef = useRef<ActionType>();
+    const formRef = useRef<ProFormInstance>();
+    const sync = () => {
+        CorpSyncAll.run(corpId).then(res => {
+            if (res.code === 200) {
+                message.success("同步成功!")
+                actionRef?.current?.reload()
+            }
+        })
+    }
+    useEffect(() => {
+        allList.run()
+    }, [])
+    // 提交表单
+    const submit = async (values: any) => {
+        values["corpUserIds"] = editSelectedRow?.map(item => item.corpUserId)
+        CorpUserConfigUser.run({ corpId, ...values }).then(res => {
+            if (res.code === 200) {
+                actionRef?.current?.reload()
+                message.success("指派成功!")
+                setEditSelectedRow([])
+                setOpenForm(false)
+            }
+        })
+    }
+    return <div>
+        <Button size="small" type="link" onClick={() => { SetOpen(true) }}>通讯录</Button>
+        {/* 通讯录表 */}
+        <Drawer
+            open={open}
+            destroyOnClose
+            width={"35%"}
+            onClose={() => { SetOpen(false) }}
+        >
+            <ProTable<any, any>
+                actionRef={actionRef}
+                headerTitle={`《${corpName}》通讯录列表`}
+                rowKey={(r) => r.corpUserId}
+                search={{
+                    labelWidth: 120,
+                }}
+                scroll={{ x: "auto" }}
+                request={async (params) => {
+                    return await getList.run({ ...params, corpId })
+                }}
+                columns={PopUpColumns()}
+                toolBarRender={() => [
+                    <Button type="primary" onClick={() => { setOpenForm(true) }} disabled={editSelectedRow?.length === 0} loading={CorpUserConfigUser?.loading}><UserAddOutlined />批量指派</Button>,
+                    <Button type="primary" onClick={sync} loading={CorpSyncAll?.loading}><SyncOutlined />同步通讯录</Button>,
+                ]}
+                //处理搜索数据
+                beforeSearchSubmit={(params) => {
+                    if (params?.name) {
+                        params['corpUserName'] = params.name
+                        delete params.name
+                    }
+                    return params
+                }}
+                //多选
+                rowSelection={{
+                    selectedRowKeys: editSelectedRow?.map((item: { corpUserId: any }) => item.corpUserId),
+                    onSelect: (record, selected) => {
+                        if (selected) {
+                            setEditSelectedRow([...editSelectedRow, record]);
+                        } else {
+                            setEditSelectedRow(
+                                editSelectedRow?.filter((item: { corpUserId: any }) => item.corpUserId !== record.corpUserId),
+                            );
+                        }
+                    },
+                    onSelectAll: (selected, rows, changeRows) => {
+                        if (selected) {
+                            setEditSelectedRow([...editSelectedRow, ...changeRows]);
+                        } else {
+                            let newArr = editSelectedRow?.filter((item: { id: any }) =>
+                                changeRows.every((i) => i?.id !== item?.id),
+                            );
+                            setEditSelectedRow(newArr);
+                        }
+                    },
+                }}
+                //多选展示栏
+                tableAlertRender={({ selectedRowKeys, selectedRows }) => {
+                    return (
+                        <Space size={24}>
+                            <span style={{ width: 90, display: 'inline-block' }}>
+                                已选 {selectedRowKeys.length} 项
+                            </span>
+                            <span style={{ color: 'red' }}>
+                                {selectedRows
+                                    ?.map((item: { name: string, corpUserId: any }) => <Tag
+                                        closable
+                                        key={item?.corpUserId}
+                                        onClose={() => {
+                                            let newArr = selectedRows?.filter((i) => i?.corpUserId != item?.corpUserId)
+                                            setEditSelectedRow(newArr)
+                                        }}>{item?.name}</Tag>)
+                                }
+                            </span>
+                        </Space>
+                    );
+                }}
+                // 添加取消选择按钮
+                tableAlertOptionRender={() => {
+                    return (
+                        <Button type="link" onClick={() => {
+                            setEditSelectedRow([])
+                        }}>
+                            取消选择
+                        </Button>
+                    );
+                }}
+            />
+            {/* 付费配置 */}
+            <BetaSchemaForm<any>
+                title={"批量指派"}
+                formRef={formRef}
+                open={openForm}
+                onOpenChange={(b) => { !b && setOpenForm(b) }}
+                layoutType={"ModalForm"}
+                labelCol={{ span: 6 }}
+                wrapperCol={{ span: 14 }}
+                layout='horizontal'
+                onFinish={submit}
+                columns={[
+                    {
+                        title: "分销商账号",
+                        dataIndex: "distributorAccountId",
+                        valueEnum: () => {
+                            let obj: any = {}
+                            allList?.data?.data?.forEach((item: { id: string | number; nickname: any }) => {
+                                return obj[item.id] = { text: item.nickname }
+                            })
+                            return obj
+                        },
+                        fieldProps: {
+                            showSearch: true,
+                            placeholder: '选择要指派的分销商账号',
+                        },
+                        formItemProps: {
+                            rules: [
+                                {
+                                    required: true,
+                                    message: '此项为必填项',
+                                }
+                            ]
+                        }
+                    }
+                ]}
+                loading={CorpUserConfigUser?.loading}
+            />
+        </Drawer>
+    </div>
+
+}
+export default PopUp

+ 163 - 62
src/pages/Distributor/CorpManage/tableConfig.tsx

@@ -1,58 +1,124 @@
-import MenuChange from "@/components/MenuChange";
-import { MyIcon } from "@/global";
 import { ProColumns } from "@ant-design/pro-components";
-import { Badge, Space, TableColumnsType } from "antd";
+import { useModel } from "@umijs/max";
+import { Badge, Button, Image, Space, Tag } from "antd";
+import PopUp from "./popUp";
 
-export const columns = (): ProColumns<any>[] => {
+export const columns = (sync: (id: any) => void): ProColumns<any>[] => {
+    const { getEnum } = useModel("global")
     return [
         {
-            title: "小程序名称",
-            dataIndex: 'appName',
-            key: "appName",
-            align: "left",
-            render: (a: any, b: any) => {
-                return <Space size={[3, 0]}>
-                    <MyIcon type="icon-xiaochengxu-dy" />
-                    {b.appName}
-                </Space>
-            }
+            title: "企微名称",
+            dataIndex: 'corpName',
+            key: "corpName",
+            align: "center",
+            fixed: 'left'
         },
         {
-            title: "AppId",
-            dataIndex: 'appKey',
-            key: "appKey",
+            title: "企微ID",
+            dataIndex: 'corpId',
+            key: "corpId",
             hideInSearch: true,
-            align: "left",
+            align: "center",
         },
         {
-            title: "小程序类型",
-            dataIndex: 'appCategory',
-            key: "appCategory",
+            title: "授权方企业类型",
+            dataIndex: 'corpType',
+            key: "corpType",
             hideInSearch: true,
-            align: "left",
-            render: (a: any, b: any) => {
-                return b.appCategory === 1 ? "长篇" : "短篇"
-            }
+            align: "center",
+            valueEnum: getEnum("CORPTYPE", "map")
         },
         {
-            title: "允许投放渠道",
-            dataIndex: 'advertisingChannels',
-            key: "advertisingChannels",
+            title: "授权方企业用户规模",
+            dataIndex: 'corpUserMax',
+            key: "corpUserMax",
             hideInSearch: true,
-            align: "left",
-            render:(a:any,b:any)=>{
-                return "需后端提供枚举"
-            }
+            align: "center",
+        },
+        {
+            title: "授权方企业的主体名称",
+            dataIndex: 'corpFullName',
+            key: "corpFullName",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "认证到期时间",
+            dataIndex: 'verifiedEndTime',
+            key: "verifiedEndTime",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "企业类型",
+            dataIndex: 'subjectType',
+            key: "subjectType",
+            hideInSearch: true,
+            align: "center",
+            valueEnum: getEnum("SUBJECTTYPE", "map")
+        },
+        {
+            title: "企业规模",
+            dataIndex: 'corpScale',
+            key: "corpScale",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "所属行业",
+            dataIndex: 'corpIndustry',
+            key: "corpIndustry",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "所属子行业",
+            dataIndex: 'corpSubIndustry',
+            key: "corpSubIndustry",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "授权方应用id",
+            dataIndex: 'agentId',
+            key: "agentId",
+            hideInSearch: true,
+            align: "center",
         },
         {
-            title: "运营载体状态",
-            dataIndex: 'appCarrierList',
-            key: "appCarrierList",
+            title: "所属分销商账号id",
+            dataIndex: 'authDistributorAccountId',
+            key: "authDistributorAccountId",
             hideInSearch: true,
             align: "center",
-            render: (a,b:any) => {
-                let isTrue = b?.appCarrierList?.length > 0 
-                return <Badge status={isTrue ? "processing" : "error"} text={isTrue ? "有" : "无"} />
+        },
+        {
+            title: "授权状态",
+            dataIndex: 'authStatus',
+            key: "authStatus",
+            align: "center",
+            valueEnum(row) {
+                return { "1": { text: <Badge status="success" text="授权成功" /> }, "-1": { text: <Badge status="error" text="取消授权" /> } }
+            },
+        },
+        {
+            title: "授权时间",
+            dataIndex: 'createTime',
+            key: "createTime",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "关注二维码",
+            tooltip: "授权企业在微信插件(原企业号)的二维码,可用于关注微信插件",
+            dataIndex: 'corpWxQrcode',
+            key: "corpWxQrcode",
+            hideInSearch: true,
+            align: "center",
+            fixed: 'right',
+            width: 120,
+            render: (_, row) => {
+                return <Image src={row?.corpWxQrcode} style={{ width: 20 }} />
             }
         },
         {
@@ -60,32 +126,67 @@ export const columns = (): ProColumns<any>[] => {
             dataIndex: 'option',
             valueType: 'option',
             align: "center",
+            fixed: 'right',
+            width: 90,
             render: (_, record) => {
-                return <MenuChange menuType="miniApp" data={{ ...record, appType: 2 }}><a type='primary'>管理</a></MenuChange>
+                return <Space>
+                    <Button onClick={() => { sync(record?.corpId) }} type="link" size="small">同步</Button>
+                    <PopUp corpId={record?.corpId} corpName={record?.corpName} />
+                </Space>
             },
         },
     ];
 }
-export const childrenColumns: TableColumnsType<any> = [
-    {
-        title: "载体名称",
-        dataIndex: 'carrierName',
-        key: "carrierName",
-        align: "center",
-    },
-    {
-        title: "载体类型",
-        dataIndex: 'carrierType',
-        key: "carrierType",
-        align: "center",
-        render: (a: string, b: any) => {
-            return { '1': '企业微信', "2": "公众号" }[a]
-        }
-    },
-    {
-        title: "绑定时间",
-        dataIndex: 'createTime',
-        key: "createTime",
-        align: "center",
-    }
-]
+
+export function PopUpColumns(): ProColumns<any>[] {
+    const { getEnum } = useModel("global")
+    return [
+        {
+            title: "企微客服id",
+            dataIndex: 'corpUserId',
+            key: "corpUserId",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "企微客服名称",
+            dataIndex: 'name',
+            key: "name",
+            align: "center",
+        },
+        {
+            title: "性别",
+            dataIndex: 'gender',
+            key: "gender",
+            align: "center",
+            hideInSearch: true,
+            valueEnum(row) {
+                return { 0: { text: <Tag >未知</Tag> }, 1: { text: <Tag color="green">男</Tag> }, 2: { text: <Tag color="red">女</Tag> } }
+            },
+        },
+        {
+            title: "分销商账号",
+            dataIndex: 'distributorAccountName',
+            key: "distributorAccountName",
+            hideInSearch: true,
+            align: "center",
+        },
+        {
+            title: "状态",
+            dataIndex: 'status',
+            key: "status",
+            hideInSearch: true,
+            align: "center",
+            valueEnum:()=>{
+                let obj = getEnum("CORPSTATE", "obj")
+                let colors = ["success","error","default","warning"]
+                Object.keys(obj).forEach((key:any,index)=>{
+                    obj[key] = {
+                        text:<Tag color={colors[index]}>{obj[key].text}</Tag>
+                    }
+                })
+                return obj
+            }
+        },
+    ]
+}

+ 1 - 1
src/pages/MiniApp/CompConfig/DrawerBox/compFormConfig.tsx

@@ -87,7 +87,7 @@ export function bannersConfig(pageList: any[]): ProFormColumnsType<any>[] {
                                             span: 24
                                         },
                                         fieldProps: {
-                                            style: { width: '100%' },
+                                            style: { width: '100%'  },
                                             showSearch: true,
                                             placeholder: '请选择活动页面'
                                         },

+ 27 - 0
src/services/distributor/corpManage/index.tsx

@@ -26,6 +26,33 @@ export async function corpPreAuth() {
 /**同步*/
 export async function corpSyncAll(corpId:any) {
   return request(api + `/admin/corp/syncAll/${corpId}`, {
+    method: 'PUT',
+  });
+}
+
+//=========================================企微客服管理==========================
+/**获取分销商账号列表 */
+export async function corpUserListOfPage(params: Params) {
+  return request(api + '/admin/corpUser/listOfPage', {
     method: 'GET',
+    params
+  });
+}
+/**批量指派 */
+export async function corpUserConfigUser(data:{
+  corpId:string,//企微ID
+  corpUserIds:any[],//用户
+  distributorAccountId:number,//分销商账号
+}) {
+  return request(api + '/admin/corpUser/configUser', {
+    method: 'PUT',
+    data
+  });
+}
+
+/**同步*/
+export async function corpUserSyncAll(corpId:any) {
+  return request(api + `/admin/corpUser/syncAll/${corpId}`, {
+    method: 'PUT',
   });
 }