Modal.jsx 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. import {
  2. Form,
  3. Modal,
  4. Row,
  5. Col,
  6. Input,
  7. DatePicker,
  8. Upload,
  9. Button,
  10. Divider,
  11. Steps,
  12. } from 'antd';
  13. import ModuleTitle from '../../../components/ModuleTitle/moduleTitle';
  14. import { CloudUploadOutlined } from '@ant-design/icons';
  15. import moment from 'moment';
  16. const ContractModal = (props) => {
  17. const Type = {
  18. add: 0, //新增
  19. detail: 1, //详情
  20. cancel: 2, //作废
  21. };
  22. const FORMAT = 'YYYY-MM-DD';
  23. const { title, type, visible, handleOk, handleCancel } = props;
  24. const [form] = Form.useForm();
  25. const data = {
  26. company_name: 'hdhdhdh',
  27. name: 'kkkk',
  28. effect_on: moment('2020-02-02'),
  29. party_a: 'aaaaa',
  30. party_b: 'bbbbbb',
  31. party_c: 'ccccc',
  32. created_dep: 'fffff',
  33. dep_id: '1111',
  34. code: '132456',
  35. amount: '1111111111777',
  36. project_code: '444444',
  37. deal_by: 'hhhhh',
  38. perform: 'dnjfndjfnjdnfjd',
  39. created_by: '77777',
  40. created_on: moment().format(FORMAT),
  41. };
  42. const UploadProps = {
  43. action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
  44. onChange({ file, fileList }) {
  45. if (file.status !== 'uploading') {
  46. console.log(file, fileList);
  47. }
  48. },
  49. defaultFileList: [
  50. {
  51. uid: '1',
  52. name: 'xxx.png',
  53. status: 'uploading',
  54. url: 'http://www.baidu.com/xxx.png',
  55. percent: 33,
  56. },
  57. {
  58. uid: '2',
  59. name: 'yyy.png',
  60. status: 'done',
  61. url: 'http://www.baidu.com/yyy.png',
  62. },
  63. {
  64. uid: '3',
  65. name: 'zzz.png',
  66. status: 'error',
  67. response: 'Server Error 500',
  68. // custom error message to show
  69. url: 'http://www.baidu.com/zzz.png',
  70. },
  71. ],
  72. };
  73. const handleSubmit = () => {
  74. form.validateFields().then((values) => {
  75. console.log(values);
  76. let timeObj = {
  77. effect_on: moment(values.effect_on).format(FORMAT),
  78. created_on: values.created_on || moment().format(FORMAT),
  79. };
  80. handleOk({ ...values, ...timeObj });
  81. });
  82. };
  83. return (
  84. <Modal
  85. width={'85%'}
  86. title={title}
  87. open={visible}
  88. okText="提交"
  89. cancelText="返回"
  90. onOk={handleSubmit}
  91. onCancel={handleCancel}
  92. >
  93. <Divider />
  94. <ModuleTitle title="合同信息" />
  95. <Form
  96. form={form}
  97. initialValues={data}
  98. labelCol={{ span: 7 }}
  99. wrapperCol={{ span: 17 }}
  100. >
  101. <Row>
  102. <Col span={10} offset={1}>
  103. <Form.Item
  104. name="company_name"
  105. label="所属公司:"
  106. tooltip="所属公司"
  107. rules={[
  108. {
  109. required: true,
  110. message: '请填写所属公司',
  111. },
  112. ]}
  113. >
  114. <Input />
  115. </Form.Item>
  116. <Form.Item
  117. name="name"
  118. label="合同名称:"
  119. tooltip="合同名称"
  120. rules={[
  121. {
  122. required: true,
  123. message: '请填写合同名称',
  124. },
  125. ]}
  126. >
  127. <Input />
  128. </Form.Item>
  129. <Form.Item
  130. name="effect_on"
  131. label="合同生效日期:"
  132. rules={[
  133. {
  134. required: true,
  135. message: '请填写合同名称',
  136. },
  137. ]}
  138. >
  139. <DatePicker />
  140. </Form.Item>
  141. <Form.Item
  142. name="party_a"
  143. label="甲方:"
  144. rules={[
  145. {
  146. required: true,
  147. message: '请选择甲方',
  148. },
  149. ]}
  150. >
  151. <Input />
  152. </Form.Item>
  153. <Form.Item
  154. name="party_c"
  155. label="丙方(及其他):"
  156. rules={[
  157. {
  158. required: true,
  159. message: '请选择(支持多选)',
  160. },
  161. ]}
  162. >
  163. <Input />
  164. </Form.Item>
  165. <Form.Item
  166. name="created_dep"
  167. label="签约承办部门:"
  168. rules={[
  169. {
  170. required: true,
  171. message: '请选择签约承办部门',
  172. },
  173. ]}
  174. >
  175. <Input />
  176. </Form.Item>
  177. </Col>
  178. <Col span={10}>
  179. <Form.Item
  180. name="dep_id"
  181. label="所属部门:"
  182. rules={[
  183. {
  184. required: true,
  185. message: '请选择所属部门',
  186. },
  187. ]}
  188. >
  189. <Input />
  190. </Form.Item>
  191. <Form.Item name="code" label="合同编号:">
  192. <Input disabled />
  193. </Form.Item>
  194. <Form.Item label="合同总价款:">
  195. <Row gutter={8}>
  196. <Col span={12}>
  197. <Form.Item
  198. style={{ marginBottom: 0 }}
  199. name="amount"
  200. rules={[
  201. {
  202. required: true,
  203. message: '请输入合同总价款',
  204. },
  205. ]}
  206. >
  207. <Input />
  208. </Form.Item>
  209. </Col>
  210. <Col span={12}>
  211. <div style={{ lineHeight: '32px' }}>万元</div>
  212. </Col>
  213. </Row>
  214. </Form.Item>
  215. <Form.Item name="project_code" label="项目编号:">
  216. <Input disabled />
  217. </Form.Item>
  218. <Form.Item
  219. name="party_b"
  220. label="乙方:"
  221. rules={[
  222. {
  223. required: true,
  224. message: '请选择乙方',
  225. },
  226. ]}
  227. >
  228. <Input />
  229. </Form.Item>
  230. <Form.Item
  231. name="deal_by"
  232. label="经办人:"
  233. rules={[
  234. {
  235. required: true,
  236. message: '请选择经办人',
  237. },
  238. ]}
  239. >
  240. <Input />
  241. </Form.Item>
  242. </Col>
  243. </Row>
  244. <Form.Item name="perform" label="合同履行情况:" labelCol={{ span: 4 }}>
  245. <Input.TextArea />
  246. </Form.Item>
  247. <Form.Item label="合同上传:" labelCol={{ span: 4 }}>
  248. <Upload {...UploadProps}>
  249. <Button icon={<CloudUploadOutlined />}>Upload</Button>
  250. </Upload>
  251. </Form.Item>
  252. <Row>
  253. <Col span={10} offset={1}>
  254. <Form.Item name="created_by" label="创建人:">
  255. <Input disabled />
  256. </Form.Item>
  257. </Col>
  258. <Col span={10}>
  259. <Form.Item name="created_on" label="创建时间:">
  260. <Input disabled />
  261. </Form.Item>
  262. </Col>
  263. </Row>
  264. {type == Type.detail && (
  265. <>
  266. <ModuleTitle title="归档流程" />
  267. <Steps
  268. current={1}
  269. items={[
  270. {
  271. title: 'Finished',
  272. description,
  273. },
  274. {
  275. title: 'In Progress',
  276. description,
  277. subTitle: 'Left 00:00:08',
  278. },
  279. {
  280. title: 'Waiting',
  281. description,
  282. },
  283. ]}
  284. />
  285. </>
  286. )}
  287. {type == Type.cancel && (
  288. <>
  289. <ModuleTitle title="作废信息" />
  290. <Form.Item
  291. name="cancel_desc"
  292. label="作废原因:"
  293. labelCol={{ span: 4 }}
  294. >
  295. <Input />
  296. </Form.Item>
  297. <Form.Item
  298. name="cancel_on"
  299. label="创建时间:"
  300. labelCol={{ span: 4 }}
  301. >
  302. <Input defaultValue={moment(new Date()).format('YYYY-MM-DD')} />
  303. </Form.Item>
  304. </>
  305. )}
  306. </Form>
  307. <Divider />
  308. </Modal>
  309. );
  310. };
  311. export default ContractModal;