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
472b32ff
Commit
472b32ff
authored
Mar 19, 2024
by
guang.wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 优化服务展示
parent
f678c23e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
3 deletions
+56
-3
FormInformationBasic.jsx
src/pages/ServiceGoods/components/FormInformationBasic.jsx
+44
-3
service.js
src/pages/ServiceGoods/service.js
+12
-0
No files found.
src/pages/ServiceGoods/components/FormInformationBasic.jsx
View file @
472b32ff
...
...
@@ -22,7 +22,7 @@ import { formItemLayout } from '../config';
import
{
ServiceContext
}
from
'
../context
'
;
import
{
debounce
}
from
'
@/utils/utils
'
;
import
UploadCropImage
from
'
./UploadCropImage
'
;
import
{
apiShopIds
,
apiQueryShopList
,
getByProductType
}
from
'
../service
'
;
import
{
apiShopIds
,
apiQueryShopList
,
apiServiceByCategory
}
from
'
../service
'
;
import
GroupInfo
from
'
../../GoodsManage/Takeaway/components/GroupInfo
'
;
const
CreateSelectOption
=
optionList
=>
...
...
@@ -58,6 +58,8 @@ const FormInformationBasic = forwardRef((props, ref) => {
const
[
isEditTakeaway
,
setIsEditTakeaway
]
=
useState
(
false
);
const
[
isModalOpen
,
setIsModalOpen
]
=
useState
(
false
);
const
[
shopIdSource
,
setShopIdSource
]
=
useState
(
''
);
const
[
serviceList
,
setServiceList
]
=
useState
({});
// 品类下的服务承诺
const
[
specServiceList
,
setSpecServiceList
]
=
useState
([]);
// 服务承诺列表
const
onCheck
=
async
()
=>
{
try
{
...
...
@@ -82,6 +84,25 @@ const FormInformationBasic = forwardRef((props, ref) => {
}
};
// 获取品类下的服务承诺
const
getServiceList
=
async
ids
=>
{
const
id
=
ids
[
ids
.
length
-
1
];
const
res
=
await
apiServiceByCategory
(
id
);
if
(
res
?.
data
?.
length
>
0
)
{
const
obj
=
{};
res
.
data
.
forEach
(
item
=>
{
obj
[
item
.
productServiceId
]
=
item
.
required
;
});
setServiceList
(
obj
);
}
};
const
onCategoryChange
=
ids
=>
{
props
.
onCategoryChange
(
ids
);
getServiceList
(
ids
);
};
// 自定义加入菜单
const
showModal
=
()
=>
{
if
(
shopIdSource
||
editData
?.
productRefShopId
)
{
...
...
@@ -185,6 +206,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
if
(
editData
?.
commonImageList
?.
length
)
{
onTakeawayImageList
(
editData
?.
commonImageList
);
}
getServiceList
(
editData
.
categoryId
);
},
[
customer
.
isEdit
,
editData
]);
useEffect
(()
=>
{
setShopList
([]);
...
...
@@ -200,6 +222,25 @@ const FormInformationBasic = forwardRef((props, ref) => {
};
form
.
setFieldsValue
(
temp
);
},
[
groupShopData
]);
useEffect
(()
=>
{
// 品类下的设置的服务承诺不可选 required true默认选中 false默认不选中
if
(
specListData
.
length
>
0
)
{
const
defaultChecked
=
new
Set
(
editData
?.[
specListData
[
0
].
specId
]
||
[]);
const
arr
=
specListData
[
0
].
specValues
.
map
(
item
=>
{
if
(
serviceList
[
item
.
value
])
{
defaultChecked
.
add
(
item
.
value
);
}
return
{
...
item
,
disabled
:
typeof
serviceList
[
item
.
value
]
===
'
boolean
'
,
};
});
setSpecServiceList
(
arr
);
form
.
setFieldsValue
({
[
specListData
[
0
].
specId
]:
Array
.
from
(
defaultChecked
)
});
}
},
[
serviceList
,
specListData
]);
return
(
<
Form
{
...
formItemLayout
}
...
...
@@ -275,7 +316,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
disabled=
{
customer
.
isEdit
&&
customer
.
isNormal
}
showSearch=
{
{
filter
:
filterCategoryOptions
}
}
fieldNames=
{
{
label
:
'
name
'
,
value
:
'
id
'
,
children
:
'
children
'
}
}
onChange=
{
props
.
onCategoryChange
}
onChange=
{
onCategoryChange
}
options=
{
newCategoryList
[
customer
.
productType
]
}
/>
</
Form
.
Item
>
...
...
@@ -351,7 +392,7 @@ const FormInformationBasic = forwardRef((props, ref) => {
!
customer
.
isCard
&&
specListData
.
map
((
item
,
index
)
=>
(
<
Form
.
Item
name=
{
item
.
specId
}
key=
{
item
.
specId
}
label=
{
item
.
specName
}
>
<
Checkbox
.
Group
options=
{
item
.
specValues
}
/>
<
Checkbox
.
Group
options=
{
specServiceList
}
/>
</
Form
.
Item
>
))
}
...
...
src/pages/ServiceGoods/service.js
View file @
472b32ff
...
...
@@ -176,3 +176,15 @@ export const apiGetShopDetail = data =>
'
Content-Type
'
:
'
application/x-www-form-urlencoded
'
,
},
});
/**
* 获取类目关联服务
* yApi地址: http://yapi.quantgroups.com/project/389/interface/api/69189
* */
export
const
apiServiceByCategory
=
(
categoryId
,
refIdType
=
1
)
=>
request
.
get
(
`/api/merchants/products/service/config/list?refId=
${
categoryId
}
&refIdType=
${
refIdType
}
`
,
{
prefix
:
goodsApi
,
},
);
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