Commit 9d240c03 authored by GuanHua's avatar GuanHua
parents 171cb86a beef48a8
......@@ -13,6 +13,8 @@ import TabAnchor from '@/components/TabAnchor'
import CitySelect from '@/components/CitySelect'
import ImgUpload, { imgUploadRefProps } from '@/components/ImgUpload'
import UploadFiles from '@/pages/transaction/components/uploadFiles'
import { useLocalStore, observer } from 'mobx-react'
import { store } from '@/store'
import styles from './index.less'
......@@ -39,7 +41,8 @@ const defaultCityData = { index: 0, provinceCode: 0, province: '', cityCode: 0,
const OwnMallAboutUs = () => {
const { query: { id } } = history.location;
const SiteStore = useLocalStore(() => store.SiteStore)
const { siteId } = SiteStore
const workshopImgRef = useRef<imgUploadRefProps>()
const honorImgRef = useRef<imgUploadRefProps>()
......@@ -51,11 +54,12 @@ const OwnMallAboutUs = () => {
const [albumUrls, setAlbumUrls] = useState<any[]>([])
const [allMallList, setAllMallList] = useState<any[]>([])
const [selectCityData, setSelectCityData] = useState<any>([defaultCityData])
const [mallUrl, setMallUrl] = useState<string>()
const getAlbumUrls = (data) => {
setAlbumUrls(data);
form.setFieldsValue({
"albumUrls": data
albumUrls: data
})
}
......@@ -64,7 +68,7 @@ const OwnMallAboutUs = () => {
files.splice(index, 1);
setAlbumUrls(files);
form.setFieldsValue({
"albumUrls": files
albumUrls: files
})
}
......@@ -73,7 +77,7 @@ const OwnMallAboutUs = () => {
temp.push(item)
setSelectCityData(temp)
form.setFieldsValue({
city: temp
memberChannelAreas: temp
})
}
......@@ -82,14 +86,22 @@ const OwnMallAboutUs = () => {
temp = temp.filter((item: any) => item.index !== index)
setSelectCityData(temp)
form.setFieldsValue({
city: temp
memberChannelAreas: temp
})
}
const handleCityChange = (data: any) => {
setSelectCityData(data)
form.setFieldsValue({
city: data
memberChannelAreas: data
})
}
// 额外处理商城链接
const selectMall = (value, { url }: any) => {
setMallUrl(url)
form.setFieldsValue({
url
})
}
......@@ -97,19 +109,17 @@ const OwnMallAboutUs = () => {
const onSave = () => {
form.validateFields().then(values => {
console.log(`values`, values)
return
const { albumUrls, ...rest } = values
const params = {
id,
...values,
...rest,
albumName: albumUrls[0]?.name,
albumUrl: albumUrls[0]?.url
}
console.log(`params`, params)
setSaveLoading(true)
const requestApi = id ? PublicApi.postManageActivityShopSeoUpdate : PublicApi.postManageActivityShopSeoAdd
requestApi(params).then(res => {
PublicApi.postManageShopAboutSubmit(params).then(res => {
if (res.code === 1000) {
setIsFormChange(false)
setTimeout(() => {
history.goBack()
}, 500)
}
}).finally(() => {
setSaveLoading(false)
......@@ -117,9 +127,9 @@ const OwnMallAboutUs = () => {
})
}
// 根据站点获取商城信息
// 根据站点获取自营商城
const getAllMallList = () => {
PublicApi.getManageShopFindByDoorType({ doorType: 1 }).then(res => {
PublicApi.getManageWebShopWebFindWebEnterpriseSelfShop({ siteId }).then(res => {
if (res.code === 1000) {
const data = res.data.map(item => {
return {
......@@ -136,17 +146,34 @@ const OwnMallAboutUs = () => {
// 获取关于我们详情
const getAboutUsInfo = () => {
PublicApi.getManageShopAboutGet().then(res => {
const { code, data } = res
if (code === 1000 && data) {
const { albumName, albumUrl, honorPics, workshopPics, ...rest } = data
const newAlbumUrls = albumName && albumUrl ? [{ name: albumName, url: albumUrl }] : []
workshopImgRef.current.setData(workshopPics)
honorImgRef.current.setData(honorPics)
form.setFieldsValue({
...rest,
albumUrls: newAlbumUrls
})
setIsFormChange(false)
setAlbumUrls(newAlbumUrls)
setSelectCityData(rest.memberChannelAreas)
setMallUrl(rest.url)
}
})
}
useEffect(() => {
getAboutUsInfo()
getAllMallList()
}, [])
return (
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />}
title={'自营商城'}
className={styles.container}
extra={[<Button key="1" type="primary" icon={<SaveOutlined />} onClick={onSave} loading={saveLoading}> 保存 </Button>]}
......@@ -157,7 +184,7 @@ const OwnMallAboutUs = () => {
<Row gutter={24}>
<Col span={12}>
<Form.Item
name='introduction'
name='describe'
label={<RequireItem label="公司简介" isRequire={true}/>}
rules={[
{ required: true, message: "请输公司简介" },
......@@ -169,8 +196,11 @@ const OwnMallAboutUs = () => {
</Col>
<Col span={12}>
<Form.Item
name='city'
name='memberChannelAreas'
label={<RequireItem label="业务覆盖地市" isRequire={true}/>}
rules={[
{ required: true, message: "请选择业务覆盖地市" }
]}
>
<CitySelect
selectData={selectCityData}
......@@ -183,17 +213,17 @@ const OwnMallAboutUs = () => {
</Col>
<Col span={12}>
<Form.Item label='自营商城链接'>
<Form.Item name='mallLink'>
<Select allowClear options={allMallList}/>
<Form.Item name='shopId'>
<Select placeholder='请选择自营商城' allowClear options={allMallList} onChange={selectMall}/>
</Form.Item>
<div className={styles.mallLink}>当前自营商城链接: <span>https://www.shushangyun.com/B2B/index.html?id=11011</span></div>
<Form.Item name='url'><div className={styles.mallLink}>当前自营商城链接: <span>{mallUrl}</span></div></Form.Item>
</Form.Item>
</Col>
</Row>
</Card>
<Card id='2' title='厂房照片' style={{ marginBottom: 16 }}>
<Form.Item
name='workshop'
name='workshopPics'
label='厂房照片'
{...otherLayout}
>
......@@ -207,7 +237,7 @@ const OwnMallAboutUs = () => {
</Card>
<Card id='3' title='资质荣誉' style={{ marginBottom: 16 }}>
<Form.Item
name='honor'
name='honorPics'
label='资质荣誉'
{...otherLayout}
>
......@@ -232,6 +262,7 @@ const OwnMallAboutUs = () => {
fileList={albumUrls}
onChange={getAlbumUrls}
onRemove={removeAlbumUrls}
visible={albumUrls.length === 0}
/>
</Form.Item>
</Card>
......@@ -241,4 +272,4 @@ const OwnMallAboutUs = () => {
)
}
export default OwnMallAboutUs
\ No newline at end of file
export default observer(OwnMallAboutUs)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment