Commit 75355b2c8643b8e0d99d1e07e63fc08b68efa941
Merge branch 'mmd' into 'master'
Mmd See merge request !696
Showing
8 changed files
with
117 additions
and
25 deletions
src/pages/mmd/DeviceAlloc/api.ts
1 | 1 | import { http } from '@/typing/http'; |
2 | 2 | import request from '@/utils/request'; |
3 | -import { MMD_HOST } from '@/utils/host'; | |
3 | +import { MMD_HOST, CONTRACT_HOST } from '@/utils/host'; | |
4 | 4 | import * as common from '@/typing/common'; |
5 | 5 | |
6 | 6 | interface Params extends common.PageParams { |
... | ... | @@ -8,6 +8,7 @@ interface Params extends common.PageParams { |
8 | 8 | deviceType?: number; // 设备类型 1 语音盒子 |
9 | 9 | deviceNo?: number; // 设备编号 |
10 | 10 | rangeId?: number; // 门店id |
11 | + rangeType?: number; // 范围类型 | |
11 | 12 | } |
12 | 13 | |
13 | 14 | export interface ListResult { |
... | ... | @@ -19,6 +20,7 @@ export interface ListResult { |
19 | 20 | createTime?: number; // 创建时间 |
20 | 21 | psCode?: string; // 位置场景编码 |
21 | 22 | psName?: string; // 位置场景名称 |
23 | + rangeType?: number; // 范围类型 | |
22 | 24 | } |
23 | 25 | |
24 | 26 | interface RangeList { |
... | ... | @@ -35,6 +37,7 @@ interface SceneListResult { |
35 | 37 | id?: number; // id |
36 | 38 | name?: string; // 位置场景名称 |
37 | 39 | code?: string; // 位置场景编码 |
40 | + rangeType?: number; // 范围类型 | |
38 | 41 | } |
39 | 42 | |
40 | 43 | interface SaveParams { |
... | ... | @@ -58,6 +61,16 @@ export const Status = [ |
58 | 61 | { label: '已分配', value: 1 }, |
59 | 62 | ]; |
60 | 63 | |
64 | +export const RangeType = [ | |
65 | + {label: '门店', value: 1}, | |
66 | + {label: '餐厅', value: 2} | |
67 | +] | |
68 | + | |
69 | +export enum RangeTypeEnum { | |
70 | + "门店" = 1, | |
71 | + "餐厅" | |
72 | +} | |
73 | + | |
61 | 74 | /** 获取设备分配列表 */ |
62 | 75 | export function getListApi(params: Params): http.PromisePageResp<ListResult> { |
63 | 76 | return request.get(`${MMD_HOST}/deviceAlloc/page/list`, { params }); |
... | ... | @@ -72,3 +85,10 @@ export function getPositionSceneListApi(params: SceneParams): http.PromiseResp<S |
72 | 85 | export function saveDeviceAllocApi(params: SaveParams): http.PromiseResp<string> { |
73 | 86 | return request.post(`${MMD_HOST}/deviceAlloc/save`, params); |
74 | 87 | } |
88 | + | |
89 | +/** | |
90 | + * 分页查询食堂 | |
91 | + */ | |
92 | +export function getCanteenPageListApi(params?: KtCanteenSpace.QueryParams): http.PromisePageResp<KtCanteenSpace.Item> { | |
93 | + return request.get(`${CONTRACT_HOST}/erp/canteen/page`, { params }); | |
94 | +} | |
75 | 95 | \ No newline at end of file | ... | ... |
src/pages/mmd/DeviceAlloc/components/AddModal.tsx
... | ... | @@ -5,32 +5,45 @@ import { saveDeviceAllocApi } from '../api'; |
5 | 5 | import debounce from 'lodash/debounce'; |
6 | 6 | import ShopSelectNew from '@/components/ShopSelectNew'; |
7 | 7 | import { isFinite } from 'lodash'; |
8 | +import SelectorWithFull from '@/components/SelectorWithFull'; | |
9 | + | |
8 | 10 | |
9 | 11 | export default function DetailModal() { |
10 | - const { itemData, setItemData, setLoading, sceneData } = useStore(); | |
12 | + const { itemData, setItemData, setLoading, sceneData, canteenData } = useStore(); | |
11 | 13 | const [confrimLoading, setConfirmLoading] = useState<boolean>(false); |
12 | 14 | const [form] = Form.useForm(); |
15 | + const [rangeType, setRangeType] = useState<number>(); | |
13 | 16 | |
14 | 17 | useEffect(() => { |
15 | 18 | if (itemData.visible) { |
16 | 19 | form.setFieldsValue({ |
17 | - shops: itemData.data?.rangeList?.length ? itemData.data.rangeList.map((v) => ({ label: v.rangeValue, value: v.rangeId })) : [], | |
20 | + shops: itemData.data?.rangeList?.length ? itemData.data.rangeList.map((v) => ({ label: v.rangeValue, value: v.rangeId })) : undefined, | |
18 | 21 | psCode: itemData.data.psCode && isFinite(+itemData.data?.psCode) ? undefined : itemData.data?.psCode, |
19 | 22 | }); |
23 | + setRangeType(itemData.data.rangeList?.length ? itemData.data?.rangeType : undefined); | |
20 | 24 | } |
21 | 25 | }, [itemData.visible]); |
22 | 26 | |
23 | 27 | const handleCancel = () => { |
24 | 28 | form.resetFields(); |
29 | + setRangeType(undefined); | |
25 | 30 | setItemData({ visible: false, type: undefined, data: {} }); |
26 | 31 | }; |
27 | 32 | |
33 | + function handleSceneChange(value?: number, option?: any) { | |
34 | + if (rangeType != option.rangeType) { | |
35 | + form.setFieldsValue({shops: undefined}); | |
36 | + } | |
37 | + setRangeType(option.rangeType) | |
38 | + } | |
39 | + | |
28 | 40 | async function handleSubmit() { |
29 | 41 | const params = await form.validateFields(); |
30 | 42 | const _params = { |
31 | 43 | id: itemData.data?.id, |
32 | 44 | psCode: params.psCode, |
33 | 45 | rangeIds: params.shops?.map((v: any) => v.value)?.join(','), |
46 | + rangeType | |
34 | 47 | }; |
35 | 48 | setConfirmLoading(true); |
36 | 49 | saveDeviceAllocApi(_params) |
... | ... | @@ -73,12 +86,29 @@ export default function DetailModal() { |
73 | 86 | filterOption |
74 | 87 | optionFilterProp="label" |
75 | 88 | placeholder="请选择" |
76 | - options={sceneData.map((v) => ({ label: v.name, value: v.code }))} | |
89 | + options={sceneData.map((v) => ({ label: v.name, value: v.code, rangeType: v.rangeType }))} | |
90 | + onChange={(value, option) => handleSceneChange(value, option)} | |
77 | 91 | /> |
78 | 92 | </Form.Item> |
79 | - <Form.Item name="shops" label="授权范围" rules={[{ required: true, message: '请选择授权范围!' }]}> | |
80 | - <ShopSelectNew placeholder="请选择" multiple /> | |
81 | - </Form.Item> | |
93 | + {rangeType == 1 ? ( | |
94 | + <Form.Item name="shops" label="授权范围" rules={[{ required: true, message: '请选择授权范围!' }]}> | |
95 | + <ShopSelectNew placeholder="请选择" multiple /> | |
96 | + </Form.Item> | |
97 | + ) : null} | |
98 | + {rangeType == 2 ? ( | |
99 | + <Form.Item label="授权范围" name="shops" rules={[{ required: true, message: '请选择授权范围!' }]}> | |
100 | + <Select | |
101 | + placeholder="请选择授权范围" | |
102 | + mode="multiple" | |
103 | + filterOption | |
104 | + optionFilterProp='label' | |
105 | + showSearch | |
106 | + allowClear | |
107 | + labelInValue | |
108 | + options={canteenData.map(v => ({label: v.name, value: v.id})) || []} | |
109 | + /> | |
110 | + </Form.Item> | |
111 | + ) : null} | |
82 | 112 | </Form> |
83 | 113 | </Modal> |
84 | 114 | ); | ... | ... |
src/pages/mmd/DeviceAlloc/components/List.tsx
... | ... | @@ -34,12 +34,12 @@ export default function LargeList() { |
34 | 34 | <Column title="设备类型" dataIndex="deviceType" align="left" render={(_text) => _text && DeviceTypeEnum[_text]} /> |
35 | 35 | <Column title="设备编号" dataIndex="deviceNo" align="left" /> |
36 | 36 | <Column |
37 | - title="门店授权范围" | |
37 | + title="授权范围" | |
38 | 38 | // width="200px" |
39 | 39 | // ellipsis |
40 | 40 | dataIndex="rangeList" |
41 | 41 | align="left" |
42 | - render={(_text) => _text && <TableArrayColumnFormat unit="个门店" key="rangeId" showKey="rangeValue" data={_text} />} | |
42 | + render={(_text, record: ListResult) => _text && <TableArrayColumnFormat unit={record.rangeType == 2 ? '个餐厅' : '个门店'} key="rangeId" showKey="rangeValue" data={_text} />} | |
43 | 43 | /> |
44 | 44 | <Column title="分配状态" dataIndex="status" align="left" render={(_text) => !isNil(_text) && StatusEnum[_text]} /> |
45 | 45 | {/* <Column title="位置场景编码" dataIndex="psCode" align="left" /> */} |
... | ... | @@ -50,7 +50,7 @@ export default function LargeList() { |
50 | 50 | dataIndex="option" |
51 | 51 | align="left" |
52 | 52 | render={(_text, record: ListResult) => ( |
53 | - <Space> | |
53 | + <Space wrap> | |
54 | 54 | <a style={{ color: '#4189FD' }} onClick={() => handleEdit(record)}> |
55 | 55 | 编辑绑定 |
56 | 56 | </a> | ... | ... |
src/pages/mmd/DeviceAlloc/index.tsx
... | ... | @@ -5,13 +5,13 @@ import { createStore } from '@/hooks/moz'; |
5 | 5 | import store from './store'; |
6 | 6 | import List from './components/List'; |
7 | 7 | import EditMoadal from './components/AddModal'; |
8 | -import { DeviceType, Status } from './api'; | |
8 | +import { DeviceType, Status, RangeType, RangeTypeEnum } from './api'; | |
9 | 9 | import { debounce } from 'lodash'; |
10 | 10 | |
11 | 11 | export const { Provider, useStore } = createStore(store); |
12 | 12 | |
13 | 13 | function PositionScene() { |
14 | - const { setParams, innerParams, shopData } = useStore(); | |
14 | + const { setParams, innerParams, shopData, canteenData } = useStore(); | |
15 | 15 | |
16 | 16 | const handleChange = debounce((e: any) => { |
17 | 17 | setParams({ ...innerParams, deviceNo: e }, true); |
... | ... | @@ -36,16 +36,40 @@ function PositionScene() { |
36 | 36 | placeholder="请选择分配状态" |
37 | 37 | options={Status} |
38 | 38 | /> |
39 | + | |
39 | 40 | <Select |
40 | 41 | style={{ width: '200px' }} |
41 | 42 | allowClear |
42 | - onChange={(value) => setParams({ ...innerParams, rangeId: value }, true)} | |
43 | - placeholder="请选择授权门店" | |
44 | - filterOption | |
45 | - showSearch | |
46 | - optionFilterProp="label" | |
47 | - options={shopData.map((v) => ({ label: v.name, value: v.id }))} | |
43 | + onChange={(value) => setParams({ ...innerParams, rangeType: value, rangeId: undefined }, true)} | |
44 | + placeholder="请选择范围类型" | |
45 | + options={RangeType} | |
48 | 46 | /> |
47 | + | |
48 | + {innerParams?.rangeType === 1 ? ( | |
49 | + <Select | |
50 | + style={{ width: '200px' }} | |
51 | + allowClear | |
52 | + onChange={(value) => setParams({ ...innerParams, rangeId: value }, true)} | |
53 | + placeholder="请选择授权门店" | |
54 | + filterOption | |
55 | + showSearch | |
56 | + optionFilterProp="label" | |
57 | + options={shopData.map((v) => ({ label: v.name, value: v.id }))} | |
58 | + /> | |
59 | + ) : null} | |
60 | + | |
61 | + {innerParams?.rangeType === 2 ? ( | |
62 | + <Select | |
63 | + style={{ width: '200px' }} | |
64 | + allowClear | |
65 | + onChange={(value) => setParams({ ...innerParams, rangeId: value }, true)} | |
66 | + placeholder="请选择授权餐厅" | |
67 | + filterOption | |
68 | + showSearch | |
69 | + optionFilterProp="label" | |
70 | + options={canteenData.map((v) => ({ label: v.name, value: v.id }))} | |
71 | + /> | |
72 | + ) : null} | |
49 | 73 | </Space> |
50 | 74 | </Row> |
51 | 75 | <List /> | ... | ... |
src/pages/mmd/DeviceAlloc/store.ts
1 | 1 | import React, { useState } from 'react'; |
2 | 2 | import usePagination from '@/hooks/usePagination'; |
3 | -import { getListApi, ListResult, getPositionSceneListApi } from './api'; | |
3 | +import { getListApi, ListResult, getPositionSceneListApi, getCanteenPageListApi } from './api'; | |
4 | 4 | import useInitail from '@/hooks/useInitail'; |
5 | 5 | import { getShopApi } from '@/common/api'; |
6 | 6 | |
... | ... | @@ -12,6 +12,7 @@ interface ModalData { |
12 | 12 | |
13 | 13 | export default function useStore() { |
14 | 14 | const { list, setParams, setLoading, loading, paginationConfig, innerParams } = usePagination(getListApi, { pageSize: 10, current: 1 }); |
15 | + const { list: canteenData } = usePagination(getCanteenPageListApi, { pageSize: 200, current: 1 }); | |
15 | 16 | const { data: sceneData } = useInitail(getPositionSceneListApi, [], {}); |
16 | 17 | const { data: shopData } = useInitail(getShopApi, [], {}); |
17 | 18 | const [itemData, setItemData] = useState<ModalData>({ visible: false, data: {} }); |
... | ... | @@ -26,5 +27,6 @@ export default function useStore() { |
26 | 27 | paginationConfig, |
27 | 28 | sceneData, |
28 | 29 | shopData, |
30 | + canteenData | |
29 | 31 | }; |
30 | 32 | } | ... | ... |
src/pages/mmd/PositionScene/api.ts
... | ... | @@ -13,6 +13,7 @@ export interface ListResult { |
13 | 13 | code?: string; // 方位编码 |
14 | 14 | createTime?: number; // 创建时间 |
15 | 15 | yn?: number; // 1.正常-1逻辑删除 |
16 | + rangeType?: number; // 配置范围 | |
16 | 17 | } |
17 | 18 | |
18 | 19 | interface SceneParams { |
... | ... | @@ -24,11 +25,23 @@ export interface SceneListResult { |
24 | 25 | id?: number; // id |
25 | 26 | name?: string; // 位置场景名称 |
26 | 27 | code?: string; // 位置场景编码 |
28 | + rangeType?: number; // 配置范围 | |
27 | 29 | } |
28 | 30 | |
29 | 31 | interface SaveParams { |
30 | 32 | id?: number; // id |
31 | 33 | name?: string; // 位置场景名称 |
34 | + rangeType?: number; // 允许范围 | |
35 | +} | |
36 | + | |
37 | +export const RangeTypeValue = [ | |
38 | + {label: '门店', value: 1}, | |
39 | + {label: '餐厅', value: 2}, | |
40 | +] | |
41 | + | |
42 | +export enum RangeTypeEnum { | |
43 | + "门店" = 1, | |
44 | + "餐厅" | |
32 | 45 | } |
33 | 46 | |
34 | 47 | /** 获取场景位置列表 */ | ... | ... |
src/pages/mmd/PositionScene/components/AddModal.tsx
1 | 1 | import React, { useState, useEffect } from 'react'; |
2 | -import { Modal, Button, message, Form, Input } from 'antd'; | |
2 | +import { Modal, Button, message, Form, Input, Select } from 'antd'; | |
3 | 3 | import { useStore } from '../index'; |
4 | -import { savePositionSceneApi } from '../api'; | |
4 | +import { savePositionSceneApi, RangeTypeValue } from '../api'; | |
5 | 5 | import debounce from 'lodash/debounce'; |
6 | 6 | |
7 | 7 | export default function DetailModal() { |
... | ... | @@ -14,6 +14,7 @@ export default function DetailModal() { |
14 | 14 | form.setFieldsValue({ |
15 | 15 | name: itemData.data?.name, |
16 | 16 | code: itemData.data?.code, |
17 | + rangeType: itemData.data?.rangeType, | |
17 | 18 | }); |
18 | 19 | } |
19 | 20 | }, [itemData.visible]); |
... | ... | @@ -26,7 +27,7 @@ export default function DetailModal() { |
26 | 27 | async function handleSubmit() { |
27 | 28 | const params = await form.validateFields(); |
28 | 29 | setConfirmLoading(true); |
29 | - savePositionSceneApi({ name: params.name, id: itemData.data?.id }) | |
30 | + savePositionSceneApi({ name: params.name, id: itemData.data?.id, rangeType: params.rangeType }) | |
30 | 31 | .then((res) => { |
31 | 32 | setConfirmLoading(false); |
32 | 33 | message.success(res.result); |
... | ... | @@ -47,7 +48,6 @@ export default function DetailModal() { |
47 | 48 | open={itemData.visible} |
48 | 49 | maskClosable={false} |
49 | 50 | onCancel={handleCancel} |
50 | - width="40%" | |
51 | 51 | afterClose={form.resetFields} |
52 | 52 | footer={[ |
53 | 53 | <Button key="cancel" loading={confrimLoading} disabled={confrimLoading} onClick={handleCancel} style={{ marginLeft: 10 }}> |
... | ... | @@ -62,6 +62,9 @@ export default function DetailModal() { |
62 | 62 | <Form.Item label="位置场景" rules={[{ required: true, message: '请输入位置场景名称' }]} name="name"> |
63 | 63 | <Input placeholder="请输入位置场景名称" /> |
64 | 64 | </Form.Item> |
65 | + <Form.Item label="场景范围" rules={[{ required: true, message: '请选择场景范围' }]} name="rangeType"> | |
66 | + <Select optionFilterProp='label' showSearch allowClear placeholder="请选择场景范围" options={RangeTypeValue} /> | |
67 | + </Form.Item> | |
65 | 68 | {itemData.type === 2 ? ( |
66 | 69 | <Form.Item label="场景编码" name="code"> |
67 | 70 | <Input disabled /> | ... | ... |
src/pages/mmd/PositionScene/components/List.tsx
1 | 1 | import React from 'react'; |
2 | 2 | import { Table, Popconfirm, message, Space } from 'antd'; |
3 | 3 | import { useStore } from '../index'; |
4 | -import { ListResult, deletePositionSceneApi } from '../api'; | |
4 | +import { ListResult, deletePositionSceneApi, RangeTypeEnum } from '../api'; | |
5 | 5 | import moment from 'moment'; |
6 | -import { isNil, debounce } from 'lodash'; | |
7 | 6 | |
8 | 7 | const Column = Table.Column; |
9 | 8 | |
... | ... | @@ -33,6 +32,7 @@ export default function LargeList() { |
33 | 32 | <Table dataSource={list} loading={loading} rowKey="id" pagination={paginationConfig}> |
34 | 33 | <Column title="方位名称" dataIndex="name" align="left" /> |
35 | 34 | <Column title="方位编码" dataIndex="code" align="left" /> |
35 | + <Column title="场景范围" dataIndex="rangeType" align="left" render={(_text) => _text && RangeTypeEnum[_text] || '--'} /> | |
36 | 36 | <Column title="创建时间" dataIndex="createTime" align="left" render={(_text) => _text && moment(_text).format('YYYY-MM-DD HH:mm:ss')} /> |
37 | 37 | <Column |
38 | 38 | title="操作" | ... | ... |