lisenzhou před 2 roky
rodič
revize
c2c88fc1a8

+ 1
- 1
config/proxy.js Zobrazit soubor

@@ -12,7 +12,7 @@ export default {
12 12
     '/api/': {
13 13
       // 要代理的地址
14 14
       //http://192.168.89.147:8087
15
-      target: 'http://localhost:8087',
15
+      target: 'http://192.168.89.147:8087',
16 16
       // 配置了这个可以从 http 代理到 https
17 17
       // 依赖 origin 的功能可能需要这个,比如 cookie
18 18
       changeOrigin: true,

+ 45
- 0
config/routes.js Zobrazit soubor

@@ -88,6 +88,51 @@
88 88
     // hideInMenu: true,
89 89
     component: './guaranteeTask/Edit/index',
90 90
   },
91
+  {
92
+    path: '/stock/list',
93
+    name: '库存管理',
94
+    icon: 'smile',
95
+    component: './stock/list',
96
+  },
97
+  {
98
+    path: '/stock/add',
99
+    name: '库存新增',
100
+    hideInMenu: true,
101
+    component: './stock/edit',
102
+  },
103
+
104
+  {
105
+    path: '/stock/edit',
106
+    name: '库存详细',
107
+    hideInMenu: true,
108
+    component: './stock/edit',
109
+  },
110
+  {
111
+    path: '/stock/outAndIn',
112
+    name: '出入库管理',
113
+    hideInMenu: true,
114
+    component: './stock/outAndIn',
115
+  },
116
+  {
117
+    path: '/stockLog/list',
118
+    name: '库存日志',
119
+    icon: 'VideoCameraOutlined',
120
+    component: './stock/stockLog',
121
+  },
122
+  {
123
+    path: '/stockClassification/list',
124
+    name: '分类管理',
125
+    icon: 'smile',
126
+    component: './stockClassification/list',
127
+  },
128
+  {
129
+    path: '/stockClassification/edit',
130
+    name: '分类管理',
131
+    icon: 'smile',
132
+    hideInMenu: true,
133
+    component: './stockClassification/edit',
134
+  },
135
+  
91 136
   {
92 137
     component: './404',
93 138
   },

+ 104
- 0
src/pages/stock/edit/index.jsx Zobrazit soubor

@@ -0,0 +1,104 @@
1
+import { updataDish } from '@/services/api/dish';
2
+import { addStore, getStoreTypeList,getStoreById,updataStore } from '@/services/api/stock';
3
+import { queryDict } from '@/utils/request';
4
+import { PageContainer, ProForm, ProFormSelect, ProFormText } from '@ant-design/pro-components';
5
+import { history, useSearchParams } from '@umijs/max';
6
+import { Card, Col, message, Row, Space } from 'antd';
7
+import { useEffect, useRef } from 'react';
8
+
9
+export default (props) => {
10
+  const [searchParams, setSearchParams] = useSearchParams();
11
+  const id = searchParams.get('id');
12
+  const formRef = useRef();
13
+  useEffect(() => {
14
+    if (id) {
15
+      getStoreById(id).then((res) => {
16
+        formRef.current.setFieldsValue(res);
17
+      });
18
+    }
19
+  }, [id]);
20
+
21
+  const onFinish = async (values) => {
22
+    console.log(values);
23
+
24
+    if (id) {
25
+      // 修改
26
+      updataStore(id, { ...values }).then((res) => {
27
+        message.success('修改成功');
28
+        history.back();
29
+      });
30
+    } else {
31
+      // 新增
32
+      addStore({ ...values }).then((res) => {
33
+        message.success('添加成功');
34
+        history.back();
35
+      });
36
+    }
37
+
38
+    return false;
39
+  };
40
+
41
+  return (
42
+    <PageContainer>
43
+      <Card>
44
+        <ProForm
45
+          formRef={formRef}
46
+          layout={'horizontal'}
47
+          labelCol={{ span: 8 }}
48
+          wrapperCol={{ span: 16 }}
49
+          onFinish={onFinish}
50
+          // initialValues={{ type: '1', state: '1' }}
51
+          submitter={{
52
+            searchConfig: {
53
+              resetText: '返回',
54
+            },
55
+            onReset: () => history.back(),
56
+            render: (props, doms) => {
57
+              return (
58
+                <Row>
59
+                  <Col span={8} offset={8}>
60
+                    <Space>{doms}</Space>
61
+                  </Col>
62
+                </Row>
63
+              );
64
+            },
65
+          }}
66
+        >
67
+          <ProFormSelect
68
+            name="typeId"
69
+            label="分类"
70
+            placeholder="请选择分类"
71
+            request={() => queryDict(getStoreTypeList)()}
72
+            rules={[{ required: true, message: '请选择分类' }]}
73
+            allowClear={false}
74
+            width={460}
75
+          />
76
+          <ProFormText
77
+            name="name"
78
+            label="名称"
79
+            placeholder="请输入名称"
80
+            rules={[{ required: true, message: '请输入名称' }]}
81
+            allowClear={false}
82
+            width={460}
83
+          />
84
+          <ProFormText
85
+            name="unit"
86
+            label="单位"
87
+            placeholder="请输入单位"
88
+            rules={[{ required: true, message: '请输入单位' }]}
89
+            allowClear={false}
90
+            width={460}
91
+          />
92
+          <ProFormText
93
+            name="amount"
94
+            label="库存"
95
+            disabled={true}
96
+            placeholder="请输入库存"
97
+            allowClear={false}
98
+            width={460}
99
+          />
100
+        </ProForm>
101
+      </Card>
102
+    </PageContainer>
103
+  );
104
+};

+ 165
- 0
src/pages/stock/list/index.jsx Zobrazit soubor

@@ -0,0 +1,165 @@
1
+import { deleteStore, getStoreList, getStoreTypeList, storeExport } from '@/services/api/stock';
2
+import { downloadBlob } from '@/utils/download';
3
+import { queryDict, queryTable } from '@/utils/request';
4
+import { PageContainer, ProTable } from '@ant-design/pro-components';
5
+import { history } from '@umijs/max';
6
+import { Button, message, Modal, Popconfirm } from 'antd';
7
+import { useRef, useState } from 'react';
8
+import OutAndIn from '../outAndIn';
9
+
10
+const StockList = (props) => {
11
+  const [isOpen, setIsOpen] = useState(false);
12
+  const [modalData, setModalData] = useState({});
13
+  // const [storeTypeDict, setStoreTypeDict] = useState([]);
14
+  const actionRef = useRef();
15
+  const formRef = useRef();
16
+  
17
+  // useEffect(() => {
18
+  //   getStoreTypeList({ pageSize: 9999, pageNum: 1 }).then((res) => {
19
+  //     setStoreTypeDict(
20
+  //       res?.records?.map((x) => ({
21
+  //         label: x.name,
22
+  //         value: x.id,
23
+  //       })) || [],
24
+  //     );
25
+  //   });
26
+  // }, []);
27
+
28
+  const handleDelete = (id) => {
29
+    if (id) {
30
+      deleteStore(id).then((res) => {
31
+        message.success('删除成功');
32
+        actionRef.current.reload();
33
+      });
34
+    }
35
+  };
36
+
37
+  const onCancel = () => {
38
+    setIsOpen(false);
39
+    setModalData({});
40
+  };
41
+
42
+  const onExport = () => {
43
+    storeExport(formRef.current.getFieldsValue()).then((res) => {
44
+      downloadBlob(res, '库存列表.xlsx');
45
+    });
46
+  };
47
+
48
+  const columns = [
49
+    // {
50
+    //   title: 'id',
51
+    //   dataIndex: 'id',
52
+    //   search: false,
53
+    // },
54
+    {
55
+      title: '名称',
56
+      dataIndex: 'name',
57
+    },
58
+    {
59
+      title: '单位',
60
+      dataIndex: 'unit',
61
+      search: false,
62
+    },
63
+    {
64
+      title: '分类',
65
+      dataIndex: 'typeId',
66
+      valueType: 'select',
67
+      // option: storeTypeDict,
68
+      request: () => queryDict(getStoreTypeList)(),
69
+    },
70
+    {
71
+      title: '库存',
72
+      dataIndex: 'amount',
73
+      search: false,
74
+    },
75
+
76
+    {
77
+      title: '操作',
78
+      valueType: 'option',
79
+      width: 200,
80
+      render: (_, record) => [
81
+        <Button
82
+          key={1}
83
+          style={{ padding: 0 }}
84
+          type="link"
85
+          onClick={() => {
86
+            console.log(record, 'record');
87
+            setModalData(record);
88
+            setIsOpen(true);
89
+            // history.push(`/stock/outAndIn?id=${record.id}`);
90
+          }}
91
+        >
92
+          出入库
93
+        </Button>,
94
+        <Button
95
+          key={2}
96
+          style={{ padding: 0 }}
97
+          type="link"
98
+          onClick={() => {
99
+            history.push(`/stock/edit?id=${record.id}`);
100
+          }}
101
+        >
102
+          修改
103
+        </Button>,
104
+
105
+        <Popconfirm
106
+          key={3}
107
+          title="您是否确认删除 ?"
108
+          onConfirm={() => handleDelete(record.id)}
109
+          okText="确定"
110
+          cancelText="取消"
111
+        >
112
+          {/* manualPush */}
113
+          <Button style={{ padding: 0 }} type="link">
114
+            删除
115
+          </Button>
116
+        </Popconfirm>,
117
+      ],
118
+    },
119
+  ];
120
+
121
+  return (
122
+    <PageContainer>
123
+      <ProTable
124
+        actionRef={actionRef}
125
+        formRef={formRef}
126
+        rowKey="id"
127
+        toolBarRender={() => [
128
+          <Button
129
+            key="2"
130
+            type="primary"
131
+            onClick={() => {
132
+              history.push('/stock/add');
133
+            }}
134
+          >
135
+            新增
136
+          </Button>,
137
+          <Button
138
+            key="2"
139
+            type="primary"
140
+            onClick={() => {
141
+              onExport();
142
+              // history.push('/stock/add');
143
+            }}
144
+          >
145
+            导出
146
+          </Button>,
147
+        ]}
148
+        request={queryTable(getStoreList)}
149
+        columns={columns}
150
+      />
151
+      <Modal open={isOpen} footer={null} onCancel={onCancel}>
152
+        <OutAndIn
153
+          data={modalData}
154
+          onCancel={onCancel}
155
+          onSuccess={() => {
156
+            actionRef.current.reload();
157
+            onCancel();
158
+          }}
159
+        />
160
+      </Modal>
161
+    </PageContainer>
162
+  );
163
+};
164
+
165
+export default StockList;

+ 73
- 0
src/pages/stock/outAndIn/components/outAndInForm.jsx Zobrazit soubor

@@ -0,0 +1,73 @@
1
+import { ProForm, ProFormDigit, ProFormText } from '@ant-design/pro-components';
2
+import { Col, Row, Space } from 'antd';
3
+import { useEffect, useRef } from 'react';
4
+
5
+export default (props) => {
6
+  const { data, type, onFinish, storeTypeDict = [], onCancel } = props;
7
+  const formRef = useRef();
8
+  useEffect(() => {
9
+    // formRef.current.resetFields();
10
+    formRef.current.setFieldsValue({
11
+      typeId: data.typeName,
12
+      name: data.name,
13
+      unit: data.unit,
14
+      amount: null,
15
+    });
16
+  }, [data]);
17
+
18
+  return (
19
+    <ProForm
20
+      formRef={formRef}
21
+      layout={'horizontal'}
22
+      labelCol={{ span: 4 }}
23
+      wrapperCol={{ span: 18 }}
24
+      onFinish={onFinish}
25
+      // initialValues={{ type: '1', state: '1' }}
26
+      submitter={{
27
+        searchConfig: {
28
+          resetText: '返回',
29
+        },
30
+        onReset: () => onCancel(),
31
+        render: (props, doms) => {
32
+          return (
33
+            <Row>
34
+              <Col span={8} offset={8}>
35
+                <Space>{doms}</Space>
36
+              </Col>
37
+            </Row>
38
+          );
39
+        },
40
+      }}
41
+    >
42
+      <ProFormText
43
+        name="typeId"
44
+        label="分类"
45
+        disabled={true}
46
+        placeholder="请选择分类"
47
+        allowClear={false}
48
+      />
49
+      <ProFormText
50
+        name="name"
51
+        label="名称"
52
+        placeholder="请输入名称"
53
+        disabled={true}
54
+        allowClear={false}
55
+      />
56
+      <ProFormText
57
+        name="unit"
58
+        label="单位"
59
+        placeholder="请输入单位"
60
+        disabled={true}
61
+        allowClear={false}
62
+      />
63
+      <ProFormDigit
64
+        name="amount"
65
+        label="库存"
66
+        addonBefore={type === 'out' ? '-' : '+'}
67
+        placeholder="请输入库存"
68
+        fieldProps={{ precision: 0 }}
69
+        rules={[{ required: true, message: '请输入库存' }]}
70
+      />
71
+    </ProForm>
72
+  );
73
+};

+ 51
- 0
src/pages/stock/outAndIn/components/outAndInList.jsx Zobrazit soubor

@@ -0,0 +1,51 @@
1
+import { ProTable } from '@ant-design/pro-components';
2
+import {getStoreLogList} from '@/services/api/stock'
3
+import { queryTable,queryDict } from '@/utils/request';
4
+import { useRef, useState } from 'react';
5
+
6
+const OutAndInList = (props) => {
7
+  const { id } = props;
8
+
9
+  const [showDetail, setShowDetail] = useState(false);
10
+  const [activeKey, setActiveKey] = useState('');
11
+  const actionRef = useRef();
12
+
13
+  const columns = [
14
+    {
15
+      title: '名称',
16
+      dataIndex: 'name',
17
+    },
18
+    {
19
+      title: '分类',
20
+      dataIndex: 'type',
21
+    },
22
+    {
23
+      title: '操作',
24
+      dataIndex: 'optType',
25
+      search: false,
26
+    },
27
+    {
28
+      title: '操作量',
29
+      dataIndex: 'amount',
30
+      search: false,
31
+    },
32
+    {
33
+      title: '操作后库存',
34
+      dataIndex: 'pre_amount',
35
+      search: false,
36
+    },
37
+  ];
38
+
39
+  return (
40
+    <ProTable
41
+      actionRef={actionRef}
42
+      params={{storeId:id}}
43
+      rowKey="id"
44
+      // search={false}
45
+      request={queryTable(getStoreLogList)}
46
+      columns={columns}
47
+    />
48
+  );
49
+};
50
+
51
+export default OutAndInList;

+ 67
- 0
src/pages/stock/outAndIn/index.jsx Zobrazit soubor

@@ -0,0 +1,67 @@
1
+import { addStoreLog } from '@/services/api/stock';
2
+import { ProCard } from '@ant-design/pro-components';
3
+// import { history, useSearchParams } from '@umijs/max';
4
+import { message } from 'antd';
5
+import { useState } from 'react';
6
+import OutAndInForm from './components/outAndInForm';
7
+
8
+const OutAndIn = (props) => {
9
+  const { data, onCancel, onSuccess } = props;
10
+
11
+  const [tabKey, setTabKey] = useState('in');
12
+
13
+  const onFinish = async (values) => {
14
+    console.log(data, values);
15
+
16
+    if (data.id) {
17
+      addStoreLog({
18
+        storeId: Number(data.id),
19
+        amount: tabKey === 'out' ? -values.amount : values.amount,
20
+        optType: tabKey,
21
+      }).then((res) => {
22
+        message.success('操作成功');
23
+
24
+        onSuccess();
25
+      });
26
+    }
27
+  };
28
+
29
+  return (
30
+    <ProCard
31
+      tabs={{
32
+        // tabPosition,
33
+        centered: true,
34
+        activeKey: tabKey,
35
+        destroyInactiveTabPane: false,
36
+        items: [
37
+          {
38
+            label: `入库`,
39
+            key: 'in',
40
+            children: (
41
+              <OutAndInForm data={data} type={tabKey} onFinish={onFinish} onCancel={onCancel} />
42
+            ),
43
+          },
44
+          {
45
+            label: `出库`,
46
+            key: 'out',
47
+            children: (
48
+              <OutAndInForm data={data} type={tabKey} onFinish={onFinish} onCancel={onCancel} />
49
+            ),
50
+          },
51
+          {
52
+            label: `盘点`,
53
+            key: 'fix',
54
+            children: (
55
+              <OutAndInForm data={data} type={tabKey} onFinish={onFinish} onCancel={onCancel} />
56
+            ),
57
+          },
58
+        ],
59
+        onChange: (key) => {
60
+          setTabKey(key);
61
+        },
62
+      }}
63
+    />
64
+  );
65
+};
66
+
67
+export default OutAndIn;

+ 81
- 0
src/pages/stock/stockLog/index.jsx Zobrazit soubor

@@ -0,0 +1,81 @@
1
+import { getStoreLogList, getStoreTypeList,storeLogExport } from '@/services/api/stock';
2
+import { queryDict, queryTable } from '@/utils/request';
3
+import { downloadBlob } from '@/utils/download';
4
+import { PageContainer, ProTable } from '@ant-design/pro-components';
5
+import { Button } from 'antd';
6
+import { useRef } from 'react';
7
+
8
+const StockLog = (props) => {
9
+  const actionRef = useRef();
10
+  const formRef = useRef()
11
+  const onExport = () => {
12
+    storeLogExport(formRef.current.getFieldsValue()).then((res) => {
13
+      downloadBlob(res, '库存日志.xlsx');
14
+    });
15
+  };
16
+  const columns = [
17
+    {
18
+      title: '名称',
19
+      dataIndex: 'storeName',
20
+    },
21
+    {
22
+      title: '分类',
23
+      dataIndex: 'typeId',
24
+      valueType: 'select',
25
+      request: () => queryDict(getStoreTypeList)(),
26
+    },
27
+    {
28
+      title: '操作',
29
+      dataIndex: 'optType',
30
+      valueEnum: {
31
+        in: '入库',
32
+        out: '出库',
33
+        fix: '盘点',
34
+      },
35
+      search: false,
36
+    },
37
+    {
38
+      title: '操作量',
39
+      dataIndex: 'amount',
40
+      search: false,
41
+    },
42
+    {
43
+      title: '操作后库存',
44
+      dataIndex: 'aftAmount',
45
+      search: false,
46
+    },
47
+    {
48
+      title: '操作时间',
49
+      dataIndex: 'createDate',
50
+      valueType: 'dateTime',
51
+      search: false,
52
+    },
53
+  ];
54
+
55
+  return (
56
+    <PageContainer>
57
+      <ProTable
58
+        actionRef={actionRef}
59
+        formRef={formRef}
60
+        rowKey="id"
61
+        toolBarRender={() => [
62
+          <Button
63
+            key="2"
64
+            type="primary"
65
+            onClick={() => {
66
+              onExport();
67
+              // history.push('/stock/add');
68
+            }}
69
+          >
70
+            导出
71
+          </Button>,
72
+        ]}
73
+        // search={false}
74
+        request={queryTable(getStoreLogList)}
75
+        columns={columns}
76
+      />
77
+    </PageContainer>
78
+  );
79
+};
80
+
81
+export default StockLog;

+ 89
- 0
src/pages/stockClassification/edit/index.jsx Zobrazit soubor

@@ -0,0 +1,89 @@
1
+import { addStoreType, getStoreTypeById, updataStoreType } from '@/services/api/stock';
2
+import { PageContainer, ProForm, ProFormSelect, ProFormText } from '@ant-design/pro-components';
3
+import { history, useSearchParams } from '@umijs/max';
4
+import { Card, Col, message, Row, Space } from 'antd';
5
+import { useEffect, useRef } from 'react';
6
+
7
+export default (props) => {
8
+  const [searchParams, setSearchParams] = useSearchParams();
9
+  const id = searchParams.get('id');
10
+
11
+  const formRef = useRef();
12
+  useEffect(() => {
13
+    if (id) {
14
+      getStoreTypeById(id).then((res) => {
15
+        formRef.current.setFieldsValue(res);
16
+      });
17
+    }
18
+  }, [id]);
19
+
20
+  const onFinish = async (values) => {
21
+    console.log(values);
22
+
23
+    if (id) {
24
+      // 修改
25
+      updataStoreType(id, { ...values }).then((res) => {
26
+        message.success('修改成功');
27
+        history.back();
28
+      });
29
+    } else {
30
+      // 新增;
31
+      addStoreType({ ...values }).then((res) => {
32
+        message.success('添加成功');
33
+        history.back();
34
+      });
35
+    }
36
+
37
+    return false;
38
+  };
39
+
40
+  return (
41
+    <PageContainer>
42
+      <Card>
43
+        <ProForm
44
+          formRef={formRef}
45
+          layout={'horizontal'}
46
+          labelCol={{ span: 8 }}
47
+          wrapperCol={{ span: 16 }}
48
+          onFinish={onFinish}
49
+          submitter={{
50
+            searchConfig: {
51
+              resetText: '返回',
52
+            },
53
+            onReset: () => history.back(),
54
+            render: (props, doms) => {
55
+              return (
56
+                <Row>
57
+                  <Col span={8} offset={8}>
58
+                    <Space>{doms}</Space>
59
+                  </Col>
60
+                </Row>
61
+              );
62
+            },
63
+          }}
64
+        >
65
+          <ProFormText
66
+            name="name"
67
+            label="名称"
68
+            placeholder="请输入名称"
69
+            width={460}
70
+            allowClear={false}
71
+            rules={[{ required: true, message: '请输入名称' }]}
72
+          />
73
+          <ProFormSelect
74
+            name="isFood"
75
+            label="食材"
76
+            options={[
77
+              { label: '是', value: 1 },
78
+              { label: '否', value: 0 },
79
+            ]}
80
+            placeholder="请选择"
81
+            width={460}
82
+            allowClear={false}
83
+            rules={[{ required: true, message: '请选择是否食材' }]}
84
+          />
85
+        </ProForm>
86
+      </Card>
87
+    </PageContainer>
88
+  );
89
+};

+ 97
- 0
src/pages/stockClassification/list/index.jsx Zobrazit soubor

@@ -0,0 +1,97 @@
1
+
2
+import { getStoreTypeList,deleteStoreType } from '@/services/api/stock';
3
+import { queryTable } from '@/utils/request';
4
+import { PageContainer, ProTable } from '@ant-design/pro-components';
5
+import { history } from '@umijs/max';
6
+import { Button, message, Popconfirm } from 'antd';
7
+import { useRef, useState } from 'react';
8
+
9
+const StockList = (props) => {
10
+  const [showDetail, setShowDetail] = useState(false);
11
+  const [activeKey, setActiveKey] = useState('');
12
+  const actionRef = useRef();
13
+
14
+
15
+
16
+  const handleDelete = (id) => {
17
+    if (id) {
18
+      deleteStoreType(id).then((res) => {
19
+        message.success('删除成功');
20
+        actionRef.current.reload();
21
+      });
22
+    }
23
+  };
24
+
25
+  const columns = [
26
+    {
27
+      title: '分类名称',
28
+      dataIndex: 'name',
29
+    },
30
+
31
+    {
32
+      title: '排序',
33
+      dataIndex: 'isFood',
34
+      search: false,
35
+      valueEnum: {
36
+        1: '是',
37
+        0: '否',
38
+      },
39
+    },
40
+
41
+    {
42
+      title: '操作',
43
+      valueType: 'option',
44
+      width: 200,
45
+      render: (_, record) => [
46
+        <Button
47
+          key={2}
48
+          style={{ padding: 0 }}
49
+          type="link"
50
+          onClick={() => {
51
+            history.push(`/stockClassification/edit?id=${record.id}`);
52
+          }}
53
+        >
54
+          修改
55
+        </Button>,
56
+
57
+        <Popconfirm
58
+          key={3}
59
+          title="您是否确认删除 ?"
60
+          onConfirm={() => handleDelete(record.id)}
61
+          okText="确定"
62
+          cancelText="取消"
63
+        >
64
+          {/* manualPush */}
65
+          <Button style={{ padding: 0 }} type="link">
66
+            删除
67
+          </Button>
68
+        </Popconfirm>,
69
+      ],
70
+    },
71
+  ];
72
+
73
+  return (
74
+    <PageContainer>
75
+      <ProTable
76
+        actionRef={actionRef}
77
+        rowKey="id"
78
+        toolBarRender={() => [
79
+          <Button
80
+            key="2"
81
+            type="primary"
82
+            onClick={() => {
83
+              history.push('/stockClassification/edit');
84
+            }}
85
+          >
86
+            新增
87
+          </Button>,
88
+        ]}
89
+        // search={false}
90
+        request={queryTable(getStoreTypeList)}
91
+        columns={columns}
92
+      />
93
+    </PageContainer>
94
+  );
95
+};
96
+
97
+export default StockList;

+ 107
- 0
src/services/api/stock.js Zobrazit soubor

@@ -0,0 +1,107 @@
1
+import { request } from '@umijs/max';
2
+
3
+// 库存
4
+/**
5
+ * 查询列表
6
+ * @param {*} params
7
+ * @returns
8
+ */
9
+export const getStoreList = (params) => request('/store', { params });
10
+
11
+/**
12
+ * 新增
13
+ * @param {*} data
14
+ * @returns
15
+ */
16
+export const addStore = (data) => request('/store', { method: 'post', data });
17
+
18
+/**
19
+ * 详情
20
+ * @param {*} id
21
+ * @returns
22
+ */
23
+export const getStoreById = (id) => request(`/store/${id}`);
24
+
25
+/**
26
+ * 编辑
27
+ *  @param {*} id
28
+ * @param {*} data
29
+ * @returns
30
+ */
31
+export const updataStore = (id, data) => request(`/store/${id}`, { method: 'put', data });
32
+
33
+/**
34
+ * 删除
35
+ * @param {*} id
36
+ * @returns
37
+ */
38
+export const deleteStore = (id) => request(`/store/${id}`, { method: 'delete' });
39
+
40
+/**
41
+ * 导出
42
+ * @param {*} params
43
+ * @returns
44
+ */
45
+export const storeExport = (params) => request('/store/export',  { responseType: 'arraybuffer', params });
46
+
47
+
48
+// 库存分类
49
+/**
50
+ * 查询列表
51
+ * @param {*} params
52
+ * @returns
53
+ */
54
+export const getStoreTypeList = (params) => request('/storeType', { params });
55
+
56
+/**
57
+ * 新增
58
+ * @param {*} data
59
+ * @returns
60
+ */
61
+export const addStoreType = (data) => request('/storeType', { method: 'post', data });
62
+
63
+/**
64
+ * 详情
65
+ * @param {*} id
66
+ * @returns
67
+ */
68
+export const getStoreTypeById = (id) => request(`/storeType/${id}`);
69
+
70
+/**
71
+ * 编辑
72
+ *  @param {*} id
73
+ * @param {*} data
74
+ * @returns
75
+ */
76
+export const updataStoreType = (id, data) => request(`/storeType/${id}`, { method: 'put', data });
77
+
78
+/**
79
+ * 删除
80
+ * @param {*} id
81
+ * @returns
82
+ */
83
+export const deleteStoreType = (id) => request(`/storeType/${id}`, { method: 'delete' });
84
+
85
+// 库存日志
86
+
87
+/**
88
+ * 查询列表
89
+ * @param {*} params
90
+ * @returns
91
+ */
92
+export const getStoreLogList = (params) => request('/storeLog', { params });
93
+
94
+/**
95
+ * 新增
96
+ * @param {*} data
97
+ * @returns
98
+ */
99
+export const addStoreLog = (data) => request('/storeLog', { method: 'post', data });
100
+
101
+
102
+/**
103
+ * 导出
104
+ * @param {*} params
105
+ * @returns
106
+ */
107
+ export const storeLogExport = (params) => request('/storeLog/export',  { responseType: 'arraybuffer', params });

+ 1
- 1
src/utils/download.js Zobrazit soubor

@@ -3,7 +3,7 @@ export function fetchBlob(url) {
3 3
 }
4 4
 
5 5
 export function downloadBlob(blob, fileName) {
6
-  const url = window.URL.createObjectURL(blob);
6
+  const url = window.URL.createObjectURL(new Blob([blob]));
7 7
   const link = document.createElement('a');
8 8
   link.href = url;
9 9
   link.setAttribute('download', fileName);

+ 34
- 11
src/utils/request.js Zobrazit soubor

@@ -19,7 +19,14 @@ function requestInterceptor(url, options) {
19 19
   };
20 20
 }
21 21
 
22
-function responseInterceptor(response) {
22
+async function responseInterceptor(response) {
23
+  console.log(response, 'responseresponse');
24
+
25
+  if (response.headers['content-type'] === 'application/vnd.ms-excel;charset=utf-8') {
26
+    console.log(response.data, 'data');
27
+    return response;
28
+  }
29
+
23 30
   const { data } = response;
24 31
   if (data.code === 1000) {
25 32
     return data;
@@ -36,12 +43,13 @@ export const requestConfig = {
36 43
 
37 44
 export function queryTable(apiRequest) {
38 45
   return function (params) {
46
+    const { current, pageSize, ...leftParams } = params;
39 47
     return apiRequest({
40
-      ...params,
48
+      pageSize,
41 49
       pageNum: params.current,
50
+      ...(leftParams || {}),
42 51
     })
43 52
       .then((res) => {
44
-        console.log(res, '--000');
45 53
         return {
46 54
           data: res.records,
47 55
           success: true,
@@ -55,11 +63,26 @@ export function queryTable(apiRequest) {
55 63
       });
56 64
   };
57 65
 }
58
-// return {
59
-//   data: msg.result,
60
-//   // success 请返回 true,
61
-//   // 不然 table 会停止解析数据,即使有数据
62
-//   success: boolean,
63
-//   // 不传会使用 data 的长度,如果是分页一定要传
64
-//   total: number,
65
-// };
66
+
67
+export function queryDict(apiRequest) {
68
+  return function (params, labelKey = 'name', valueKey = 'id') {
69
+    const { current, pageSize, ...leftParams } = params || {};
70
+    return apiRequest({
71
+      pageSize: 9999,
72
+      pageNum: 1,
73
+      ...(leftParams || {}),
74
+    })
75
+      .then((res) => {
76
+        return res?.records?.map((x) => ({
77
+          label: x[labelKey],
78
+          value: x[valueKey],
79
+          ...x,
80
+        }));
81
+      })
82
+      .catch((err) => {
83
+        return {
84
+          success: false,
85
+        };
86
+      });
87
+  };
88
+}