Ver código fonte

Merge branch 'master' of http://git.ycjcjy.com/jgz/admin into master

lisenzhou 2 anos atrás
pai
commit
5d66a33056

+ 7
- 1
config/routes.js Ver arquivo

132
     hideInMenu: true,
132
     hideInMenu: true,
133
     component: './stockClassification/edit',
133
     component: './stockClassification/edit',
134
   },
134
   },
135
-  
135
+  {
136
+    path: '/guaranteeTask/print',
137
+    name: '保障单',
138
+    hideInMenu: true,
139
+    layout: false,
140
+    component: './guaranteeTask/print/index',
141
+  },
136
   {
142
   {
137
     component: './404',
143
     component: './404',
138
   },
144
   },

+ 15
- 0
src/components/EditableTag/Tag.jsx Ver arquivo

1
+import React from 'react';
2
+import { Button } from 'antd';
3
+import { CloseOutlined } from '@ant-design/icons';
4
+import './style.less'
5
+
6
+export default (props) => {
7
+  const { size, type, onDelete, children } = props;
8
+
9
+  return (
10
+    <div className='tag-btn-group'>
11
+      <Button size={size} type={type}>{children}</Button>
12
+      <Button size={size} type="primary" icon={<CloseOutlined />} onClick={onDelete} />
13
+    </div>
14
+  )
15
+}

+ 21
- 0
src/components/EditableTag/index.jsx Ver arquivo

1
+import React from 'react';
2
+import { Button } from 'antd';
3
+import Tag from './Tag';
4
+import './style.less'
5
+
6
+export default (props) => {
7
+  const { size, type, list = [], onDelete, keyFuc, labelFunc } = props;
8
+
9
+  return (
10
+    <div className='editable-tag-box'>
11
+      {
12
+        list.map((item, index) => {
13
+          const key = keyFuc(item, index);
14
+          const label = labelFunc(item, index);
15
+
16
+          return <Tag key={key} size={size} type={type} onDelete={() => onDelete(item)}>{label}</Tag>
17
+        })
18
+      }
19
+    </div>
20
+  )
21
+}

+ 27
- 0
src/components/EditableTag/style.less Ver arquivo

1
+.tag-btn-group {
2
+  .ant-btn {
3
+    vertical-align: middle;
4
+  }
5
+
6
+  .ant-btn:first-child {
7
+    border-right: none;
8
+  }
9
+
10
+  .ant-btn:last-child {
11
+    // border-left: none;
12
+    border-top-left-radius: 0;
13
+    border-bottom-left-radius: 0;
14
+    margin-left: -1px;
15
+  }
16
+}
17
+
18
+.editable-tag-box {
19
+  display: flex;
20
+  flex-wrap: wrap;
21
+
22
+  .tag-btn-group {
23
+    flex: none;
24
+    box-sizing: border-box;
25
+    padding: 1em;
26
+  }
27
+}

+ 1
- 1
src/pages/dish/edit/index.jsx Ver arquivo

7
 import { useEffect, useRef, useState } from 'react';
7
 import { useEffect, useRef, useState } from 'react';
8
 
8
 
9
 export default (props) => {
9
 export default (props) => {
10
-  const [searchParams, setSearchParams] = useSearchParams();
10
+  const [searchParams] = useSearchParams();
11
   const id = searchParams.get('id');
11
   const id = searchParams.get('id');
12
   const [data, setData] = useState({});
12
   const [data, setData] = useState({});
13
   const formRef = useRef();
13
   const formRef = useRef();

+ 63
- 20
src/pages/guaranteeTask/Edit/BasicForm.jsx Ver arquivo

1
-import React, { useState } from 'react';
1
+import React, { useState, useEffect } from 'react';
2
+import moment from 'moment';
3
+import { Link } from 'umi';
2
 import { Button, Row, Col, Form, Input, InputNumber, DatePicker, notification } from 'antd';
4
 import { Button, Row, Col, Form, Input, InputNumber, DatePicker, notification } from 'antd';
5
+import { addGuaranteeTask, updateGuaranteeTask } from '@/services/api/guaranteeTask';
3
 
6
 
4
 const { TextArea } = Input;
7
 const { TextArea } = Input;
5
 const { RangePicker } = DatePicker;
8
 const { RangePicker } = DatePicker;
6
 
9
 
7
 export default (props) => {
10
 export default (props) => {
11
+  const { dataSource, setDataSource } = props;
12
+  const id = dataSource ? dataSource.id : undefined;
13
+
8
   const [form] = Form.useForm()
14
   const [form] = Form.useForm()
9
   const [rangeDate, setRangeDate] = useState([]);
15
   const [rangeDate, setRangeDate] = useState([]);
16
+  const [loading, setLoading] = useState(false);
10
 
17
 
11
   const onChange = (dts) => {
18
   const onChange = (dts) => {
12
     const [start, end] = dts;
19
     const [start, end] = dts;
22
       notification.warn({ message: '未检索到填写内容' });
29
       notification.warn({ message: '未检索到填写内容' });
23
       return ;
30
       return ;
24
     }
31
     }
32
+
33
+    const [start, end] = rangeDate;
34
+    const startDate = start ? start.format('YYYY-MM-DD') : undefined;
35
+    const endDate = end ? end.format('YYYY-MM-DD') : undefined;
36
+
37
+    const func = id ? updateGuaranteeTask : addGuaranteeTask;
38
+
39
+    setLoading(true);
40
+    func({ ...values, startDate, endDate }, id).then(res => {
41
+      setLoading(false);
42
+      setDataSource(res);
43
+      notification.success({ message: '操作成功' })
44
+    }).catch(() => {
45
+      setLoading(false);
46
+    });
25
   }
47
   }
26
 
48
 
49
+  useEffect(() => {
50
+    if (dataSource) {
51
+      form.setFieldsValue(dataSource);
52
+
53
+      let rangeDt = [];
54
+
55
+      if (dataSource.startDate) {
56
+        rangeDt[0] = moment(dataSource.startDate);
57
+      }
58
+
59
+      if (dataSource.endDate) {
60
+        rangeDt[1] = moment(dataSource.endDate);
61
+      }
62
+
63
+      setRangeDate(rangeDt);
64
+    }
65
+  }, [dataSource, form]);
66
+
27
   return (
67
   return (
28
-    <Form layout="vertical" onFinish={onFinish}>
68
+    <Form layout="vertical" form={form} onFinish={onFinish}>
29
       <h3 style={{ marginBottom: '1.5em', fontWeight: 700 }}>人员安排</h3>
69
       <h3 style={{ marginBottom: '1.5em', fontWeight: 700 }}>人员安排</h3>
30
       <Row gutter={48}>
70
       <Row gutter={48}>
31
         <Col span={6}>
71
         <Col span={6}>
39
           </Form.Item>
79
           </Form.Item>
40
         </Col>
80
         </Col>
41
         <Col span={6}>
81
         <Col span={6}>
42
-          <Form.Item label="部队联系人" name="concat_person">
82
+          <Form.Item label="部队联系人" name="concatPerson">
43
             <Input allowClear />
83
             <Input allowClear />
44
           </Form.Item>
84
           </Form.Item>
45
         </Col>
85
         </Col>
46
         <Col span={6}>
86
         <Col span={6}>
47
-          <Form.Item label="部队联系人电话" name="concat_phone">
87
+          <Form.Item label="部队联系人电话" name="concatPhone">
48
             <Input allowClear />
88
             <Input allowClear />
49
           </Form.Item>
89
           </Form.Item>
50
         </Col>
90
         </Col>
56
           </Form.Item>
96
           </Form.Item>
57
         </Col>
97
         </Col>
58
         <Col span={6}>
98
         <Col span={6}>
59
-          <Form.Item label="制餐人电话" name="chef_phone">
99
+          <Form.Item label="制餐人电话" name="chefPhone">
60
             <Input allowClear />
100
             <Input allowClear />
61
           </Form.Item>
101
           </Form.Item>
62
         </Col>
102
         </Col>
63
         <Col span={6}>
103
         <Col span={6}>
64
-          <Form.Item label="送餐人" name="delivery_man">
104
+          <Form.Item label="送餐人" name="deliveryMan">
65
             <Input allowClear />
105
             <Input allowClear />
66
           </Form.Item>
106
           </Form.Item>
67
         </Col>
107
         </Col>
68
         <Col span={6}>
108
         <Col span={6}>
69
-          <Form.Item label="送餐人电话" name="delivery_phone">
109
+          <Form.Item label="送餐人电话" name="deliveryPhone">
70
             <Input allowClear />
110
             <Input allowClear />
71
           </Form.Item>
111
           </Form.Item>
72
         </Col>
112
         </Col>
75
       <h3 style={{ margin: '1.5em 0', fontWeight: 700 }}>基本情况</h3>
115
       <h3 style={{ margin: '1.5em 0', fontWeight: 700 }}>基本情况</h3>
76
       <Row gutter={48}>
116
       <Row gutter={48}>
77
         <Col span={6}>
117
         <Col span={6}>
78
-          <Form.Item label="军代表" name="deputy_man">
118
+          <Form.Item label="军代表" name="deputyMan">
79
             <Input allowClear />
119
             <Input allowClear />
80
           </Form.Item>
120
           </Form.Item>
81
         </Col>
121
         </Col>
82
         <Col span={6}>
122
         <Col span={6}>
83
-          <Form.Item label="电话" name="deputy_phone">
123
+          <Form.Item label="电话" name="deputyPhone">
84
             <Input allowClear />
124
             <Input allowClear />
85
           </Form.Item>
125
           </Form.Item>
86
         </Col>
126
         </Col>
87
         <Col span={6}>
127
         <Col span={6}>
88
-          <Form.Item label="通报时间" name="got_date">
128
+          <Form.Item label="通报时间" name="gotDate">
89
             <Input allowClear />
129
             <Input allowClear />
90
           </Form.Item>
130
           </Form.Item>
91
         </Col>
131
         </Col>
92
       </Row>
132
       </Row>
93
       <Row gutter={48}>
133
       <Row gutter={48}>
94
         <Col span={6}>
134
         <Col span={6}>
95
-          <Form.Item label="保障序号" name="guarantee_no">
135
+          <Form.Item label="保障序号" name="guaranteeNo">
96
             <Input allowClear />
136
             <Input allowClear />
97
           </Form.Item>
137
           </Form.Item>
98
         </Col>
138
         </Col>
99
         <Col span={6}>
139
         <Col span={6}>
100
-          <Form.Item label="军运号" name="transport_no">
140
+          <Form.Item label="军运号" name="transportNo">
101
             <Input allowClear />
141
             <Input allowClear />
102
           </Form.Item>
142
           </Form.Item>
103
         </Col>
143
         </Col>
104
         <Col span={6}>
144
         <Col span={6}>
105
-          <Form.Item label="车次" name="trips_no">
145
+          <Form.Item label="车次" name="tripsNo">
106
             <Input allowClear />
146
             <Input allowClear />
107
           </Form.Item>
147
           </Form.Item>
108
         </Col>
148
         </Col>
114
           </Form.Item>
154
           </Form.Item>
115
         </Col>
155
         </Col>
116
         <Col span={6}>
156
         <Col span={6}>
117
-          <Form.Item label="保障时间" name="time_range">
157
+          <Form.Item label="保障时间" name="timeRange">
118
             <Input allowClear />
158
             <Input allowClear />
119
           </Form.Item>
159
           </Form.Item>
120
         </Col>
160
         </Col>
121
       </Row>
161
       </Row>
122
       <Row gutter={48}>
162
       <Row gutter={48}>
123
         <Col span={6}>
163
         <Col span={6}>
124
-          <Form.Item label="保障人数" name="total_person_num">
164
+          <Form.Item label="保障人数" name="totalPersonNum">
125
             <InputNumber min={1} style={{ width: '100%' }}/>
165
             <InputNumber min={1} style={{ width: '100%' }}/>
126
           </Form.Item>
166
           </Form.Item>
127
         </Col>
167
         </Col>
128
         <Col span={6}>
168
         <Col span={6}>
129
-          <Form.Item label="其中回民" name="hui_person_num">
169
+          <Form.Item label="其中回民" name="huiPersonNum">
130
             <InputNumber min={0} style={{ width: '100%' }}/>
170
             <InputNumber min={0} style={{ width: '100%' }}/>
131
           </Form.Item>
171
           </Form.Item>
132
         </Col>
172
         </Col>
133
         <Col span={6}>
173
         <Col span={6}>
134
-          <Form.Item label="其中病号" name="patient_num">
174
+          <Form.Item label="其中病号" name="patientNum">
135
             <InputNumber min={0} style={{ width: '100%' }}/>
175
             <InputNumber min={0} style={{ width: '100%' }}/>
136
           </Form.Item>
176
           </Form.Item>
137
         </Col>
177
         </Col>
157
       </Row>
197
       </Row>
158
 
198
 
159
       <Row gutter={48}>
199
       <Row gutter={48}>
160
-        <Col offset={6} span={6}>
161
-          <Button type="primary" htmlType="submit">提交</Button>
162
-          <Button style={{ marginLeft: '100px' }}>返回</Button>
200
+        <Col offset={6} span={12}>
201
+          <Button type="primary" htmlType="submit" loading={loading}>提交</Button>
202
+          <Button style={{ marginLeft: '48px' }}>返回</Button>
203
+          <Button style={{ marginLeft: '48px' }}>
204
+            <Link target="_blank" to={`/guaranteeTask/print?id=${id}`}>打印预览</Link>
205
+          </Button>
163
         </Col>
206
         </Col>
164
       </Row>
207
       </Row>
165
 
208
 

+ 144
- 2
src/pages/guaranteeTask/Edit/DishList.jsx Ver arquivo

1
-import React from 'react'
1
+import React, { useState, useEffect, useRef } from 'react';
2
+import { Row, Col, Card, Button, notification } from 'antd';
3
+import EditableTag from '@/components/EditableTag';
4
+import { getDishList } from '@/services/api/dish';
5
+import { getPackageList, getPackageDetailList } from '@/services/api/package';
6
+import {
7
+  updateGuaranteeTask,
8
+  getGuaranteeDetailList,
9
+  addGuaranteeDetailBatch,
10
+  deleteGuaranteeDetail
11
+} from '@/services/api/guaranteeTask';
12
+import Selector from './components/Selector';
2
 
13
 
3
 export default (props) => {
14
 export default (props) => {
15
+  const { dataSource, setDataSource } = props;
16
+
17
+  const [list, setList] = useState([]);
18
+  const [loading, setLoading] = useState(false);
19
+  const packageRef = useRef();
20
+
21
+  const handlePackageSubmit = ({item, amount}) => {
22
+    packageRef.current = item;
23
+
24
+    // 获取套餐下所有的菜肴
25
+    // 然后把菜肴放入到列表
26
+    getPackageDetailList({ pageNum: 1, pageSize: 500, packageId: item.id }).then(res => {
27
+      const { records = [] } = res;
28
+      if (records.length > 0) {
29
+        for (let it of records) {
30
+          const found = list.filter(x => x.dishId === it.id)[0]
31
+          if (found) {
32
+            found.dishAmount = amount;
33
+          } else {
34
+            list.push({
35
+              guaranteeId: dataSource.id,
36
+              dishId: it.id,
37
+              dishName: it.name,
38
+              dishUnit: it.unit,
39
+              dishAmount: amount,
40
+            })
41
+          }
42
+        }
43
+
44
+        setList(list.slice());
45
+      }
46
+    })
47
+  };
48
+
49
+  const handleDishSubmit = ({item, amount}) => {
50
+    const found = list.filter(x => x.dishId === item.id)[0]
51
+    if (found) {
52
+      found.dishAmount = amount;
53
+    } else {
54
+      list.push({
55
+        guaranteeId: dataSource.id,
56
+        dishId: item.id,
57
+        dishName: item.name,
58
+        dishUnit: item.unit,
59
+        dishAmount: amount,
60
+      })
61
+    }
62
+
63
+    setList(list.slice());
64
+  };
65
+
66
+  const onDelete = (item) => {
67
+    if (item.id) {
68
+      setLoading(true);
69
+      deleteGuaranteeDetail(item.id).then(res => {
70
+        setLoading(false);
71
+
72
+        const nwList = list.filter(x => x.dishId !== item.dishId);
73
+        setList(nwList);
74
+      }).catch(() => {
75
+        setLoading(false);
76
+      })
77
+    } else {
78
+      const nwList = list.filter(x => x.dishId !== item.dishId);
79
+      setList(nwList);
80
+    }
81
+  }
82
+
83
+  const onSubmit = () => {
84
+    setLoading(true);
85
+    addGuaranteeDetailBatch(list, dataSource.id).then(res => {
86
+      setLoading(false);
87
+      setList(res);
88
+      notification.success({ message: '操作成功' });
89
+    }).catch(() => {
90
+      setLoading(false);
91
+    });
92
+
93
+    if (packageRef.current) {
94
+      dataSource.packageName = packageRef.current.name;
95
+      updateGuaranteeTask(dataSource, dataSource.id).then(res => {
96
+        setDataSource(res);
97
+      });
98
+    }
99
+  }
100
+
101
+  useEffect(() => {
102
+    if (dataSource.id) {
103
+      setLoading(true);
104
+      getGuaranteeDetailList({ pageNum: 1, pageSize: 500, guaranteeId: dataSource.id }).then(res => {
105
+        setLoading(false);
106
+        setList(res.records || []);
107
+      }).catch(() => {
108
+        setLoading(false);
109
+      })
110
+    }
111
+  }, [dataSource.id])
112
+
4
   return (
113
   return (
5
-    <div></div>
114
+    <Row gutter={48}>
115
+      <Col span={8}>
116
+        <div>
117
+          <h3>选择套餐</h3>
118
+          <Selector
119
+            placeholder="请选择套餐"
120
+            fetch={getPackageList}
121
+            onSubmit={handlePackageSubmit}
122
+          />
123
+        </div>
124
+        <div style={{ marginTop: '48px' }}>
125
+          <h3>选择菜肴</h3>
126
+          <Selector
127
+            placeholder="请选择菜肴"
128
+            fetch={getDishList}
129
+            onSubmit={handleDishSubmit}
130
+          />
131
+        </div>
132
+      </Col>
133
+      <Col span={16}>
134
+        <Card
135
+          title="已选菜肴"
136
+          loading={loading}
137
+          extra={<Button type='primary' loading={loading} onClick={onSubmit}>保存</Button>}
138
+        >
139
+          <EditableTag
140
+            list={list}
141
+            keyFuc={x => x.dishId}
142
+            labelFunc={x => `${x.dishName} × ${x.dishAmount}`}
143
+            onDelete={onDelete}
144
+          />
145
+        </Card>
146
+      </Col>
147
+    </Row>
6
   )
148
   )
7
 }
149
 }

+ 70
- 0
src/pages/guaranteeTask/Edit/components/Selector.jsx Ver arquivo

1
+import React, { useState, useEffect } from 'react';
2
+import { Button, Input, InputNumber, Select, notification } from 'antd';
3
+
4
+const { Group } = Input;
5
+const { Option } = Select;
6
+
7
+export default (props) => {
8
+  const { fetch, placeholder, onSubmit } = props;
9
+
10
+  const [data, setData] = useState([]);
11
+  const [value, setValue] = useState();
12
+  const [amount, setAmount] = useState();
13
+
14
+  const options = data.map(d => <Option key={d.id}>{d.name}</Option>);
15
+
16
+  const handleSearch = (name) => {
17
+    fetch({ pageNum: 1, pageSize: 20, name }).then(res => {
18
+      setData(res.records || []);
19
+    })
20
+  };
21
+
22
+  const handleChange = (val) => {
23
+    setValue(val);
24
+  }
25
+
26
+  const handleSubmit = () => {
27
+    if (!amount || amount <= 0) {
28
+      notification.warn({ message: '请输入正确的数量' });
29
+      return;
30
+    }
31
+
32
+    if (!value) {
33
+      notification.warn({ message: placeholder });
34
+      return;
35
+    }
36
+
37
+    const item = data.filter(x => `${x.id}` === `${value}`)[0];
38
+    if (item) {
39
+      onSubmit({ item, amount });
40
+    }
41
+  }
42
+
43
+  useEffect(() => {
44
+    fetch({ pageNum: 1, pageSize: 20 }).then(res => {
45
+      setData(res.records || []);
46
+    })
47
+  }, []);
48
+
49
+  return (
50
+    <Group compact>
51
+      <Select
52
+        allowClear
53
+        showSearch
54
+        value={value}
55
+        style={{ width: '50%' }}
56
+        placeholder={placeholder}
57
+        defaultActiveFirstOption={false}
58
+        showArrow={false}
59
+        filterOption={false}
60
+        onSearch={handleSearch}
61
+        onChange={handleChange}
62
+        notFoundContent={null}
63
+      >
64
+        {options}
65
+      </Select>
66
+      <InputNumber style={{ width: '30%' }} placeholder="请输入数量" value={amount} onChange={setAmount} />
67
+      <Button type="primary" onClick={handleSubmit}>确定</Button>
68
+    </Group>
69
+  )
70
+}

+ 23
- 5
src/pages/guaranteeTask/Edit/index.jsx Ver arquivo

1
-import React, { useState } from 'react';
1
+import React, { useState, useEffect } from 'react';
2
+import { useSearchParams } from '@umijs/max';
2
 import { Tabs, Card } from 'antd';
3
 import { Tabs, Card } from 'antd';
3
 import { PageContainer } from '@ant-design/pro-components';
4
 import { PageContainer } from '@ant-design/pro-components';
5
+import { getGuaranteeTask } from '@/services/api/guaranteeTask';
4
 import BasicForm from './BasicForm';
6
 import BasicForm from './BasicForm';
5
 import DishList from './DishList';
7
 import DishList from './DishList';
6
 
8
 
7
 export default (props) => {
9
 export default (props) => {
8
   const [activeTabKey, setActiveTabKey] = useState('item-1');
10
   const [activeTabKey, setActiveTabKey] = useState('item-1');
11
+  const [loading, setLoading] = useState(false);
12
+  const [dataSource, setDataSource] = useState();
13
+  const [searchParams] = useSearchParams();
14
+  const id = searchParams.get('id');
9
 
15
 
10
   const tabList = [
16
   const tabList = [
11
     { tab: '基本情况', key: 'item-1', }, // 务必填写 key
17
     { tab: '基本情况', key: 'item-1', }, // 务必填写 key
12
-    { tab: '菜单详情', key: 'item-2', },
18
+    { tab: '军供菜单', key: 'item-2', },
13
   ];
19
   ];
14
 
20
 
21
+  useEffect(() => {
22
+    if (id) {
23
+      setLoading(true);
24
+      getGuaranteeTask(id).then(res => {
25
+        setLoading(false);
26
+        setDataSource(res);
27
+      }).catch(() => {
28
+        setLoading(false);
29
+      });
30
+    }
31
+  }, [id]);
32
+
15
   return (
33
   return (
16
     <PageContainer>
34
     <PageContainer>
17
       <Card
35
       <Card
18
         style={{ width: '100%' }}
36
         style={{ width: '100%' }}
37
+        loading={loading}
19
         tabList={tabList}
38
         tabList={tabList}
20
         activeTabKey={activeTabKey}
39
         activeTabKey={activeTabKey}
21
         onTabChange={setActiveTabKey}>
40
         onTabChange={setActiveTabKey}>
22
 
41
 
23
         {
42
         {
24
-          activeTabKey === 'item-1' && <BasicForm />
43
+          activeTabKey === 'item-1' && <BasicForm dataSource={dataSource} setDataSource={setDataSource} />
25
         }
44
         }
26
 
45
 
27
         {
46
         {
28
-          activeTabKey === 'item-2' && <DishList />
47
+          activeTabKey === 'item-2' && <DishList dataSource={dataSource} setDataSource={setDataSource} />
29
         }
48
         }
30
-
31
       </Card>
49
       </Card>
32
     </PageContainer>
50
     </PageContainer>
33
   )
51
   )

+ 132
- 0
src/pages/guaranteeTask/print/index.jsx Ver arquivo

1
+import React, { useRef, useState, useEffect } from 'react';
2
+import moment from 'moment';
3
+import { Button } from 'antd';
4
+import { useSearchParams } from '@umijs/max';
5
+import { getGuaranteeTask } from '@/services/api/guaranteeTask';
6
+import { getGuaranteeDetailList } from '@/services/api/guaranteeTask';
7
+import Styles from './style.less';
8
+
9
+export default (props) => {
10
+  const [dataSource, setDataSource] = useState({});
11
+  const [list, setList] = useState([]);
12
+  const [searchParams] = useSearchParams();
13
+  const id = searchParams.get('id');
14
+
15
+  const onPrint = () => {
16
+    window.print();
17
+  }
18
+  
19
+  useEffect(() => {
20
+    if (id) {
21
+      // setLoading(true);
22
+      getGuaranteeTask(id).then(res => {
23
+        // setLoading(false);
24
+        setDataSource(res);
25
+      }).catch(() => {
26
+        // setLoading(false);
27
+      });
28
+      
29
+      // setLoading(true);
30
+      getGuaranteeDetailList({ pageNum: 1, pageSize: 500, guaranteeId: id }).then(res => {
31
+        // setLoading(false);
32
+        setList(res.records || []);
33
+      }).catch(() => {
34
+        // setLoading(false);
35
+      })
36
+    }
37
+  }, [id]);
38
+
39
+  const details = list.map(x => `${x.dishName} × ${x.dishAmount}`).join(',');
40
+  const startDate = dataSource.startDate ? moment(dataSource.startDate).format('YYYY-MM-DD') : '';
41
+  const endDate = dataSource.endDate ? moment(dataSource.endDate).format('YYYY-MM-DD') : '';
42
+  const dateStr = `${startDate} ~ ${endDate}`;
43
+
44
+  return (
45
+    <div className={Styles['print-page']}>
46
+      <table className={Styles['print-table']}>
47
+        {/* col 用于固定宽度 */}
48
+        <col />
49
+        <col />
50
+        <col />
51
+        <col />
52
+        <col />
53
+        <col />
54
+        <col />
55
+        <col />
56
+        <thead>
57
+          <tr>
58
+            <th className={Styles['title']} colSpan={8}>江苏省海安军供站军供保障受领单</th>
59
+          </tr>
60
+          <tr className={Styles['sub-title']}>
61
+            <th colSpan={2}><div>军代表:{dataSource.deputyMan || ' '}</div></th>
62
+            <th colSpan={2}><div>电话:{dataSource.deputyPhone || ' '}</div></th>
63
+            <th colSpan={2}><div>通报时间:{dataSource.gotDate || ' '}</div></th>
64
+            <th colSpan={2}><div>受领人:{dataSource.receiver || ' '}</div></th>
65
+          </tr>
66
+        </thead>
67
+        <tbody>
68
+          <tr>
69
+            <td><div>保障序号</div></td>
70
+            <td colSpan={2}><div>{dataSource.guaranteeNo || ' '}</div></td>
71
+            <td><div>军运号</div></td>
72
+            <td colSpan={2}><div>{dataSource.transportNo || ' '}</div></td>
73
+            <td><div>车次</div></td>
74
+            <td><div>{dataSource.tripsNo || ' '}</div></td>
75
+          </tr>
76
+          <tr>
77
+            <td><div>保障日期</div></td>
78
+            <td colSpan={3}>{dateStr}</td>
79
+            <td><div>保障时间</div></td>
80
+            <td colSpan={3}>{dataSource.timeRange || ' '}</td>
81
+          </tr>
82
+          <tr>
83
+            <td rowSpan={2}><div>保障人数</div></td>
84
+            <td rowSpan={2}>{dataSource.totalPersonNum || ' '}</td>
85
+            <td><div>其中回民</div></td>
86
+            <td>{dataSource.huiPersonNum || ' '}</td>
87
+            <td rowSpan={2}><div>伙食标准</div></td>
88
+            <td>{dataSource.standard || ' '}</td>
89
+          </tr>
90
+          <tr>
91
+            <td className={Styles['bd-left']}><div>其中病号</div></td>
92
+            <td>{dataSource.patientNum || ' '}</td>
93
+            <td>套餐: {dataSource.packageName || ' '}</td>
94
+          </tr>
95
+          <tr>
96
+            <td><div>保障地点</div></td>
97
+            <td colSpan={7}>{dataSource.address || ' '}</td>
98
+          </tr>
99
+          <tr>
100
+            <td><div>部队联系人</div></td>
101
+            <td colSpan={3}>{dataSource.concatPerson || ' '}</td>
102
+            <td><div>联系电话</div></td>
103
+            <td colSpan={3}>{dataSource.concatPhone || ' '}</td>
104
+          </tr>
105
+          <tr>
106
+            <td><div>制餐人</div></td>
107
+            <td colSpan={3}>{dataSource.chef || ' '}</td>
108
+            <td><div>联系电话</div></td>
109
+            <td colSpan={3}>{dataSource.chefPhone || ' '}</td>
110
+          </tr>
111
+          <tr>
112
+            <td><div>配送人</div></td>
113
+            <td colSpan={3}>{dataSource.deliveryMan || ' '}</td>
114
+            <td><div>联系电话</div></td>
115
+            <td colSpan={3}>{dataSource.deliveryPhone || ' '}</td>
116
+          </tr>
117
+          <tr className={Styles['cell-lg']}>
118
+            <td>配餐明细</td>
119
+            <td colSpan={7}><div>{details}</div></td>
120
+          </tr>
121
+          <tr className={Styles['cell-lg']}>
122
+            <td>备注</td>
123
+            <td colSpan={7}><div>{dataSource.remark || ' '}</div></td>
124
+          </tr>
125
+        </tbody>
126
+      </table>
127
+      <div className={Styles['print-btn']}>
128
+        <Button type="primary" onClick={onPrint}>打印</Button>
129
+      </div>
130
+    </div>
131
+  )
132
+}

+ 109
- 0
src/pages/guaranteeTask/print/style.less Ver arquivo

1
+.print-page {
2
+  width: 100%;
3
+  height: 100%;
4
+  position: relative;
5
+  box-sizing: border-box;
6
+  padding: 1cm;
7
+}
8
+
9
+// A4 大小 210 * 279
10
+@width: 190mm; // 210 - 20
11
+@height: 277mm;  // 279 - 20
12
+
13
+@minWidth: calc(@width / 8);
14
+
15
+.print-table {
16
+  table-layout: fixed;
17
+  width: @width;
18
+  height: @height;
19
+  margin: auto;
20
+  font-size: 16px;
21
+  overflow-x: hidden;
22
+
23
+  col {
24
+    width: @minWidth;
25
+  }
26
+
27
+  th {
28
+    font-weight: 400;
29
+  }
30
+
31
+  thead {
32
+    tr {
33
+      border: none !important;
34
+    }
35
+  }
36
+
37
+  @border: 1.5px solid #333;
38
+
39
+  tbody {
40
+    border: @border;
41
+  }
42
+  
43
+  tr {
44
+    & + tr {
45
+      border-top: @border;
46
+    }
47
+  }
48
+
49
+  td {
50
+    padding: 0 .5em;
51
+    overflow: hidden;
52
+    text-overflow: ellipsis;
53
+    div {
54
+      min-width: @minWidth;
55
+      min-height: 10mm;
56
+      line-height: 10mm;
57
+    }
58
+
59
+    & + td {
60
+      border-left: @border;
61
+    }
62
+  }
63
+
64
+  .cell-lg {
65
+    div {
66
+      width: auto;
67
+      min-height: 70mm;
68
+      line-height: 1.6em;
69
+    }
70
+  }
71
+
72
+  .title {
73
+    font-size: 2em;
74
+  }
75
+
76
+  .sub-title {
77
+    // font-size: 12px;
78
+  }
79
+
80
+  .bd-left {
81
+    border-left: @border;
82
+  }
83
+}
84
+
85
+@media screen {
86
+  .print-btn {
87
+    text-align: center;
88
+    margin: 64px auto;
89
+  }
90
+
91
+  .print-table {
92
+    padding: 5mm 5mm 5mm 10mm;
93
+  }
94
+}
95
+
96
+@media print {
97
+  .print-table {
98
+    padding: 0;
99
+  }
100
+
101
+  .print-btn {
102
+    display: none;
103
+  }
104
+}
105
+
106
+@page {
107
+  size: A4;
108
+  margin: 0;
109
+}

+ 29
- 27
src/pages/package/BasicForm.jsx Ver arquivo

1
 import React, { useState, useEffect } from 'react';
1
 import React, { useState, useEffect } from 'react';
2
-import { Button, Checkbox, Form, Input } from 'antd';
2
+import { Button, Checkbox, Card, Form, Input } from 'antd';
3
 import { addPackage, updataPackage } from '@/services/api/package';
3
 import { addPackage, updataPackage } from '@/services/api/package';
4
 
4
 
5
 export default (props) => {
5
 export default (props) => {
30
   }, [form, current])
30
   }, [form, current])
31
 
31
 
32
   return (
32
   return (
33
-    <Form
34
-      form={form}
35
-      labelCol={{ span: 6 }}
36
-      wrapperCol={{ span: 16 }}
37
-      onFinish={onFinish}
38
-      autoComplete="off"
39
-    >
40
-      <Form.Item
41
-        label="套餐名称"
42
-        name="name"
43
-        rules={[{ required: true, message: '请输入套餐名称' }]}
33
+    <Card>
34
+      <Form
35
+        form={form}
36
+        labelCol={{ span: 6 }}
37
+        wrapperCol={{ span: 16 }}
38
+        onFinish={onFinish}
39
+        autoComplete="off"
44
       >
40
       >
45
-        <Input placeholder='请输入套餐名称' />
46
-      </Form.Item>
41
+        <Form.Item
42
+          label="套餐名称"
43
+          name="name"
44
+          rules={[{ required: true, message: '请输入套餐名称' }]}
45
+        >
46
+          <Input placeholder='请输入套餐名称' />
47
+        </Form.Item>
47
 
48
 
48
-      <Form.Item
49
-        label="套餐单位"
50
-        name="unit"
51
-      >
52
-        <Input placeholder='请输入套餐单位' />
53
-      </Form.Item>
54
-
55
-      <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
56
-        <Button type="primary" htmlType="submit" loading={loading}>
57
-          提交
58
-        </Button>
59
-      </Form.Item>
60
-    </Form>
49
+        <Form.Item
50
+          label="套餐单位"
51
+          name="unit"
52
+        >
53
+          <Input placeholder='请输入套餐单位' />
54
+        </Form.Item>
55
+
56
+        <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
57
+          <Button type="primary" htmlType="submit" loading={loading}>
58
+            保存
59
+          </Button>
60
+        </Form.Item>
61
+      </Form>
62
+    </Card>
61
   )
63
   )
62
 }
64
 }

+ 1
- 0
src/pages/package/DishList.jsx Ver arquivo

118
       renderItem={item => (
118
       renderItem={item => (
119
         <List.Item
119
         <List.Item
120
           className={classNames({ active: detail.id === item.id })}
120
           className={classNames({ active: detail.id === item.id })}
121
+          onClick={() => setDetail(item)}
121
           actions={[
122
           actions={[
122
             <Popconfirm
123
             <Popconfirm
123
               key="delete"
124
               key="delete"

+ 1
- 1
src/pages/package/index.jsx Ver arquivo

19
           </Col>
19
           </Col>
20
           <Col span={8}>
20
           <Col span={8}>
21
             <BasicForm current={current} onChange={it => setCurrent(it)} />
21
             <BasicForm current={current} onChange={it => setCurrent(it)} />
22
-            <div style={{ marginTop: '100px' }}>
22
+            <div style={{ marginTop: '24px' }}>
23
               <DishList current={current} />
23
               <DishList current={current} />
24
             </div>
24
             </div>
25
           </Col>
25
           </Col>

+ 44
- 0
src/services/api/guaranteeTask.js Ver arquivo

1
+import { request } from '@umijs/max';
2
+
3
+/**
4
+ * 详情
5
+ * @param {*} data
6
+ * @returns
7
+ */
8
+ export const getGuaranteeTask = (id) => request(`/guaranteeTask/${id}`);
9
+
10
+/**
11
+ * 新增
12
+ * @param {*} data
13
+ * @returns
14
+ */
15
+ export const addGuaranteeTask = (data) => request('/guaranteeTask', { method: 'post', data });
16
+
17
+ 
18
+/**
19
+ * 更新
20
+ * @param {*} data
21
+ * @returns
22
+ */
23
+ export const updateGuaranteeTask = (data, id) => request(`/guaranteeTask/${id}`, { method: 'put', data });
24
+
25
+ /**
26
+  * 查询明细
27
+  * @param {*} data
28
+  * @returns
29
+  */
30
+  export const getGuaranteeDetailList = (params) => request('/guaranteeDetail', { params });
31
+
32
+/**
33
+ * 批量新增明细
34
+ * @param {*} data
35
+ * @returns
36
+ */
37
+ export const addGuaranteeDetailBatch = (data, guaranteeId) => request('/guaranteeDetail/batch', { method: 'post', data, params: { guaranteeId } });
38
+ 
39
+/**
40
+ * 删除明细
41
+ * @param {*} data
42
+ * @returns
43
+ */
44
+ export const deleteGuaranteeDetail = id => request(`/guaranteeDetail/${id}`, { method: 'delete' });