tableConfig.tsx 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. import { copy } from "@/utils/utils"
  2. import { Badge, Button, Space, Typography } from "antd"
  3. import { ColumnsType } from "antd/es/table"
  4. import { tableDfixed } from "@/utils/tableDfixed"
  5. const { Text } = Typography;
  6. export function TableConfig(handle: (data: any, type: string) => void): ColumnsType<any> {
  7. let arr: ColumnsType<any> = [
  8. {
  9. title: '企微名称',
  10. dataIndex: 'corpName',
  11. key: 'corpName',
  12. width: 150,
  13. ellipsis: true,
  14. fixed: 'left'
  15. },
  16. {
  17. title: 'corpId',
  18. dataIndex: 'corpId',
  19. key: 'corpId',
  20. align: 'center',
  21. width: 150,
  22. ellipsis: true,
  23. fixed: 'left',
  24. render: (a: any) => {
  25. return <a onClick={() => copy(a)}>{a}</a>
  26. }
  27. },
  28. {
  29. title: '企微ID',
  30. dataIndex: 'originCorpId',
  31. key: 'originCorpId',
  32. align: 'center',
  33. width: 125,
  34. ellipsis: true,
  35. render(value) {
  36. return value || '--'
  37. },
  38. },
  39. {
  40. title: '用户规模',
  41. dataIndex: 'corpUserMax',
  42. key: 'corpUserMax',
  43. align: 'center',
  44. width: 100,
  45. render(value) {
  46. return value && value === 0 ? value : '--'
  47. },
  48. },
  49. {
  50. title: '授权方企业类型',
  51. dataIndex: 'corpType',
  52. key: 'corpType',
  53. align: 'center',
  54. width: 60,
  55. render: (a: string) => {
  56. return <span>{{ verified: '认证号', unverified: '注册号' }[a] || '--'}</span>
  57. }
  58. },
  59. {
  60. title: '认证到期时间',
  61. dataIndex: 'verifiedEndTime',
  62. key: 'verifiedEndTime',
  63. align: 'center',
  64. width: 120,
  65. render(value) {
  66. return value || '--'
  67. },
  68. },
  69. {
  70. title: '授权状态',
  71. dataIndex: 'authStatus',
  72. key: 'authStatus',
  73. align: 'center',
  74. width: 80,
  75. render: (a: any) => {
  76. return <span>{a === 1 ? <Badge status="success" text='成功授权' /> : <Badge status="error" text='取消授权' />}</span>
  77. }
  78. },
  79. {
  80. title: '配置状态',
  81. dataIndex: 'configStatus',
  82. key: 'configStatus',
  83. align: 'center',
  84. width: 80,
  85. render: (a: any) => {
  86. return <span>{({ 'SUCCESS': <Badge status="success" text='配置成功' />, 'ING': <Badge status="default" text='未配置' /> } as any)[a] || <Badge status="error" text='配置失败' />}</span>
  87. }
  88. },
  89. {
  90. title: '回调地址',
  91. dataIndex: 'externalUserCallbackUrl',
  92. key: 'externalUserCallbackUrl',
  93. width: 150,
  94. ellipsis: true,
  95. render: (a: any) => {
  96. return <a onClick={() => copy(a)}>{a || '--'}</a>
  97. }
  98. },
  99. {
  100. title: 'Token',
  101. dataIndex: 'externalUserToken',
  102. key: 'externalUserToken',
  103. width: 150,
  104. ellipsis: true,
  105. render: (a: any) => {
  106. return <a onClick={() => copy(a)}>{a || '--'}</a>
  107. }
  108. },
  109. {
  110. title: 'AESKey',
  111. dataIndex: 'externalUserAesKey',
  112. key: 'externalUserAesKey',
  113. width: 150,
  114. ellipsis: true,
  115. render: (a: any) => {
  116. return <a onClick={() => copy(a)}>{a || '--'}</a>
  117. }
  118. },
  119. {
  120. title: '授权时间',
  121. dataIndex: 'createTime',
  122. key: 'createTime',
  123. align: 'center',
  124. width: 130,
  125. ellipsis: true,
  126. },
  127. {
  128. title: '备注',
  129. dataIndex: 'remark',
  130. key: 'remark',
  131. width: 200,
  132. ellipsis: true,
  133. render(value) {
  134. return value || '--'
  135. },
  136. },
  137. {
  138. title: '操作',
  139. dataIndex: 'cz',
  140. key: 'cz',
  141. align: 'center',
  142. width: 100,
  143. fixed: 'right',
  144. render: (a, b) => {
  145. return <Space wrap size={'small'}>
  146. <a onClick={() => handle(b, 'sx')}>修改</a>
  147. <a onClick={() => handle(b, 'txl')}>企微通讯录</a>
  148. </Space>
  149. }
  150. },
  151. ]
  152. return tableDfixed(arr)
  153. }
  154. export function TableMailConfig(handle?: (data: any, type: string) => void, setAccountOpen?: (d: any) => void, setChangeLog?: (d: any) => void): ColumnsType<any> {
  155. let arr: ColumnsType<any> = [
  156. {
  157. title: '企微号ID',
  158. dataIndex: 'corpUserId',
  159. key: 'corpUserId',
  160. align: 'center',
  161. width: 80,
  162. ellipsis: true,
  163. fixed: 'left'
  164. },
  165. {
  166. title: '企微号',
  167. dataIndex: 'name',
  168. key: 'name',
  169. align: 'center',
  170. width: 90,
  171. ellipsis: true,
  172. },
  173. {
  174. title: '公众号',
  175. dataIndex: 'mpAccountInfo.name',
  176. key: 'mpAccountInfo.name',
  177. align: 'center',
  178. width: 90,
  179. ellipsis: true,
  180. render: (a: any, b: any) => {
  181. return b?.mpAccountInfo?.name || '--'
  182. }
  183. },
  184. {
  185. title: '书城',
  186. dataIndex: 'mpAccountInfo.platformName',
  187. key: 'mpAccountInfo.platformName',
  188. align: 'center',
  189. width: 90,
  190. ellipsis: true,
  191. render: (a: any, b: any) => {
  192. return b?.mpAccountInfo?.platformName || '--'
  193. }
  194. },
  195. {
  196. title: '运营',
  197. dataIndex: 'operUserId',
  198. key: 'operUserId',
  199. align: 'center',
  200. width: 90,
  201. ellipsis: true,
  202. render: (a: any, b: any) => {
  203. return b?.operUser?.nickName || '--'
  204. }
  205. },
  206. {
  207. title: '投手',
  208. dataIndex: 'putUserId',
  209. key: 'putUserId',
  210. align: 'center',
  211. width: 90,
  212. ellipsis: true,
  213. render: (a: any, b: any) => {
  214. return b?.putUser?.nickName || '--'
  215. }
  216. },
  217. {
  218. title: '运营助手',
  219. dataIndex: 'userList',
  220. key: 'userList',
  221. align: 'center',
  222. width: 90,
  223. ellipsis: true,
  224. render: (a: any[], b: any) => {
  225. return <Text ellipsis={{ tooltip: true }}>{a?.map(item => item?.nickname)?.toString() || '--'}</Text>
  226. }
  227. },
  228. {
  229. title: '状态',
  230. dataIndex: 'status',
  231. key: 'status',
  232. align: 'center',
  233. width: 80,
  234. render: (a: number) => {
  235. return <span>{a === 1 ? '已激活' : a === 2 ? '已禁用' : a === 4 ?
  236. '未激活' : a === 5 ? '退出企业' : '--'}</span>
  237. }
  238. },
  239. {
  240. title: '创建时间',
  241. dataIndex: 'createTime',
  242. key: 'createTime',
  243. align: 'center',
  244. ellipsis: true,
  245. width: 120
  246. },
  247. {
  248. title: '操作',
  249. dataIndex: 'cz',
  250. key: 'cz',
  251. align: 'center',
  252. width: 200,
  253. fixed: 'right',
  254. render: (a, b) => {
  255. return <Space wrap size={'small'}>
  256. <Button size='small' type="link" style={{ padding: 0 }} onClick={() => handle?.([b], '')}>指派</Button>
  257. <Button size='small' type="link" style={{ padding: 0 }} onClick={() => handle?.([b], 'zs')}>运营助手指派</Button>
  258. <Button size='small' type="link" style={{ padding: 0 }} onClick={() => setAccountOpen?.(b)}>指派公众号</Button>
  259. <Button size='small' type="link" style={{ padding: 0 }} onClick={() => setChangeLog?.(b)}>变更记录</Button>
  260. </Space>
  261. }
  262. },
  263. ]
  264. return tableDfixed(arr)
  265. }
  266. export function TableChangeLogConfig(): ColumnsType<any> {
  267. let arr: ColumnsType<any> = [
  268. {
  269. title: 'ID',
  270. dataIndex: 'id',
  271. key: 'id',
  272. align: 'center',
  273. width: 30,
  274. ellipsis: true,
  275. },
  276. {
  277. title: '变更时间',
  278. dataIndex: 'createTime',
  279. key: 'createTime',
  280. align: 'center',
  281. width: 120,
  282. ellipsis: true,
  283. },
  284. {
  285. title: '变更后公众号',
  286. dataIndex: 'mpAccount.name',
  287. key: 'mpAccount.name',
  288. align: 'center',
  289. width: 80,
  290. ellipsis: true,
  291. render: (a: any, b: any) => {
  292. return b?.mpAccount?.name || '--'
  293. }
  294. },
  295. {
  296. title: '变更后书城',
  297. dataIndex: 'mpAccount.platformName',
  298. key: 'mpAccount.platformName',
  299. align: 'center',
  300. width: 80,
  301. ellipsis: true,
  302. render: (a: any, b: any) => {
  303. return b?.mpAccount?.platformName || '--'
  304. }
  305. },
  306. ]
  307. return arr
  308. }