Commit 4019883332c631829dc89e70aa03493021882c83
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/services/definition.ts # src/services/request.ts
Showing
19 changed files
with
748 additions
and
329 deletions
.umirc.ts
src/pages/Instalment/components/comfire/comfire.tsx
1 | 1 | import { ModalForm } from '@ant-design/pro-components'; |
2 | -import { Form, message } from 'antd'; | |
2 | +import { Form } from 'antd'; | |
3 | 3 | import { useState } from 'react'; |
4 | 4 | |
5 | 5 | const waitTime = (time: number = 100) => { |
... | ... | @@ -41,7 +41,6 @@ export default ({ currtDid, sureDelete }) => { |
41 | 41 | onFinish={async () => { |
42 | 42 | await waitTime(100); |
43 | 43 | sureDelete([ids]); |
44 | - message.success('提交成功'); | |
45 | 44 | return true; |
46 | 45 | }} |
47 | 46 | > | ... | ... |
src/pages/Instalment/components/detail/detail.tsx
... | ... | @@ -207,6 +207,7 @@ export default ({ toReload }) => { |
207 | 207 | payWay: values.payWay || contextBody.payWay, |
208 | 208 | annex: contextBody.annex, |
209 | 209 | remark: values.remark || contextBody.remark, |
210 | + createByName: null, | |
210 | 211 | }; |
211 | 212 | if (values.annex) { |
212 | 213 | formData.append('file', values.annex[0].originFileObj as RcFile); |
... | ... | @@ -221,6 +222,9 @@ export default ({ toReload }) => { |
221 | 222 | toSendEdit.annex = res.data; |
222 | 223 | } |
223 | 224 | } |
225 | + toSendEdit.createByName = JSON.parse( | |
226 | + localStorage.getItem('userInfo'), | |
227 | + ).username; | |
224 | 228 | const isSaveOrUpdate = await postOrderErpOrderStagesAdd({ |
225 | 229 | data: { ...toSendEdit }, |
226 | 230 | }); |
... | ... | @@ -230,31 +234,32 @@ export default ({ toReload }) => { |
230 | 234 | |
231 | 235 | otherBody.forEach((item) => { |
232 | 236 | let remakeItem = { |
233 | - ossId: item.ossId, | |
237 | + ossId: contextBody.id, | |
234 | 238 | number: item.id, |
235 | 239 | dateRange: item.payDate, |
236 | 240 | fileName: item.fileName, |
241 | + fileUrl: item.fileUrl, | |
237 | 242 | }; |
238 | - if ( | |
239 | - typeof item.fileUrl === 'object' && | |
240 | - item.fileUrl instanceof File | |
241 | - ) { | |
242 | - const formData = new FormData(); | |
243 | - formData.append('file', item.fileUrl as RcFile); | |
244 | - const uploadPromise = async () => { | |
245 | - const res = await postOrderErpOrderStagesUpload({ | |
246 | - data: formData, | |
247 | - headers: { | |
248 | - 'Content-Type': | |
249 | - 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq', | |
250 | - }, | |
251 | - }); | |
252 | - if (res.data) { | |
253 | - remakeItem.fileUrl = res.data; | |
254 | - } | |
255 | - }; | |
256 | - promises.push(uploadPromise()); | |
257 | - } | |
243 | + // if ( | |
244 | + // typeof item.fileUrl === 'object' && | |
245 | + // item.fileUrl instanceof File | |
246 | + // ) { | |
247 | + // const formData = new FormData(); | |
248 | + // formData.append('file', item.fileUrl as RcFile); | |
249 | + // const uploadPromise = async () => { | |
250 | + // const res = await postOrderErpOrderStagesUpload({ | |
251 | + // data: formData, | |
252 | + // headers: { | |
253 | + // 'Content-Type': | |
254 | + // 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq', | |
255 | + // }, | |
256 | + // }); | |
257 | + // if (res.data) { | |
258 | + // remakeItem.fileUrl = res.data; | |
259 | + // } | |
260 | + // }; | |
261 | + // promises.push(uploadPromise()); | |
262 | + // } | |
258 | 263 | remakeValue.push(remakeItem); |
259 | 264 | }); |
260 | 265 | ... | ... |
src/pages/Instalment/components/edit/edit.tsx
... | ... | @@ -33,7 +33,6 @@ export default ({ currentContract, toReload }) => { |
33 | 33 | const [total, setTotal] = useState(0); |
34 | 34 | const [payWayBody, setPayWayBody] = useState([]); |
35 | 35 | const [otherBody, setOtherBody] = useState([]); |
36 | - | |
37 | 36 | type OrderStagesWithListItem = { |
38 | 37 | //文件编号 |
39 | 38 | id: number; |
... | ... | @@ -85,6 +84,7 @@ export default ({ currentContract, toReload }) => { |
85 | 84 | } |
86 | 85 | |
87 | 86 | function setSave(value) { |
87 | + console.log(value); | |
88 | 88 | setOtherBody(value); |
89 | 89 | } |
90 | 90 | |
... | ... | @@ -134,18 +134,32 @@ export default ({ currentContract, toReload }) => { |
134 | 134 | } |
135 | 135 | }; |
136 | 136 | |
137 | - async function getBody() { | |
138 | - const res = await postOrderErpOrderStagesSearch({ | |
139 | - data: { contract: currentContract }, | |
140 | - }); | |
141 | - const context = res.data[0]; | |
142 | - | |
143 | - if (context.contract !== null) { | |
144 | - setContextBody(context); | |
145 | - setTotal(context.totalPrice); | |
146 | - form.setFieldValue('totalPrice', context.totalPrice); | |
137 | + async function getBody(value) { | |
138 | + if (value !== null) { | |
139 | + const res = await postOrderErpOrderStagesSearch({ | |
140 | + data: { contract: value }, | |
141 | + }); | |
142 | + const context = res.data[0]; | |
143 | + console.log(context); | |
144 | + if (context.contract !== null) { | |
145 | + setContextBody(context); | |
146 | + setTotal(context.totalPrice); | |
147 | + form.setFieldValue('totalPrice', context.totalPrice); | |
148 | + } | |
149 | + handleInputChange(context.payWay, 0, context.totalPrice); | |
150 | + } else { | |
151 | + const res = await postOrderErpOrderStagesSearch({ | |
152 | + data: { contract: currentContract }, | |
153 | + }); | |
154 | + const context = res.data[0]; | |
155 | + console.log(context); | |
156 | + if (context.contract !== null) { | |
157 | + setContextBody(context); | |
158 | + setTotal(context.totalPrice); | |
159 | + form.setFieldValue('totalPrice', context.totalPrice); | |
160 | + } | |
161 | + handleInputChange(context.payWay, 0, context.totalPrice); | |
147 | 162 | } |
148 | - handleInputChange(context.payWay, 0, context.totalPrice); | |
149 | 163 | } |
150 | 164 | |
151 | 165 | function getEditProductBody(value) { |
... | ... | @@ -157,7 +171,8 @@ export default ({ currentContract, toReload }) => { |
157 | 171 | } |
158 | 172 | |
159 | 173 | useEffect(() => { |
160 | - getBody(); | |
174 | + console.log('1'); | |
175 | + getBody(null); | |
161 | 176 | }, []); |
162 | 177 | |
163 | 178 | return ( |
... | ... | @@ -177,34 +192,35 @@ export default ({ currentContract, toReload }) => { |
177 | 192 | } |
178 | 193 | let remakeValue = []; |
179 | 194 | const promises = []; |
180 | - | |
195 | + console.log(otherBody); | |
181 | 196 | otherBody.forEach((item) => { |
182 | 197 | let remakeItem = { |
183 | 198 | ossId: contextBody.id, |
184 | 199 | number: item.id, |
185 | 200 | dateRange: item.payDate, |
186 | 201 | fileName: item.fileName, |
202 | + fileUrl: item.fileUrl, | |
187 | 203 | }; |
188 | - if ( | |
189 | - typeof item.fileUrl === 'object' && | |
190 | - item.fileUrl instanceof File | |
191 | - ) { | |
192 | - const formData = new FormData(); | |
193 | - formData.append('file', item.fileUrl as RcFile); | |
194 | - const uploadPromise = async () => { | |
195 | - const res = await postOrderErpOrderStagesUpload({ | |
196 | - data: formData, | |
197 | - headers: { | |
198 | - 'Content-Type': | |
199 | - 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq', | |
200 | - }, | |
201 | - }); | |
202 | - if (res.data) { | |
203 | - remakeItem.fileUrl = res.data; | |
204 | - } | |
205 | - }; | |
206 | - promises.push(uploadPromise()); | |
207 | - } | |
204 | + // if ( | |
205 | + // typeof item.fileUrl === 'object' && | |
206 | + // item.fileUrl instanceof File | |
207 | + // ) { | |
208 | + // const formData = new FormData(); | |
209 | + // formData.append('file', item.fileUrl as RcFile); | |
210 | + // const uploadPromise = async () => { | |
211 | + // const res = await postOrderErpOrderStagesUpload({ | |
212 | + // data: formData, | |
213 | + // headers: { | |
214 | + // 'Content-Type': | |
215 | + // 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq', | |
216 | + // }, | |
217 | + // }); | |
218 | + // if (res.data) { | |
219 | + // remakeItem.fileUrl = res.data; | |
220 | + // } | |
221 | + // }; | |
222 | + // promises.push(uploadPromise()); | |
223 | + // } | |
208 | 224 | remakeValue.push(remakeItem); |
209 | 225 | }); |
210 | 226 | Promise.all(promises).then(async () => { |
... | ... | @@ -243,8 +259,9 @@ export default ({ currentContract, toReload }) => { |
243 | 259 | const isSaveOrUpdate = await postOrderErpOrderStagesSaveOrUpdate({ |
244 | 260 | data: { ...toSendEdit }, |
245 | 261 | }); |
246 | - if (isSaveOrUpdate) { | |
247 | - getBody(); | |
262 | + if (isSaveOrUpdate.message === '成功') { | |
263 | + console.log('2'); | |
264 | + getBody(toSendEdit.contract); | |
248 | 265 | toReload(); |
249 | 266 | } |
250 | 267 | await waitTime(2000); | ... | ... |
src/pages/Instalment/components/payWayDetail/payWayDetail.tsx
... | ... | @@ -4,19 +4,18 @@ import { |
4 | 4 | EditableProTable, |
5 | 5 | ProFormDatePicker, |
6 | 6 | ProFormRadio, |
7 | - ProFormUploadButton, | |
8 | 7 | } from '@ant-design/pro-components'; |
9 | -import { message } from 'antd'; | |
10 | 8 | import React, { useEffect, useState } from 'react'; |
9 | +import PayWayUpload from '../upload/payWayUpload'; | |
11 | 10 | import './payWayDetail.less'; |
12 | 11 | |
13 | -const waitTime = (time: number = 100) => { | |
14 | - return new Promise((resolve) => { | |
15 | - setTimeout(() => { | |
16 | - resolve(true); | |
17 | - }, time); | |
18 | - }); | |
19 | -}; | |
12 | +// const waitTime = (time: number = 100) => { | |
13 | +// return new Promise((resolve) => { | |
14 | +// setTimeout(() => { | |
15 | +// resolve(true); | |
16 | +// }, time); | |
17 | +// }); | |
18 | +// }; | |
20 | 19 | |
21 | 20 | type DataSourceType = { |
22 | 21 | id: number; |
... | ... | @@ -74,6 +73,7 @@ export default ({ payBody, thisId, currtSave }) => { |
74 | 73 | ]; |
75 | 74 | |
76 | 75 | const [editableKeys, setEditableRowKeys] = useState<React.Key[]>([]); |
76 | + const [isRetrun, setIsRetrun] = useState(false); | |
77 | 77 | const [position, setPosition] = useState<'top' | 'bottom' | 'hidden'>( |
78 | 78 | 'hidden', |
79 | 79 | ); |
... | ... | @@ -81,9 +81,17 @@ export default ({ payBody, thisId, currtSave }) => { |
81 | 81 | readonly DataSourceType[] |
82 | 82 | >([...defaultData]); |
83 | 83 | // const [body, setBody] = useState([]) |
84 | - const [isAccept, setIsAccept] = useState(null); | |
84 | + // const [isAccept, setIsAccept] = useState(null); | |
85 | 85 | // const [isCurrtSave, setIsCurrtSave] = useState(false); |
86 | 86 | |
87 | + const waitTime = (time: number = 100) => { | |
88 | + return new Promise((resolve) => { | |
89 | + setTimeout(() => { | |
90 | + resolve(true); | |
91 | + }, time); | |
92 | + }); | |
93 | + }; | |
94 | + | |
87 | 95 | async function getOther(value, arr) { |
88 | 96 | const res = await postOrderErpOrderStagesPayWaySelect({ |
89 | 97 | data: { ossId: value }, |
... | ... | @@ -106,11 +114,32 @@ export default ({ payBody, thisId, currtSave }) => { |
106 | 114 | }); |
107 | 115 | return currt; |
108 | 116 | }); |
117 | + // console.log(remake); | |
109 | 118 | setPayWayDetailBody(remake); |
119 | + setIsRetrun(true); | |
110 | 120 | } |
111 | 121 | } |
112 | 122 | |
113 | - function setPayWay(value) { | |
123 | + function getUploadFile(value) { | |
124 | + let remakeBody = []; | |
125 | + let remakeBodyItem = {}; | |
126 | + payWayDetailBody.forEach((item) => { | |
127 | + if (item.id === value.id) { | |
128 | + remakeBodyItem = { | |
129 | + ...item, | |
130 | + fileUrl: value.url, | |
131 | + fileName: value.name, | |
132 | + }; | |
133 | + } else { | |
134 | + remakeBodyItem = { ...item }; | |
135 | + } | |
136 | + remakeBody.push(remakeBodyItem); | |
137 | + }); | |
138 | + setPayWayDetailBody(remakeBody); | |
139 | + currtSave(remakeBody); | |
140 | + } | |
141 | + | |
142 | + async function setPayWay(value) { | |
114 | 143 | const remakeData = payWayDetailBody.map((obj) => { |
115 | 144 | return { |
116 | 145 | ...obj, |
... | ... | @@ -127,9 +156,6 @@ export default ({ payBody, thisId, currtSave }) => { |
127 | 156 | getOther(thisId, remakeData); |
128 | 157 | } |
129 | 158 | } |
130 | - // useEffect(() => { | |
131 | - // getOther(thisId) | |
132 | - // }, [thisId]) | |
133 | 159 | |
134 | 160 | useEffect(() => { |
135 | 161 | setPayWay(payBody); |
... | ... | @@ -175,6 +201,7 @@ export default ({ payBody, thisId, currtSave }) => { |
175 | 201 | render: (text, record) => { |
176 | 202 | const handleChange = (value) => { |
177 | 203 | const updatedDataSource = payWayDetailBody.map((item) => { |
204 | + console.log(value); | |
178 | 205 | if (item.id === record.id) { |
179 | 206 | return { |
180 | 207 | ...item, |
... | ... | @@ -207,74 +234,33 @@ export default ({ payBody, thisId, currtSave }) => { |
207 | 234 | title: '付款单回执', |
208 | 235 | dataIndex: 'fileName', |
209 | 236 | render: (text, record) => { |
210 | - if (isAccept !== record.id) { | |
211 | - if ( | |
212 | - typeof record.fileUrl === 'object' && | |
213 | - record.fileUrl instanceof File | |
214 | - ) { | |
215 | - return ( | |
216 | - <a onClick={() => message.error('请先保存')}>{record.fileName}</a> | |
217 | - ); | |
218 | - } else { | |
219 | - return <a href={record.fileUrl}>{record.fileName}</a>; | |
220 | - } | |
237 | + if (record.fileUrl !== undefined) { | |
238 | + return ( | |
239 | + <PayWayUpload | |
240 | + natureModel={{ | |
241 | + id: record.id, | |
242 | + fileName: record.fileName, | |
243 | + fileUrl: record.fileUrl, | |
244 | + }} | |
245 | + setCurryFile={getUploadFile} | |
246 | + key={isRetrun} | |
247 | + ></PayWayUpload> | |
248 | + ); | |
221 | 249 | } else { |
222 | 250 | return ( |
223 | - <ProFormUploadButton | |
224 | - name={record.id} | |
225 | - onChange={(value) => { | |
226 | - // console.log(value); | |
227 | - // console.log(payWayDetailBody); | |
228 | - let remakeBody = []; | |
229 | - let remakeBodyItem = {}; | |
230 | - payWayDetailBody.forEach((item) => { | |
231 | - if (item.id === record.id) { | |
232 | - remakeBodyItem = { | |
233 | - ...item, | |
234 | - fileUrl: value.file.originFileObj, | |
235 | - fileName: value.file.name, | |
236 | - }; | |
237 | - } else { | |
238 | - remakeBodyItem = { ...item }; | |
239 | - } | |
240 | - // if (value.fileList.length == 0) { | |
241 | - // remakeBodyItem = { ...item, fileUrl: undefined, fileName: undefined } | |
242 | - // } | |
243 | - remakeBody.push(remakeBodyItem); | |
244 | - }); | |
245 | - setPayWayDetailBody(remakeBody); | |
246 | - currtSave(remakeBody); | |
251 | + <PayWayUpload | |
252 | + natureModel={{ | |
253 | + id: record.id, | |
254 | + fileName: undefined, | |
255 | + fileUrl: undefined, | |
247 | 256 | }} |
248 | - width="md" | |
249 | - max={1} | |
250 | - /> | |
257 | + setCurryFile={getUploadFile} | |
258 | + key={isRetrun} | |
259 | + ></PayWayUpload> | |
251 | 260 | ); |
252 | 261 | } |
253 | 262 | }, |
254 | 263 | }, |
255 | - { | |
256 | - title: '操作', | |
257 | - valueType: 'option', | |
258 | - width: 200, | |
259 | - render: (text, record) => [ | |
260 | - <a | |
261 | - key="editable" | |
262 | - onClick={() => { | |
263 | - if (isAccept !== record.id) { | |
264 | - setIsAccept(record.id); | |
265 | - } else { | |
266 | - setIsAccept(null); | |
267 | - } | |
268 | - }} | |
269 | - > | |
270 | - {record.fileName !== undefined && | |
271 | - record.fileName !== '' && | |
272 | - record.fileName !== null | |
273 | - ? '重新上传' | |
274 | - : '上传回执'} | |
275 | - </a>, | |
276 | - ], | |
277 | - }, | |
278 | 264 | ]; |
279 | 265 | |
280 | 266 | return ( | ... | ... |
src/pages/Instalment/components/read/readPayWay.tsx
... | ... | @@ -167,25 +167,19 @@ export default ({ payBody, thisId, currtSave }) => { |
167 | 167 | dataIndex: 'payDate', |
168 | 168 | editable: false, |
169 | 169 | render: (_text, record) => { |
170 | - return ( | |
171 | - <span> | |
172 | - {new Intl.DateTimeFormat('zh-CN', { | |
173 | - year: 'numeric', | |
174 | - month: 'long', | |
175 | - day: 'numeric', | |
176 | - }).format(record.payDate)} | |
177 | - </span> | |
178 | - // <ProFormDatePicker | |
179 | - // className='dataChoose' | |
180 | - // initialValue={record.payDate} | |
181 | - // value={record.payDate} | |
182 | - // placeholder={"请填写时间"} | |
183 | - // fieldProps={{ | |
184 | - // format: (value) => value.format('YYYY-MM-DD'), | |
185 | - // onChange: handleChange, | |
186 | - // }} | |
187 | - // /> | |
188 | - ); | |
170 | + if (record.payDate) { | |
171 | + return ( | |
172 | + <span> | |
173 | + {new Intl.DateTimeFormat('zh-CN', { | |
174 | + year: 'numeric', | |
175 | + month: 'long', | |
176 | + day: 'numeric', | |
177 | + }).format(record.payDate)} | |
178 | + </span> | |
179 | + ); | |
180 | + } else { | |
181 | + return <span></span>; | |
182 | + } | |
189 | 183 | }, |
190 | 184 | }, |
191 | 185 | { | ... | ... |
src/pages/Instalment/components/read/readProduct.tsx
src/pages/Instalment/components/upload/payWayUpload.tsx
0 → 100644
1 | +import { postOrderErpOrderStagesUpload } from '@/services/request'; | |
2 | +import { UploadOutlined } from '@ant-design/icons'; | |
3 | +import type { UploadProps } from 'antd'; | |
4 | +import { Button, Upload, message } from 'antd'; | |
5 | +import { RcFile } from 'antd/es/upload'; | |
6 | +import React, { useEffect } from 'react'; | |
7 | + | |
8 | +const App: React.FC = ({ natureModel, setCurryFile }) => { | |
9 | + const [fileList, setFileList] = React.useState([{}]); | |
10 | + useEffect(() => { | |
11 | + console.log(natureModel); | |
12 | + if (natureModel.fileUrl !== undefined && natureModel.fileUrl !== null) { | |
13 | + setFileList([{ name: natureModel.fileName, url: natureModel.fileUrl }]); | |
14 | + } | |
15 | + }, []); | |
16 | + | |
17 | + const handleUploadChange = (value) => { | |
18 | + setFileList(value.fileList); | |
19 | + setCurryFile({ | |
20 | + id: natureModel.id, | |
21 | + name: null, | |
22 | + url: null, | |
23 | + }); | |
24 | + if ( | |
25 | + value.fileList.length !== 0 && | |
26 | + value.fileList[0].status === 'uploading' | |
27 | + ) { | |
28 | + (async () => { | |
29 | + if (!(value.fileList[0].originFileObj instanceof File)) { | |
30 | + console.log('is not file'); | |
31 | + return false; | |
32 | + } else { | |
33 | + const formData = new FormData(); | |
34 | + formData.append('file', value.fileList[0].originFileObj as RcFile); | |
35 | + const res = await postOrderErpOrderStagesUpload({ | |
36 | + data: formData, | |
37 | + headers: { | |
38 | + 'Content-Type': 'multipart/form-data', | |
39 | + }, | |
40 | + }); | |
41 | + if (res) { | |
42 | + message.success('提交成功'); | |
43 | + console.log({ | |
44 | + uid: value.fileList[0].originFileObj.uid, | |
45 | + name: value.fileList[0].originFileObj.name, | |
46 | + url: res.data, | |
47 | + }); | |
48 | + console.log(natureModel.id); | |
49 | + | |
50 | + setCurryFile({ | |
51 | + id: natureModel.id, | |
52 | + name: value.fileList[0].originFileObj.name, | |
53 | + url: res.data, | |
54 | + }); | |
55 | + setFileList([ | |
56 | + { | |
57 | + id: value.fileList[0].originFileObj.uid, | |
58 | + name: value.fileList[0].originFileObj.name, | |
59 | + url: res.data, | |
60 | + }, | |
61 | + ]); | |
62 | + return ( | |
63 | + <a href={res.data} target="_blank" rel="noopener noreferrer"> | |
64 | + {value.fileList[0].originFileObj.name} | |
65 | + </a> | |
66 | + ); | |
67 | + } | |
68 | + } | |
69 | + })(); | |
70 | + } | |
71 | + }; | |
72 | + | |
73 | + const props: UploadProps = { | |
74 | + onChange(value) { | |
75 | + handleUploadChange(value); | |
76 | + }, | |
77 | + }; | |
78 | + | |
79 | + const shouldShowUploadButton = | |
80 | + fileList.length !== 1 || fileList[0].url === undefined; | |
81 | + | |
82 | + return ( | |
83 | + <Upload | |
84 | + {...props} | |
85 | + fileList={fileList.filter( | |
86 | + (item) => item.url !== undefined && item.url !== null, | |
87 | + )} | |
88 | + > | |
89 | + {shouldShowUploadButton && ( | |
90 | + <Button icon={<UploadOutlined />}>上传</Button> | |
91 | + )} | |
92 | + </Upload> | |
93 | + ); | |
94 | +}; | |
95 | + | |
96 | +export default App; | |
97 | + | |
98 | +{ | |
99 | + /* {!shouldShowUploadButton && <a href={fileList[0].url}>{fileList[0].name}</a>} */ | |
100 | +} | ... | ... |
src/pages/Instalment/components/upload/uploadApp.tsx
... | ... | @@ -21,13 +21,7 @@ const App: React.FC = ({ uploadFile }) => { |
21 | 21 | <p className="ant-upload-drag-icon"> |
22 | 22 | <InboxOutlined /> |
23 | 23 | </p> |
24 | - <p className="ant-upload-text"> | |
25 | - Click or drag file to this area to upload | |
26 | - </p> | |
27 | - <p className="ant-upload-hint"> | |
28 | - Support for a single or bulk upload. Strictly prohibited from | |
29 | - uploading company data or other banned files. | |
30 | - </p> | |
24 | + <p className="ant-upload-text">点击或者拖动文件到此处</p> | |
31 | 25 | </Dragger> |
32 | 26 | <a |
33 | 27 | href="https://order-erp.oss-cn-qingdao.aliyuncs.com/%E5%88%86%E6%9C%9F%E4%BB%98%E6%AC%BE-%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx?Expires=2035527699&OSSAccessKeyId=LTAIZCPI7OaWud0m&Signature=npHyEhfRd6LugJ0St8OkvRmLYtQ%3D" | ... | ... |
src/pages/Order/components/OrderDrawer.tsx
... | ... | @@ -3,6 +3,8 @@ import { |
3 | 3 | postCanrdApiUserAddressList, |
4 | 4 | postCanrdApiUserDetail, |
5 | 5 | postCanrdApiUserNowMoneyCheck, |
6 | + postDistrictSelectBelongByName, | |
7 | + postDistrictSelectByLevel, | |
6 | 8 | postKingdeeRepCustomerDetail, |
7 | 9 | postKingdeeRepMaterial, |
8 | 10 | postKingdeeRepMaterialUnit, |
... | ... | @@ -71,6 +73,10 @@ export default ({ onClose, data, subOrders, orderOptType }) => { |
71 | 73 | // [], |
72 | 74 | // ); //商品的仓库选项 |
73 | 75 | const [productUnitOptionsList, setProductUnitOptionsList] = useState([]); //商品的单位选项 |
76 | + //省市区 | |
77 | + const [province, setProvince] = useState(''); | |
78 | + const [city, setCity] = useState(''); | |
79 | + const [district, setDistrict] = useState(''); | |
74 | 80 | // const [productCustomerContactOptions, setProductCustomerContactOptions] = |
75 | 81 | // useState([]); //客户的收货人选项 |
76 | 82 | const [form] = Form.useForm<{ |
... | ... | @@ -246,7 +252,7 @@ export default ({ onClose, data, subOrders, orderOptType }) => { |
246 | 252 | newAccountOptions.push(uidDetail); |
247 | 253 | } |
248 | 254 | |
249 | - //查询当前手机号允许使用的预存账号 | |
255 | + // 查询当前手机号允许使用的预存账号 | |
250 | 256 | if (phone) { |
251 | 257 | let res = await postPrepaidPhoneAvailableList({ data: { phone: phone } }); |
252 | 258 | if (res && res.result === RESPONSE_CODE.SUCCESS) { |
... | ... | @@ -863,6 +869,8 @@ export default ({ onClose, data, subOrders, orderOptType }) => { |
863 | 869 | values.institution = values.institution?.trim(); |
864 | 870 | values.institutionContactName = values.institutionContactName?.trim(); |
865 | 871 | values.customerName = values.customerNameString.trim(); |
872 | + values.customerShippingAddress = | |
873 | + province + city + district + values.customerShippingAddress; | |
866 | 874 | |
867 | 875 | if (typeof values.erpCustomerId !== 'string') { |
868 | 876 | values.erpCustomerId = values.erpCustomerId?.id; |
... | ... | @@ -1015,7 +1023,6 @@ export default ({ onClose, data, subOrders, orderOptType }) => { |
1015 | 1023 | name="contactAddress" |
1016 | 1024 | hidden |
1017 | 1025 | ></ProFormText> |
1018 | - | |
1019 | 1026 | <ProFormSelect |
1020 | 1027 | key="customerName" |
1021 | 1028 | label="收货人" |
... | ... | @@ -1176,6 +1183,113 @@ export default ({ onClose, data, subOrders, orderOptType }) => { |
1176 | 1183 | placeholder="请输入课题组" |
1177 | 1184 | rules={[{ required: true, message: '课题组必填' }]} |
1178 | 1185 | /> |
1186 | + <div | |
1187 | + style={{ | |
1188 | + display: 'flex', | |
1189 | + justifyContent: 'space-between', | |
1190 | + width: 340, | |
1191 | + }} | |
1192 | + > | |
1193 | + <ProFormSelect | |
1194 | + name="province" | |
1195 | + key="province" | |
1196 | + width={100} | |
1197 | + label="省" | |
1198 | + fieldProps={{ | |
1199 | + labelInValue: true, | |
1200 | + }} | |
1201 | + onChange={(value) => { | |
1202 | + setProvince(value?.value); | |
1203 | + }} | |
1204 | + placeholder="请选择" | |
1205 | + rules={[ | |
1206 | + { | |
1207 | + required: true, | |
1208 | + message: '请选择!', | |
1209 | + }, | |
1210 | + ]} | |
1211 | + request={async () => { | |
1212 | + let province = []; | |
1213 | + let res = await postDistrictSelectByLevel({ data: 1 }); | |
1214 | + if (res) { | |
1215 | + res.data.forEach((item) => { | |
1216 | + province.push({ value: item.district, label: item.district }); | |
1217 | + }); | |
1218 | + } | |
1219 | + return province; | |
1220 | + }} | |
1221 | + /> | |
1222 | + <ProFormSelect | |
1223 | + key={province} | |
1224 | + name="city" | |
1225 | + width={100} | |
1226 | + label="市" | |
1227 | + disabled={province === ''} | |
1228 | + fieldProps={{ | |
1229 | + labelInValue: true, | |
1230 | + }} | |
1231 | + placeholder="请选择" | |
1232 | + onChange={(value) => { | |
1233 | + setCity(value?.value); | |
1234 | + }} | |
1235 | + rules={[ | |
1236 | + { | |
1237 | + required: true, | |
1238 | + message: '请选择!', | |
1239 | + }, | |
1240 | + ]} | |
1241 | + request={async () => { | |
1242 | + if (province !== '') { | |
1243 | + let cityOptions = []; | |
1244 | + let res = await postDistrictSelectBelongByName({ | |
1245 | + data: province, | |
1246 | + }); | |
1247 | + if (res && res.data) { | |
1248 | + cityOptions = res.data.map((item) => ({ | |
1249 | + value: item.district, | |
1250 | + label: item.district, | |
1251 | + })); | |
1252 | + } | |
1253 | + return cityOptions; | |
1254 | + } | |
1255 | + return []; | |
1256 | + }} | |
1257 | + /> | |
1258 | + <ProFormSelect | |
1259 | + key={city ? city.toString() : 'district'} | |
1260 | + name="district" | |
1261 | + width={100} | |
1262 | + label="区" | |
1263 | + onChange={(value) => { | |
1264 | + setDistrict(value?.value); | |
1265 | + }} | |
1266 | + disabled={city === ''} | |
1267 | + fieldProps={{ | |
1268 | + labelInValue: true, | |
1269 | + }} | |
1270 | + placeholder="请选择" | |
1271 | + rules={[ | |
1272 | + { | |
1273 | + required: true, | |
1274 | + message: '请选择!', | |
1275 | + }, | |
1276 | + ]} | |
1277 | + request={async () => { | |
1278 | + if (city !== '') { | |
1279 | + let districtOptions = []; | |
1280 | + let res = await postDistrictSelectBelongByName({ data: city }); | |
1281 | + if (res && res.data) { | |
1282 | + districtOptions = res.data.map((item) => ({ | |
1283 | + value: item.district, | |
1284 | + label: item.district, | |
1285 | + })); | |
1286 | + } | |
1287 | + return districtOptions; | |
1288 | + } | |
1289 | + return []; | |
1290 | + }} | |
1291 | + /> | |
1292 | + </div> | |
1179 | 1293 | <ProFormTextArea |
1180 | 1294 | width="lg" |
1181 | 1295 | key="customerShippingAddress" | ... | ... |
src/pages/OrderReport/index.tsx
1 | 1 | import { |
2 | + getOrderErpOrderZoNingSelectAll, | |
3 | + getOrderErpOrderZoNingSelectUserAll, | |
4 | + postOrderErpOrderZoNingSelectSaleUserByProvince, | |
2 | 5 | postServiceOrderQueryReportFormsInformation, |
3 | 6 | postServiceOrderQuerySalesCode, |
4 | 7 | } from '@/services'; |
... | ... | @@ -63,7 +66,7 @@ const OrderReportPage = () => { |
63 | 66 | setLoading(true); |
64 | 67 | let body = { |
65 | 68 | statisticsMethod: '', |
66 | - salesCode: form.getFieldValue('salesCode'), | |
69 | + salesCode: [null], | |
67 | 70 | productBelongBusiness: form.getFieldValue('productBelongBusiness'), |
68 | 71 | maxAccount: form.getFieldValue('maxAccount'), |
69 | 72 | includeExperimentalEquipment: form.getFieldValue( |
... | ... | @@ -72,6 +75,36 @@ const OrderReportPage = () => { |
72 | 75 | // beginTime:"", |
73 | 76 | // endTime:"" |
74 | 77 | }; |
78 | + // console.log(form.getFieldValue('zoning').value); | |
79 | + | |
80 | + let res = await getOrderErpOrderZoNingSelectUserAll(); | |
81 | + if (res && res.data) { | |
82 | + let safeUserList = []; | |
83 | + res.data.forEach((element) => { | |
84 | + safeUserList.push(element.userName); | |
85 | + }); | |
86 | + body = { ...body, salesCode: safeUserList }; | |
87 | + } | |
88 | + if (form.getFieldValue('salesCode')) { | |
89 | + body = { ...body, salesCode: [form.getFieldValue('salesCode')] }; | |
90 | + } | |
91 | + if (form.getFieldValue('zoning')) { | |
92 | + if ( | |
93 | + form.getFieldValue('zoning').value !== '' || | |
94 | + form.getFieldValue('zoning').value !== null || | |
95 | + form.getFieldValue('zoning').value !== undefined | |
96 | + ) { | |
97 | + let res = await postOrderErpOrderZoNingSelectSaleUserByProvince({ | |
98 | + data: form.getFieldValue('zoning').value, | |
99 | + }); | |
100 | + if (res && res.data) { | |
101 | + body = { ...body, salesCode: res.data }; | |
102 | + } | |
103 | + } | |
104 | + } | |
105 | + | |
106 | + if (form.getFieldValue('zoning')) { | |
107 | + } | |
75 | 108 | |
76 | 109 | // if(form.getFieldValue("dateRange")!==undefined){ |
77 | 110 | // body.beginTime=formatDate(form.getFieldValue("dateRange")[0]), |
... | ... | @@ -162,6 +195,30 @@ const OrderReportPage = () => { |
162 | 195 | initialValue={false} |
163 | 196 | label="包含实验设备事业部汇总统计" |
164 | 197 | /> |
198 | + | |
199 | + <ProFormSelect | |
200 | + key="zoning" | |
201 | + name="zoning" | |
202 | + width="md" | |
203 | + label="所属地区" | |
204 | + fieldProps={{ | |
205 | + labelInValue: true, | |
206 | + }} | |
207 | + placeholder="请选择" | |
208 | + request={async () => { | |
209 | + let zoningOptions = []; | |
210 | + let res = await getOrderErpOrderZoNingSelectAll(); | |
211 | + if (res && res.data) { | |
212 | + console.log(res.data); | |
213 | + | |
214 | + zoningOptions = res.data.map((item) => ({ | |
215 | + value: item.zoning, | |
216 | + label: item.zoning, | |
217 | + })); | |
218 | + } | |
219 | + return zoningOptions; | |
220 | + }} | |
221 | + /> | |
165 | 222 | </QueryFilter> |
166 | 223 | </ProCard> |
167 | 224 | ... | ... |
src/pages/ResearchGroup/components/ImportModal.tsx
... | ... | @@ -6,7 +6,7 @@ import { Button, Modal, Upload, message } from 'antd'; |
6 | 6 | import { RcFile, UploadFile, UploadProps } from 'antd/es/upload'; |
7 | 7 | import { useState } from 'react'; |
8 | 8 | export default ({ onClose }) => { |
9 | - // const [form] = Form.useForm<{ name: string; company: string }>(); | |
9 | + // const [form] = Form.useForm<{ name: string; company: string }>(); | |
10 | 10 | const [messageApi, contextHolder] = message.useMessage(); |
11 | 11 | const [fileList, setFileList] = useState<UploadFile[]>([]); |
12 | 12 | const [uploading, setUploading] = useState(false); |
... | ... | @@ -41,8 +41,8 @@ export default ({ onClose }) => { |
41 | 41 | //originFileObj二进制文件 |
42 | 42 | formData.append('file', file.originFileObj as RcFile); |
43 | 43 | }); |
44 | - // console.log(fileList[0] as RcFile) | |
45 | - // formData.append('file', fileList[0] as RcFile); | |
44 | + console.log(fileList[0] as RcFile); | |
45 | + formData.append('file', fileList[0] as RcFile); | |
46 | 46 | setUploading(true); |
47 | 47 | // You can use any AJAX library you like |
48 | 48 | const res = await postResearchGroupsImport({ | ... | ... |
src/pages/ResearchGroup/index.css
0 → 100644
src/pages/ZoNing/components/constant.tsx
1 | 1 | import { List } from 'lodash'; |
2 | 2 | |
3 | 3 | export type zoningItem = { |
4 | - id: number; //id | |
4 | + id?: number; //id | |
5 | 5 | zoning: string; //区域名称 |
6 | 6 | orderProvinceVoList: List<provinceItem>; //所包含的省份列表 |
7 | 7 | orderUserVoList: List<userItem>; //所包含的销售列表 |
8 | 8 | }; |
9 | 9 | |
10 | 10 | export type zoningShowItem = { |
11 | - id: number; //id | |
11 | + id?: number; //id | |
12 | 12 | zoning: string; //区域名称 |
13 | 13 | orderProvinceShowList: string; //所包含的省份列表 |
14 | 14 | orderUserShowList: string; //所包含的销售列表 |
15 | + orderUserNumberShowList: number[]; //销售对应的uId | |
15 | 16 | }; |
16 | 17 | |
17 | 18 | export type provinceItem = { |
18 | - pId: number; | |
19 | + pId?: number; | |
19 | 20 | province: string; |
20 | 21 | }; |
21 | 22 | |
22 | 23 | export type userItem = { |
23 | 24 | uId: number; |
24 | - userName: string; | |
25 | + userName?: string; | |
26 | +}; | |
27 | + | |
28 | +export const provinceEnum = { | |
29 | + 全选: '全选', | |
30 | + 北京市: '北京市', | |
31 | + 天津市: '天津市', | |
32 | + 河北省: '河北省', | |
33 | + 山西省: '山西省', | |
34 | + 内蒙古自治区: '内蒙古自治区', | |
35 | + 辽宁省: '辽宁省', | |
36 | + 吉林省: '吉林省', | |
37 | + 黑龙江省: '黑龙江省', | |
38 | + 上海市: '上海市', | |
39 | + 江苏省: '江苏省', | |
40 | + 浙江省: '浙江省', | |
41 | + 安徽省: '安徽省', | |
42 | + 福建省: '福建省', | |
43 | + 江西省: '江西省', | |
44 | + 山东省: '山东省', | |
45 | + 河南省: '河南省', | |
46 | + 湖北省: '湖北省', | |
47 | + 湖南省: '湖南省', | |
48 | + 广东省: '广东省', | |
49 | + 广西壮族自治区: '广西壮族自治区', | |
50 | + 海南省: '海南省', | |
51 | + 重庆市: '重庆市', | |
52 | + 四川省: '四川省', | |
53 | + 贵州省: '贵州省', | |
54 | + 云南省: '云南省', | |
55 | + 西藏自治区: '西藏自治区', | |
56 | + 陕西省: '陕西省', | |
57 | + 甘肃省: '甘肃省', | |
58 | + 青海省: '青海省', | |
59 | + 宁夏回族自治区: '宁夏回族自治区', | |
60 | + 新疆维吾尔自治区: '新疆维吾尔自治区', | |
61 | + 台湾省: '台湾省', | |
62 | + 香港特别行政区: '香港特别行政区', | |
63 | + 澳门特别行政区: '澳门特别行政区', | |
25 | 64 | }; | ... | ... |
src/pages/ZoNing/components/modal.tsx
1 | +import { | |
2 | + getOrderErpOrderZoNingSelectUserAll, | |
3 | + postOrderErpOrderZoNingSaveOrUpdate, | |
4 | +} from '@/services'; | |
1 | 5 | import { PlusOutlined } from '@ant-design/icons'; |
2 | 6 | import { |
3 | 7 | ModalForm, |
... | ... | @@ -6,8 +10,7 @@ import { |
6 | 10 | ProFormText, |
7 | 11 | } from '@ant-design/pro-components'; |
8 | 12 | import { Button, Form, message } from 'antd'; |
9 | -import { zoningItem } from './constant'; | |
10 | - | |
13 | +import { provinceEnum, zoningItem } from './constant'; | |
11 | 14 | const waitTime = (time: number = 100) => { |
12 | 15 | return new Promise((resolve) => { |
13 | 16 | setTimeout(() => { |
... | ... | @@ -16,66 +19,126 @@ const waitTime = (time: number = 100) => { |
16 | 19 | }); |
17 | 20 | }; |
18 | 21 | |
19 | -export default () => { | |
22 | +export default ({ toReload, option, needEditBody }) => { | |
20 | 23 | const [form] = Form.useForm<zoningItem>(); |
24 | + | |
21 | 25 | return ( |
22 | 26 | <ModalForm<{ |
23 | - name: string; | |
24 | - company: string; | |
27 | + zoning: string; | |
28 | + province: string[]; | |
29 | + user: number[]; | |
25 | 30 | }> |
26 | - title="新增区域" | |
31 | + title={option} | |
27 | 32 | trigger={ |
28 | - <Button type="primary"> | |
29 | - <PlusOutlined /> | |
30 | - 新增区域 | |
33 | + <Button type="primary" key={option.id}> | |
34 | + {option !== '编辑' && <PlusOutlined />} | |
35 | + {option} | |
31 | 36 | </Button> |
32 | 37 | } |
33 | 38 | form={form} |
34 | 39 | autoFocusFirstInput |
40 | + initialValues={{ | |
41 | + zoning: needEditBody.zoning ? needEditBody.zoning : '', | |
42 | + province: needEditBody.orderProvinceShowList | |
43 | + ? needEditBody.orderProvinceShowList.split('、') | |
44 | + : [], | |
45 | + user: needEditBody.orderUserNumberShowList | |
46 | + ? needEditBody.orderUserNumberShowList | |
47 | + : [], | |
48 | + }} | |
35 | 49 | modalProps={{ |
36 | 50 | destroyOnClose: true, |
37 | - onCancel: () => console.log('run'), | |
38 | 51 | }} |
39 | - submitTimeout={2000} | |
52 | + submitTimeout={500} | |
40 | 53 | onFinish={async (values) => { |
41 | - await waitTime(2000); | |
42 | - console.log(values.name); | |
43 | - message.success('提交成功'); | |
44 | - return true; | |
54 | + console.log(values); | |
55 | + const orderProvinceList = values.province.map((item) => { | |
56 | + return { province: item }; | |
57 | + }); | |
58 | + const orderUserList = values.user.map((item) => { | |
59 | + return { uId: item }; | |
60 | + }); | |
61 | + const fetchData: zoningItem = { | |
62 | + zoning: values.zoning, | |
63 | + orderProvinceVoList: orderProvinceList, | |
64 | + orderUserVoList: orderUserList, | |
65 | + }; | |
66 | + let res = await postOrderErpOrderZoNingSaveOrUpdate({ | |
67 | + data: fetchData, | |
68 | + }); | |
69 | + if (res) { | |
70 | + console.log(res); | |
71 | + await waitTime(500); | |
72 | + console.log(values); | |
73 | + message.success('提交成功'); | |
74 | + toReload(); | |
75 | + return true; | |
76 | + } | |
77 | + return false; | |
45 | 78 | }} |
46 | 79 | > |
47 | 80 | <ProForm.Group> |
48 | 81 | <ProFormText |
49 | - width="md" | |
82 | + width="lg" | |
50 | 83 | name="zoning" |
51 | 84 | label="区域名称" |
52 | 85 | placeholder="请输入" |
86 | + rules={[{ required: true, message: '此项为必填项' }]} | |
53 | 87 | /> |
54 | 88 | </ProForm.Group> |
55 | 89 | <ProForm.Group> |
56 | 90 | <ProFormSelect |
57 | - request={async () => [ | |
91 | + name="user" | |
92 | + width="lg" | |
93 | + label="负责销售" | |
94 | + request={async () => { | |
95 | + const userList = await getOrderErpOrderZoNingSelectUserAll(); | |
96 | + if (userList) { | |
97 | + let userSelList = []; | |
98 | + userList.data.forEach((item: { uId: any; userName: any }) => | |
99 | + userSelList.push({ | |
100 | + value: item.uId, | |
101 | + label: item.userName, | |
102 | + }), | |
103 | + ); | |
104 | + userSelList.unshift({ | |
105 | + value: 0, | |
106 | + label: '全选', | |
107 | + }); | |
108 | + return userSelList; | |
109 | + } | |
110 | + return []; | |
111 | + }} | |
112 | + fieldProps={{ | |
113 | + mode: 'multiple', | |
114 | + }} | |
115 | + placeholder="请选择" | |
116 | + rules={[ | |
58 | 117 | { |
59 | - value: 'chapter', | |
60 | - label: '盖章后生效', | |
118 | + required: true, | |
119 | + message: '请选择!', | |
120 | + type: 'array', | |
61 | 121 | }, |
62 | 122 | ]} |
63 | - width="xs" | |
64 | - name="orderProvinceVoList" | |
65 | - label="合同约定生效方式" | |
66 | 123 | /> |
67 | 124 | </ProForm.Group> |
68 | 125 | <ProForm.Group> |
69 | 126 | <ProFormSelect |
70 | - width="xs" | |
71 | - options={[ | |
127 | + name="province" | |
128 | + width="lg" | |
129 | + label="管辖地区" | |
130 | + valueEnum={provinceEnum} | |
131 | + fieldProps={{ | |
132 | + mode: 'multiple', | |
133 | + }} | |
134 | + placeholder="请选择" | |
135 | + rules={[ | |
72 | 136 | { |
73 | - value: 'time', | |
74 | - label: '履行完终止', | |
137 | + required: true, | |
138 | + message: '请选择!', | |
139 | + type: 'array', | |
75 | 140 | }, |
76 | 141 | ]} |
77 | - name="orderUserVoList" | |
78 | - label="合同约定失效效方式" | |
79 | 142 | /> |
80 | 143 | </ProForm.Group> |
81 | 144 | </ModalForm> | ... | ... |
src/pages/ZoNing/components/table.tsx
1 | -import type { ProColumns } from '@ant-design/pro-components'; | |
2 | 1 | import { |
3 | - EditableProTable, | |
4 | - ProCard, | |
5 | - ProFormField, | |
6 | -} from '@ant-design/pro-components'; | |
7 | -import React, { useState } from 'react'; | |
2 | + deleteOrderErpOrderZoNingDelete, | |
3 | + getOrderErpOrderZoNingSelectAll, | |
4 | +} from '@/services'; | |
5 | +import type { ProColumns } from '@ant-design/pro-components'; | |
6 | +import { EditableProTable } from '@ant-design/pro-components'; | |
7 | +import { Button, Popconfirm, PopconfirmProps, message } from 'antd'; | |
8 | +import React, { useRef, useState } from 'react'; | |
9 | +import '../index.less'; | |
8 | 10 | import { zoningItem, zoningShowItem } from './constant'; |
9 | 11 | import Modal from './modal'; |
10 | 12 | |
... | ... | @@ -16,68 +18,81 @@ const waitTime = (time: number = 100) => { |
16 | 18 | }); |
17 | 19 | }; |
18 | 20 | |
19 | -const defaultData: zoningItem[] = [ | |
20 | - { | |
21 | - id: 1, | |
22 | - zoning: '华南地区', | |
23 | - orderProvinceVoList: [ | |
24 | - { | |
25 | - pId: 1, | |
26 | - province: '广东省', | |
27 | - }, | |
28 | - { | |
29 | - pId: 2, | |
30 | - province: '四川省', | |
31 | - }, | |
32 | - { | |
33 | - pId: 3, | |
34 | - province: '北京市', | |
35 | - }, | |
36 | - { | |
37 | - pId: 4, | |
38 | - province: '上海市', | |
39 | - }, | |
40 | - ], | |
41 | - orderUserVoList: [ | |
42 | - { | |
43 | - uId: 1, | |
44 | - userName: '李华', | |
45 | - }, | |
46 | - ], | |
47 | - }, | |
48 | -]; | |
21 | +function changeToShow(array: zoningItem[]) { | |
22 | + console.log(JSON.parse(localStorage.getItem('userInfo')).username); | |
23 | + const showArray: zoningShowItem[] = array.map((item) => { | |
24 | + let orderProvinceShowList = ''; | |
25 | + let orderUserShowList = ''; | |
26 | + let orderUserNumberShowList: number[] = []; | |
27 | + item.orderProvinceVoList.forEach((element, index) => { | |
28 | + orderProvinceShowList += element.province; | |
29 | + if (index < item.orderProvinceVoList.length - 1) { | |
30 | + orderProvinceShowList += '、'; | |
31 | + } | |
32 | + }); | |
49 | 33 | |
50 | -const defaultShowData: zoningShowItem[] = defaultData.map((item) => { | |
51 | - let orderProvinceShowList = ''; | |
52 | - let orderUserShowList = ''; | |
34 | + item.orderUserVoList.forEach((event, index) => { | |
35 | + orderUserShowList += event.userName; | |
36 | + orderUserNumberShowList.push(event.uId); | |
37 | + if (index < item.orderUserVoList.length - 1) { | |
38 | + orderUserShowList += '、'; | |
39 | + } | |
40 | + }); | |
53 | 41 | |
54 | - item.orderProvinceVoList.forEach((element, index) => { | |
55 | - orderProvinceShowList += element.province; | |
56 | - if (index < item.orderProvinceVoList.length - 1) { | |
57 | - orderProvinceShowList += '、'; | |
42 | + if (orderUserShowList === '') { | |
43 | + orderUserShowList = '全选'; | |
44 | + orderUserNumberShowList.push(0); | |
58 | 45 | } |
59 | - }); | |
60 | 46 | |
61 | - item.orderUserVoList.forEach((event, index) => { | |
62 | - orderUserShowList += event.userName; | |
63 | - if (index < item.orderUserVoList.length - 1) { | |
64 | - orderUserShowList += '、'; | |
65 | - } | |
47 | + return { | |
48 | + id: item.id, | |
49 | + zoning: item.zoning, | |
50 | + orderProvinceShowList, | |
51 | + orderUserShowList, | |
52 | + orderUserNumberShowList, | |
53 | + }; | |
66 | 54 | }); |
67 | - | |
68 | - return { | |
69 | - id: item.id, | |
70 | - zoning: item.zoning, | |
71 | - orderProvinceShowList, | |
72 | - orderUserShowList, | |
73 | - }; | |
74 | -}); | |
55 | + return showArray; | |
56 | +} | |
75 | 57 | |
76 | 58 | export default () => { |
77 | 59 | const [editableKeys, setEditableRowKeys] = useState<React.Key[]>([]); |
78 | 60 | const [dataSource, setDataSource] = useState<readonly zoningItem[]>([]); |
79 | 61 | const [position] = useState<'top' | 'bottom' | 'hidden'>('hidden'); |
80 | 62 | |
63 | + interface ActionType { | |
64 | + reload: (resetPageIndex?: boolean) => void; | |
65 | + reloadAndRest: () => void; | |
66 | + reset: () => void; | |
67 | + clearSelected?: () => void; | |
68 | + startEditable: (rowKey: Key) => boolean; | |
69 | + cancelEditable: (rowKey: Key) => boolean; | |
70 | + } | |
71 | + | |
72 | + const ref = useRef<ActionType>({ | |
73 | + reload: () => {}, | |
74 | + reloadAndRest: () => {}, | |
75 | + reset: () => {}, | |
76 | + startEditable: () => {}, | |
77 | + cancelEditable: () => {}, | |
78 | + }); | |
79 | + | |
80 | + function reload() { | |
81 | + ref.current.reload(); | |
82 | + } | |
83 | + | |
84 | + const confirm: PopconfirmProps['onConfirm'] = async (id) => { | |
85 | + await deleteOrderErpOrderZoNingDelete({ | |
86 | + data: id, | |
87 | + }); | |
88 | + reload(); | |
89 | + message.success('删除成功'); | |
90 | + }; | |
91 | + | |
92 | + const cancel: PopconfirmProps['onCancel'] = () => { | |
93 | + message.error('取消删除'); | |
94 | + }; | |
95 | + | |
81 | 96 | const columns: ProColumns<zoningItem>[] = [ |
82 | 97 | { |
83 | 98 | title: '区域名称', |
... | ... | @@ -101,74 +116,72 @@ export default () => { |
101 | 116 | title: '操作', |
102 | 117 | valueType: 'option', |
103 | 118 | width: 200, |
104 | - render: (text, record, _, action) => [ | |
105 | - <a | |
106 | - key="editable" | |
107 | - onClick={() => { | |
108 | - action?.startEditable?.(record.id); | |
109 | - }} | |
110 | - > | |
111 | - 编辑 | |
112 | - </a>, | |
113 | - <a | |
114 | - key="delete" | |
115 | - onClick={() => { | |
116 | - setDataSource(dataSource.filter((item) => item.id !== record.id)); | |
117 | - }} | |
118 | - > | |
119 | - 删除 | |
120 | - </a>, | |
119 | + render: (text, record) => [ | |
120 | + <> | |
121 | + <Modal | |
122 | + toReload={reload} | |
123 | + option={'编辑'} | |
124 | + needEditBody={record} | |
125 | + key={record.id} | |
126 | + /> | |
127 | + <Popconfirm | |
128 | + title="删除此项" | |
129 | + description="你确定你要删除此项吗?" | |
130 | + onConfirm={() => { | |
131 | + confirm(record.id); | |
132 | + }} | |
133 | + onCancel={cancel} | |
134 | + okText="确定" | |
135 | + cancelText="取消" | |
136 | + > | |
137 | + <Button>删除</Button> | |
138 | + </Popconfirm> | |
139 | + </>, | |
121 | 140 | ], |
122 | 141 | }, |
123 | 142 | ]; |
124 | 143 | |
125 | 144 | return ( |
126 | - <> | |
127 | - <EditableProTable<zoningItem> | |
128 | - rowKey="id" | |
129 | - headerTitle={<Modal></Modal>} | |
130 | - maxLength={5} | |
131 | - scroll={{ | |
132 | - x: 960, | |
133 | - }} | |
134 | - recordCreatorProps={ | |
135 | - position !== 'hidden' | |
136 | - ? { | |
137 | - position: position as 'top', | |
138 | - record: () => ({ id: (Math.random() * 1000000).toFixed(0) }), | |
139 | - } | |
140 | - : false | |
145 | + <EditableProTable<zoningItem> | |
146 | + rowKey="id" | |
147 | + className="table-index" | |
148 | + deletePopconfirmMessage | |
149 | + actionRef={ref} | |
150 | + headerTitle={ | |
151 | + <Modal toReload={reload} option={'新增区域'} needEditBody={{}}></Modal> | |
152 | + } | |
153 | + maxLength={5} | |
154 | + scroll={{ | |
155 | + x: 960, | |
156 | + }} | |
157 | + recordCreatorProps={ | |
158 | + position !== 'hidden' | |
159 | + ? { | |
160 | + position: position as 'top', | |
161 | + record: () => ({ id: (Math.random() * 1000000).toFixed(0) }), | |
162 | + } | |
163 | + : false | |
164 | + } | |
165 | + loading={false} | |
166 | + columns={columns} | |
167 | + request={async () => { | |
168 | + const res = await getOrderErpOrderZoNingSelectAll(); | |
169 | + if (res) { | |
170 | + const initDataSource = changeToShow(res.data); | |
171 | + return { data: initDataSource || [] }; | |
141 | 172 | } |
142 | - loading={false} | |
143 | - columns={columns} | |
144 | - request={async () => ({ | |
145 | - data: defaultShowData, | |
146 | - })} | |
147 | - value={dataSource} | |
148 | - onChange={setDataSource} | |
149 | - editable={{ | |
150 | - type: 'multiple', | |
151 | - editableKeys, | |
152 | - onSave: async (rowKey, data, row) => { | |
153 | - console.log(rowKey, data, row); | |
154 | - await waitTime(2000); | |
155 | - }, | |
156 | - onChange: setEditableRowKeys, | |
157 | - }} | |
158 | - /> | |
159 | - <ProCard title="表格数据" headerBordered collapsible defaultCollapsed> | |
160 | - <ProFormField | |
161 | - ignoreFormItem | |
162 | - fieldProps={{ | |
163 | - style: { | |
164 | - width: '100%', | |
165 | - }, | |
166 | - }} | |
167 | - mode="read" | |
168 | - valueType="jsonCode" | |
169 | - text={JSON.stringify(dataSource)} | |
170 | - /> | |
171 | - </ProCard> | |
172 | - </> | |
173 | + }} | |
174 | + value={dataSource} | |
175 | + onChange={setDataSource} | |
176 | + editable={{ | |
177 | + type: 'multiple', | |
178 | + editableKeys, | |
179 | + onSave: async (rowKey, data, row) => { | |
180 | + console.log(rowKey, data, row); | |
181 | + await waitTime(2000); | |
182 | + }, | |
183 | + onChange: setEditableRowKeys, | |
184 | + }} | |
185 | + /> | |
173 | 186 | ); |
174 | 187 | }; | ... | ... |
src/pages/ZoNing/index.css
0 → 100644
1 | +.item { | |
2 | + background: '#0092ff'; | |
3 | + padding: '8px 0'; | |
4 | + display: flex; | |
5 | + flex-flow: row nowrap; | |
6 | + align-content: normal; | |
7 | + align-items: center; | |
8 | + padding-bottom: 20px; | |
9 | +} | |
10 | + | |
11 | +.table-index td { | |
12 | + font-family: 'San Francisco', 'Helvetica Neue', Helvetica, Arial, | |
13 | + 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', 'Heiti SC', | |
14 | + 'WenQuanYi Micro Hei', sans-serif; | |
15 | + font-size: 14px; | |
16 | +} | ... | ... |
src/pages/ZoNing/index.less
0 → 100644
1 | +.item { | |
2 | + background: '#0092ff'; | |
3 | + padding: '8px 0'; | |
4 | + display: flex; | |
5 | + flex-flow: row nowrap; | |
6 | + // flex-direction: row; | |
7 | + // flex-wrap: nowrap; | |
8 | + align-content: normal; | |
9 | + align-items: center; | |
10 | + padding-bottom: 20px; | |
11 | +} | |
12 | + | |
13 | +.table-index td { | |
14 | + font-family: 'San Francisco', 'Helvetica Neue', Helvetica, Arial, | |
15 | + 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', 'Heiti SC', | |
16 | + 'WenQuanYi Micro Hei', sans-serif; | |
17 | + font-size: 14px; | |
18 | +} | ... | ... |
tailwind.config.js
1 | -module.exports = { | |
2 | - content: [ | |
3 | - './src/pages/**/*.tsx', | |
4 | - './src/components/**/*.tsx', | |
5 | - './src/layouts/**/*.tsx', | |
6 | - ], | |
7 | - corePlugins: { | |
8 | - preflight: false, | |
9 | - }, | |
1 | +export const content = [ | |
2 | + './src/pages/**/*.tsx', | |
3 | + './src/components/**/*.tsx', | |
4 | + './src/layouts/**/*.tsx', | |
5 | +]; | |
6 | +export const corePlugins = { | |
7 | + preflight: false, | |
10 | 8 | }; | ... | ... |