index.tsx 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. import React, { useState } from 'react';
  2. import { Space, Table, Button, Input, Select, Tabs } from 'antd';
  3. import type { TableProps } from 'antd';
  4. import styles from './index.module.css';
  5. import PunlishPlanModal from '../weGZH/components/publishPlanModal';
  6. import { wxPlanType } from './type';
  7. const WeGZHContent: React.FC = () => {
  8. // 状态管理
  9. const [videoTitle, setVideoTitle] = useState<string>('');
  10. const [selectedPublisher, setSelectedPublisher] = useState<string>();
  11. const [isShowAddPunlishPlan, setIsShowAddPunlishPlan] = useState<boolean>(false);
  12. const [actionType, setActionType] = useState<'add' | 'edit'>('add');
  13. const [editPlanData, setEditPlanData] = useState<wxPlanType>();
  14. const [activeKey, setActiveKey] = useState<string>('1');
  15. // 表格列配置
  16. const columns: TableProps<wxPlanType>['columns'] = [
  17. {
  18. title: '公众号名称',
  19. dataIndex: 'officialAccount',
  20. key: 'officialAccount',
  21. },
  22. {
  23. title: '场景',
  24. dataIndex: 'scene',
  25. key: 'scene',
  26. },
  27. {
  28. title: '视频数量',
  29. dataIndex: 'videoCount',
  30. key: 'videoCount',
  31. },
  32. {
  33. title: '视频标题',
  34. dataIndex: 'videoTitle',
  35. key: 'videoTitle',
  36. ellipsis: true,
  37. },
  38. {
  39. title: '计划创建时间',
  40. dataIndex: 'planPublishTime',
  41. key: 'planPublishTime',
  42. },
  43. {
  44. title: '发布方',
  45. dataIndex: 'publisher',
  46. key: 'publisher',
  47. },
  48. {
  49. title: '操作',
  50. key: 'action',
  51. render: (_, record) => (
  52. <Space size="middle">
  53. <Button type="link" onClick={() => editPlan(record)}>编辑</Button>
  54. <Button type="link">详情</Button>
  55. </Space>
  56. ),
  57. },
  58. ];
  59. const editPlan = (record: wxPlanType) => {
  60. console.log(editPlanData)
  61. setEditPlanData(record);
  62. setActionType('edit');
  63. setIsShowAddPunlishPlan(true);
  64. };
  65. // 模拟数据
  66. const data: wxPlanType[] = [
  67. {
  68. officialAccount: '小慧爱厨房',
  69. scene: 1,
  70. videoCount: 3,
  71. videoTitle: '养老金最新规定,快来看看...',
  72. planPublishTime: '2024-08-13 13:32:07',
  73. publisher: '平台发布',
  74. videoList: [],
  75. },
  76. {
  77. officialAccount: '小阳看天下',
  78. scene: 1,
  79. videoCount: 1,
  80. videoTitle: '养老金最新规定,快来看看...',
  81. planPublishTime: '2024-08-13 13:32:07',
  82. publisher: '用户发布',
  83. videoList: [],
  84. },
  85. ];
  86. const addPunlishPlan = () => {
  87. setActionType('add');
  88. setIsShowAddPunlishPlan(true);
  89. }
  90. return (
  91. <div>
  92. <div className="rounded-lg">
  93. <div className="text-lg font-medium mb-3">公众号内容</div>
  94. {/* 搜索区域 */}
  95. <div className="flex flex-wrap gap-4 mb-3">
  96. <div className="flex items-center gap-2">
  97. <span className="text-gray-600">视频标题:</span>
  98. <Input
  99. placeholder="搜索视频标题"
  100. style={{ width: 200 }}
  101. value={videoTitle}
  102. allowClear
  103. onChange={e => setVideoTitle(e.target.value)}
  104. />
  105. </div>
  106. <div className="flex items-center gap-2">
  107. <span className="text-gray-600">发布方:</span>
  108. <Select
  109. placeholder="筛选场景"
  110. style={{ width: 200 }}
  111. value={selectedPublisher}
  112. onChange={setSelectedPublisher}
  113. allowClear
  114. options={[
  115. { label: '关注回复', value: 'platform' },
  116. { label: '用户发布', value: 'user' },
  117. ]}
  118. />
  119. </div>
  120. <Button type="primary" className="ml-2">搜索</Button>
  121. </div>
  122. <Tabs
  123. defaultActiveKey="1"
  124. type="card"
  125. size="large"
  126. items={[
  127. { label: '每日推送', key: '1' },
  128. { label: '自动回复', key: '2' },
  129. ]}
  130. activeKey={activeKey}
  131. onChange={setActiveKey}
  132. tabBarExtraContent={
  133. { right: <Button type="primary" onClick={addPunlishPlan}>+ 创建发布</Button> }}
  134. />
  135. {/* 表格区域 */}
  136. {
  137. activeKey === '1' && (
  138. <Table
  139. rowKey={(record) => record.officialAccount}
  140. className={styles.antTable}
  141. columns={columns}
  142. dataSource={data}
  143. pagination={{
  144. total: data.length,
  145. pageSize: 10,
  146. showTotal: (total) => `共 ${total} 条`,
  147. }}
  148. />
  149. )
  150. }
  151. {
  152. activeKey === '2' && (
  153. <Table
  154. rowKey={(record) => record.officialAccount}
  155. className={styles.antTable}
  156. columns={columns}
  157. dataSource={data}
  158. pagination={{
  159. total: data.length,
  160. pageSize: 10,
  161. showTotal: (total) => `共 ${total} 条`,
  162. }}
  163. />
  164. )
  165. }
  166. <PunlishPlanModal
  167. visible={isShowAddPunlishPlan}
  168. onCancel={() => setIsShowAddPunlishPlan(false)}
  169. onOk={() => setIsShowAddPunlishPlan(false)}
  170. actionType={actionType}
  171. editPlanData={undefined}
  172. />
  173. </div>
  174. </div>
  175. );
  176. };
  177. export default WeGZHContent;