BudgetModal.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import React, { useEffect } from 'react';
  2. import { Form, Modal, InputNumber } from 'antd';
  3. import { connect } from 'dva';
  4. function BudgetModal(props) {
  5. const { visible, onCancel, onOk, loading, currentItem, dispatch, budget } = props;
  6. const [form] = Form.useForm();
  7. const subTypeList = [
  8. { name: '建设期项目管理人员', code: '02-010', id: 12 },
  9. { name: '工程设计人日(含BIM设计)', code: '04-010', id: 13 },
  10. { name: '设计联络人日', code: '05-010', id: 14 },
  11. { name: '金科陪客户设计联络/培训人日', code: '05-050', id: 16 },
  12. { name: '采购和质量控制人日', code: '06-010', id: 17 },
  13. { name: '双胞胎运营平台实施人日', code: '07-010', id: 18 },
  14. { name: '预算审核及费控人日', code: '08-010', id: 19 },
  15. { name: '现场安装/调试/性能测试/试运行人日', code: '10-010', id: 20 },
  16. { name: '质保期项目经理人日', code: '11-010', id: 21 },
  17. { name: '质保期服务工程师人日', code: '11-030', id: 22 },
  18. { name: '运营期项目管理人员', code: '02-030', id: 26 },
  19. { name: '运营期培训人日', code: '05-070', id: 27 },
  20. { name: '运营期采购和质量控制人日', code: '06-030', id: 28 },
  21. { name: '运营期预算审核及费控人日', code: '08-030', id: 29 },
  22. { name: '质保采购工程师人日', code: '11-050', id: 30 },
  23. { name: '投资技术服务人日', code: '18-010', id: 31 },
  24. { name: '运营期技术服务人日', code: '18-030', id: 32 },
  25. ];
  26. const handleOk = () => {
  27. form.validateFields().then(values => {
  28. console.log(values);
  29. let params = [];
  30. let isUpdate = budget?.length !== 0;
  31. Object.keys(values).forEach(item => {
  32. let elm = {
  33. project_id: Number(currentItem?.id),
  34. type_id: Number(item),
  35. workload: Number(values[item])
  36. };
  37. if (isUpdate) {
  38. elm.id = budget?.find(child => child.type_id == item)?.id;
  39. }
  40. params.push(elm);
  41. })
  42. console.log(params);
  43. dispatch({
  44. type: 'approval/setBudget',
  45. payload: params,
  46. callback: () => onOk?.(),
  47. });
  48. });
  49. };
  50. return (
  51. <Modal
  52. title="项目预算"
  53. visible={visible}
  54. width={800}
  55. onOk={handleOk}
  56. onCancel={onCancel}
  57. confirmLoading={loading}
  58. destroyOnClose
  59. >
  60. <Form form={form} labelCol={{ span: 10 }} wrapperCol={{ span: 10 }}>
  61. {subTypeList.map(item => (
  62. <Form.Item label={item.name} name={item.id} initialValue={Number(budget?.find(child => child.type_id === item.id)?.workload) || 0}>
  63. <InputNumber min={0} style={{ width: '100%' }} />
  64. </Form.Item>
  65. ))}
  66. </Form>
  67. </Modal>
  68. );
  69. }
  70. export default connect()(BudgetModal);