Commit 4681a0abb1ab0b0817598f173b8dd78e11a1b733

Authored by boyang
1 parent 8586bf0f

feat: 预存管理优化

src/pages/Order/OrderList/OrderDrawer copy.tsx deleted 100644 → 0
1 -import { RESPONSE_CODE } from '@/constants/enum';  
2 -import {  
3 - postKingdeeRepCustomer,  
4 - postKingdeeRepCustomerDetail,  
5 - postKingdeeRepMaterial,  
6 - postKingdeeRepMaterialUnit,  
7 - postKingdeeRepMeasureUnit,  
8 - postServiceOrderAddOrder,  
9 - postServiceOrderQuerySalesCode,  
10 - postServiceOrderUpdateOrder,  
11 -} from '@/services';  
12 -import {  
13 - enumToSelect,  
14 - getAliYunOSSFileNameFromUrl,  
15 - getUserInfo,  
16 -} from '@/utils';  
17 -import { getTeacherCustomFieldNumber } from '@/utils/kingdee';  
18 -import {  
19 - DrawerForm,  
20 - FormListActionType,  
21 - ProCard,  
22 - ProFormDateTimePicker,  
23 - ProFormDigit,  
24 - ProFormList,  
25 - ProFormSelect,  
26 - ProFormText,  
27 - ProFormTextArea,  
28 - ProFormUploadDragger,  
29 -} from '@ant-design/pro-components';  
30 -import { Button, Form, message } from 'antd';  
31 -import { cloneDeep } from 'lodash';  
32 -import { useEffect, useRef, useState } from 'react';  
33 -import {  
34 - INVOCING_STATUS_OPTIONS,  
35 - INVOCING_STATUS_OPTIONS_OLD,  
36 - PAYMENT_CHANNEL_OPTIONS,  
37 - PAYMENT_METHOD_OPTIONS,  
38 - PRODUCT_BELONG_DEPARTMENT_OPTIONS,  
39 -} from '../constant';  
40 -import KingdeeCustomerModal from './KingdeeCustomerModal';  
41 -  
42 -export default ({ onClose, data, subOrders, orderOptType }) => {  
43 - const [invoicingStatus, setInvoicingStatus] = useState('');  
44 - const [salesCodeOptions, setSalesCodeOptions] = useState([]);  
45 - const [customer, setCustomer] = useState({});  
46 - const [kingdeeCstomerModalVisible, setKingdeeCstomerModalVisible] =  
47 - useState(false);  
48 - const [  
49 - productParametersDisabledFlagList,  
50 - setProductParametersDisabledFlagList,  
51 - ] = useState([]);  
52 - // const [productInvStockOptionsList, setProductInvStockOptionsList] = useState(  
53 - // [],  
54 - // ); //商品的仓库选项  
55 - const [productUnitOptionsList, setProductUnitOptionsList] = useState([]); //商品的单位选项  
56 - const [productCustomerContactOptions, setProductCustomerContactOptions] =  
57 - useState([]); //客户的收货人选项  
58 - const [form] = Form.useForm<{  
59 - salesCode: '';  
60 - customerName: '';  
61 - customerContactNumber: '';  
62 - institution: '';  
63 - institutionContactName: '';  
64 - customerShippingAddress: '';  
65 - totalPayment: '';  
66 - paymentChannel: '';  
67 - paymentMethod: '';  
68 - productBelongBusiness: '';  
69 - invoicingStatus: '';  
70 - invoiceIdentificationNumber: '';  
71 - invoicingTime: '';  
72 - bank: '';  
73 - bankAccountNumber: '';  
74 - deleteSubOrderLists: [];  
75 - notes: '';  
76 - list: [  
77 - {  
78 - productCode: '';  
79 - productName: '';  
80 - quantity: '';  
81 - productPrice: '';  
82 - parameters: '';  
83 - subOrderPayment: '';  
84 - unit: '';  
85 - serialNumber: '';  
86 - notes: '';  
87 - },  
88 - ];  
89 - }>();  
90 -  
91 - let originSubOrders = cloneDeep(subOrders);  
92 - /**  
93 - * 获取当前的操作类型boolean值  
94 - * @param type 操作类型,如果与当前匹配返回true  
95 - */  
96 - function optType(type: string) {  
97 - return orderOptType === type;  
98 - }  
99 -  
100 - /**  
101 - *  
102 - * @returns 获取开票选项  
103 - */  
104 - function getInvoicingSelect() {  
105 - if (optType('edit')) {  
106 - return enumToSelect(INVOCING_STATUS_OPTIONS_OLD);  
107 - }  
108 - return enumToSelect(INVOCING_STATUS_OPTIONS);  
109 - }  
110 -  
111 - const fileList: any = [];  
112 -  
113 - const getSalesCodeOptions = async () => {  
114 - const res = await postServiceOrderQuerySalesCode();  
115 - let options = res.data?.map((item) => {  
116 - return {  
117 - label: item.userName,  
118 - value: item.userName,  
119 - number: item.number,  
120 - };  
121 - });  
122 - setSalesCodeOptions(options);  
123 -  
124 - if (optType('copy') || optType('edit')) {  
125 - let includeFlag = false;  
126 - //销售代码校验,如果是旧的销售代码,则提示并清空  
127 - for (let option of options) {  
128 - if (option.value === data.salesCode) {  
129 - includeFlag = true;  
130 - }  
131 - }  
132 - if (!includeFlag) {  
133 - form.resetFields(['salesCode']);  
134 - message.warning('检测到销售代码为旧的,已清空,请重新选择');  
135 - }  
136 - }  
137 - };  
138 -  
139 - //复制的时候,如果是不需要开票,要把开票信息清空  
140 - if (optType('copy') && data.invoicingStatus === 'UN_INVOICE') {  
141 - data.invoiceIdentificationNumber = undefined;  
142 - }  
143 -  
144 - if (subOrders !== undefined && subOrders.length > 0) {  
145 - data.list = subOrders;  
146 - }  
147 -  
148 - const actionRef = useRef<  
149 - FormListActionType<{  
150 - name: string;  
151 - }>  
152 - >();  
153 -  
154 - useEffect(() => {  
155 - form.setFieldsValue({ ...data });  
156 - //如果是新建,需要清空list  
157 - if (optType('add')) {  
158 - form.resetFields(['list']);  
159 - }  
160 - }, [data]);  
161 -  
162 - /**  
163 - * 选择客户后自动为收货人Select添加选项,填充课题组和单位信息  
164 - * @param option 客户选项  
165 - */  
166 - async function autoFillCustomerContactSelectOptions(customerId: any) {  
167 - //查询单位详细信息  
168 - let res = await postKingdeeRepCustomerDetail({  
169 - data: {  
170 - id: customerId,  
171 - },  
172 - });  
173 -  
174 - //erp客户名称  
175 - form.setFieldValue('erpCustomerName', res?.name);  
176 -  
177 - //重新设置当前option  
178 - form.setFieldValue('erpCustomerId', {  
179 - label: res?.name,  
180 - value: res?.id,  
181 - id: res?.id,  
182 - });  
183 -  
184 - //查询客户自定义字段,课题组  
185 - let entity_number = await getTeacherCustomFieldNumber();  
186 -  
187 - //在单位详细信息中拿到自定义字段的值  
188 - let customField = res?.custom_field;  
189 - if (customField) {  
190 - let teacherName = customField[entity_number];  
191 - //填充到课题组老师表单字段中  
192 - form.setFieldValue('institutionContactName', teacherName);  
193 - }  
194 -  
195 - //单位名称,从客户名称中获取,客户名称规则<单位名称>-<联系人名称和电话>  
196 - let namePortions = res?.name?.split('-');  
197 - if (namePortions && namePortions.length >= 2) {  
198 - form.setFieldValue('institution', namePortions[0]);  
199 - }  
200 -  
201 - //如果原来的收货信息没有包含在这次查询出来的收货人选项中,那么清除原来的收货人信息  
202 - let existFlag = false;  
203 -  
204 - //填充收货人选项  
205 - let newProductCustomerContactOptions = res?.bomentity?.map((item) => {  
206 - let address =  
207 - item.contact_person + ',' + item.mobile + ',' + item.contact_address;  
208 - if (address === data.contactAddress) {  
209 - existFlag = true;  
210 - }  
211 - return { ...item, label: address, value: address };  
212 - });  
213 -  
214 - setProductCustomerContactOptions(newProductCustomerContactOptions);  
215 -  
216 - if (!existFlag) {  
217 - //清空原来的收货人信息  
218 - form.setFieldValue('customerShippingAddress', undefined);  
219 - form.setFieldValue('customerContactNumber', undefined);  
220 - form.setFieldValue('customerName', undefined);  
221 - form.setFieldValue('erpCustomerAddress', undefined);  
222 - }  
223 - }  
224 -  
225 - /**  
226 - * 回显金蝶信息  
227 - */  
228 - async function showKindeeInfo() {  
229 - //客户信息  
230 - if (data.customerId) {  
231 - //客户回显  
232 - autoFillCustomerContactSelectOptions(data.customerId);  
233 - }  
234 -  
235 - //商品单位回显  
236 - let list = data?.subOrderInformationLists;  
237 - if (list) {  
238 - let newProductUnitOptionsList = [...productUnitOptionsList];  
239 - for (let i = 0; i < list.length; i++) {  
240 - newProductUnitOptionsList[i] = [  
241 - { label: list[i].unit, value: list[i].unitId },  
242 - ];  
243 - }  
244 - setProductUnitOptionsList(newProductUnitOptionsList);  
245 - }  
246 - }  
247 -  
248 - /**  
249 - *  
250 - * @param option 商品名称所对应的商品数据  
251 - * @param currentRowData list中当前行的数据  
252 - */  
253 - async function autoFillProductInfo(  
254 - option: any,  
255 - currentRowData: any,  
256 - index: any,  
257 - ) {  
258 - let newProductParametersDisabledFlagList = [  
259 - ...productParametersDisabledFlagList,  
260 - ];  
261 - let newProductUnitOptionsList = [...productUnitOptionsList];  
262 - newProductUnitOptionsList[index] = [];  
263 -  
264 - //是新增商品  
265 - if (option.type === 'add') {  
266 - //商品参数开放权限可以编辑  
267 - newProductParametersDisabledFlagList[index] = false;  
268 -  
269 - //清空商品信息  
270 - let copyList = form.getFieldValue('list');  
271 - let currentData = copyList[index];  
272 - currentData.productCode = undefined;  
273 - currentData.parameters = undefined;  
274 - currentData.unit = undefined;  
275 - currentData.subOrderPayment = undefined;  
276 - currentData.quantity = undefined;  
277 - currentData.notes = undefined;  
278 - currentData.productPrice = undefined;  
279 - form.setFieldValue('list', copyList);  
280 -  
281 - //查询计量单价列表  
282 - let res = await postKingdeeRepMeasureUnit({ data: {} });  
283 - if (res && res?.rows) {  
284 - for (let row of res?.rows) {  
285 - newProductUnitOptionsList[index].push({  
286 - label: row.name,  
287 - value: row.id,  
288 - });  
289 - }  
290 - }  
291 - } else {  
292 - //选择的是已有的商品,进行内容自动填充  
293 - let copyList = form.getFieldValue('list');  
294 - let currentData = copyList[index];  
295 - currentData.productCode = option?.number;  
296 - currentData.parameters = option?.model;  
297 - currentData.unit = option?.base_unit_name;  
298 -  
299 - //商品id  
300 - currentData.materialId = option?.id;  
301 -  
302 - //单位  
303 - currentData.unit = option.base_unit_name;  
304 - currentData.unitId = option.base_unit_id;  
305 -  
306 - form.setFieldValue('list', copyList);  
307 -  
308 - //商品所在的仓库选项填充  
309 - // let res = await postKingdeeRepMaterialStock({  
310 - // data: {  
311 - // material_id: option.id,  
312 - // },  
313 - // });  
314 - // let newProductInvStockOptionsList = [...productInvStockOptionsList];  
315 - // newProductInvStockOptionsList[index] = res?.rows?.map((item) => {  
316 - // return { label: item.inv_stock, value: item.inv_stock_id };  
317 - // });  
318 - // setProductInvStockOptionsList(newProductInvStockOptionsList);  
319 -  
320 - //商品单位填充,查询商品单位列表  
321 - let res = await postKingdeeRepMaterialUnit({  
322 - data: { material_id: option.id },  
323 - });  
324 - if (res && res.rows) {  
325 - for (let row of res.rows) {  
326 - newProductUnitOptionsList[index].push({  
327 - label: row.unit_name,  
328 - value: row.unit_id,  
329 - });  
330 - }  
331 - }  
332 - //商品参数不允许编辑  
333 - newProductParametersDisabledFlagList[index] = true;  
334 - }  
335 -  
336 - setProductParametersDisabledFlagList(newProductParametersDisabledFlagList);  
337 - setProductUnitOptionsList(newProductUnitOptionsList);  
338 - }  
339 -  
340 - /**  
341 - * 选择收货人后自动填充信息  
342 - * @param option 收货人信息  
343 - */  
344 - async function autoFillCustomerInfo(option: any) {  
345 - form.setFieldValue('customerShippingAddress', option.contact_address);  
346 - form.setFieldValue('customerContactNumber', option.mobile);  
347 - form.setFieldValue('customerName', option.contact_person);  
348 -  
349 - //erp收货地址:需要与客户联系人中的地址一样:姓名,手机号,地址  
350 - form.setFieldValue('contactAddress', option.value);  
351 - }  
352 -  
353 - /**  
354 - * 填充销售代表的信息  
355 - * @param option  
356 - */  
357 - function autoFillSalesInfo(option: any) {  
358 - console.log(option);  
359 - //销售代表对应职员编码填充  
360 - form.setFieldValue('empNumber', option.number);  
361 - }  
362 -  
363 - /**  
364 - * 选择商品单位后自动填充  
365 - * @param option  
366 - * @param index  
367 - */  
368 - function autoFillUnit(option: any, index: any) {  
369 - let copyList = form.getFieldValue('list');  
370 - let currentData = copyList[index];  
371 - currentData.unit = option?.label;  
372 - form.setFieldValue('list', copyList);  
373 - }  
374 -  
375 - /**  
376 - * 计算子订单金额  
377 - * @param listMeta 当前商品信息  
378 - */  
379 - function computeSubOrderPayment(listMeta: any) {  
380 - let quantity = listMeta?.record?.quantity;  
381 - let productPrice = listMeta?.record?.productPrice;  
382 - quantity = quantity === '' || quantity === undefined ? 0 : quantity;  
383 - productPrice =  
384 - productPrice === '' || productPrice === undefined ? 0 : productPrice;  
385 -  
386 - listMeta.subOrderPayment = quantity * productPrice;  
387 - let list = form.getFieldValue('list');  
388 - list[listMeta?.index].subOrderPayment = quantity * productPrice;  
389 - form.setFieldValue('list', list);  
390 - }  
391 -  
392 - /**  
393 - * 计算支付总额  
394 - */  
395 - function computeTotalPayment() {  
396 - let list = form.getFieldValue('list');  
397 - let totalPayment = 0;  
398 - list?.forEach((subOrder: any) => {  
399 - let subOrderPayment = subOrder?.subOrderPayment;  
400 - if (subOrderPayment === '' || subOrderPayment === undefined) {  
401 - totalPayment += 0;  
402 - } else {  
403 - totalPayment += subOrderPayment;  
404 - }  
405 - });  
406 - form.setFieldValue('totalPayment', totalPayment);  
407 - }  
408 -  
409 - useEffect(() => {  
410 - getSalesCodeOptions();  
411 - showKindeeInfo();  
412 - }, []);  
413 -  
414 - useEffect(() => {  
415 - // 在组件挂载或数据变化时,更新组件状态  
416 - if (data) {  
417 - setInvoicingStatus(data.invoicingStatus);  
418 - }  
419 - }, [data]);  
420 -  
421 - // let mainInfoDisbled = optType('edit');  
422 - if (optType('edit') || optType('copy')) {  
423 - //如果是复制,需要开票,不回显是否需要开票字段  
424 - if (optType('copy')) {  
425 - if (data.invoicingStatus === 'INVOICED') {  
426 - data.invoicingStatus = undefined;  
427 - }  
428 - }  
429 - //订单修改和新增的子订单列表命名是list  
430 - data.list = data.subOrderInformationLists;  
431 - //主订单事业部默认显示子订单第一条的事业部  
432 - data.productBelongBusiness = data.list[0].productBelongBusiness;  
433 - data.paymentMethod = data.list[0].paymentMethod;  
434 - data.paymentChannel = data.list[0].paymentChannel;  
435 - data.invoicingStatus = data.list[0].invoicingStatus;  
436 -  
437 - data.list = data.list?.map((item) => {  
438 - item.filePaths = item.listAnnex?.map((path) => {  
439 - let i = 0;  
440 - return {  
441 - uid: i++,  
442 - name: getAliYunOSSFileNameFromUrl(path),  
443 - status: 'uploaded',  
444 - url: path,  
445 - response: { data: [path] },  
446 - };  
447 - });  
448 - return item;  
449 - });  
450 - }  
451 -  
452 - return (  
453 - <>  
454 - <DrawerForm<{  
455 - deleteSubOrderLists: any;  
456 - name: string;  
457 - company: string;  
458 - }>  
459 - open  
460 - width="35%"  
461 - title={optType('add') || optType('copy') ? '新建订单' : '修改订单'}  
462 - resize={{  
463 - onResize() {  
464 - console.log('resize!');  
465 - },  
466 - maxWidth: window.innerWidth * 0.8,  
467 - minWidth: 400,  
468 - }}  
469 - // layout="horizontal"  
470 - // labelCol={{ span: 8 }}  
471 - form={form}  
472 - autoFocusFirstInput  
473 - drawerProps={{  
474 - destroyOnClose: true,  
475 - maskClosable: false,  
476 - }}  
477 - submitTimeout={2000}  
478 - onFinish={async (values) => {  
479 - let res = {};  
480 - //附件处理  
481 - let list = values.list;  
482 - // console.log(list);  
483 - list = list.map((item) => {  
484 - item.filePaths = item.filePaths?.map((file) => {  
485 - console.log(file);  
486 - return { url: file.response.data[0] };  
487 - });  
488 - return item;  
489 - });  
490 -  
491 - values.list = list;  
492 - values.institution = values.institution?.trim();  
493 - values.institutionContactName = values.institutionContactName?.trim();  
494 -  
495 - if (typeof values.erpCustomerId !== 'string') {  
496 - values.erpCustomerId = values.erpCustomerId?.id;  
497 - }  
498 -  
499 - if (optType('add') || optType('copy')) {  
500 - res = await postServiceOrderAddOrder({ data: values });  
501 - } else {  
502 - //计算已删除的子订单id  
503 - const originIds = originSubOrders.map((item) => {  
504 - return item.id;  
505 - });  
506 - const curIds = form.getFieldValue('list')?.map((item) => {  
507 - return item.id;  
508 - });  
509 - let diff = originIds.filter((item) => !curIds.includes(item));  
510 - values.deleteSubOrderLists = diff;  
511 - res = await postServiceOrderUpdateOrder({ data: values });  
512 - }  
513 -  
514 - if (res.result === RESPONSE_CODE.SUCCESS) {  
515 - message.success(res.message);  
516 - // 不返回不会关闭弹框  
517 - onClose(true);  
518 - return true;  
519 - }  
520 - }}  
521 - onOpenChange={(val) => {  
522 - return !val && onClose();  
523 - }}  
524 - >  
525 - <h2>订单基本信息</h2>  
526 - <ProFormText  
527 - key="id"  
528 - name="id"  
529 - width="lg"  
530 - disabled  
531 - label="id"  
532 - placeholder="id"  
533 - hidden  
534 - />  
535 -  
536 - <ProFormText  
537 - key="empNumber"  
538 - name="empNumber"  
539 - width="lg"  
540 - label="销售职员编码"  
541 - placeholder="销售职员编码"  
542 - hidden  
543 - />  
544 -  
545 - <ProFormSelect  
546 - name="salesCode"  
547 - key="salesCode"  
548 - width="lg"  
549 - showSearch  
550 - label="销售代表"  
551 - placeholder="请输入销售代表"  
552 - rules={[{ required: true, message: '销售代表必填' }]}  
553 - options={salesCodeOptions}  
554 - onChange={(_, option) => {  
555 - autoFillSalesInfo(option);  
556 - }}  
557 - // disabled={mainInfoDisbled}  
558 - />  
559 -  
560 - <ProFormText  
561 - key="erpCustomerName"  
562 - name="erpCustomerName"  
563 - hidden  
564 - ></ProFormText>  
565 -  
566 - <ProFormText  
567 - key="contactAddress"  
568 - name="contactAddress"  
569 - hidden  
570 - ></ProFormText>  
571 -  
572 - <ProFormSelect  
573 - name="erpCustomerId"  
574 - key="erpCustomerId"  
575 - width="lg"  
576 - showSearch  
577 - label={  
578 - <>  
579 - <span>客户</span>  
580 - <span  
581 - className="pl-2 text-xs text-[#1677ff] cursor-pointer"  
582 - onClick={() => {  
583 - let customerId = form.getFieldValue('erpCustomerId');  
584 - if (typeof customerId === 'string') {  
585 - setCustomer({ ...customer, id: customerId });  
586 - } else {  
587 - setCustomer({ ...customer, id: customerId.id });  
588 - }  
589 - setKingdeeCstomerModalVisible(true);  
590 - }}  
591 - >  
592 - 编辑客户信息  
593 - </span>  
594 - </>  
595 - }  
596 - placeholder="请选择客户"  
597 - rules={[{ required: true, message: '客户必填' }]}  
598 - onChange={(_, option) => {  
599 - //新增客户  
600 - if (option.type === 'add') {  
601 - setCustomer({ name: option.name });  
602 - setKingdeeCstomerModalVisible(true);  
603 - return;  
604 - }  
605 - autoFillCustomerContactSelectOptions(option.id);  
606 - }}  
607 - initialValue={{  
608 - label: data?.erpCustomerName,  
609 - value: data?.customerId,  
610 - id: data?.customerId,  
611 - }}  
612 - fieldProps={{  
613 - optionItemRender(item) {  
614 - if (item.type === 'add') {  
615 - return (  
616 - <div title={item.name + '(新增客户)'}>  
617 - <span style={{ color: '#333333' }}>{item.name}</span>  
618 - {' | '}  
619 - <span style={{ color: 'orange' }}>自定义</span>  
620 - </div>  
621 - );  
622 - }  
623 - return (  
624 - <div  
625 - title={  
626 - item.name +  
627 - ' | ' +  
628 - item.customerContactNumber +  
629 - ' | ' +  
630 - (item.customerShippingAddress === undefined  
631 - ? '无地址'  
632 - : item.customerShippingAddress) +  
633 - ' | ' +  
634 - item.institutionContactName +  
635 - ' | ' +  
636 - item.institution  
637 - }  
638 - >  
639 - <span style={{ color: '#333333' }}>{item.name}</span>  
640 - </div>  
641 - );  
642 - },  
643 - }}  
644 - debounceTime={1000}  
645 - request={async (value, {}) => {  
646 - const keywords = value.keyWords;  
647 - const res = await postKingdeeRepCustomer({  
648 - data: { search: keywords },  
649 - });  
650 - console.log(res);  
651 -  
652 - let options = res?.rows?.map((c: any) => {  
653 - return {  
654 - ...c,  
655 - label: c.name,  
656 - value: c.id,  
657 - key: c.id,  
658 - };  
659 - });  
660 -  
661 - //第一个商品默认为要新增客户  
662 - if (keywords.trim() !== '') {  
663 - options.unshift({  
664 - name: keywords,  
665 - type: 'add',  
666 - label: keywords,  
667 - value: 3.1415926,  
668 - key: keywords,  
669 - });  
670 - }  
671 - return options;  
672 - }}  
673 - />  
674 - <ProFormSelect  
675 - key="customerName"  
676 - label="收货人"  
677 - width="lg"  
678 - showSearch  
679 - name="customerName"  
680 - placeholder="请选择收货人"  
681 - rules={[{ required: true, message: '收货人必填' }]}  
682 - onChange={(_, option) => {  
683 - autoFillCustomerInfo(option);  
684 - }}  
685 - initialValue={data.contactAddress}  
686 - options={productCustomerContactOptions}  
687 - />  
688 - <ProFormText  
689 - width="lg"  
690 - key="customerContactNumber"  
691 - name="customerContactNumber"  
692 - label="联系方式"  
693 - placeholder="请输入联系方式"  
694 - rules={[{ required: true, message: '联系方式必填' }]}  
695 - disabled  
696 - />  
697 - <ProFormText  
698 - width="lg"  
699 - key="institution"  
700 - name="institution"  
701 - label="单位"  
702 - placeholder="请输入单位"  
703 - rules={[{ required: true, message: '单位必填' }]}  
704 - disabled  
705 - />  
706 - <ProFormText  
707 - width="lg"  
708 - key="institutionContactName"  
709 - name="institutionContactName"  
710 - label="课题组"  
711 - placeholder="请输入课题组"  
712 - rules={[{ required: true, message: '课题组必填' }]}  
713 - disabled  
714 - />  
715 - <ProFormTextArea  
716 - width="lg"  
717 - key="customerShippingAddress"  
718 - name="customerShippingAddress"  
719 - label="收货地址"  
720 - placeholder="请输入收货地址"  
721 - rules={[{ required: true, message: '收货地址必填' }]}  
722 - disabled  
723 - />  
724 - <div id="total-payment">  
725 - <ProFormDigit  
726 - name="totalPayment"  
727 - width="lg"  
728 - key="totalPayment"  
729 - label="支付总额(¥)"  
730 - rules={[{ required: true, message: '支付总额必填' }]}  
731 - tooltip="点击计算,合计所有子订单金额"  
732 - fieldProps={{  
733 - addonAfter: (  
734 - <Button  
735 - className="rounded-l-none"  
736 - type="primary"  
737 - onClick={computeTotalPayment}  
738 - >  
739 - 计算  
740 - </Button>  
741 - ),  
742 - }}  
743 - // disabled={mainInfoDisbled}  
744 - />  
745 - </div>  
746 -  
747 - <ProFormSelect  
748 - placeholder="请输入支付渠道"  
749 - name="paymentChannel"  
750 - width="lg"  
751 - key="paymentChannel"  
752 - label="支付渠道"  
753 - options={enumToSelect(PAYMENT_CHANNEL_OPTIONS)}  
754 - rules={[{ required: true, message: '支付渠道必填' }]}  
755 - // disabled={mainInfoDisbled}  
756 - />  
757 - <ProFormSelect  
758 - placeholder="请输入支付方式"  
759 - name="paymentMethod"  
760 - width="lg"  
761 - key="paymentMethod"  
762 - label="支付方式"  
763 - options={enumToSelect(PAYMENT_METHOD_OPTIONS)}  
764 - rules={[{ required: true, message: '支付方式必填' }]}  
765 - // disabled={mainInfoDisbled}  
766 - />  
767 - <ProFormSelect  
768 - placeholder="选择是否需要开票"  
769 - name="invoicingStatus"  
770 - width="lg"  
771 - key="invoicingStatus"  
772 - label="是否需要开票"  
773 - options={getInvoicingSelect()}  
774 - // disabled={mainInfoDisbled}  
775 - onChange={(_, option) => {  
776 - setInvoicingStatus(option.value);  
777 - if (option.value === 'UN_INVOICE') {  
778 - form.setFieldValue('invoiceIdentificationNumber', undefined);  
779 - form.setFieldValue('bank', undefined);  
780 - form.setFieldValue('bankAccountNumber', undefined);  
781 - }  
782 - }}  
783 - rules={[{ required: true, message: '是否需要开票必填' }]}  
784 - />  
785 - <ProFormText  
786 - width="lg"  
787 - name="invoiceIdentificationNumber"  
788 - label="开票信息"  
789 - key="invoiceIdentificationNumber"  
790 - // disabled={mainInfoDisbled}  
791 - hidden={invoicingStatus === 'UN_INVOICE'}  
792 - placeholder="请输入开票信息"  
793 - rules={[  
794 - {  
795 - required: invoicingStatus === 'UN_INVOICE' ? false : true,  
796 - message: '开票信息必填',  
797 - },  
798 - ]}  
799 - />  
800 -  
801 - {getUserInfo().roleSmallVO?.code === 'admin' ? (  
802 - <ProFormDateTimePicker  
803 - width="lg"  
804 - key="invoicingTime"  
805 - name="invoicingTime"  
806 - // disabled={mainInfoDisbled}  
807 - hidden={invoicingStatus === 'UN_INVOICE'}  
808 - label="开票时间"  
809 - placeholder="请输入开票时间"  
810 - />  
811 - ) : (  
812 - ''  
813 - )}  
814 - <ProFormText  
815 - width="lg"  
816 - name="bank"  
817 - key="bank"  
818 - label="开户银行"  
819 - // disabled={mainInfoDisbled}  
820 - hidden={invoicingStatus === 'UN_INVOICE'}  
821 - placeholder="请输入开户银行"  
822 - />  
823 - <ProFormText  
824 - width="lg"  
825 - key="bankAccountNumber"  
826 - name="bankAccountNumber"  
827 - hidden={invoicingStatus === 'UN_INVOICE'}  
828 - label="银行账号"  
829 - // disabled={mainInfoDisbled}  
830 - placeholder="请输入银行账号"  
831 - />  
832 - <ProFormTextArea  
833 - width="lg"  
834 - name="notes"  
835 - label="备注"  
836 - key="notes"  
837 - // disabled={mainInfoDisbled}  
838 - placeholder="请输入备注"  
839 - rules={[  
840 - {  
841 - max: 120, // 最大长度为120个字符  
842 - message: '备注不能超过120个字符',  
843 - },  
844 - ]}  
845 - />  
846 -  
847 - <h2>商品信息</h2>  
848 - <ProFormList  
849 - creatorButtonProps={{ disabled: false }}  
850 - name="list"  
851 - label=""  
852 - copyIconProps={false} //复制按钮不显示  
853 - initialValue={[  
854 - {  
855 - productCode: '',  
856 - productName: '',  
857 - quantity: '',  
858 - productPrice: '',  
859 - parameters: '',  
860 - subOrderPayment: '',  
861 - },  
862 - ]}  
863 - actionGuard={{  
864 - beforeRemoveRow: async (index) => {  
865 - return new Promise((resolve) => {  
866 - if (index === 0) {  
867 - message.error('第一行数据不能删除');  
868 - resolve(false);  
869 - return;  
870 - }  
871 - resolve(true);  
872 - });  
873 - },  
874 - }}  
875 - itemRender={(doms, listMeta) => {  
876 - if (optType('edit')) {  
877 - let i = 0;  
878 - let defaultFileList = listMeta.record?.listAnnex?.map((annex) => {  
879 - return {  
880 - uid: i++,  
881 - name: annex,  
882 - status: 'uploaded',  
883 - url: annex,  
884 - response: { data: [annex] },  
885 - };  
886 - });  
887 - fileList[listMeta.index] = defaultFileList;  
888 - }  
889 - let itemFileList = fileList[listMeta.index];  
890 - return (  
891 - <ProCard  
892 - bordered  
893 - extra={doms.action}  
894 - title={'商品' + (listMeta.index + 1)}  
895 - style={{  
896 - marginBlockEnd: 8,  
897 - }}  
898 - >  
899 - {[  
900 - <ProFormText  
901 - key={'material' + listMeta.index}  
902 - name="materialId"  
903 - hidden  
904 - ></ProFormText>,  
905 - <ProFormSelect  
906 - key="key"  
907 - label="商品名称"  
908 - width="lg"  
909 - showSearch  
910 - name="productName"  
911 - // options={options}  
912 - placeholder="请搜索商品"  
913 - rules={[{ required: true, message: '商品名称必填' }]}  
914 - onChange={(_, option) => {  
915 - autoFillProductInfo(option, listMeta, listMeta.index);  
916 - }}  
917 - initialValue={{  
918 - label: listMeta?.record?.productName,  
919 - value: listMeta?.record?.materialId,  
920 - }}  
921 - fieldProps={{  
922 - optionItemRender(item) {  
923 - if (item.type === 'add') {  
924 - return (  
925 - <div title={item.name + '(新增商品信息)'}>  
926 - <span style={{ color: '#333333' }}>  
927 - {item.label}  
928 - </span>  
929 - {' | '}  
930 - <span style={{ color: 'orange' }}>新增商品</span>  
931 - </div>  
932 - );  
933 - }  
934 - return (  
935 - <div  
936 - title={  
937 - item.label +  
938 - ' | ' +  
939 - (item.model === undefined  
940 - ? '无参数'  
941 - : item.model) +  
942 - ' | ' +  
943 - item.base_unit_name  
944 - }  
945 - >  
946 - <span style={{ color: '#333333' }}>  
947 - {item.label}  
948 - </span>  
949 - {' | '}  
950 - <span style={{ color: '#339999' }}>  
951 - {item.model === undefined ? '无参数' : item.model}  
952 - </span>  
953 - {' | '}  
954 - <span style={{ color: '#666666' }}>  
955 - {item.base_unit_name === undefined  
956 - ? '无单位'  
957 - : item.base_unit_name}  
958 - </span>  
959 - </div>  
960 - );  
961 - },  
962 - }}  
963 - debounceTime={1000}  
964 - request={async (value) => {  
965 - const keywords = value.keyWords;  
966 - const res = await postKingdeeRepMaterial({  
967 - data: { search: keywords },  
968 - });  
969 - let options = res?.rows?.map((p: any) => {  
970 - return {  
971 - ...p,  
972 - label: p.name,  
973 - value: p.id + '|' + p.name,  
974 - key: p.id,  
975 - };  
976 - });  
977 -  
978 - //第一个商品默认为要新增的商品  
979 - if (keywords.trim() !== '') {  
980 - options.unshift({  
981 - productName: keywords,  
982 - type: 'add',  
983 - label: keywords,  
984 - value: 13 + '|' + keywords,  
985 - key: keywords,  
986 - });  
987 - }  
988 - return options;  
989 - }}  
990 - />,  
991 - <ProFormText  
992 - key={'productCode' + listMeta.index}  
993 - width="lg"  
994 - name="productCode"  
995 - disabled  
996 - label={  
997 - <>  
998 - <span>商品编码</span>  
999 - <span className="pl-2 text-xs text-gray-400">  
1000 - 新增商品时,商品编码由系统自动生成  
1001 - </span>  
1002 - </>  
1003 - }  
1004 - placeholder="商品编码"  
1005 - />,  
1006 - // <ProFormSelect  
1007 - // key="inv_stock"  
1008 - // placeholder="请选择仓库"  
1009 - // name="invStockId"  
1010 - // width="lg"  
1011 - // label="仓库"  
1012 - // options={productInvStockOptionsList[listMeta.index]}  
1013 - // />,  
1014 - <ProFormText  
1015 - key={'parameters' + listMeta.index}  
1016 - width="lg"  
1017 - name="parameters"  
1018 - label="商品参数"  
1019 - placeholder="请输入商品参数"  
1020 - rules={[{ required: true, message: '商品参数必填' }]}  
1021 - disabled={  
1022 - productParametersDisabledFlagList[listMeta.index] !==  
1023 - false  
1024 - }  
1025 - />,  
1026 - <ProFormDigit  
1027 - key={'quantity' + listMeta.index}  
1028 - width="lg"  
1029 - name="quantity"  
1030 - label="商品数量"  
1031 - fieldProps={{  
1032 - onChange: (value) => {  
1033 - listMeta.record.quantity = value;  
1034 - computeSubOrderPayment(listMeta);  
1035 - },  
1036 - }}  
1037 - placeholder="请输入商品数量"  
1038 - rules={[{ required: true, message: '商品数量必填' }]}  
1039 - />,  
1040 -  
1041 - <ProFormDigit  
1042 - key={'productPrice' + listMeta.index}  
1043 - width="lg"  
1044 - name="productPrice"  
1045 - label="商品单价"  
1046 - fieldProps={{  
1047 - onChange: (value) => {  
1048 - listMeta.record.productPrice = value;  
1049 - computeSubOrderPayment(listMeta);  
1050 - },  
1051 - }}  
1052 - placeholder="请输入商品单价"  
1053 - rules={[{ required: true, message: '商品单价必填' }]}  
1054 - />,  
1055 -  
1056 - <ProFormSelect  
1057 - key="unitId"  
1058 - placeholder="请选择单位"  
1059 - name="unitId"  
1060 - width="lg"  
1061 - label="单位"  
1062 - showSearch  
1063 - onChange={(_, option) => {  
1064 - autoFillUnit(option, listMeta.index);  
1065 - }}  
1066 - options={productUnitOptionsList[listMeta.index]}  
1067 - rules={[{ required: true, message: '商品单位必填' }]}  
1068 - />,  
1069 - <ProFormText  
1070 - key={'unit' + listMeta.index}  
1071 - width="lg"  
1072 - name="unit"  
1073 - label="商品单位"  
1074 - placeholder="请输入商品单位"  
1075 - rules={[{ required: true, message: '商品单位必填' }]}  
1076 - hidden  
1077 - />,  
1078 -  
1079 - <ProFormDigit  
1080 - width="lg"  
1081 - key={'subOrderPayment' + listMeta.index}  
1082 - name="subOrderPayment"  
1083 - label="子订单金额"  
1084 - placeholder="请输入子订单金额"  
1085 - tooltip="商品数量和单价变化后会自动计算子订单金额"  
1086 - rules={[{ required: true, message: '子订单金额必填' }]}  
1087 - />,  
1088 - <ProFormSelect  
1089 - key={'productBelongBusiness' + listMeta.index}  
1090 - placeholder="请输入所属事业部"  
1091 - name="productBelongBusiness"  
1092 - width="lg"  
1093 - label="所属事业部"  
1094 - options={enumToSelect(PRODUCT_BELONG_DEPARTMENT_OPTIONS)}  
1095 - initialValue={'EXPERIMENTAL_CONSUMABLES'}  
1096 - rules={[{ required: true, message: '所属事业部必填' }]}  
1097 - // disabled={mainInfoDisbled}  
1098 - />,  
1099 - <ProFormTextArea  
1100 - key={'notes' + listMeta.index}  
1101 - width="lg"  
1102 - name="notes"  
1103 - label={  
1104 - <div>  
1105 - <span>备注</span>  
1106 - <span className="pl-2 text-xs text-gray-400">  
1107 - 备注将体现在出货单上,请将需要仓管看见的信息写在备注上,例如需要开收据等信息。  
1108 - </span>  
1109 - </div>  
1110 - }  
1111 - placeholder="请输入备注"  
1112 - rules={[  
1113 - {  
1114 - max: 120, // 最大长度为120个字符  
1115 - message: '备注不能超过120个字符',  
1116 - },  
1117 - ]}  
1118 - />,  
1119 - <>  
1120 - <ProFormUploadDragger  
1121 - key={'filePaths' + listMeta.index}  
1122 - label="附件"  
1123 - name="filePaths"  
1124 - action="/api/service/order/fileProcess"  
1125 - fieldProps={{  
1126 - headers: {  
1127 - Authorization: localStorage.getItem('token'),  
1128 - },  
1129 - itemFileList,  
1130 - }}  
1131 - />  
1132 - </>,  
1133 - ]}  
1134 - </ProCard>  
1135 - );  
1136 - }}  
1137 - actionRef={actionRef}  
1138 - ></ProFormList>  
1139 - </DrawerForm>  
1140 -  
1141 - {kingdeeCstomerModalVisible && (  
1142 - <KingdeeCustomerModal  
1143 - setVisible={setKingdeeCstomerModalVisible}  
1144 - data={customer}  
1145 - onClose={(customerId: any) => {  
1146 - setKingdeeCstomerModalVisible(false);  
1147 - //回显已经新建好的客户  
1148 - autoFillCustomerContactSelectOptions(customerId);  
1149 - }}  
1150 - />  
1151 - )}  
1152 - </>  
1153 - );  
1154 -};  
src/pages/Order/OrderList/OrderDrawer.tsx
@@ -871,11 +871,43 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; { @@ -871,11 +871,43 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
871 }); 871 });
872 return item; 872 return item;
873 }); 873 });
874 - 874 + list = list.map((item, index) => {
  875 + // //记录部门修改时间
  876 + if (
  877 + optType('edit') &&
  878 + copyData?.subOrderInformationLists[index]
  879 + ?.productBelongBusiness &&
  880 + item.productBelongBusiness !==
  881 + copyData?.subOrderInformationLists[index]?.productBelongBusiness
  882 + ) {
  883 + const date = new Date();
  884 + const year = date.getFullYear();
  885 + const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1
  886 + const day = String(date.getDate()).padStart(2, '0');
  887 + const hours = String(date.getHours()).padStart(2, '0');
  888 + const minutes = String(date.getMinutes()).padStart(2, '0');
  889 + const seconds = String(date.getSeconds()).padStart(2, '0');
  890 +
  891 + const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  892 + values.productBelongBusinessUpdateTime = formattedDate;
  893 + } else if (optType('add')) {
  894 + const date = new Date();
  895 + const year = date.getFullYear();
  896 + const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1
  897 + const day = String(date.getDate()).padStart(2, '0');
  898 + const hours = String(date.getHours()).padStart(2, '0');
  899 + const minutes = String(date.getMinutes()).padStart(2, '0');
  900 + const seconds = String(date.getSeconds()).padStart(2, '0');
  901 + const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  902 + values.productBelongBusinessUpdateTime = formattedDate;
  903 + }
  904 + return item;
  905 + });
875 values.list = list; 906 values.list = list;
876 values.institution = values.institution?.trim(); 907 values.institution = values.institution?.trim();
877 values.institutionContactName = values.institutionContactName?.trim(); 908 values.institutionContactName = values.institutionContactName?.trim();
878 values.customerName = values.customerNameString.trim(); 909 values.customerName = values.customerNameString.trim();
  910 +
879 // values.customerShippingAddress = 911 // values.customerShippingAddress =
880 // province + city + district + values.customerShippingAddress; 912 // province + city + district + values.customerShippingAddress;
881 913
@@ -909,7 +941,6 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; { @@ -909,7 +941,6 @@ export default ({ onClose, data, subOrders, orderOptType }) =&gt; {
909 }); 941 });
910 let diff = originIds.filter((item) => !curIds.includes(item)); 942 let diff = originIds.filter((item) => !curIds.includes(item));
911 values.deleteSubOrderLists = diff; 943 values.deleteSubOrderLists = diff;
912 -  
913 if (optType('edit')) { 944 if (optType('edit')) {
914 values.province = province; 945 values.province = province;
915 values.city = city; 946 values.city = city;
src/pages/Prepaid/constant.tsx
@@ -19,6 +19,11 @@ export const PREPAID_STATUS_OPTIONS = { @@ -19,6 +19,11 @@ export const PREPAID_STATUS_OPTIONS = {
19 AUDIT_FAIL: '审核失败', 19 AUDIT_FAIL: '审核失败',
20 AUDIT_PASS: '审核通过', 20 AUDIT_PASS: '审核通过',
21 }; 21 };
  22 +export const REMAINING_OPTIONS = {
  23 + MORE: '大于0',
  24 + EQUAL: '等于0',
  25 + LESS: '小于0',
  26 +};
22 export const SALES_RECHARGE_PREPAYMENT_COLUMNS = [ 27 export const SALES_RECHARGE_PREPAYMENT_COLUMNS = [
23 // { 28 // {
24 // title: '编号', 29 // title: '编号',
@@ -51,7 +56,7 @@ export const SALES_RECHARGE_PREPAYMENT_COLUMNS = [ @@ -51,7 +56,7 @@ export const SALES_RECHARGE_PREPAYMENT_COLUMNS = [
51 valueType: 'text', 56 valueType: 'text',
52 }, 57 },
53 { 58 {
54 - title: '金额', 59 + title: '充值金额',
55 dataIndex: 'rechargeAmount', 60 dataIndex: 'rechargeAmount',
56 key: 'rechargeAmount', 61 key: 'rechargeAmount',
57 valueType: 'money', 62 valueType: 'money',
@@ -208,6 +213,15 @@ export const ACCOUNT_COLUMNS = [ @@ -208,6 +213,15 @@ export const ACCOUNT_COLUMNS = [
208 }, 213 },
209 }, 214 },
210 }, 215 },
  216 + {
  217 + title: '余额(¥)',
  218 + dataIndex: 'nowMoneySearch',
  219 + key: 'nowMoneySearch',
  220 + valueType: 'text',
  221 + hideInSearch: false,
  222 + hideInTable: true,
  223 + valueEnum: enumToProTableEnumValue(REMAINING_OPTIONS),
  224 + },
211 ]; 225 ];
212 226
213 export const BALANCE_CHANGE_COLUMNS = [ 227 export const BALANCE_CHANGE_COLUMNS = [
src/pages/Prepaid/index.tsx
@@ -220,7 +220,7 @@ const PrepaidPage = () =&gt; { @@ -220,7 +220,7 @@ const PrepaidPage = () =&gt; {
220 const tabsItems = [ 220 const tabsItems = [
221 { 221 {
222 key: 1, 222 key: 1,
223 - label: '预存管理', 223 + label: '预存充值',
224 children: ( 224 children: (
225 <ProTable 225 <ProTable
226 columns={prepaidColumnsInit()} 226 columns={prepaidColumnsInit()}
@@ -259,7 +259,7 @@ const PrepaidPage = () =&gt; { @@ -259,7 +259,7 @@ const PrepaidPage = () =&gt; {
259 }} 259 }}
260 form={{}} 260 form={{}}
261 dateFormatter="string" 261 dateFormatter="string"
262 - headerTitle="预存管理" 262 + headerTitle="预存充值"
263 scroll={{ x: 1400 }} 263 scroll={{ x: 1400 }}
264 toolBarRender={() => [ 264 toolBarRender={() => [
265 <Button 265 <Button
@@ -271,7 +271,7 @@ const PrepaidPage = () =&gt; { @@ -271,7 +271,7 @@ const PrepaidPage = () =&gt; {
271 }} 271 }}
272 type="primary" 272 type="primary"
273 > 273 >
274 - 新 274 + 新增充值
275 </Button>, 275 </Button>,
276 ]} 276 ]}
277 /> 277 />