Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
merchant-manage-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
merchant-manage-ui
Commits
74b477ce
Commit
74b477ce
authored
Jul 30, 2022
by
武广
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修改门店信息
parent
5ec86b4f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
16 deletions
+90
-16
storeModal.jsx
src/pages/chainStoreManage/components/storeModal.jsx
+68
-13
index.jsx
src/pages/chainStoreManage/index.jsx
+10
-3
services.js
src/pages/chainStoreManage/services.js
+12
-0
No files found.
src/pages/chainStoreManage/components/storeModal.jsx
View file @
74b477ce
...
@@ -12,10 +12,11 @@ import {
...
@@ -12,10 +12,11 @@ import {
Radio
,
Radio
,
notification
,
notification
,
}
from
'
antd
'
;
}
from
'
antd
'
;
import
{
apiAddrArea
,
apiCreatStore
}
from
'
../services
'
;
import
{
apiAddrArea
,
apiCreatStore
,
apiEditStore
}
from
'
../services
'
;
import
{
weekOptions
,
weekDefault
,
layout
}
from
'
../data
'
;
import
{
weekOptions
,
weekDefault
,
layout
}
from
'
../data
'
;
import
MapModal
from
'
@/components/BaiduMap
'
;
import
MapModal
from
'
@/components/BaiduMap
'
;
import
style
from
'
./style.less
'
;
import
style
from
'
./style.less
'
;
// import { await } from '@umijs/deps/compiled/signale';
const
FormItem
=
Form
.
Item
;
const
FormItem
=
Form
.
Item
;
...
@@ -23,12 +24,13 @@ const StoreModal = props => {
...
@@ -23,12 +24,13 @@ const StoreModal = props => {
const
{
const
{
visible
,
visible
,
onCancel
,
onCancel
,
form
:
{
getFieldDecorator
,
getFieldValue
,
setFieldsValue
,
validateFields
,
resetFields
},
form
:
{
getFieldDecorator
,
setFieldsValue
,
validateFields
,
resetFields
},
form
Data
,
form
Info
,
}
=
props
;
}
=
props
;
const
[
areaAddr
,
setAreaAddr
]
=
useState
([]);
const
[
areaAddr
,
setAreaAddr
]
=
useState
([]);
const
[
visibleMap
,
setVisibleMap
]
=
useState
(
false
);
const
[
visibleMap
,
setVisibleMap
]
=
useState
(
false
);
const
[
times
,
setTimes
]
=
useState
([{
name
:
'
time0
'
}]);
const
[
times
,
setTimes
]
=
useState
([{
name
:
'
time0
'
}]);
const
[
formData
,
setFormData
]
=
useState
({});
const
divDom
=
useRef
();
const
divDom
=
useRef
();
...
@@ -39,7 +41,7 @@ const StoreModal = props => {
...
@@ -39,7 +41,7 @@ const StoreModal = props => {
const
onSubmit
=
()
=>
{
const
onSubmit
=
()
=>
{
validateFields
(
async
(
error
,
fieldsValue
)
=>
{
validateFields
(
async
(
error
,
fieldsValue
)
=>
{
if
(
!
error
)
{
if
(
!
error
)
{
const
params
=
Object
.
assign
({},
fieldsValue
);
const
params
=
Object
.
assign
({},
f
ormInfo
,
f
ieldsValue
);
const
areaArr
=
[
'
provinceId
'
,
'
cityId
'
,
'
countyId
'
,
'
townId
'
];
const
areaArr
=
[
'
provinceId
'
,
'
cityId
'
,
'
countyId
'
,
'
townId
'
];
if
(
params
.
addr
&&
params
.
addr
.
forEach
)
{
if
(
params
.
addr
&&
params
.
addr
.
forEach
)
{
params
.
addr
.
forEach
((
item
,
i
)
=>
{
params
.
addr
.
forEach
((
item
,
i
)
=>
{
...
@@ -66,7 +68,11 @@ const StoreModal = props => {
...
@@ -66,7 +68,11 @@ const StoreModal = props => {
weeks
:
params
.
week
,
weeks
:
params
.
week
,
hoursItems
,
hoursItems
,
};
};
const
res
=
await
apiCreatStore
(
params
);
let
api
=
apiCreatStore
;
if
(
params
.
id
)
{
api
=
apiEditStore
;
}
const
res
=
await
api
(
params
);
if
(
res
===
'
0000
'
)
{
if
(
res
===
'
0000
'
)
{
notification
.
success
({
message
:
'
保存成功
'
});
notification
.
success
({
message
:
'
保存成功
'
});
handleCancel
(
true
);
handleCancel
(
true
);
...
@@ -79,9 +85,12 @@ const StoreModal = props => {
...
@@ -79,9 +85,12 @@ const StoreModal = props => {
const
openMap
=
v
=>
setVisibleMap
(
v
);
const
openMap
=
v
=>
setVisibleMap
(
v
);
// 获取地址省
// 获取地址省
const
getAreaAddr
=
async
()
=>
{
const
getAreaAddr
=
async
id
=>
{
const
res
=
await
apiAddrArea
();
const
params
=
{};
console
.
log
(
'
res :>>
'
,
res
);
if
(
id
)
{
params
.
parentId
=
id
;
}
const
res
=
await
apiAddrArea
(
params
);
if
(
res
)
{
if
(
res
)
{
const
arr
=
res
.
map
(
item
=>
({
const
arr
=
res
.
map
(
item
=>
({
isLeaf
:
false
,
isLeaf
:
false
,
...
@@ -90,7 +99,9 @@ const StoreModal = props => {
...
@@ -90,7 +99,9 @@ const StoreModal = props => {
value
:
item
.
addrId
,
value
:
item
.
addrId
,
}));
}));
setAreaAddr
(
arr
);
setAreaAddr
(
arr
);
return
arr
;
}
}
return
[];
};
};
// 获取市区街道
// 获取市区街道
...
@@ -137,10 +148,46 @@ const StoreModal = props => {
...
@@ -137,10 +148,46 @@ const StoreModal = props => {
});
});
};
};
const
getLazyAddr
=
async
info
=>
{
const
arr
=
await
getAreaAddr
();
const
parr
=
arr
.
filter
(
item
=>
+
item
.
value
===
+
info
.
provinceId
);
parr
[
0
].
children
=
await
getAreaAddr
(
parr
[
0
].
value
);
const
carr
=
parr
[
0
].
children
.
filter
(
item
=>
+
item
.
value
===
+
info
.
cityId
);
carr
[
0
].
children
=
await
getAreaAddr
(
carr
[
0
].
value
);
if
(
info
.
townId
)
{
const
aarr
=
carr
[
0
].
children
.
filter
(
item
=>
+
item
.
value
===
+
info
.
countyId
);
aarr
[
0
].
children
=
await
getAreaAddr
(
aarr
[
0
].
value
);
}
setAreaAddr
([...
arr
]);
};
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
props
.
visible
)
{
if
(
props
.
visible
)
{
resetFields
();
resetFields
();
getAreaAddr
();
const
info
=
Object
.
assign
({},
formInfo
);
if
(
info
&&
info
.
id
)
{
info
.
week
=
info
.
businessHours
.
weeks
;
const
hours
=
info
.
businessHours
.
hoursItems
;
const
harr
=
[];
if
(
hours
&&
hours
.
length
)
{
hours
.
forEach
((
item
,
i
)
=>
{
info
[
`time
${
i
}
`
]
=
[
moment
(
item
.
begin
,
'
HH:mm
'
),
moment
(
item
.
end
,
'
HH:mm
'
)];
harr
.
push
({
name
:
`time
${
i
}
`
,
});
});
}
info
.
lnglat
=
`
${
info
.
longitude
}
,
${
info
.
latitude
}
`
;
info
.
addr
=
[
info
.
provinceId
,
info
.
cityId
,
info
.
countyId
];
if
(
info
.
townId
)
{
info
.
addr
.
push
(
info
.
townId
);
}
setTimes
(
harr
);
setFormData
(
info
);
getLazyAddr
(
info
);
}
else
{
getAreaAddr
(
0
);
}
}
}
},
[
visible
]);
},
[
visible
]);
...
@@ -157,13 +204,13 @@ const StoreModal = props => {
...
@@ -157,13 +204,13 @@ const StoreModal = props => {
{
getFieldDecorator
(
'
name
'
,
{
{
getFieldDecorator
(
'
name
'
,
{
rules
:
[{
required
:
true
,
message
:
'
请输入门店名称!
'
}],
rules
:
[{
required
:
true
,
message
:
'
请输入门店名称!
'
}],
initialValue
:
formData
.
name
,
initialValue
:
formData
.
name
,
})(<
Input
placeholder=
"请输入门店名称"
maxLength=
{
50
}
/>)
}
})(<
Input
placeholder=
"请输入门店名称"
allowClear
maxLength=
{
50
}
/>)
}
</
FormItem
>
</
FormItem
>
<
FormItem
label=
"门店电话"
name=
"phone"
>
<
FormItem
label=
"门店电话"
name=
"phone"
>
{
getFieldDecorator
(
'
phone
'
,
{
{
getFieldDecorator
(
'
phone
'
,
{
rules
:
[{
required
:
true
,
message
:
'
请输入门店电话!
'
}],
rules
:
[{
required
:
true
,
message
:
'
请输入门店电话!
'
}],
initialValue
:
formData
.
phone
,
initialValue
:
formData
.
phone
,
})(<
Input
placeholder=
"请输入门店电话"
maxLength=
{
20
}
/>)
}
})(<
Input
placeholder=
"请输入门店电话"
allowClear
maxLength=
{
20
}
/>)
}
</
FormItem
>
</
FormItem
>
<
FormItem
label=
"营业时间"
required
>
<
FormItem
label=
"营业时间"
required
>
{
times
&&
{
times
&&
...
@@ -173,6 +220,7 @@ const StoreModal = props => {
...
@@ -173,6 +220,7 @@ const StoreModal = props => {
<
FormItem
name=
{
item
.
name
}
>
<
FormItem
name=
{
item
.
name
}
>
{
getFieldDecorator
(
item
.
name
,
{
{
getFieldDecorator
(
item
.
name
,
{
rules
:
[{
required
:
true
,
message
:
'
请选择营业时间!
'
}],
rules
:
[{
required
:
true
,
message
:
'
请选择营业时间!
'
}],
initialValue
:
formData
[
item
.
name
],
})(<
TimePicker
.
RangePicker
format=
"HH:mm"
/>)
}
})(<
TimePicker
.
RangePicker
format=
"HH:mm"
/>)
}
</
FormItem
>
</
FormItem
>
</
div
>
</
div
>
...
@@ -206,13 +254,20 @@ const StoreModal = props => {
...
@@ -206,13 +254,20 @@ const StoreModal = props => {
{
getFieldDecorator
(
'
address
'
,
{
{
getFieldDecorator
(
'
address
'
,
{
rules
:
[{
required
:
true
,
message
:
'
请输入详细地址!
'
}],
rules
:
[{
required
:
true
,
message
:
'
请输入详细地址!
'
}],
initialValue
:
formData
.
address
,
initialValue
:
formData
.
address
,
})(<
Input
placeholder=
"请输入详细地址"
maxLength=
{
100
}
/>)
}
})(<
Input
placeholder=
"请输入详细地址"
allowClear
maxLength=
{
100
}
/>)
}
</
FormItem
>
</
FormItem
>
<
FormItem
label=
"经纬度"
>
<
FormItem
label=
"经纬度"
>
{
getFieldDecorator
(
'
lnglat
'
,
{
{
getFieldDecorator
(
'
lnglat
'
,
{
rules
:
[{
required
:
true
,
message
:
'
请选择经纬度!
'
}],
rules
:
[{
required
:
true
,
message
:
'
请选择经纬度!
'
}],
initialValue
:
formData
.
lnglat
,
initialValue
:
formData
.
lnglat
,
})(<
Input
placeholder=
"请选择经纬度"
onClick=
{
()
=>
openMap
(
true
)
}
maxLength=
{
100
}
/>)
}
})(
<
Input
placeholder=
"请选择经纬度"
readOnly
onClick=
{
()
=>
openMap
(
true
)
}
maxLength=
{
100
}
/>,
)
}
</
FormItem
>
</
FormItem
>
<
FormItem
label=
"是否启用"
>
<
FormItem
label=
"是否启用"
>
{
getFieldDecorator
(
'
state
'
,
{
{
getFieldDecorator
(
'
state
'
,
{
...
...
src/pages/chainStoreManage/index.jsx
View file @
74b477ce
...
@@ -20,6 +20,11 @@ export default () => {
...
@@ -20,6 +20,11 @@ export default () => {
}
}
};
};
const
onCreate
=
()
=>
{
const
onCreate
=
()
=>
{
setStoreInfo
({});
setVisible
(
true
);
};
const
onShowInfo
=
info
=>
{
setStoreInfo
(
info
);
setVisible
(
true
);
setVisible
(
true
);
};
};
const
closeModal
=
isReload
=>
{
const
closeModal
=
isReload
=>
{
...
@@ -96,7 +101,6 @@ export default () => {
...
@@ -96,7 +101,6 @@ export default () => {
valueEnum
:
stateDesc
,
valueEnum
:
stateDesc
,
hideInSearch
:
true
,
hideInSearch
:
true
,
width
:
120
,
width
:
120
,
// render: state => <span>{`${stateDesc[state]}`}</span>,
},
},
{
{
title
:
'
创建时间
'
,
title
:
'
创建时间
'
,
...
@@ -108,12 +112,15 @@ export default () => {
...
@@ -108,12 +112,15 @@ export default () => {
title
:
'
操作
'
,
title
:
'
操作
'
,
hideInSearch
:
true
,
hideInSearch
:
true
,
dataIndex
:
'
action
'
,
dataIndex
:
'
action
'
,
width
:
1
0
0
,
width
:
1
7
0
,
fixed
:
'
right
'
,
fixed
:
'
right
'
,
render
:
(
val
,
r
)
=>
[
render
:
(
val
,
r
)
=>
[
<
Button
onClick=
{
()
=>
onEnableState
(
r
)
}
type=
"primary"
>
<
Button
onClick=
{
()
=>
onEnableState
(
r
)
}
type=
"primary"
>
{
+
r
.
state
?
'
禁用
'
:
'
启用
'
}
{
+
r
.
state
?
'
禁用
'
:
'
启用
'
}
</
Button
>,
</
Button
>,
<
Button
style=
{
{
marginLeft
:
'
10px
'
}
}
onClick=
{
()
=>
onShowInfo
(
r
)
}
>
查看
</
Button
>,
],
],
},
},
];
];
...
@@ -140,7 +147,7 @@ export default () => {
...
@@ -140,7 +147,7 @@ export default () => {
</
Button
>,
</
Button
>,
]
}
]
}
/>
/>
<
StoreModal
visible=
{
visible
}
onCancel=
{
closeModal
}
form
Data
=
{
storeInfo
}
/>
<
StoreModal
visible=
{
visible
}
onCancel=
{
closeModal
}
form
Info
=
{
storeInfo
}
/>
</
div
>
</
div
>
);
);
};
};
src/pages/chainStoreManage/services.js
View file @
74b477ce
...
@@ -62,3 +62,15 @@ export async function apiCreatStore(params) {
...
@@ -62,3 +62,15 @@ export async function apiCreatStore(params) {
});
});
return
data
.
businessCode
;
return
data
.
businessCode
;
}
}
// 更新门店
export
async
function
apiEditStore
(
params
)
{
const
data
=
await
request
.
post
(
'
/shop/update
'
,
{
prefix
:
kdspApi
,
data
:
params
,
// headers: {
// 'Content-Type': 'application/x-www-form-urlencoded',
// },
});
return
data
.
businessCode
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment