expandedRowTable.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { useAjax } from "@/Hook/useAjax"
  2. import { delAdSysWarningRuleApi, DelAdSysWarningRuleProps, getSysWarningRuleApi } from "@/services/adMonitor/earlyWarning"
  3. import { SyncOutlined } from "@ant-design/icons"
  4. import { message, Table } from "antd"
  5. import React, { useEffect } from "react"
  6. import columns from "./expandedColumns"
  7. const ExpandedRowTable: React.FC<{ data: any }> = ({ data }) => {
  8. /*****************************/
  9. const getSysWarningRule = useAjax((params) => getSysWarningRuleApi(params), { formatResult: true })
  10. const delAdSysWarningRule = useAjax((params) => delAdSysWarningRuleApi(params))
  11. /*****************************/
  12. useEffect(() => {
  13. console.log(data);
  14. if (data?.id) {
  15. getSysWarningRule.run(data.id)
  16. }
  17. }, [])
  18. const del = (data: DelAdSysWarningRuleProps) => {
  19. let { accountId, adgroupId, campaignId } = data
  20. delAdSysWarningRule.run([{ accountId, adgroupId, campaignId }]).then(res => {
  21. message.success('删除成功')
  22. getSysWarningRule.refresh()
  23. })
  24. }
  25. return <Table
  26. size="small"
  27. bordered
  28. columns={columns(del)}
  29. loading={getSysWarningRule.loading}
  30. dataSource={getSysWarningRule?.data?.data}
  31. title={() => <div style={{ textAlign: 'center', color: '#1890ff', fontWeight: 700, position: 'relative' }}>
  32. <span>当前规则配置下的广告</span>
  33. <a style={{ position: 'absolute', left: 0 }} onClick={() => getSysWarningRule.refresh()}><SyncOutlined /></a>
  34. </div>}
  35. pagination={false}
  36. />;
  37. }
  38. export default React.memo(ExpandedRowTable)