index.tsx 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. import { FC, useState } from "react";
  2. import classNames from "classnames";
  3. import { Col, Form, Input, InputNumber, Radio, Row, Select } from "antd";
  4. import { useNavigate } from "react-router-dom";
  5. import { FileTemplateTable, FormPageFooter, PageContainer } from "@/components";
  6. import style from "./index.module.scss";
  7. const { TextArea } = Input;
  8. const CONFIRM_OPTIONS = [
  9. {
  10. label: "是",
  11. value: 1,
  12. },
  13. {
  14. label: "否",
  15. value: 0,
  16. },
  17. ];
  18. const CreateOrEditIndex: FC = () => {
  19. const navigate = useNavigate();
  20. const [form] = Form.useForm();
  21. const [fields, setFields] = useState<any[]>([
  22. {
  23. name: "dfd",
  24. value: 1,
  25. },
  26. {
  27. name: "gjqz",
  28. value: 1,
  29. },
  30. ]);
  31. const handleSubmit = async () => {
  32. if (!(await form.validateFields())) return;
  33. console.log(form.getFieldsValue());
  34. };
  35. return (
  36. <PageContainer title="新增指标">
  37. <Form
  38. fields={fields}
  39. labelCol={{ span: 4 }}
  40. form={form}
  41. onFieldsChange={(_, newFields) => {
  42. setFields(newFields);
  43. }}
  44. onFinish={handleSubmit}
  45. >
  46. <Form.Item label="父级指标">
  47. <Select className="mw650" placeholder="请选择" options={[]} />
  48. </Form.Item>
  49. <Form.Item label="指标名称" required>
  50. <Input
  51. className="mw650"
  52. placeholder="请输入内容,最多20字"
  53. showCount
  54. maxLength={20}
  55. />
  56. </Form.Item>
  57. <Form.Item label="指标编号">
  58. <Input
  59. className="mw650"
  60. placeholder="请输入内容,最多20字"
  61. showCount
  62. maxLength={20}
  63. />
  64. </Form.Item>
  65. <Form.Item label="指标说明">
  66. <TextArea
  67. className="mw650"
  68. showCount
  69. maxLength={500}
  70. placeholder="请输入内容,最多500字"
  71. style={{ height: 120, resize: "none" }}
  72. />
  73. </Form.Item>
  74. <Form.Item label="打分点" name="dfd">
  75. <Radio.Group
  76. options={CONFIRM_OPTIONS}
  77. optionType="button"
  78. buttonStyle="solid"
  79. />
  80. </Form.Item>
  81. <Form.Item label=" " colon={false} style={{ marginTop: -14 }}>
  82. <div className={classNames("mw650", style.panel)}>
  83. {fields[0].value ? (
  84. <>
  85. <Form.Item required label="指标分值" labelCol={{ span: 4 }}>
  86. <InputNumber
  87. precision={0}
  88. placeholder="请输入正整数"
  89. className="w160"
  90. />
  91. </Form.Item>
  92. <Form.Item label="数据API" labelCol={{ span: 4 }}>
  93. <Input placeholder="请输入地址" style={{ width: 427 }} />
  94. </Form.Item>
  95. <Form.Item label="加分项" labelCol={{ span: 4 }} colon={false}>
  96. <span className={style.tips}>
  97. 注:设为加分项后,该指标的分值不会参与父级指标的计算
  98. </span>
  99. </Form.Item>
  100. </>
  101. ) : (
  102. <Form.Item label="分值:0" labelCol={{ span: 4 }} colon={false}>
  103. <span className={style.tips}>
  104. 注:当指标不作为打分点时,分值=该指标各分项分值(除加分项)之和
  105. </span>
  106. </Form.Item>
  107. )}
  108. </div>
  109. </Form.Item>
  110. <Form.Item label="告警阈值" name="gjqz">
  111. <Radio.Group
  112. options={CONFIRM_OPTIONS}
  113. optionType="button"
  114. buttonStyle="solid"
  115. />
  116. </Form.Item>
  117. {fields[1].value ? (
  118. <Form.Item label=" " colon={false} style={{ marginTop: -14 }}>
  119. <div
  120. className={classNames("mw650", style.panel)}
  121. style={{ padding: "10px 30px" }}
  122. >
  123. <Row gutter={10}>
  124. <Col span={8}>
  125. <Select placeholder="请选择" options={[]} />
  126. </Col>
  127. <Col span={12}>
  128. <InputNumber
  129. precision={0}
  130. placeholder="请输入正整数"
  131. className="w100"
  132. />
  133. </Col>
  134. <Col span={4}>
  135. <span className={style.required}>(必填)</span>
  136. </Col>
  137. </Row>
  138. <Radio.Group
  139. options={[
  140. {
  141. label: "与",
  142. value: 0,
  143. },
  144. {
  145. label: "否",
  146. value: 1,
  147. },
  148. ]}
  149. style={{ margin: "3px 0" }}
  150. />
  151. <Row gutter={10}>
  152. <Col span={8}>
  153. <Select placeholder="请选择" options={[]} />
  154. </Col>
  155. <Col span={12}>
  156. <InputNumber
  157. precision={0}
  158. placeholder="请输入正整数"
  159. className="w100"
  160. />
  161. </Col>
  162. <Col span={4}></Col>
  163. </Row>
  164. </div>
  165. </Form.Item>
  166. ) : (
  167. ""
  168. )}
  169. <Form.Item label="需上传资料">
  170. <FileTemplateTable />
  171. </Form.Item>
  172. <Form.Item required label="排序值">
  173. <InputNumber
  174. precision={0}
  175. min={1}
  176. max={999}
  177. placeholder="请输入1~999的数字。数字越小,排序越靠前"
  178. className="mw650 w100"
  179. />
  180. </Form.Item>
  181. <FormPageFooter onSubmit={handleSubmit} onCancel={() => navigate(-1)} />
  182. </Form>
  183. </PageContainer>
  184. );
  185. };
  186. export default CreateOrEditIndex;