Blame view

src/pages/Order/OrderWarning/components/ShippingWarehouseChangeModal.tsx 1.88 KB
zhongnanhuang authored
1
2
3
4
5
import { RESPONSE_CODE } from '@/constants/enum';
import { postServiceOrderShippingWarehouseChange } from '@/services';
import { enumToSelect } from '@/utils';
import { ModalForm, ProFormSelect } from '@ant-design/pro-components';
import { Form, message } from 'antd';
boyang authored
6
import { SHIPPING_WAREHOUSE_OPTIONS } from '../../constant';
zhongnanhuang authored
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
64
65
66
67
68
69
70

export default ({
  setVisible,
  subOrderIds,
  originShippingWarehouse,
  onClose,
}) => {
  const [form] = Form.useForm<{ shippingWarehouse: string }>();

  let newOriginShippingWarehouse = originShippingWarehouse;
  if (
    originShippingWarehouse === null ||
    originShippingWarehouse === undefined
  ) {
    newOriginShippingWarehouse = 'DALANG_WAREHOUSE';
  }
  return (
    <>
      <ModalForm<{
        shippingWarehouse: string;
      }>
        width={500}
        open
        title="修改发货仓库"
        form={form}
        autoFocusFirstInput
        modalProps={{
          okText: '保存',
          cancelText: '取消',
          destroyOnClose: true,
          onCancel: () => {
            setVisible(false);
          },
        }}
        onFinish={async (values) => {
          let res = await postServiceOrderShippingWarehouseChange({
            data: {
              ...values,
              ids: subOrderIds,
            },
          });

          if (res && res.result === RESPONSE_CODE.SUCCESS) {
            message.success(res.message);
          }
          onClose();
        }}
        onOpenChange={setVisible}
      >
        <ProFormSelect
          key={'shippingWarehouse'}
          placeholder="请选择发货仓库"
          name="shippingWarehouse"
          width="lg"
          label="发货仓库"
          rules={[{ required: true, message: '发货仓库必填' }]}
          initialValue={newOriginShippingWarehouse}
          options={enumToSelect(SHIPPING_WAREHOUSE_OPTIONS)}
        />
        ,
      </ModalForm>
    </>
  );
};