|
@@ -1,43 +1,74 @@
|
|
-import { PageContainer, ProTable } from "@ant-design/pro-components"
|
|
|
|
|
|
+import { ActionType, PageContainer, ProTable } from "@ant-design/pro-components"
|
|
import { columns } from "./tableConfig"
|
|
import { columns } from "./tableConfig"
|
|
import { useAjax } from "@/Hook/useAjax"
|
|
import { useAjax } from "@/Hook/useAjax"
|
|
import { useModel } from "@umijs/max"
|
|
import { useModel } from "@umijs/max"
|
|
-import { getAllAvailableKfs, getAllBindKfs } from "@/services/miniApp/entWeChat"
|
|
|
|
-import { Button, Modal, Space, Tag } from "antd"
|
|
|
|
|
|
+import { configUser, getAllAvailableKfs, getAllBindKfs, revoke } from "@/services/miniApp/entWeChat"
|
|
|
|
+import { Button, message, Modal, Space, Tag } from "antd"
|
|
import { PlusOutlined } from "@ant-design/icons"
|
|
import { PlusOutlined } from "@ant-design/icons"
|
|
-import { useState } from "react"
|
|
|
|
|
|
+import { useRef, useState } from "react"
|
|
|
|
|
|
const Page: React.FC = () => {
|
|
const Page: React.FC = () => {
|
|
let { initialState } = useModel("@@initialState")
|
|
let { initialState } = useModel("@@initialState")
|
|
let [open, setOpen] = useState(false)
|
|
let [open, setOpen] = useState(false)
|
|
|
|
+ const actionRef = useRef<ActionType>();
|
|
const [editSelectedRow, setEditSelectedRow] = useState<any[]>([]); //选择
|
|
const [editSelectedRow, setEditSelectedRow] = useState<any[]>([]); //选择
|
|
let getList = useAjax((params) => getAllBindKfs(params), { type: 'table' })//已授权列表
|
|
let getList = useAjax((params) => getAllBindKfs(params), { type: 'table' })//已授权列表
|
|
let getNoAuthList = useAjax((params) => getAllAvailableKfs(params), { type: 'table' })//未授权列表
|
|
let getNoAuthList = useAjax((params) => getAllAvailableKfs(params), { type: 'table' })//未授权列表
|
|
-
|
|
|
|
|
|
+ let ConfigUser = useAjax((params) => configUser(params))//批量授权
|
|
|
|
+ let Revoke = useAjax((params) => revoke(params))//取消授权
|
|
|
|
+ let publicData = {
|
|
|
|
+ appId: initialState?.selectApp?.id || "",
|
|
|
|
+ appType: initialState?.selectApp?.appType || ""
|
|
|
|
+ }
|
|
|
|
+ // 批量授权
|
|
const auth = () => {
|
|
const auth = () => {
|
|
- if(editSelectedRow.length>0){
|
|
|
|
-
|
|
|
|
|
|
+ if (editSelectedRow.length > 0) {
|
|
|
|
+ let corpUserList = editSelectedRow?.map(item => ({ corpId: item.corpId, corpUserId: item.corpUserId }))
|
|
|
|
+ ConfigUser.run({
|
|
|
|
+ ...publicData,
|
|
|
|
+ corpUserList
|
|
|
|
+ }).then(res => {
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ setOpen(false)
|
|
|
|
+ setEditSelectedRow([])
|
|
|
|
+ message.success("授权成功!")
|
|
|
|
+ actionRef?.current?.reload()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 取消授权
|
|
|
|
+ const offAuth = (user: { corpId: any, corpUserId: any }) => {
|
|
|
|
+ let corpUserList: any = []
|
|
|
|
+ if (user) {
|
|
|
|
+ corpUserList = [{ corpId: user.corpId, corpUserId: user.corpUserId }]
|
|
|
|
+ }
|
|
|
|
+ if (corpUserList.length > 0) {
|
|
|
|
+ Revoke.run({ ...publicData, corpUserList }).then(res => {
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
+ message.success("取消授权成功!")
|
|
|
|
+ actionRef?.current?.reload()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return <PageContainer
|
|
return <PageContainer
|
|
title={false}
|
|
title={false}
|
|
>
|
|
>
|
|
<ProTable<any, any>
|
|
<ProTable<any, any>
|
|
|
|
+ actionRef={actionRef}
|
|
scroll={{ x: true }}
|
|
scroll={{ x: true }}
|
|
toolBarRender={() => [
|
|
toolBarRender={() => [
|
|
<Button type="primary" onClick={() => { setOpen(true) }} ><PlusOutlined />添加授权</Button>,
|
|
<Button type="primary" onClick={() => { setOpen(true) }} ><PlusOutlined />添加授权</Button>,
|
|
]}
|
|
]}
|
|
- params={{
|
|
|
|
- appId: initialState?.selectApp?.id || "",
|
|
|
|
- appType: initialState?.selectApp?.appType || ""
|
|
|
|
- }}
|
|
|
|
|
|
+ params={publicData}
|
|
headerTitle={"已授权客服号列表"}
|
|
headerTitle={"已授权客服号列表"}
|
|
- rowKey={(r) => r.openid}
|
|
|
|
- search={false}
|
|
|
|
|
|
+ rowKey={(r) => r.corpUserId}
|
|
|
|
+ search={{labelWidth:0}}
|
|
request={async (params) => {
|
|
request={async (params) => {
|
|
return await getList.run(params)
|
|
return await getList.run(params)
|
|
}}
|
|
}}
|
|
- columns={columns(true)}
|
|
|
|
|
|
+ columns={columns(true,offAuth)}
|
|
// bordered
|
|
// bordered
|
|
/>
|
|
/>
|
|
<Modal
|
|
<Modal
|
|
@@ -46,6 +77,8 @@ const Page: React.FC = () => {
|
|
onCancel={() => { setOpen(false) }}
|
|
onCancel={() => { setOpen(false) }}
|
|
onOk={auth}
|
|
onOk={auth}
|
|
width={"40%"}
|
|
width={"40%"}
|
|
|
|
+ loading={ConfigUser?.loading}
|
|
|
|
+ destroyOnClose
|
|
>
|
|
>
|
|
<ProTable<any, any>
|
|
<ProTable<any, any>
|
|
scroll={{ x: true, y: 600 }}
|
|
scroll={{ x: true, y: 600 }}
|
|
@@ -95,7 +128,7 @@ const Page: React.FC = () => {
|
|
</span>
|
|
</span>
|
|
<span style={{ color: 'red' }}>
|
|
<span style={{ color: 'red' }}>
|
|
{selectedRows
|
|
{selectedRows
|
|
- ?.map((item: { corpName:string,name: string, corpUserId: any }) => <Tag
|
|
|
|
|
|
+ ?.map((item: { corpName: string, name: string, corpUserId: any }) => <Tag
|
|
closable
|
|
closable
|
|
key={item?.corpUserId}
|
|
key={item?.corpUserId}
|
|
onClose={() => {
|
|
onClose={() => {
|
|
@@ -108,9 +141,11 @@ const Page: React.FC = () => {
|
|
);
|
|
);
|
|
}}
|
|
}}
|
|
toolBarRender={false}
|
|
toolBarRender={false}
|
|
- headerTitle={false}
|
|
|
|
|
|
+ // headerTitle={false}
|
|
rowKey={(r) => r.corpUserId}
|
|
rowKey={(r) => r.corpUserId}
|
|
- search={false}
|
|
|
|
|
|
+ search={{
|
|
|
|
+ labelWidth: 0,
|
|
|
|
+ }}
|
|
request={async (params) => {
|
|
request={async (params) => {
|
|
return await getNoAuthList.run(params)
|
|
return await getNoAuthList.run(params)
|
|
}}
|
|
}}
|