Commit 4019883332c631829dc89e70aa03493021882c83

Authored by 曾国涛
2 parents 6a906c3b 4e743bb5

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/services/definition.ts
#	src/services/request.ts
.umirc.ts
@@ -84,7 +84,7 @@ export default defineConfig({ @@ -84,7 +84,7 @@ export default defineConfig({
84 path: '/zoning', 84 path: '/zoning',
85 component: './ZoNing', 85 component: './ZoNing',
86 icon: 'BookOutlined', 86 icon: 'BookOutlined',
87 - access: 'canReadAdminAndSales', 87 + access: 'canReadAdmin',
88 }, 88 },
89 { 89 {
90 name: '打印', 90 name: '打印',
src/pages/Instalment/components/comfire/comfire.tsx
1 import { ModalForm } from '@ant-design/pro-components'; 1 import { ModalForm } from '@ant-design/pro-components';
2 -import { Form, message } from 'antd'; 2 +import { Form } from 'antd';
3 import { useState } from 'react'; 3 import { useState } from 'react';
4 4
5 const waitTime = (time: number = 100) => { 5 const waitTime = (time: number = 100) => {
@@ -41,7 +41,6 @@ export default ({ currtDid, sureDelete }) => { @@ -41,7 +41,6 @@ export default ({ currtDid, sureDelete }) => {
41 onFinish={async () => { 41 onFinish={async () => {
42 await waitTime(100); 42 await waitTime(100);
43 sureDelete([ids]); 43 sureDelete([ids]);
44 - message.success('提交成功');  
45 return true; 44 return true;
46 }} 45 }}
47 > 46 >
src/pages/Instalment/components/detail/detail.tsx
@@ -207,6 +207,7 @@ export default ({ toReload }) => { @@ -207,6 +207,7 @@ export default ({ toReload }) => {
207 payWay: values.payWay || contextBody.payWay, 207 payWay: values.payWay || contextBody.payWay,
208 annex: contextBody.annex, 208 annex: contextBody.annex,
209 remark: values.remark || contextBody.remark, 209 remark: values.remark || contextBody.remark,
  210 + createByName: null,
210 }; 211 };
211 if (values.annex) { 212 if (values.annex) {
212 formData.append('file', values.annex[0].originFileObj as RcFile); 213 formData.append('file', values.annex[0].originFileObj as RcFile);
@@ -221,6 +222,9 @@ export default ({ toReload }) => { @@ -221,6 +222,9 @@ export default ({ toReload }) => {
221 toSendEdit.annex = res.data; 222 toSendEdit.annex = res.data;
222 } 223 }
223 } 224 }
  225 + toSendEdit.createByName = JSON.parse(
  226 + localStorage.getItem('userInfo'),
  227 + ).username;
224 const isSaveOrUpdate = await postOrderErpOrderStagesAdd({ 228 const isSaveOrUpdate = await postOrderErpOrderStagesAdd({
225 data: { ...toSendEdit }, 229 data: { ...toSendEdit },
226 }); 230 });
@@ -230,31 +234,32 @@ export default ({ toReload }) => { @@ -230,31 +234,32 @@ export default ({ toReload }) => {
230 234
231 otherBody.forEach((item) => { 235 otherBody.forEach((item) => {
232 let remakeItem = { 236 let remakeItem = {
233 - ossId: item.ossId, 237 + ossId: contextBody.id,
234 number: item.id, 238 number: item.id,
235 dateRange: item.payDate, 239 dateRange: item.payDate,
236 fileName: item.fileName, 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 remakeValue.push(remakeItem); 263 remakeValue.push(remakeItem);
259 }); 264 });
260 265
src/pages/Instalment/components/edit/edit.tsx
@@ -33,7 +33,6 @@ export default ({ currentContract, toReload }) => { @@ -33,7 +33,6 @@ export default ({ currentContract, toReload }) => {
33 const [total, setTotal] = useState(0); 33 const [total, setTotal] = useState(0);
34 const [payWayBody, setPayWayBody] = useState([]); 34 const [payWayBody, setPayWayBody] = useState([]);
35 const [otherBody, setOtherBody] = useState([]); 35 const [otherBody, setOtherBody] = useState([]);
36 -  
37 type OrderStagesWithListItem = { 36 type OrderStagesWithListItem = {
38 //文件编号 37 //文件编号
39 id: number; 38 id: number;
@@ -85,6 +84,7 @@ export default ({ currentContract, toReload }) => { @@ -85,6 +84,7 @@ export default ({ currentContract, toReload }) => {
85 } 84 }
86 85
87 function setSave(value) { 86 function setSave(value) {
  87 + console.log(value);
88 setOtherBody(value); 88 setOtherBody(value);
89 } 89 }
90 90
@@ -134,18 +134,32 @@ export default ({ currentContract, toReload }) => { @@ -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 function getEditProductBody(value) { 165 function getEditProductBody(value) {
@@ -157,7 +171,8 @@ export default ({ currentContract, toReload }) => { @@ -157,7 +171,8 @@ export default ({ currentContract, toReload }) => {
157 } 171 }
158 172
159 useEffect(() => { 173 useEffect(() => {
160 - getBody(); 174 + console.log('1');
  175 + getBody(null);
161 }, []); 176 }, []);
162 177
163 return ( 178 return (
@@ -177,34 +192,35 @@ export default ({ currentContract, toReload }) => { @@ -177,34 +192,35 @@ export default ({ currentContract, toReload }) => {
177 } 192 }
178 let remakeValue = []; 193 let remakeValue = [];
179 const promises = []; 194 const promises = [];
180 - 195 + console.log(otherBody);
181 otherBody.forEach((item) => { 196 otherBody.forEach((item) => {
182 let remakeItem = { 197 let remakeItem = {
183 ossId: contextBody.id, 198 ossId: contextBody.id,
184 number: item.id, 199 number: item.id,
185 dateRange: item.payDate, 200 dateRange: item.payDate,
186 fileName: item.fileName, 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 remakeValue.push(remakeItem); 224 remakeValue.push(remakeItem);
209 }); 225 });
210 Promise.all(promises).then(async () => { 226 Promise.all(promises).then(async () => {
@@ -243,8 +259,9 @@ export default ({ currentContract, toReload }) => { @@ -243,8 +259,9 @@ export default ({ currentContract, toReload }) => {
243 const isSaveOrUpdate = await postOrderErpOrderStagesSaveOrUpdate({ 259 const isSaveOrUpdate = await postOrderErpOrderStagesSaveOrUpdate({
244 data: { ...toSendEdit }, 260 data: { ...toSendEdit },
245 }); 261 });
246 - if (isSaveOrUpdate) {  
247 - getBody(); 262 + if (isSaveOrUpdate.message === '成功') {
  263 + console.log('2');
  264 + getBody(toSendEdit.contract);
248 toReload(); 265 toReload();
249 } 266 }
250 await waitTime(2000); 267 await waitTime(2000);
src/pages/Instalment/components/payWayDetail/payWayDetail.tsx
@@ -4,19 +4,18 @@ import { @@ -4,19 +4,18 @@ import {
4 EditableProTable, 4 EditableProTable,
5 ProFormDatePicker, 5 ProFormDatePicker,
6 ProFormRadio, 6 ProFormRadio,
7 - ProFormUploadButton,  
8 } from '@ant-design/pro-components'; 7 } from '@ant-design/pro-components';
9 -import { message } from 'antd';  
10 import React, { useEffect, useState } from 'react'; 8 import React, { useEffect, useState } from 'react';
  9 +import PayWayUpload from '../upload/payWayUpload';
11 import './payWayDetail.less'; 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 type DataSourceType = { 20 type DataSourceType = {
22 id: number; 21 id: number;
@@ -74,6 +73,7 @@ export default ({ payBody, thisId, currtSave }) => { @@ -74,6 +73,7 @@ export default ({ payBody, thisId, currtSave }) => {
74 ]; 73 ];
75 74
76 const [editableKeys, setEditableRowKeys] = useState<React.Key[]>([]); 75 const [editableKeys, setEditableRowKeys] = useState<React.Key[]>([]);
  76 + const [isRetrun, setIsRetrun] = useState(false);
77 const [position, setPosition] = useState<'top' | 'bottom' | 'hidden'>( 77 const [position, setPosition] = useState<'top' | 'bottom' | 'hidden'>(
78 'hidden', 78 'hidden',
79 ); 79 );
@@ -81,9 +81,17 @@ export default ({ payBody, thisId, currtSave }) =&gt; { @@ -81,9 +81,17 @@ export default ({ payBody, thisId, currtSave }) =&gt; {
81 readonly DataSourceType[] 81 readonly DataSourceType[]
82 >([...defaultData]); 82 >([...defaultData]);
83 // const [body, setBody] = useState([]) 83 // const [body, setBody] = useState([])
84 - const [isAccept, setIsAccept] = useState(null); 84 + // const [isAccept, setIsAccept] = useState(null);
85 // const [isCurrtSave, setIsCurrtSave] = useState(false); 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 async function getOther(value, arr) { 95 async function getOther(value, arr) {
88 const res = await postOrderErpOrderStagesPayWaySelect({ 96 const res = await postOrderErpOrderStagesPayWaySelect({
89 data: { ossId: value }, 97 data: { ossId: value },
@@ -106,11 +114,32 @@ export default ({ payBody, thisId, currtSave }) =&gt; { @@ -106,11 +114,32 @@ export default ({ payBody, thisId, currtSave }) =&gt; {
106 }); 114 });
107 return currt; 115 return currt;
108 }); 116 });
  117 + // console.log(remake);
109 setPayWayDetailBody(remake); 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 const remakeData = payWayDetailBody.map((obj) => { 143 const remakeData = payWayDetailBody.map((obj) => {
115 return { 144 return {
116 ...obj, 145 ...obj,
@@ -127,9 +156,6 @@ export default ({ payBody, thisId, currtSave }) =&gt; { @@ -127,9 +156,6 @@ export default ({ payBody, thisId, currtSave }) =&gt; {
127 getOther(thisId, remakeData); 156 getOther(thisId, remakeData);
128 } 157 }
129 } 158 }
130 - // useEffect(() => {  
131 - // getOther(thisId)  
132 - // }, [thisId])  
133 159
134 useEffect(() => { 160 useEffect(() => {
135 setPayWay(payBody); 161 setPayWay(payBody);
@@ -175,6 +201,7 @@ export default ({ payBody, thisId, currtSave }) =&gt; { @@ -175,6 +201,7 @@ export default ({ payBody, thisId, currtSave }) =&gt; {
175 render: (text, record) => { 201 render: (text, record) => {
176 const handleChange = (value) => { 202 const handleChange = (value) => {
177 const updatedDataSource = payWayDetailBody.map((item) => { 203 const updatedDataSource = payWayDetailBody.map((item) => {
  204 + console.log(value);
178 if (item.id === record.id) { 205 if (item.id === record.id) {
179 return { 206 return {
180 ...item, 207 ...item,
@@ -207,74 +234,33 @@ export default ({ payBody, thisId, currtSave }) =&gt; { @@ -207,74 +234,33 @@ export default ({ payBody, thisId, currtSave }) =&gt; {
207 title: '付款单回执', 234 title: '付款单回执',
208 dataIndex: 'fileName', 235 dataIndex: 'fileName',
209 render: (text, record) => { 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 } else { 249 } else {
222 return ( 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 return ( 266 return (
src/pages/Instalment/components/read/readPayWay.tsx
@@ -167,25 +167,19 @@ export default ({ payBody, thisId, currtSave }) =&gt; { @@ -167,25 +167,19 @@ export default ({ payBody, thisId, currtSave }) =&gt; {
167 dataIndex: 'payDate', 167 dataIndex: 'payDate',
168 editable: false, 168 editable: false,
169 render: (_text, record) => { 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
@@ -85,7 +85,7 @@ export default ({ productBody, EditProductBody }) =&gt; { @@ -85,7 +85,7 @@ export default ({ productBody, EditProductBody }) =&gt; {
85 { 85 {
86 title: '设备型号', 86 title: '设备型号',
87 dataIndex: 'deviceModel', 87 dataIndex: 'deviceModel',
88 - width: '15%', 88 + width: '20%',
89 formItemProps: () => { 89 formItemProps: () => {
90 return { 90 return {
91 rules: [{ required: true, message: '此项为必填项' }], 91 rules: [{ required: true, message: '此项为必填项' }],
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 }) =&gt; { @@ -21,13 +21,7 @@ const App: React.FC = ({ uploadFile }) =&gt; {
21 <p className="ant-upload-drag-icon"> 21 <p className="ant-upload-drag-icon">
22 <InboxOutlined /> 22 <InboxOutlined />
23 </p> 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 </Dragger> 25 </Dragger>
32 <a 26 <a
33 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" 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,6 +3,8 @@ import {
3 postCanrdApiUserAddressList, 3 postCanrdApiUserAddressList,
4 postCanrdApiUserDetail, 4 postCanrdApiUserDetail,
5 postCanrdApiUserNowMoneyCheck, 5 postCanrdApiUserNowMoneyCheck,
  6 + postDistrictSelectBelongByName,
  7 + postDistrictSelectByLevel,
6 postKingdeeRepCustomerDetail, 8 postKingdeeRepCustomerDetail,
7 postKingdeeRepMaterial, 9 postKingdeeRepMaterial,
8 postKingdeeRepMaterialUnit, 10 postKingdeeRepMaterialUnit,
@@ -71,6 +73,10 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; { @@ -71,6 +73,10 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
71 // [], 73 // [],
72 // ); //商品的仓库选项 74 // ); //商品的仓库选项
73 const [productUnitOptionsList, setProductUnitOptionsList] = useState([]); //商品的单位选项 75 const [productUnitOptionsList, setProductUnitOptionsList] = useState([]); //商品的单位选项
  76 + //省市区
  77 + const [province, setProvince] = useState('');
  78 + const [city, setCity] = useState('');
  79 + const [district, setDistrict] = useState('');
74 // const [productCustomerContactOptions, setProductCustomerContactOptions] = 80 // const [productCustomerContactOptions, setProductCustomerContactOptions] =
75 // useState([]); //客户的收货人选项 81 // useState([]); //客户的收货人选项
76 const [form] = Form.useForm<{ 82 const [form] = Form.useForm<{
@@ -246,7 +252,7 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; { @@ -246,7 +252,7 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
246 newAccountOptions.push(uidDetail); 252 newAccountOptions.push(uidDetail);
247 } 253 }
248 254
249 - //查询当前手机号允许使用的预存账号 255 + // 查询当前手机号允许使用的预存账号
250 if (phone) { 256 if (phone) {
251 let res = await postPrepaidPhoneAvailableList({ data: { phone: phone } }); 257 let res = await postPrepaidPhoneAvailableList({ data: { phone: phone } });
252 if (res && res.result === RESPONSE_CODE.SUCCESS) { 258 if (res && res.result === RESPONSE_CODE.SUCCESS) {
@@ -863,6 +869,8 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; { @@ -863,6 +869,8 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
863 values.institution = values.institution?.trim(); 869 values.institution = values.institution?.trim();
864 values.institutionContactName = values.institutionContactName?.trim(); 870 values.institutionContactName = values.institutionContactName?.trim();
865 values.customerName = values.customerNameString.trim(); 871 values.customerName = values.customerNameString.trim();
  872 + values.customerShippingAddress =
  873 + province + city + district + values.customerShippingAddress;
866 874
867 if (typeof values.erpCustomerId !== 'string') { 875 if (typeof values.erpCustomerId !== 'string') {
868 values.erpCustomerId = values.erpCustomerId?.id; 876 values.erpCustomerId = values.erpCustomerId?.id;
@@ -1015,7 +1023,6 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; { @@ -1015,7 +1023,6 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
1015 name="contactAddress" 1023 name="contactAddress"
1016 hidden 1024 hidden
1017 ></ProFormText> 1025 ></ProFormText>
1018 -  
1019 <ProFormSelect 1026 <ProFormSelect
1020 key="customerName" 1027 key="customerName"
1021 label="收货人" 1028 label="收货人"
@@ -1176,6 +1183,113 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; { @@ -1176,6 +1183,113 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
1176 placeholder="请输入课题组" 1183 placeholder="请输入课题组"
1177 rules={[{ required: true, message: '课题组必填' }]} 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 <ProFormTextArea 1293 <ProFormTextArea
1180 width="lg" 1294 width="lg"
1181 key="customerShippingAddress" 1295 key="customerShippingAddress"
src/pages/OrderReport/index.tsx
1 import { 1 import {
  2 + getOrderErpOrderZoNingSelectAll,
  3 + getOrderErpOrderZoNingSelectUserAll,
  4 + postOrderErpOrderZoNingSelectSaleUserByProvince,
2 postServiceOrderQueryReportFormsInformation, 5 postServiceOrderQueryReportFormsInformation,
3 postServiceOrderQuerySalesCode, 6 postServiceOrderQuerySalesCode,
4 } from '@/services'; 7 } from '@/services';
@@ -63,7 +66,7 @@ const OrderReportPage = () =&gt; { @@ -63,7 +66,7 @@ const OrderReportPage = () =&gt; {
63 setLoading(true); 66 setLoading(true);
64 let body = { 67 let body = {
65 statisticsMethod: '', 68 statisticsMethod: '',
66 - salesCode: form.getFieldValue('salesCode'), 69 + salesCode: [null],
67 productBelongBusiness: form.getFieldValue('productBelongBusiness'), 70 productBelongBusiness: form.getFieldValue('productBelongBusiness'),
68 maxAccount: form.getFieldValue('maxAccount'), 71 maxAccount: form.getFieldValue('maxAccount'),
69 includeExperimentalEquipment: form.getFieldValue( 72 includeExperimentalEquipment: form.getFieldValue(
@@ -72,6 +75,36 @@ const OrderReportPage = () =&gt; { @@ -72,6 +75,36 @@ const OrderReportPage = () =&gt; {
72 // beginTime:"", 75 // beginTime:"",
73 // endTime:"" 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 // if(form.getFieldValue("dateRange")!==undefined){ 109 // if(form.getFieldValue("dateRange")!==undefined){
77 // body.beginTime=formatDate(form.getFieldValue("dateRange")[0]), 110 // body.beginTime=formatDate(form.getFieldValue("dateRange")[0]),
@@ -162,6 +195,30 @@ const OrderReportPage = () =&gt; { @@ -162,6 +195,30 @@ const OrderReportPage = () =&gt; {
162 initialValue={false} 195 initialValue={false}
163 label="包含实验设备事业部汇总统计" 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 </QueryFilter> 222 </QueryFilter>
166 </ProCard> 223 </ProCard>
167 224
src/pages/ResearchGroup/components/ImportModal.tsx
@@ -6,7 +6,7 @@ import { Button, Modal, Upload, message } from &#39;antd&#39;; @@ -6,7 +6,7 @@ import { Button, Modal, Upload, message } from &#39;antd&#39;;
6 import { RcFile, UploadFile, UploadProps } from 'antd/es/upload'; 6 import { RcFile, UploadFile, UploadProps } from 'antd/es/upload';
7 import { useState } from 'react'; 7 import { useState } from 'react';
8 export default ({ onClose }) => { 8 export default ({ onClose }) => {
9 - // const [form] = Form.useForm<{ name: string; company: string }>(); 9 + // const [form] = Form.useForm<{ name: string; company: string }>();
10 const [messageApi, contextHolder] = message.useMessage(); 10 const [messageApi, contextHolder] = message.useMessage();
11 const [fileList, setFileList] = useState<UploadFile[]>([]); 11 const [fileList, setFileList] = useState<UploadFile[]>([]);
12 const [uploading, setUploading] = useState(false); 12 const [uploading, setUploading] = useState(false);
@@ -41,8 +41,8 @@ export default ({ onClose }) =&gt; { @@ -41,8 +41,8 @@ export default ({ onClose }) =&gt; {
41 //originFileObj二进制文件 41 //originFileObj二进制文件
42 formData.append('file', file.originFileObj as RcFile); 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 setUploading(true); 46 setUploading(true);
47 // You can use any AJAX library you like 47 // You can use any AJAX library you like
48 const res = await postResearchGroupsImport({ 48 const res = await postResearchGroupsImport({
src/pages/ResearchGroup/index.css 0 → 100644
  1 +.research-group-index td {
  2 + font-family: 'San Francisco', 'Helvetica Neue', Helvetica, Arial,
  3 + 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', 'Heiti SC',
  4 + 'WenQuanYi Micro Hei', sans-serif;
  5 + font-size: 13px;
  6 +}
src/pages/ZoNing/components/constant.tsx
1 import { List } from 'lodash'; 1 import { List } from 'lodash';
2 2
3 export type zoningItem = { 3 export type zoningItem = {
4 - id: number; //id 4 + id?: number; //id
5 zoning: string; //区域名称 5 zoning: string; //区域名称
6 orderProvinceVoList: List<provinceItem>; //所包含的省份列表 6 orderProvinceVoList: List<provinceItem>; //所包含的省份列表
7 orderUserVoList: List<userItem>; //所包含的销售列表 7 orderUserVoList: List<userItem>; //所包含的销售列表
8 }; 8 };
9 9
10 export type zoningShowItem = { 10 export type zoningShowItem = {
11 - id: number; //id 11 + id?: number; //id
12 zoning: string; //区域名称 12 zoning: string; //区域名称
13 orderProvinceShowList: string; //所包含的省份列表 13 orderProvinceShowList: string; //所包含的省份列表
14 orderUserShowList: string; //所包含的销售列表 14 orderUserShowList: string; //所包含的销售列表
  15 + orderUserNumberShowList: number[]; //销售对应的uId
15 }; 16 };
16 17
17 export type provinceItem = { 18 export type provinceItem = {
18 - pId: number; 19 + pId?: number;
19 province: string; 20 province: string;
20 }; 21 };
21 22
22 export type userItem = { 23 export type userItem = {
23 uId: number; 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 import { PlusOutlined } from '@ant-design/icons'; 5 import { PlusOutlined } from '@ant-design/icons';
2 import { 6 import {
3 ModalForm, 7 ModalForm,
@@ -6,8 +10,7 @@ import { @@ -6,8 +10,7 @@ import {
6 ProFormText, 10 ProFormText,
7 } from '@ant-design/pro-components'; 11 } from '@ant-design/pro-components';
8 import { Button, Form, message } from 'antd'; 12 import { Button, Form, message } from 'antd';
9 -import { zoningItem } from './constant';  
10 - 13 +import { provinceEnum, zoningItem } from './constant';
11 const waitTime = (time: number = 100) => { 14 const waitTime = (time: number = 100) => {
12 return new Promise((resolve) => { 15 return new Promise((resolve) => {
13 setTimeout(() => { 16 setTimeout(() => {
@@ -16,66 +19,126 @@ const waitTime = (time: number = 100) =&gt; { @@ -16,66 +19,126 @@ const waitTime = (time: number = 100) =&gt; {
16 }); 19 });
17 }; 20 };
18 21
19 -export default () => { 22 +export default ({ toReload, option, needEditBody }) => {
20 const [form] = Form.useForm<zoningItem>(); 23 const [form] = Form.useForm<zoningItem>();
  24 +
21 return ( 25 return (
22 <ModalForm<{ 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 trigger={ 32 trigger={
28 - <Button type="primary">  
29 - <PlusOutlined />  
30 - 新增区域 33 + <Button type="primary" key={option.id}>
  34 + {option !== '编辑' && <PlusOutlined />}
  35 + {option}
31 </Button> 36 </Button>
32 } 37 }
33 form={form} 38 form={form}
34 autoFocusFirstInput 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 modalProps={{ 49 modalProps={{
36 destroyOnClose: true, 50 destroyOnClose: true,
37 - onCancel: () => console.log('run'),  
38 }} 51 }}
39 - submitTimeout={2000} 52 + submitTimeout={500}
40 onFinish={async (values) => { 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 <ProForm.Group> 80 <ProForm.Group>
48 <ProFormText 81 <ProFormText
49 - width="md" 82 + width="lg"
50 name="zoning" 83 name="zoning"
51 label="区域名称" 84 label="区域名称"
52 placeholder="请输入" 85 placeholder="请输入"
  86 + rules={[{ required: true, message: '此项为必填项' }]}
53 /> 87 />
54 </ProForm.Group> 88 </ProForm.Group>
55 <ProForm.Group> 89 <ProForm.Group>
56 <ProFormSelect 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 </ProForm.Group> 124 </ProForm.Group>
68 <ProForm.Group> 125 <ProForm.Group>
69 <ProFormSelect 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 </ProForm.Group> 143 </ProForm.Group>
81 </ModalForm> 144 </ModalForm>
src/pages/ZoNing/components/table.tsx
1 -import type { ProColumns } from '@ant-design/pro-components';  
2 import { 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 import { zoningItem, zoningShowItem } from './constant'; 10 import { zoningItem, zoningShowItem } from './constant';
9 import Modal from './modal'; 11 import Modal from './modal';
10 12
@@ -16,68 +18,81 @@ const waitTime = (time: number = 100) =&gt; { @@ -16,68 +18,81 @@ const waitTime = (time: number = 100) =&gt; {
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 export default () => { 58 export default () => {
77 const [editableKeys, setEditableRowKeys] = useState<React.Key[]>([]); 59 const [editableKeys, setEditableRowKeys] = useState<React.Key[]>([]);
78 const [dataSource, setDataSource] = useState<readonly zoningItem[]>([]); 60 const [dataSource, setDataSource] = useState<readonly zoningItem[]>([]);
79 const [position] = useState<'top' | 'bottom' | 'hidden'>('hidden'); 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 const columns: ProColumns<zoningItem>[] = [ 96 const columns: ProColumns<zoningItem>[] = [
82 { 97 {
83 title: '区域名称', 98 title: '区域名称',
@@ -101,74 +116,72 @@ export default () =&gt; { @@ -101,74 +116,72 @@ export default () =&gt; {
101 title: '操作', 116 title: '操作',
102 valueType: 'option', 117 valueType: 'option',
103 width: 200, 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 return ( 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 };