Commit 82e3c418 authored by 卢均锐's avatar 卢均锐

feat: 采购竞价&在线竞价 调整store取值,websocket链接端口修改为9880

parent 35eb5aac
......@@ -24,7 +24,7 @@
"build:all": "cross-env SITE_ID=1 BACK_GATEWAY=http://lingxi-all.wg.shushangyun.com USE_ROUTE_CONFIG=false SOCKET_URL=ws://lingxi-all.wg.shushangyun.com yarn build",
"build:10": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.10:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.0.10:9400 yarn build",
"build:study": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.1.207:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.1.207:9400 yarn build",
"build:v2": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.17:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.0.17:9400 yarn build",
"build:v2": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.17:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.0.17:9880 yarn build",
"build:v2Preview": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.1.220:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.1.220:9400 yarn build",
"postinstall": "umi generate tmp",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
......@@ -36,7 +36,7 @@
"start:10": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.10:8100 USE_ROUTE_CONFIG=true SOCKET_URL=ws://10.0.0.10:9400 yarn start",
"start:study": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.1.207:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.1.207:9400 yarn start",
"start:25": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.25:8100 USE_ROUTE_CONFIG=true SOCKET_URL=ws://10.0.0.25:9400 yarn start",
"start:v2": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.17:8100 USE_ROUTE_CONFIG=true SOCKET_URL=ws://10.0.0.17:9400 yarn start",
"start:v2": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.0.17:8100 USE_ROUTE_CONFIG=true SOCKET_URL=ws://10.0.0.17:9880 yarn start",
"start:v2Preview": "cross-env SITE_ID=1 BACK_GATEWAY=http://10.0.1.220:8100 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.1.220:9400 yarn start"
},
......
import { Tooltip, Badge } from 'antd';
import { BellOutlined, CustomerServiceOutlined } from '@ant-design/icons';
import React, { useCallback, useRef, useLayoutEffect, useState } from 'react';
import React, { useCallback, useRef, useLayoutEffect, useState, useEffect } from 'react';
import Avatar from './AvatarDropdown';
import SelectLang from './SelectLang';
import Location from './Location';
......@@ -11,6 +11,8 @@ import styles from '../styles/RightContent.less';
import { getAuth } from '@/utils/auth';
import { SOCKET_URL, LAYOUT_TYPE } from '@/constants';
import { usePurchaseBidStore } from '@/store/purchaseBid';
// export type SiderTheme = 'light' | 'dark';
// export interface GlobalHeaderRightProps extends Partial<ConnectProps> {
// theme?: SiderTheme | 'realDark';
......@@ -18,7 +20,7 @@ import { SOCKET_URL, LAYOUT_TYPE } from '@/constants';
// }
const NOT_READ_MESSAGE = 1;
const GlobalHeaderRight: React.FC<{SiteStore?: any}> = (props) => {
const GlobalHeaderRight: React.FC<{ SiteStore?: any }> = (props) => {
const { SiteStore: { currentLayoutInfo } } = props;
const [message, setMessage] = useState<number>(0);
const className = styles.right;
......@@ -28,16 +30,25 @@ const GlobalHeaderRight: React.FC<{SiteStore?: any}> = (props) => {
// }
const userInfo = getAuth()
const { purchaseBidStore } = usePurchaseBidStore();
const { setPurchaseBiddingMessage, setPurchaseBiddingMessageSupplier } = purchaseBidStore;
const ws = useRef<WebSocket | null>(null);
const webSocketInit = useCallback(() => {
if (SOCKET_URL && (!ws.current || ws.current.readyState === 3) && userInfo) {
const url = `${SOCKET_URL}/report/websocket?memberId=${userInfo.memberId}&roleId=${userInfo.memberRoleId}&token=${userInfo.token}&source=${1}`;
const url = `${SOCKET_URL}/message/websocket?memberId=${userInfo.memberId}&roleId=${userInfo.memberRoleId}&token=${userInfo.token}&source=${1}`;
console.log(url)
ws.current = new WebSocket(url);
// ws.current.onopen = (e) => {}
ws.current.onmessage = (e) => {
const data = JSON.parse(e.data);
if(data.type === NOT_READ_MESSAGE) {
console.log(data)
if (data.action === 'purchase_bidding_message_supplier') {
setPurchaseBiddingMessageSupplier(data)
} else if (data.action === 'purchase_bidding_message') {
setPurchaseBiddingMessage(data)
}
if (data.type === NOT_READ_MESSAGE) {
setMessage(data.data);
}
};
......@@ -50,7 +61,7 @@ const GlobalHeaderRight: React.FC<{SiteStore?: any}> = (props) => {
}
}, [ws]);
useLayoutEffect(() => {
useEffect(() => {
webSocketInit();
return () => {
ws.current?.close();
......@@ -63,19 +74,19 @@ const GlobalHeaderRight: React.FC<{SiteStore?: any}> = (props) => {
return (
<div className={className}>
<span style={{color: 'rgba(0, 0, 0, 0.85)', cursor: "pointer"}} onClick={handleBackMall}>返回商城</span>
<span style={{ color: 'rgba(0, 0, 0, 0.85)', cursor: "pointer" }} onClick={handleBackMall}>返回商城</span>
<Roles />
{/* <Location /> */}
<SelectLang />
<Tooltip title="消息">
<a
href="/memberCenter/systemSetting/message"
className={styles.action}
>
<Badge count={message} size={"small"}>
<BellOutlined />
</Badge>
</a>
<a
href="/memberCenter/systemSetting/message"
className={styles.action}
>
<Badge count={message} size={"small"}>
<BellOutlined />
</Badge>
</a>
</Tooltip>
{/* <Tooltip title="服务">
<a
......
import React, { useEffect, useState, useRef, useCallback } from 'react';
import React, { useEffect, useState } from 'react';
import { history } from 'umi';
import { Row, Col } from 'antd';
import { ArrowLeftOutlined } from '@ant-design/icons';
import isEmpty from 'lodash/isEmpty'
import { observer } from 'mobx-react'
import { PublicApi } from '@/services/api';
import { priceFormat } from '@/utils/numberFomat';
import { formatTimeString } from '@/utils'
import { getAuth } from '@/utils/auth';
import { SOCKET_URL } from '@/constants';
import { usePurchaseBidStore } from '@/store/purchaseBid';
import StatusBox from '../../../purchaseBid/readyBid/management/components/statusBox';
import QuotationDeskLayout from '../../../components/detail/components/quotationDeskLayout';
......@@ -20,6 +21,9 @@ import HistoryItem from './history';
import styles from './index.less';
const Detail = () => {
const { purchaseBidStore } = usePurchaseBidStore();
const { purchaseBiddingMessageSupplier } = purchaseBidStore;
const {
query: {
id,
......@@ -32,43 +36,53 @@ const Detail = () => {
const [dataSource, setDataSource] = useState<any>({});
const [chartsList, setChartsList] = useState<any>([]);
const userInfo = getAuth();
const ws = useRef<WebSocket | null>(null);
const webSocketInit = useCallback(() => {
if (SOCKET_URL && (!ws.current || ws.current.readyState === 3) && userInfo) {
const url = `${SOCKET_URL}/message/websocket?memberId=${userInfo.memberId}&roleId=${userInfo.memberRoleId}&token=${userInfo.token}&source=${1}`;
console.log(url)
ws.current = new WebSocket(url);
// ws.current.onopen = (e) => {}
ws.current.onmessage = (e) => {
const data = JSON.parse(e.data);
console.log(data)
const _data = data.data;
if(data.action === 'purchase_bidding_message_supplier' && _data.id == onlineId){
const _obj = {
ranking: _data.ranking,
minLowPrice : _data.minPrice,
quotationDesks : _data.awardProcesss
}
fetchDataSource(_obj);
}
};
ws.current.onclose = (e) => {
console.log("关闭连接")
}
ws.current.onerror = (e) => {
console.log("socket 出错")
useEffect(() => {
const _data = purchaseBiddingMessageSupplier?.data
if (purchaseBiddingMessageSupplier && !isEmpty(dataSource) && _data.id == onlineId) {
const _obj = {
ranking: _data.ranking,
minLowPrice: _data.minPrice,
quotationDesks: _data.awardProcesss
}
fetchDataSource(_obj);
}
}, [ws]);
}, [purchaseBiddingMessageSupplier])
useEffect(() => {
webSocketInit();
return () => {
ws.current?.close();
};
}, [ws, webSocketInit]);
// const ws = useRef<WebSocket | null>(null);
// const webSocketInit = useCallback(() => {
// if (SOCKET_URL && (!ws.current || ws.current.readyState === 3) && userInfo) {
// const url = `${SOCKET_URL}/message/websocket?memberId=${userInfo.memberId}&roleId=${userInfo.memberRoleId}&token=${userInfo.token}&source=${1}`;
// console.log(url)
// ws.current = new WebSocket(url);
// // ws.current.onopen = (e) => {}
// ws.current.onmessage = (e) => {
// const data = JSON.parse(e.data);
// console.log(data)
// const _data = data.data;
// if(data.action === 'purchase_bidding_message_supplier' && _data.id == onlineId){
// const _obj = {
// ranking: _data.ranking,
// minLowPrice : _data.minPrice,
// quotationDesks : _data.awardProcesss
// }
// fetchDataSource(_obj);
// }
// };
// ws.current.onclose = (e) => {
// console.log("关闭连接")
// }
// ws.current.onerror = (e) => {
// console.log("socket 出错")
// }
// }
// }, [ws]);
// useEffect(() => {
// webSocketInit();
// return () => {
// ws.current?.close();
// };
// }, [ws, webSocketInit]);
const fetchDataSource = async (socketObj?: any) => {
const params = {
......@@ -84,7 +98,7 @@ const Detail = () => {
}
const { data } = res;
let _flag = false;
if(socketObj){
if (socketObj) {
_flag = true;
data.ranking = socketObj.ranking;
data.minLowPrice = socketObj.minLowPrice;
......@@ -95,16 +109,16 @@ const Detail = () => {
let _offerList = [];
let _minList = [];
let _quotationDesks = data?.quotationDesks ? [...data.quotationDesks].reverse() : [];
if(_flag){
if (_flag) {
_quotationDesks = socketObj.quotationDesks.filter((item) => item.id == onlineId)
}
_quotationDesks.forEach((item) => {
_offerList.push({ type: 'offer', time: formatTimeString(item.offerTime || item.peportTime, 'HH:mm:ss'), value: priceFormat(item.price || item.sumPice,0) });
_offerList.push({ type: 'offer', time: formatTimeString(item.offerTime || item.peportTime, 'HH:mm:ss'), value: priceFormat(item.price || item.sumPice, 0) });
})
_list.push({ title: '报价金额', type: 'offer', list: _offerList });
if (data.isOpenPurchase) {
_quotationDesks.forEach((item) => {
_minList.push({ type: 'min', time: formatTimeString(item.offerTime || item.peportTime, 'HH:mm:ss'), value: priceFormat(item.minPrice,0) });
_minList.push({ type: 'min', time: formatTimeString(item.offerTime || item.peportTime, 'HH:mm:ss'), value: priceFormat(item.minPrice, 0) });
})
_list.push({ title: '最低价', type: 'min', list: _minList });
}
......@@ -142,4 +156,4 @@ const Detail = () => {
)
}
export default Detail;
export default observer(Detail);
......@@ -280,13 +280,18 @@ const SearchDetail = () => {
const _returnTopButton = () => {
switch (pathPci) {
case 'readyAdd':
return (
<Popconfirm title="确定要提交审核吗?" okText="是" cancelText="否" onConfirm={fetchSubmitBatch}>
<Button type='primary'>
<CheckCircleOutlined /> 提交
</Button>
</Popconfirm>
)
if(button === 1){
return (
<Popconfirm title="确定要提交审核吗?" okText="是" cancelText="否" onConfirm={fetchSubmitBatch}>
<Button type='primary'>
<CheckCircleOutlined /> 提交
</Button>
</Popconfirm>
)
}else{
return null
}
case 'readyExamineOne':
case 'readyExamineTwo':
case 'readyExamineSignUp':
......
......@@ -28,7 +28,7 @@ const ReadyAdd = () => {
dataIndex: 'biddingNo',
render: (text: any, record: any) => (
<Space direction='vertical'>
<EyePreview url={`/memberCenter/procurementAbility/purchaseBid/readyAdd/detail?id=${record.id}&number=${text}`}>{text}</EyePreview>
<EyePreview url={`/memberCenter/procurementAbility/purchaseBid/readyAdd/detail?id=${record.id}&number=${text}&button=${record.button}`}>{text}</EyePreview>
<Text type='secondary'>{record.details}</Text>
</Space>
)
......
import React, { useEffect, useState, useRef, useCallback } from 'react';
import React, { useEffect, useState } from 'react';
import { history } from 'umi';
import { Row, Col } from 'antd';
import { ArrowLeftOutlined } from '@ant-design/icons';
import isEmpty from 'lodash/isEmpty'
import { observer } from 'mobx-react'
import { PublicApi } from '@/services/api';
import { formatTimeString } from '@/utils'
import { priceFormat } from '@/utils/numberFomat';
import { getAuth } from '@/utils/auth';
import { SOCKET_URL } from '@/constants';
import { usePurchaseBidStore } from '@/store/purchaseBid';
import QuotationDeskLayout from '../../../components/detail/components/quotationDeskLayout';
import BidDetailLayout from '../../../components/detail/components/bidDetailLayout';
......@@ -34,52 +35,73 @@ const Management = () => {
const [awardProcess, setAwardProcess] = useState<any>([]);
const [lowestList, setLowestList] = useState<any>({});
const userInfo = getAuth();
const ws = useRef<WebSocket | null>(null);
const webSocketInit = useCallback(() => {
if (SOCKET_URL && (!ws.current || ws.current.readyState === 3) && userInfo) {
const url = `${SOCKET_URL}/message/websocket?memberId=${userInfo.memberId}&roleId=${userInfo.memberRoleId}&token=${userInfo.token}&source=${1}`;
console.log(url)
ws.current = new WebSocket(url);
// ws.current.onopen = (e) => {}
ws.current.onmessage = (e) => {
const data = JSON.parse(e.data);
console.log(data)
const _data = data.data;
if (data.action === 'purchase_bidding_message' && _data.id == id) {
let _dynamic = { ...dynamic };
_dynamic.count = _data.count;
_dynamic.id = _data.id;
_dynamic.memberName = _data.memberName;
_dynamic.minPrice = _data.minPrice;
setDynamic(_dynamic);
setQueryPriceDynamics(_data.queryPriceDynamics);
setSignupMembers(_data.sginUpInfos);
setAwardProcess(_data.awardProcesss);
setLowestList({
type: 'min',
title: '最低价',
list: _data.awardProcesss ? _data.awardProcesss.map((item) => { return { type: 'min', time: formatTimeString(item.peportTime, 'HH:mm:ss'), value: priceFormat(item.sumPice, 0) } }) : []
})
}
};
ws.current.onclose = (e) => {
console.log(e)
console.log("关闭连接")
}
ws.current.onerror = (e) => {
console.log("socket 出错")
}
}
}, [ws]);
const { purchaseBidStore } = usePurchaseBidStore();
const { purchaseBiddingMessage } = purchaseBidStore;
useEffect(() => {
webSocketInit();
return () => {
ws.current?.close();
};
}, [ws, webSocketInit]);
const _data = purchaseBiddingMessage?.data
if (purchaseBiddingMessage && !isEmpty(dataSource) && _data.id == id) {
let _dynamic = { ...dynamic };
_dynamic.count = _data.count;
_dynamic.id = _data.id;
_dynamic.memberName = _data.memberName;
_dynamic.minPrice = _data.minPrice;
setDynamic(_dynamic);
setQueryPriceDynamics(_data.queryPriceDynamics);
setSignupMembers(_data.sginUpInfos);
setAwardProcess(_data.awardProcesss);
setLowestList({
type: 'min',
title: '最低价',
list: _data.awardProcesss ? _data.awardProcesss.map((item) => { return { type: 'min', time: formatTimeString(item.peportTime, 'HH:mm:ss'), value: priceFormat(item.sumPice, 0) } }) : []
})
}
}, [purchaseBiddingMessage])
// const ws = useRef<WebSocket | null>(null);
// const webSocketInit = useCallback(() => {
// if (SOCKET_URL && (!ws.current || ws.current.readyState === 3) && userInfo) {
// const url = `${SOCKET_URL}/message/websocket?memberId=${userInfo.memberId}&roleId=${userInfo.memberRoleId}&token=${userInfo.token}&source=${1}`;
// console.log(url)
// ws.current = new WebSocket(url);
// // ws.current.onopen = (e) => {}
// ws.current.onmessage = (e) => {
// const data = JSON.parse(e.data);
// console.log(data)
// const _data = data.data;
// if (data.action === 'purchase_bidding_message' && _data.id == id) {
// let _dynamic = { ...dynamic };
// _dynamic.count = _data.count;
// _dynamic.id = _data.id;
// _dynamic.memberName = _data.memberName;
// _dynamic.minPrice = _data.minPrice;
// setDynamic(_dynamic);
// setQueryPriceDynamics(_data.queryPriceDynamics);
// setSignupMembers(_data.sginUpInfos);
// setAwardProcess(_data.awardProcesss);
// setLowestList({
// type: 'min',
// title: '最低价',
// list: _data.awardProcesss ? _data.awardProcesss.map((item) => { return { type: 'min', time: formatTimeString(item.peportTime, 'HH:mm:ss'), value: priceFormat(item.sumPice, 0) } }) : []
// })
// }
// };
// ws.current.onclose = (e) => {
// console.log(e)
// console.log("关闭连接")
// }
// ws.current.onerror = (e) => {
// console.log("socket 出错")
// }
// }
// }, [ws]);
// useEffect(() => {
// webSocketInit();
// return () => {
// ws.current?.close();
// };
// }, [ws, webSocketInit]);
const fetchDataSource = async () => {
const params = {
......@@ -177,4 +199,4 @@ const Management = () => {
)
}
export default Management;
export default observer(Management);
import React from 'react';
import { action, computed, observable, runInAction } from 'mobx'
class PurchaseBidStore {
@observable public purchaseBiddingMessage: any = '';
@observable public purchaseBiddingMessageSupplier: any = '';
@action.bound
public setPurchaseBiddingMessage(data: any) {
this.purchaseBiddingMessage = data
}
@action.bound
public setPurchaseBiddingMessageSupplier(data: any) {
this.purchaseBiddingMessageSupplier = data
}
}
const store = { purchaseBidStore: new PurchaseBidStore() };
const storeContext = React.createContext(store);
export const usePurchaseBidStore = () => React.useContext(storeContext);
export default PurchaseBidStore
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