中泽后台管理前端
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.

index.tsx 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. import React, { useState, useRef, useEffect } from 'react';
  2. import { useIntl, FormattedMessage, useAccess } from '@umijs/max';
  3. import type { FormInstance } from 'antd';
  4. import { Button, message, Modal, Image } from 'antd';
  5. import { ActionType, FooterToolbar, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
  6. import { PlusOutlined, DeleteOutlined, ExclamationCircleOutlined, RedoOutlined } from '@ant-design/icons';
  7. // import { getNoticeList, removeNotice, addNotice, updateNotice, exportNotice } from '@/services/system/notice';
  8. import { getBiddingDocumentList, saveBiddingDocument, deleteBiddingDocument, pushBiddingDocumentDetail,pushJoinList,pushJoin,pushBiddingDocumentDetailAll } from '@/services/JoinZZ/biddingDocument';
  9. import BiddingDocumentForm from './edit';
  10. import { getDictValueEnum } from '@/services/system/dict';
  11. import moment from 'moment';
  12. import { KeepAlive } from 'react-activation';
  13. import './index.less'
  14. import DictTag from '../../../components/DictTag';
  15. import { getDataEnumList } from '../../../services/system/Enum';
  16. const stateEnum = [
  17. { label: '待发布', value: 0 },
  18. { label: '已发布', value: 1 },
  19. ]
  20. const NoticeTableList: React.FC = () => {
  21. const formTableRef = useRef<FormInstance>();
  22. const [modalVisible, setModalVisible] = useState<boolean>(false);
  23. const actionRef = useRef<ActionType>();
  24. const intl = useIntl();
  25. const [currentRow, setCurrentRow] = useState<any>();
  26. const [enumList,setEnumList] = useState()
  27. const handleRemoveOne = async (selectedRow: API.System.Notice) => {
  28. const hide = message.loading(intl.formatMessage({ id: 'public.loadingDelete' }));
  29. if (!selectedRow) return true;
  30. try {
  31. const params = [selectedRow.uuid];
  32. const resp = await deleteBiddingDocument(params.join(','));
  33. hide();
  34. if (resp.code === 200) {
  35. message.success(intl.formatMessage({ id: 'public.deleteSuccess' }));
  36. } else {
  37. message.error(resp.msg);
  38. }
  39. return true;
  40. } catch (error) {
  41. hide();
  42. message.error(intl.formatMessage({ id: 'public.deleteError' }));
  43. return false;
  44. }
  45. };
  46. useEffect(() => {
  47. getEnum()
  48. }, [])
  49. const getEnum = ()=>{
  50. getDataEnumList({ enumUuid: '2024810214616101' }).then((res) => {
  51. console.log(res.rows)
  52. const enumOptions = res.rows.map((item: any) => ({
  53. label: item.dataName,
  54. value: item.uuid,
  55. }));
  56. setEnumList(enumOptions); // 设置 enumList
  57. })
  58. }
  59. const columns: ProColumns<API.System.Notice>[] = [
  60. {
  61. title: '序号',
  62. dataIndex: 'id',
  63. valueType: 'text',
  64. hideInSearch: true,
  65. render: (_, record: any) => {
  66. // console.log('record---',_,record)
  67. return record.rowIndex;
  68. },
  69. },
  70. {
  71. title: '标题',
  72. dataIndex: 'title',
  73. valueType: 'text',
  74. },
  75. {
  76. title: '展示日期',
  77. dataIndex: 'date',
  78. valueType: 'text',
  79. hideInSearch: true,
  80. },
  81. {
  82. title: '浏览次数',
  83. dataIndex: 'vievNum',
  84. valueType: 'text',
  85. hideInSearch: true,
  86. },
  87. {
  88. title: '状态',
  89. dataIndex: 'pushStatus',
  90. valueType: 'radio',
  91. request: async () => stateEnum,
  92. render: (_, record) => {
  93. return (<DictTag enums={stateEnum} value={record.pushStatus} />);
  94. },
  95. hideInSearch: true,
  96. },
  97. {
  98. title: '操作',
  99. dataIndex: 'option',
  100. width: '120px',
  101. valueType: 'option',
  102. render: (_, record: any) => [
  103. <Button
  104. type="link"
  105. size="small"
  106. key="edit"
  107. onClick={() => {
  108. setModalVisible(true);
  109. setCurrentRow(record);
  110. }}
  111. >
  112. 编辑
  113. </Button>,
  114. <Button
  115. type="link"
  116. size="small"
  117. key="publish"
  118. disabled={record.pushStatus == 0 ? false : true}
  119. onClick={() => {
  120. let params = {
  121. uuid: record.uuid,
  122. }
  123. pushBiddingDocumentDetail(params).then((res: any) => {
  124. if (res.code == 200) {
  125. if (actionRef.current) {
  126. actionRef.current.reload();
  127. }
  128. message.success(res.msg)
  129. } else {
  130. message.error(res.msg)
  131. }
  132. })
  133. }}
  134. >
  135. {record.pushStatus == 0 ? '发布' : '已发布'}
  136. </Button>,
  137. <Button
  138. type="link"
  139. size="small"
  140. danger
  141. key="batchRemove"
  142. onClick={async () => {
  143. Modal.confirm({
  144. title: intl.formatMessage({ id: 'public.delete' }),
  145. content: intl.formatMessage({ id: 'public.confirmdeletemsg' }),
  146. okText: intl.formatMessage({ id: 'public.confirm' }),
  147. cancelText: intl.formatMessage({ id: 'public.cancel' }),
  148. onOk: async () => {
  149. const success = await handleRemoveOne(record);
  150. if (success) {
  151. if (actionRef.current) {
  152. actionRef.current.reload();
  153. }
  154. }
  155. },
  156. });
  157. }}
  158. >
  159. <FormattedMessage id="public.delete" defaultMessage="删除" />
  160. </Button>,
  161. ],
  162. },
  163. ];
  164. /**
  165. * 一键发布
  166. */
  167. const publishing = async () => {
  168. try {
  169. const resp = await pushJoinList();
  170. if (resp.code === 200) {
  171. message.success('发布成功');
  172. if(actionRef){
  173. actionRef.current.reload();
  174. }
  175. } else {
  176. message.error(resp.msg);
  177. }
  178. } catch (error) { }
  179. }
  180. return (
  181. <KeepAlive name={'招标文件'} path="/JoinZZ/biddingDocument">
  182. <PageContainer>
  183. <div style={{ width: '100%', float: 'right' }}>
  184. <ProTable<API.System.Notice>
  185. actionRef={actionRef}
  186. formRef={formTableRef}
  187. rowKey="uuid"
  188. key="newsList"
  189. search={{
  190. labelWidth: 120,
  191. }}
  192. toolBarRender={() => [
  193. <Button
  194. type="primary"
  195. key="add"
  196. onClick={async () => {
  197. setCurrentRow(undefined);
  198. setModalVisible(true);
  199. }}
  200. >
  201. <PlusOutlined /> <FormattedMessage id="public.add" defaultMessage="新建" />
  202. </Button>,
  203. <Button
  204. type="primary"
  205. key="fabu"
  206. onClick={publishing}
  207. >
  208. 一键发布
  209. </Button>,
  210. ]}
  211. request={(params) => {
  212. return getBiddingDocumentList({ ...params } as API.System.NoticeListParams).then((res) => {
  213. res.rows.forEach((item: any, index: any) => {
  214. item.rowIndex = index + 1
  215. })
  216. const result = {
  217. data: res.rows,
  218. total: res.total,
  219. success: true,
  220. };
  221. return result;
  222. })
  223. }
  224. }
  225. columns={columns}
  226. />
  227. </div>
  228. <BiddingDocumentForm
  229. onSubmit={async (values) => {
  230. let success = false;
  231. if (currentRow) {
  232. values.uuid = currentRow.uuid;
  233. }
  234. success = await saveBiddingDocument({ ...values });
  235. if (success) {
  236. setModalVisible(false);
  237. setCurrentRow(undefined);
  238. if (actionRef.current) {
  239. actionRef.current.reload();
  240. }
  241. }
  242. }}
  243. onCancel={() => {
  244. setModalVisible(false);
  245. setCurrentRow(undefined);
  246. }}
  247. currentRow={currentRow}
  248. open={modalVisible}
  249. />
  250. </PageContainer>
  251. </KeepAlive>
  252. );
  253. };
  254. export default NoticeTableList;