BudgetModal.js 2.8 KB

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