You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.3 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. import api from "@/api"
  2. import MyTable from "@/components/MyTable"
  3. import { getTime } from "@/utils"
  4. import { EditOutlined } from "@ant-design/icons"
  5. import { Button, Form, Input, Modal, Switch, notification } from "antd"
  6. import React, { useEffect, useRef, useState } from "react"
  7. const AssetsList = () => {
  8. const [visible, setVisible] = useState(false)
  9. const [currentItem, setCurrentItem] = useState({} as any)
  10. const [form] = Form.useForm()
  11. const currentType = useRef(1)
  12. const tableRef = useRef(null)
  13. const columns = [
  14. {
  15. title: '操作',
  16. render: (row) => {
  17. return row.status_code === 0 ? (
  18. <div style={{ display: "flex", alignItems: 'center' }}>
  19. <EditOutlined onClick={() => {
  20. setCurrentItem(() => row)
  21. setVisible(true)
  22. }} />
  23. </div>
  24. ) : <></>
  25. }
  26. },
  27. {
  28. title: '状态',
  29. dataIndex: 'status',
  30. width: 150,
  31. },
  32. {
  33. title: '类型',
  34. dataIndex: 'type',
  35. width: 200,
  36. },
  37. {
  38. title: '时间',
  39. width: 200,
  40. dataIndex: 'time',
  41. render: (time) => (
  42. <div>{getTime(time * 1000)}</div>
  43. )
  44. },
  45. {
  46. title: '用户',
  47. dataIndex: 'email',
  48. width: 240,
  49. },
  50. {
  51. title: 'MT账号',
  52. dataIndex: 'account',
  53. width: 200,
  54. },
  55. {
  56. title: '金额',
  57. dataIndex: 'amount',
  58. width: 200
  59. },
  60. {
  61. title: '订单号',
  62. dataIndex: 'order',
  63. width: 200
  64. },
  65. {
  66. title: '审核人',
  67. dataIndex: 'review',
  68. width: 200
  69. },
  70. ]
  71. useEffect(() => {
  72. !visible && setCurrentItem({})
  73. }, [visible])
  74. const onFinish = async (values) => {
  75. setVisible(false)
  76. const res: any = await api.assets_review({
  77. ...values,
  78. id: currentItem.id,
  79. status_code: currentType.current
  80. })
  81. if (res.code === 0) {
  82. tableRef.current.update()
  83. form.resetFields()
  84. notification.success({
  85. message: currentType.current === 1 ? '已拒绝' : '已同意'
  86. })
  87. }
  88. }
  89. return (
  90. <div>
  91. <MyTable
  92. apiFun={api.get_assetsList}
  93. columns={columns}
  94. ref={tableRef}
  95. searchConfigList={[{
  96. key: 'search',
  97. name: 'search',
  98. slot: <Input style={{ minWidth: 350 }} placeholder="请输入MT账号、邮箱搜索" />
  99. }]}
  100. />
  101. <Modal
  102. visible={visible}
  103. onCancel={() => setVisible(false)}
  104. footer={() => null}
  105. title={`审核用户:${currentItem.email}`}
  106. >
  107. <Form form={form} onFinish={onFinish}>
  108. <Form.Item name="reason" label="原因" initialValue="">
  109. <Input placeholder="请输入原因" />
  110. </Form.Item>
  111. <Form.Item label="邮箱通知" name="email_flag" initialValue={false} valuePropName="checked">
  112. <Switch />
  113. </Form.Item>
  114. <Form.Item>
  115. <Button onClick={() => setVisible(false)}></Button>
  116. <Button style={{ margin: '0 10px', backgroundColor: "#FF8C00", borderColor: '#FF8C00' }} type="primary" htmlType="submit" onClick={() => currentType.current = 1}></Button>
  117. <Button type="primary" htmlType="submit" onClick={() => currentType.current = 2}></Button>
  118. </Form.Item>
  119. </Form>
  120. </Modal>
  121. </div>
  122. )
  123. }
  124. export default AssetsList