Commit 7293ba7264e7cb16cb4fa79ce3e7bf550582e77a

Authored by zhongnanhuang
1 parent 91ecba53

feat: update

.umirc.ts
... ... @@ -13,7 +13,7 @@ export default defineConfig({
13 13 },
14 14 proxy: {
15 15 '/service/': {
16   - target: 'http://localhost:8085/',
  16 + target: 'http://39.108.227.113:8085/',
17 17 changeOrigin: true,
18 18 // pathRewrite: { '^/api': '' },
19 19 },
... ...
src/pages/Order/components/OrderDrawer.tsx
... ... @@ -9,7 +9,6 @@ import {
9 9 ProCard,
10 10 ProFormDateTimePicker,
11 11 ProFormDigit,
12   - ProFormGroup,
13 12 ProFormList,
14 13 ProFormSelect,
15 14 ProFormText,
... ... @@ -25,8 +24,37 @@ import {
25 24 } from '../constant';
26 25  
27 26 export default ({ onClose, data }) => {
28   - console.log('');
29   - const [form] = Form.useForm<{ name: string; company: string }>();
  27 + const [form] = Form.useForm<{
  28 + salesCode: '';
  29 + customerName: '';
  30 + customerContactNumber: '';
  31 + institution: '';
  32 + institutionContactName: '';
  33 + customerShippingAddress: '';
  34 + totalPayment: '';
  35 + paymentChannel: '';
  36 + paymentMethod: '';
  37 + productBelongBusiness: '';
  38 + invoicingStatus: '';
  39 + invoiceIdentificationNumber: '';
  40 + invoicingTime: '';
  41 + bank: '';
  42 + bankAccountNumber: '';
  43 + notes: '';
  44 + list: [
  45 + {
  46 + productCode: '';
  47 + productName: '';
  48 + quantity: '';
  49 + productPrice: '';
  50 + parameters: '';
  51 + subOrderPayment: '';
  52 + unit: '';
  53 + serialNumber: '';
  54 + notes: '';
  55 + },
  56 + ];
  57 + }>();
30 58 const actionRef = useRef<
31 59 FormListActionType<{
32 60 name: string;
... ... @@ -39,8 +67,18 @@ export default ({ onClose, data }) =&gt; {
39 67 form.setFieldsValue({ ...data });
40 68 }, [data]);
41 69  
42   - function autoFillProductInfo(action) {
43   - console.log(action);
  70 + /**
  71 + *
  72 + * @param option 商品名称所对应的商品数据
  73 + * @param currentRowData list中当前行的数据
  74 + */
  75 + function autoFillProductInfo(option: any, currentRowData: any) {
  76 + let copyList = form.getFieldValue('list');
  77 + let currentData = copyList[currentRowData.field.key];
  78 + currentData.productCode = option.productCode;
  79 + currentData.parameters = option.specifications;
  80 + currentData.unit = option.unit;
  81 + form.setFieldValue('list', copyList);
44 82 }
45 83  
46 84 return (
... ... @@ -344,95 +382,97 @@ export default ({ onClose, data }) =&gt; {
344 382 });
345 383 },
346 384 }}
347   - itemRender={({ listDom, action }, {}) => {
  385 + itemRender={(doms, listMeta) => {
348 386 // const list = actionRef.current?.getList();
349 387 return (
350 388 <ProCard
351 389 bordered
352   - extra={action}
  390 + extra={doms.action}
353 391 title={'商品' + rowNumber.current++}
354 392 style={{
355 393 marginBlockEnd: 8,
356 394 }}
357 395 >
358   - {listDom}
  396 + {[
  397 + <ProFormSelect
  398 + key={listMeta.field.key}
  399 + label="商品名称"
  400 + width="lg"
  401 + showSearch
  402 + name="productName"
  403 + placeholder="请搜索商品"
  404 + onChange={(_, option) => {
  405 + autoFillProductInfo(option, listMeta);
  406 + }}
  407 + request={async (value) => {
  408 + const { data } =
  409 + await postServiceOrderQueryProductInformation({
  410 + data: { productName: value.keyWords },
  411 + });
  412 + return data.map((p: any) => {
  413 + return { ...p, label: p.productName, value: p.id };
  414 + });
  415 + }}
  416 + />,
  417 + doms.listDom,
  418 + ]}
359 419 </ProCard>
360 420 );
361 421 }}
362 422 actionRef={actionRef}
363 423 >
364   - <ProFormGroup key="group">
365   - <ProFormSelect
366   - label="商品名称"
367   - width="lg"
368   - showSearch
369   - name="productName"
370   - placeholder="请搜索商品"
371   - onChange={() => {
372   - autoFillProductInfo(actionRef);
373   - }}
374   - request={async (value) => {
375   - const { data } = await postServiceOrderQueryProductInformation({
376   - data: { productName: value.keyWords },
377   - });
378   - return data.map((p: any) => {
379   - return { ...p, label: p.productName, value: p.id };
380   - });
381   - }}
382   - />
383   - <ProFormText
384   - width="lg"
385   - name="productCode"
386   - disabled
387   - label="商品编码"
388   - placeholder="未输入商品名称"
389   - />
390   - <ProFormText
391   - width="lg"
392   - disabled
393   - name="parameters"
394   - label="商品参数"
395   - placeholder="请输入商品参数"
396   - />
397   - <ProFormText
398   - width="lg"
399   - name="quantity"
400   - label="商品数量"
401   - placeholder="请输入商品数量"
402   - />
403   - <ProFormDigit
404   - width="lg"
405   - name="productPrice"
406   - label="商品单价"
407   - placeholder="请输入商品单价"
408   - />
409   - <ProFormText
410   - width="lg"
411   - name="unit"
412   - disabled
413   - label="价格单位"
414   - placeholder="请输入价格单位"
415   - />
  424 + <ProFormText
  425 + width="lg"
  426 + name="productCode"
  427 + disabled
  428 + label="商品编码"
  429 + placeholder="未输入商品名称"
  430 + />
  431 + <ProFormText
  432 + width="lg"
  433 + disabled
  434 + name="parameters"
  435 + label="商品参数"
  436 + placeholder="请输入商品参数"
  437 + />
  438 + <ProFormText
  439 + width="lg"
  440 + name="quantity"
  441 + label="商品数量"
  442 + placeholder="请输入商品数量"
  443 + />
  444 + <ProFormDigit
  445 + width="lg"
  446 + name="productPrice"
  447 + label="商品单价"
  448 + placeholder="请输入商品单价"
  449 + />
  450 + <ProFormText
  451 + width="lg"
  452 + name="unit"
  453 + disabled
  454 + label="价格单位"
  455 + placeholder="请输入价格单位"
  456 + />
416 457  
417   - <ProFormDigit
418   - width="lg"
419   - name="subOrderPayment"
420   - label="子订单金额"
421   - placeholder="请输入子订单金额"
422   - />
423   - <ProFormText
424   - width="lg"
425   - name="serialNumber"
426   - label="物流单号"
427   - placeholder="请输入物流单号"
428   - />
429   - <ProFormText
430   - width="lg"
431   - name="notes"
432   - label="备注"
433   - placeholder="请输入备注"
434   - />
435   - </ProFormGroup>
  458 + <ProFormDigit
  459 + width="lg"
  460 + name="subOrderPayment"
  461 + label="子订单金额"
  462 + placeholder="请输入子订单金额"
  463 + />
  464 + <ProFormText
  465 + width="lg"
  466 + name="serialNumber"
  467 + label="物流单号"
  468 + placeholder="请输入物流单号"
  469 + />
  470 + <ProFormText
  471 + width="lg"
  472 + name="notes"
  473 + label="备注"
  474 + placeholder="请输入备注"
  475 + />
436 476 </ProFormList>
437 477  
438 478 {/* <ProFormDateRangePicker name="contractTime" label="合同生效时间" /> */}
... ...
src/pages/Order/index.tsx
... ... @@ -28,6 +28,7 @@ const OrderPage = () =&gt; {
28 28 const [deliverVisible, setDeliverVisible] = useState<boolean>(false);
29 29 const [expandedRowKeys, setExpandedRowKeys] = useState<Key[]>([]);
30 30 const [orderRow, setOrderRow] = useState<Partial<OrderType>>({});
  31 + const [mainOrderAllItemKeys, setMainOrderAllItemKeys] = useState([]);
31 32  
32 33 const [selectedRows, setSelectedRows] = useState({});
33 34 const [selectedRowObj, setSelectedRowObj] = useState({});
... ... @@ -41,7 +42,14 @@ const OrderPage = () =&gt; {
41 42  
42 43 setSelectedItems(newSelectedItems);
43 44 };
  45 + const handleAllExpand = () => {
  46 + if (expandedRowKeys.length === mainOrderAllItemKeys.length) {
  47 + setExpandedRowKeys([]);
  48 + return;
  49 + }
44 50  
  51 + setExpandedRowKeys(mainOrderAllItemKeys);
  52 + };
45 53 // 主订单内容渲染
46 54 const MainOrderColumnRender = ({ record }: { record: OrderListItemType }) => {
47 55 const handleExpand = (key: number) => {
... ... @@ -61,7 +69,7 @@ const OrderPage = () =&gt; {
61 69 >
62 70 <Flex wrap="wrap" gap="middle">
63 71 <div>{record.createTime}</div>
64   - <div>订单编号:{record.main_order_id}</div>
  72 + <div>订单编号:{record.id}</div>
65 73 </Flex>
66 74 </Checkbox>
67 75 </Flex>
... ... @@ -330,6 +338,7 @@ const OrderPage = () =&gt; {
330 338 rowKey="id"
331 339 pagination={{
332 340 showQuickJumper: true,
  341 + pageSize: 10,
333 342 }}
334 343 expandedRowKeys={expandedRowKeys}
335 344 expandable={{ expandedRowRender }}
... ... @@ -342,10 +351,7 @@ const OrderPage = () =&gt; {
342 351 request={async (
343 352 // 第一个参数 params 查询表单和 params 参数的结合
344 353 // 第一个参数中一定会有 pageSize 和 current ,这两个参数是 antd 的规范
345   - params: {
346   - pageSize: 10;
347   - current: 1;
348   - },
  354 + params,
349 355 sorter,
350 356 filter,
351 357 ) => {
... ... @@ -357,13 +363,23 @@ const OrderPage = () =&gt; {
357 363 filter,
358 364 data: params,
359 365 });
360   - console.log(data);
  366 + setMainOrderAllItemKeys(data?.data?.map((d) => d.id)); //存储所有主订单的key,一键展开用
361 367 return {
362 368 data: data?.data || [],
  369 + total: data?.total || 0,
363 370 };
364 371 }}
365 372 toolBarRender={() => [
366   - <Button key="show">一键展开</Button>,
  373 + <Button
  374 + key="show"
  375 + onClick={() => {
  376 + handleAllExpand();
  377 + }}
  378 + >
  379 + {mainOrderAllItemKeys.length !== expandedRowKeys.length
  380 + ? '一键展开'
  381 + : '一键收起'}
  382 + </Button>,
367 383 <Button key="out" onClick={() => setOrderDrawerVisible(true)}>
368 384 新增
369 385 </Button>,
... ...
src/pages/OrderPrint/index.tsx
... ... @@ -19,7 +19,9 @@ function InvoiceDetails() {
19 19 <div className="grid grid-cols-2 gap-4 mb-6 text-sm">
20 20 <div>
21 21 <p>单位名称: 某某科技有限公司</p>
  22 + <p>联系人: 张三</p>
22 23 <p>联系电话: 18583817221</p>
  24 + <p>送货地址: 广东省东莞市</p>
23 25 </div>
24 26 <div className="text-right">
25 27 <p>编号: Canrd-DZ-2023-1101-004</p>
... ... @@ -34,24 +36,24 @@ function ProductsTable() {
34 36 <div className="mb-6">
35 37 <table className="w-full text-sm border border-gray-300 table-fixed">
36 38 <thead>
37   - <tr className="bg-gray-200">
  39 + <tr className="">
38 40 <th className="w-1/4 p-2 border border-gray-300 border-solid">
39   - 名称
  41 + 序号
40 42 </th>
41 43 <th className="w-1/6 p-2 border border-gray-300 border-solid">
42   - 规格
  44 + 订单号
43 45 </th>
44 46 <th className="w-1/6 p-2 border border-gray-300 border-solid">
45   - 单位
  47 + 货品名称
46 48 </th>
47 49 <th className="w-1/12 p-2 border border-gray-300 border-solid">
48   - 数量
  50 + 规格
49 51 </th>
50 52 <th className="w-1/6 p-2 border border-gray-300 border-solid">
51   - 单
  53 + 单
52 54 </th>
53 55 <th className="w-1/6 p-2 border border-gray-300 border-solid">
54   - 金额
  56 + 数量
55 57 </th>
56 58 <th className="w-1/4 p-2 border border-gray-300 border-solid">
57 59 备注
... ...