Commit e25588a3 authored by 前端-黄佳鑫's avatar 前端-黄佳鑫
parents 82e1cde8 37624bd4
......@@ -17,15 +17,15 @@
"build:dev": "pm2 start scripts/devServer.js",
"build:clean": "cross-env NODE_OPTIONS=--max_old_space_size=4096 umi build",
"build:scm": "cross-env SITE_ID=1 BACK_GATEWAY=http://lingxi-scm.wg.shushangyun.com USE_ROUTE_CONFIG=false SOCKET_URL=ws://lingxi-scm.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:8100 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 yarn build",
"postinstall": "umi generate tmp",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
"test": "umi-test",
"test:coverage": "umi-test --coverage",
"start:cross": "cross-env SITE_ID=352 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.0.25:9400 yarn start",
"start:cross": "cross-env SITE_ID=352 USE_ROUTE_CONFIG=false SOCKET_URL=ws://10.0.0.25 yarn start",
"start:scm": "cross-env SITE_ID=1 BACK_GATEWAY=http://lingxi-scm.wg.shushangyun.com USE_ROUTE_CONFIG=false SOCKET_URL=ws://lingxi-scm.wg.shushangyun.com yarn start",
"start:url": "cross-env SITE_ID=1 BACK_GATEWAY=http://lingxi-all.wg.shushangyun.com USE_ROUTE_CONFIG=true SOCKET_URL=ws://lingxi-all.wg.shushangyun.com yarn start",
"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:8100 yarn start"
"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 yarn start"
},
"lint-staged": {
"*.{js,jsx,less,md,json}": [
......
export const NOT_CHANGE_VALUE = 'hello, world'
// socket的链接地址, 默认会使用后端接口网关地址
export const SOCKET_URL = process.env.SOCKET_URL?.replace('http|https', 'ws') || process.env.BACK_GATEWAY?.replace('http|https', 'ws') || "ws://10.0.0.25:9400"
export const SOCKET_URL = process.env.SOCKET_URL?.replace('http|https', 'ws') || process.env.BACK_GATEWAY?.replace('http|https', 'ws')
console.log(SOCKET_URL);
export const MALL_TYPE = {
......
......@@ -16,6 +16,7 @@ import { SOCKET_URL } from '@/constants';
// layout: 'sidemenu' | 'topmenu';
// }
const NOT_READ_MESSAGE = 1;
const GlobalHeaderRight: React.FC<{}> = (props) => {
// const { theme, layout } = props;
const [message, setMessage] = useState<number>(0);
......@@ -30,18 +31,21 @@ const GlobalHeaderRight: React.FC<{}> = (props) => {
const ws = useRef<WebSocket | null>(null);
const webSocketInit = useCallback(() => {
console.log(ws.current)
if ((!ws.current || ws.current.readyState === 3) && userInfo) {
ws.current = new WebSocket(`${SOCKET_URL}/report/websocket?memberId=${userInfo.memberId}&roleId=${userInfo.memberRoleId}`);
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}`;
ws.current = new WebSocket(url);
ws.current.onopen = (e) => {
console.log(e)
}
ws.current.onmessage = (e) => {
console.log(e)
setMessage(e.data)
if(e.data.type === NOT_READ_MESSAGE) {
setMessage(e.data.data);
}
};
ws.current.onclose = (e) => {
console.log("关闭连接")
}
}
ws.current.onerror = (e) => {
console.log("socket 出错")
}
......
......@@ -9,6 +9,7 @@ import { topBarConfig, topAdvertConfig, headerConfig, mainNavConfig, bannerAdver
import Loading from '../components/Loading'
import { menuData } from './defaultMenu'
import { PublicApi } from '@/services/api'
import { getAuth } from '@/utils/auth'
import styles from './index.less'
interface ChannelPreviewPropsType {
......@@ -30,6 +31,7 @@ const TemplateList = ['science']
const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
const { query: { id, template } } = props.location
const userInfo = getAuth() || {}
const [loading, setLoading] = useState<boolean>(true)
const [theme, setTheme] = useState<string>('theme-channel-science')
const [componentConfigs, setComponentConfigs] = useState({})
......@@ -47,7 +49,8 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
return new Promise((resolve) => {
const params: any = {
templateId: id,
type: 1
type: 1,
memberId: userInfo.memberId
}
PublicApi.getTemplateChannelFindAdvertsByType(params).then(res => {
......@@ -64,7 +67,8 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
return new Promise((resolve) => {
const params: any = {
templateId: id,
type: 2
type: 2,
memberId: userInfo.memberId
}
PublicApi.getTemplateChannelFindAdvertsByType(params).then(res => {
......@@ -82,7 +86,10 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
*/
const fetchFirstCategory = () => {
return new Promise((resolve) => {
PublicApi.getTemplateChannelFindAllFirstCategory().then(res => {
const params: any = {
memberId: userInfo.memberId
}
PublicApi.getTemplateChannelFindAllFirstCategory(params).then(res => {
if (res.code === 1000) {
resolve(res.data)
}
......@@ -97,7 +104,8 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
return new Promise((resolve) => {
const param: any = {
templateId: id,
categoryId
categoryId,
memberId: userInfo.memberId
}
PublicApi.getTemplateChannelFindFirstCategoryDetail(param).then(res => {
......@@ -112,7 +120,10 @@ const ChannelPreview: React.FC<ChannelPreviewPropsType> = (props) => {
*/
const fetchShopInfo = () => {
return new Promise((resolve) => {
PublicApi.getTemplateChannelFindChannel().then(res => {
const params: any = {
memberId: userInfo.memberId
}
PublicApi.getTemplateChannelFindChannel(params).then(res => {
if (res.code === 1000) {
resolve(res.data)
}
......
......@@ -269,15 +269,26 @@ const Add: React.FC<{}> = () => {
}
setSubmitLoading(true);
const detailList = someLists.map((item) => {
const orderData = values.source === 1
? {
orderId: item.orderId,
orderDetailId: item.fullId,
orderNo: item.orderNo,
productId: item.commodityId,
purchaseCount: item.orderTotal, // 订单数量
surplusProcessNum: item.restTotal, // 剩余加工数量
}
: {
productId: item.id,
purchaseCount:null,
surplusProcessNum:null,
}
return {
orederNo: item.orderNo, // 如果是商品加工,那么他没有订单号
productId: item.id, // skuid
...orderData,
productName: item.name,
category: item.customerCategoryName,
brand: item.brandName,
unit: item.unitName,
purchaseCount:null,
surplusProcessNum:null,
processNum: item.processNum || 0,
processPrice: item.processUnitPrice || 0,
processTotalPrice: item.processTotalPrice,
......
......@@ -52,20 +52,22 @@ const ProcessProducts = ({visible, cancel, rowSelection, ...restProps}) => {
(item) => {
return {
orderNo: record.orderNo,
orderId: record.id, // 订单id
// orderDetailId: item.id, // 订单商品唯一id
commodityId: item.productId, // 商品id
id: item.productId,
id: item.productId, // sku id
name: item.productName,
customerCategoryName: item.category,
brandName: item.brand,
unitName: item.unit,
orderTotal: item.purchaseCount,
orderTotal: item.purchaseCount, // 采购数量
restTotal: item.purchaseCount - (item.processNum || 0),
processNum: '',
processUnitPrice: '',
processTotalPrice: '',
price: item.price, //单价,
hasProcessNum: item.processNum || 0,
fullId: item.id
fullId: item.id, //订单商品唯一id
}
}
)
......
......@@ -518,6 +518,7 @@ const CommodityDetail = (props) => {
shopId: storeId,
memberRoleId: commodityDetail.memberRoleId
}
PublicApi.postOrderDirectPayment(param).then(res => {
if (res.code === 1000) {
message.destroy()
......
......@@ -30,14 +30,14 @@ const Category: React.FC<CategoryPropsType> = (props) => {
const [initSelectAttributeList, setInitSelectAttributeList] = useState<any>([])
useEffect(() => {
console.log(JSON.stringify(filterList))
if (isEmpty(filterList)) {
setSelectedKeys([])
setLastCategoryId(null)
setSelectAttrbuteList([])
} else {
const initKeys = []
// let initAttrKeys = []
let attrInitKeys = []
for (const item of filterList) {
if (item.type === FILTER_TYPE.category) {
initKeys.push(String(item.key))
......@@ -45,9 +45,15 @@ const Category: React.FC<CategoryPropsType> = (props) => {
initKeys.push(String(item.key))
}
if (item.type === FILTER_TYPE.attribute) {
setInitSelectAttributeList(item.key)
attrInitKeys = item.key
}
}
setInitSelectAttributeList(attrInitKeys)
if(isEmpty(attrInitKeys)) {
setSelectAttrbuteList([])
}
setSelectedKeys(initKeys)
}
}, [filterList])
......@@ -197,15 +203,10 @@ const Category: React.FC<CategoryPropsType> = (props) => {
setLastCategoryId(selectedKeys[0])
}
} else {
setLastCategoryId(null)
setAttributeList([])
if(filterList.some(item => item.type === FILTER_TYPE.attribute)) {
onFilter({
type: FILTER_TYPE.attribute,
key: null,
title: ``
})
}
initAttribute()
}
if(selectedKeys.length === 0) {
initAttribute()
}
switch(layoutType) {
case LAYOUT_TYPE.mall:
......@@ -226,6 +227,18 @@ const Category: React.FC<CategoryPropsType> = (props) => {
}
const initAttribute = () => {
setLastCategoryId(null)
setAttributeList([])
if(filterList.some(item => item.type === FILTER_TYPE.attribute)) {
onFilter({
type: FILTER_TYPE.attribute,
key: null,
title: ``
})
}
}
const handleExpand = (expandedKeys) => {
setExpandedKeys(expandedKeys)
}
......
......@@ -56,7 +56,7 @@ const SideNav: React.FC<SideNavPropsType> = (props) => {
<div className="side_nav_list_item" onClick={() => linkToPurchaseOrder()}>
<MyIcon type="icon-gouwuche" />
</div>
<div className="side_nav_list_item">
<div className="side_nav_list_item" onClick={() => history.push('/memberCenter/systemSetting/message')}>
<MyIcon type="icon-xiaoxi" />
</div>
<div className="side_nav_list_item">
......@@ -72,4 +72,4 @@ const SideNav: React.FC<SideNavPropsType> = (props) => {
)
}
export default SideNav
\ No newline at end of file
export default SideNav
......@@ -136,7 +136,9 @@ class FilterStore {
for (const filterItem of newFilterList) {
switch (filterItem.type) {
case FILTER_TYPE.category:
tempFilterParam.categoryId = Number(filterItem.key[0])
if(Number(filterItem.key[0])) {
tempFilterParam.categoryId = Number(filterItem.key[0])
}
break
case FILTER_TYPE.customerCategory:
tempFilterParam.customerCategoryId = Number(filterItem.key[0])
......
......@@ -13,7 +13,7 @@ export function isObject(obj: any) {
return Object.prototype.toString.call(obj) === '[object Object]'
}
export function formatTimeString(date, format: string = 'YYYY-MM-DD HH:mm:ss') {
export function formatTimeString(date, format = 'YYYY-MM-DD HH:mm:ss') {
return date ? moment(date).format(format) : ''
}
......@@ -115,7 +115,7 @@ export function timeRange(val: number) {
export const arrayGroupsByCount = (array, count) => {
let index = 0;
let newArray = [];
const newArray = [];
while (index < array.length) {
newArray.push(array.slice(index, index += count));
}
......@@ -139,7 +139,7 @@ export function isPrimeNum(num) {
if (!isThree(num)) {
return false;
}
for (var i = 2; i < num / 5 + 1; i++) {
for (let i = 2; i < num / 5 + 1; i++) {
if (num % i == 0) {
return false;
}
......@@ -154,13 +154,13 @@ function isNum(num) {
}
function isDual(num) {
var num = num.toString();
var lastNum = num.substring(num.length - 1, num.length);
const lastNum = num.substring(num.length - 1, num.length);
return lastNum % 2 == 0 || lastNum % 5 == 0 ? false : true;
}
function isThree(num) {
var str = num.toString();
var sum = 0;
for (var i = 0; i < str.length; i++) {
const str = num.toString();
let sum = 0;
for (let i = 0; i < str.length; i++) {
sum += +str.substring(i, i + 1);
};
return sum % 3 == 0 ? false : true;
......@@ -443,7 +443,7 @@ export interface FileData {
url: string;
};
/**
/**
* 初始化 Upload 数据
*/
export function normalizeFiledata(url: string): FileData
......@@ -458,7 +458,7 @@ export function normalizeFiledata(url: any): any {
uid: Math.random().toFixed(16).slice(2, 10),
name: fileName,
status: 'done',
url,
url,
data: url, // formily Upload value 需要这个字段
};
};
......@@ -502,16 +502,16 @@ export const isJSONStr = str => {
* @param {array} item 需要赋值的值
*/
export const coverColFiltersItem = (
data: Array<{[key: string]: any}>,
dataIndex: string,
data: Array<{[key: string]: any}>,
dataIndex: string,
item: {[key: string]: any}
) => {
const index = data.findIndex(i => i.dataIndex === dataIndex);
if (index !== -1) {
data.splice(index, 1, {
...data[index],
filters: item,
filters: item,
});
}
};
......@@ -528,7 +528,7 @@ export const findLastIndexFlowState = (data: any[], customKey = 'isExecute'): nu
}
// 循环数据,找到状态值,一直覆盖
for (let i = 0; i < data.length; i++) {
if (!Boolean(data[i][customKey])) {
if (!data[i][customKey]) {
index = i - 1;
}
// 循环到最后如果 index 还是为 0 的话,说明工作流全部跑完了,此时 index 为 data.length - 1
......@@ -543,4 +543,4 @@ export default {
isArray,
isObject,
omit,
}
\ 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