123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. import React, { useState, useEffect } from "react";
  2. import { useNavigate } from "react-router-dom";
  3. import {
  4. Button,
  5. Row,
  6. Col,
  7. Form,
  8. Input,
  9. InputNumber,
  10. Card,
  11. Checkbox,
  12. } from "antd";
  13. import {
  14. getSupportCapabilityDetail,
  15. updateSupportCapability,
  16. } from "@/services/supportCapability";
  17. const configList = [
  18. {
  19. //12个
  20. title: "常规膳食保障",
  21. children: [
  22. {
  23. name: "dietDaily",
  24. label: "单日整体膳食供应能力(人次)",
  25. },
  26. {
  27. name: "dietSingle",
  28. label: "单次整体膳食供应能力(人)",
  29. },
  30. {
  31. name: "dietStationDaily",
  32. label: "单日站内膳食供应能力(人次)",
  33. },
  34. {
  35. name: "dietStationSingle",
  36. label: "单次站内膳食供应能力(人)",
  37. },
  38. {
  39. name: "dietRemoteDaily",
  40. label: "单日远程膳食供应能力(人次)",
  41. },
  42. {
  43. name: "dietRemoteSingle",
  44. label: "单次远程膳食供应能力(人)",
  45. },
  46. {
  47. name: "dietSocializationDaily",
  48. label: "单日社会化膳食供应能力(人次)",
  49. },
  50. {
  51. name: "dietSocializationSingle",
  52. label: "单次社会化膳食供应能力(人)",
  53. },
  54. {
  55. name: "dietTempDailyNum",
  56. label: "单日临时制膳点数量(个)",
  57. },
  58. {
  59. name: "dietTempSingleNum",
  60. label: "单次临时制膳点数量(个)",
  61. },
  62. {
  63. name: "dietTempDaily",
  64. label: "单日临时制膳点供应能力(人次)",
  65. },
  66. {
  67. name: "dietTempSingle",
  68. label: "单次临时制膳点供应能力(人)",
  69. },
  70. ],
  71. },
  72. {
  73. title: "应急膳食保障",
  74. children: [
  75. {
  76. name: "dietDailyEmergency",
  77. label: "应急单日整体膳食供应能力(人次)",
  78. key: 13,
  79. },
  80. {
  81. name: "dietSingleEmergency",
  82. label: "应急单次整体膳食供应能力(人)",
  83. key: 14,
  84. },
  85. {
  86. name: "dietStationDailyEmergency",
  87. label: "应急单日站内膳食供应能力(人次)",
  88. key: 15,
  89. },
  90. {
  91. name: "dietStationSingleEmergency",
  92. label: "应急单次站内膳食供应能力(人)",
  93. key: 16,
  94. },
  95. {
  96. name: "dietRemoteDailyEmergency",
  97. label: "应急单日远程膳食供应能力(人次)",
  98. key: 17,
  99. },
  100. {
  101. name: "dietRemoteSingleEmergency",
  102. label: "应急单次远程膳食供应能力(人)",
  103. key: 18,
  104. },
  105. {
  106. name: "dietSocializationDailyEmergency",
  107. label: "应急单日社会化膳食供应能力(人次)",
  108. key: 19,
  109. },
  110. {
  111. name: "dietSocializationSingleEmergency",
  112. label: "应急单次社会化膳食供应能力(人)",
  113. key: 20,
  114. },
  115. {
  116. name: "dietTempDailyNumEmergency",
  117. label: "应急单日临时制膳点数量(个)",
  118. key: 21,
  119. },
  120. {
  121. name: "dietTempSingleNumEmergency",
  122. label: "应急单次临时制膳点数量(个)",
  123. key: 22,
  124. },
  125. {
  126. name: "dietTempDailyEmergency",
  127. label: "应急单日临时制膳点供应能力(人次)",
  128. key: 23,
  129. },
  130. {
  131. name: "dietTempSingleEmergency",
  132. label: "应急单次临时制膳点供应能力(人)",
  133. key: 24,
  134. },
  135. ],
  136. },
  137. {
  138. title: "常规住宿保障",
  139. children: [
  140. {
  141. name: "stayCapability",
  142. label: "整体住宿供应能力(人)",
  143. key: 25,
  144. },
  145. {
  146. name: "stayStation",
  147. label: "站内住宿供应能力(人)",
  148. key: 26,
  149. },
  150. {
  151. name: "staySocialization",
  152. label: "社会化住宿供应能力(人)",
  153. key: 27,
  154. },
  155. ],
  156. },
  157. {
  158. title: "应急住宿保障",
  159. children: [
  160. {
  161. name: "stayCapabilityEmergency",
  162. label: "应急整体住宿供应能力(人)",
  163. key: 28,
  164. },
  165. {
  166. name: "stayStationEmergency",
  167. label: "应急站内住宿供应能力(人)",
  168. key: 29,
  169. },
  170. {
  171. name: "staySocializationEmergency",
  172. label: "应急社会化住宿供应能力(人)",
  173. key: 30,
  174. },
  175. ],
  176. },
  177. {
  178. title: "运输送出保障车辆",
  179. children: [
  180. {
  181. name: "cartNum",
  182. label: "车辆总数(台)",
  183. key: 31,
  184. },
  185. {
  186. name: "cookingCart",
  187. label: "野外自行式炊事车(台)",
  188. key: 32,
  189. },
  190. {
  191. name: "transportVehicle",
  192. label: "送餐车(台)",
  193. key: 33,
  194. },
  195. ],
  196. },
  197. {
  198. title: "物资保障",
  199. children: [
  200. {
  201. name: "supportCapability",
  202. label: "物资供应能力(人)",
  203. key: 34,
  204. },
  205. ],
  206. },
  207. ];
  208. export default (props) => {
  209. const [form] = Form.useForm();
  210. const [loading, setLoading] = useState(false);
  211. const onFinish = (values) => {
  212. setLoading(true);
  213. updateSupportCapability(1, {
  214. ...values,
  215. serviceCapability: values.serviceCapability
  216. ? values.serviceCapability?.join(",")
  217. : null,
  218. })
  219. .then((res) => {
  220. setLoading(false);
  221. })
  222. .catch(() => {});
  223. };
  224. useEffect(() => {
  225. getSupportCapabilityDetail(1).then((res) => {
  226. console.log(res, "getSupportCapabilityDetail");
  227. if (res) {
  228. form.setFieldsValue({
  229. ...res,
  230. serviceCapability: res.serviceCapability
  231. ? res.serviceCapability?.split(",")
  232. : null,
  233. });
  234. }
  235. });
  236. }, [form]);
  237. return (
  238. <Card>
  239. <Form layout="vertical" form={form} onFinish={onFinish}>
  240. {configList?.map((x, index1) => (
  241. <div key={index1}>
  242. <h3 style={{ marginBottom: "1.5em", fontWeight: 700 }}>
  243. {x.title}
  244. </h3>
  245. <Row gutter={48}>
  246. {x?.children?.map((item, index2) => (
  247. <Col span={6} key={index2}>
  248. <Form.Item label={item.label} name={item.name}>
  249. <InputNumber style={{ width: "100%" }} precision={0} />
  250. </Form.Item>
  251. </Col>
  252. ))}
  253. </Row>
  254. </div>
  255. ))}
  256. <h3 style={{ marginBottom: "1.5em", fontWeight: 700 }}>服务能力</h3>
  257. <Form.Item name="serviceCapability">
  258. <Checkbox.Group
  259. options={[
  260. "洗澡",
  261. "WIFI",
  262. "电脑",
  263. "报纸/图书",
  264. "手机充电",
  265. "代购",
  266. "休息",
  267. ]}
  268. />
  269. </Form.Item>
  270. <Row gutter={48}>
  271. <Col offset={6} span={12}>
  272. <Button type="primary" htmlType="submit" loading={loading}>
  273. 提交
  274. </Button>
  275. </Col>
  276. </Row>
  277. </Form>
  278. </Card>
  279. );
  280. };