Commit 94402b84 authored by GuanHua's avatar GuanHua

fix:1.修复进货单会员折扣价显示问题;2,商品详情交易评价图片显示问题

parent 0d99cc6c
......@@ -4,6 +4,7 @@ import proxy from './proxy'
import theme from './lingxi.theme.config'
const OPEN_THEME_BUILD = process.env.NODE_ENV === 'production' ? true : false // 是否开启动态主题
const isProduction = process.env.NODE_ENV === 'production' ? true : false
const config: any = {
// 如需写入环境变量 需在config中先写入
......@@ -49,9 +50,9 @@ const config: any = {
defaultSizes: 'parsed', // stat // gzip
},
inlineLimit: 10000,
chunks: ['vendors', 'umi'],
chunks: isProduction && ['vendors', 'umi'],
chainWebpack: function (config, { webpack }) {
config.merge({
isProduction && config.merge({
optimization: {
minimize: true,
splitChunks: {
......
......@@ -21,13 +21,13 @@ const InputNumber: React.FC<InputNumberPropsType> = (props) => {
if (min || min === 0) {
setMinCount(min)
if (value < min) {
onChange(min)
onChange(min, 'blur')
}
}
if (max || max === 0) {
setMaxCount(max)
if (value > max) {
onChange(max)
onChange(max, 'blur')
}
}
}, [min, max])
......@@ -35,14 +35,14 @@ const InputNumber: React.FC<InputNumberPropsType> = (props) => {
const handleReduce = (e) => {
e.stopPropagation()
if (value > minCount) {
onChange(Number(value) - 1)
onChange(Number(value) - 1, 'click')
}
}
const handleAdd = (e) => {
e.stopPropagation()
if (value < maxCount) {
onChange(Number(value) + 1)
onChange(Number(value) + 1, 'click')
}
}
......@@ -50,17 +50,22 @@ const InputNumber: React.FC<InputNumberPropsType> = (props) => {
const { value } = e.target;
const reg = /^\d*?$/;
if (reg.test(value)) {
onChange(value)
onChange(value, 'change')
}
}
const handleBlur = (e) => {
const { value } = e.target;
if (value === "") {
onChange(minCount)
onChange(minCount, 'blur')
} else {
Number(value) < minCount && onChange(minCount)
Number(value) > maxCount && onChange(maxCount)
if(Number(value) < minCount) {
onChange(minCount, 'blur')
} else if(Number(value) > maxCount) {
onChange(maxCount, 'blur')
} else {
onChange(value, 'blur')
}
}
}
......
......@@ -195,7 +195,7 @@ const AdvertSetting: React.FC<AdvertSettingPropsType> = forwardRef((props, ref)
setConfirmLoading(true)
let newParam: any = JSON.parse(JSON.stringify(newProps))
newParam.advertList = newParam.advertList.map((item) => {
if (!item.link.startsWith('http://') && !item.link.startsWith('https://')) {
if (!item.link && !item.link.startsWith('http://') && !item.link.startsWith('https://')) {
item.link = `http://${item.link}`
}
return item
......
......@@ -42,7 +42,7 @@ const Comment: React.FC<CommentPropsType> = (props) => {
}, [current])
const fetchCommentList = (type = '') => {
let param: any = {
const param: any = {
current,
pageSize,
productIds: productIds.toString() // '2339'
......@@ -55,7 +55,7 @@ const Comment: React.FC<CommentPropsType> = (props) => {
param.starLevel = 1
}
setSpinLoading(true)
//@ts-ignore
PublicApi.getMemberCommentMallTradeHistoryPage(param).then(res => {
setSpinLoading(false)
if (res.code === 1000) {
......@@ -85,7 +85,7 @@ const Comment: React.FC<CommentPropsType> = (props) => {
let middleCount = 0
let badCount = 0
if (data) {
for (let item of data) {
for (const item of data) {
switch (item.star) {
case 1:
case 2:
......@@ -103,9 +103,9 @@ const Comment: React.FC<CommentPropsType> = (props) => {
}
}
}
let allCount = goodCount + middleCount + badCount
const allCount = goodCount + middleCount + badCount
let result = [{
const result = [{
title: '全部评价',
sum: allCount,
sumText: allCount > 200 ? `(200+)` : `(${allCount})`,
......
......@@ -8,15 +8,10 @@ interface ImageViewListPropsType {
}
const ImageViewList: React.FC<ImageViewListPropsType> = (props) => {
const { imgList = []} = props
const [previewImage, setPreviewImage] = useState<number>(-1)
const [rotateZ, setRotateZ] = useState<number>(0)
const imgList = [
"https://woodmartcdn-cec2.kxcdn.com/wp-content/uploads/2016/09/product-furniture-1.jpg",
"https://woodmartcdn-cec2.kxcdn.com/wp-content/uploads/2016/09/product-furniture-1-5.jpg",
"https://woodmartcdn-cec2.kxcdn.com/wp-content/uploads/2016/09/product-furniture-1-3.jpg"
]
const handlePreviewImg = (index: number) => {
if (previewImage !== index) {
setPreviewImage(index)
......@@ -39,7 +34,7 @@ const ImageViewList: React.FC<ImageViewListPropsType> = (props) => {
setRotateZ(0)
break
case 'preview':
let el = document.createElement('a')
const el = document.createElement('a')
el.href = imgList[previewImage];
el.target = '_blank';
el.click()
......
......@@ -31,12 +31,12 @@ const Logistics_Type = {
3: '无需配送'
}
interface selectAttrValType {
interface SelectAttrValType {
attrId: number;
attrValId: number;
}
interface imgItemType {
interface ImgItemType {
id: number;
commodityPic: string;
}
......@@ -65,9 +65,9 @@ const CommodityDetail = (props) => {
const [attributeList, setAttributeList] = useState([])
const [commodityDetail, setCommodityDetail] = useState<GetSearchShopStoreGetCommodityDetailResponse & GetSearchShopChannelGetCommodityDetailResponse>()
const [attrAndValList, setAttrAndValList] = useState<any>({})
const [selectAttrVal, setSelectAttrVal] = useState<selectAttrValType[]>([])
const [selectAttrVal, setSelectAttrVal] = useState<SelectAttrValType[]>([])
const [stockCount, setStockCount] = useState<number>(0)
const [commodityImgList, setCommodityImgList] = useState<imgItemType[]>([])
const [commodityImgList, setCommodityImgList] = useState<ImgItemType[]>([])
const [commodityPriceInfo, setCommodityPriceInfo] = useState([])
const [parameter, setParameter] = useState<number>() // 权益参数
const [selectCommodityId, setSelectCommodityId] = useState<number>()
......@@ -91,7 +91,7 @@ const CommodityDetail = (props) => {
* @param priceType
*/
const fetchCommonCategoryCommodityList = (categoryId: number, priceType: number) => {
let param: any = {
const param: any = {
current: 1,
pageSize: 10,
categoryId
......@@ -162,7 +162,7 @@ const CommodityDetail = (props) => {
*/
const fetchDetail = () => {
let getDetailFn
let params: any = {
const params: any = {
commodityId: id
}
let headers = {}
......@@ -217,8 +217,10 @@ const CommodityDetail = (props) => {
if (!memberId) {
return
}
//@ts-ignore
PublicApi.getPayPayWayList({ memberId }).then(res => {
const param: any = {
memberId
}
PublicApi.getPayPayWayList(param).then(res => {
if (res.code === 1000) {
initPayWayList(res.data)
}
......@@ -234,7 +236,7 @@ const CommodityDetail = (props) => {
return []
}
let result = []
for (let item of data) {
for (const item of data) {
if (result.some(tempItem => tempItem.payType === item.payType)) {
result = result.map(resItem => {
if (resItem.payType === item.payType) {
......@@ -274,7 +276,7 @@ const CommodityDetail = (props) => {
* @param memberRoleId
*/
const getMemberCredit = (memberId, memberRoleId) => {
let param = {
const param = {
parentMemberId: memberId,
parentMemberRoleId: memberRoleId
}
......@@ -299,9 +301,9 @@ const CommodityDetail = (props) => {
const getCommodityPriceRange = () => {
if (commodityDetail?.unitPricePicList) {
for (let item of commodityDetail?.unitPricePicList) {
for (const item of commodityDetail?.unitPricePicList) {
let temp = item.attributeAndValueList.map(attrItem => {
const temp = item.attributeAndValueList.map(attrItem => {
return {
attrId: attrItem.customerAttribute.id,
attrValId: attrItem.customerAttributeValue.id
......@@ -320,7 +322,7 @@ const CommodityDetail = (props) => {
const judgeArrisCommon = (list, otherList) => {
if (list.length === otherList.length) {
let result = list.every(listItem => {
const result = list.every(listItem => {
return otherList.some(item => {
return JSON.stringify(item) === JSON.stringify(listItem)
})
......@@ -352,7 +354,7 @@ const CommodityDetail = (props) => {
if (clickFlag) {
clickFlag = false
let param: any = {
const param: any = {
commodityUnitPriceId: selectCommodityId,
count: buyCount
}
......@@ -482,11 +484,10 @@ const CommodityDetail = (props) => {
if (clickFlag) {
clickFlag = false
//@ts-ignore
PublicApi.postOrderDirectPayment({ productId: selectCommodityId, memberId }).then(res => {
if (res.code === 1000) {
message.destroy()
let buyCommodityInfo = {
const buyCommodityInfo = {
id: selectCommodityId,
count: buyCount,
unitName: commodityDetail.unitName,
......@@ -503,9 +504,9 @@ const CommodityDetail = (props) => {
attribute: attrAndValList.attributeAndValueList
}
let sessionKey = `${commodityDetail.id}${new Date().getTime()}`
const sessionKey = `${commodityDetail.id}${new Date().getTime()}`
let buyOrderInfo: any = {
const buyOrderInfo: any = {
logistics: commodityDetail.logistics,
payWayList: priceType === COMMODITY_TYPE.integral ? integralPayWay : payWayList,
supplyMembersName: commodityDetail.memberName,
......@@ -547,7 +548,7 @@ const CommodityDetail = (props) => {
})
const JoinValue = values.reverse().join('/');
let inquiryParam = {
const inquiryParam = {
id: selectCommodityId,
brand: commodityDetail.brand,
logistics: commodityDetail.logistics,
......@@ -562,7 +563,7 @@ const CommodityDetail = (props) => {
category: commodityDetail.customerCategory.name
}
let sessionKey = `inquiry${selectCommodityId}${new Date().getTime()}`
const sessionKey = `inquiry${selectCommodityId}${new Date().getTime()}`
updateOrderInfo(inquiryParam, sessionKey).then(() => {
window.location.href = `/memberCenter/tranactionAbility/goodsOffer/addEnquiryOrder/rfq?id=${id}&memberId=${memberId}&spam_id=${sessionKey}`
})
......@@ -598,8 +599,8 @@ const CommodityDetail = (props) => {
* @param addList
*/
const deleteRepeatImg = (list, addList) => {
let result = [...list]
for (let addItem of addList) {
const result = [...list]
for (const addItem of addList) {
if (list.every(item => item.commodityPic !== addItem.commodityPic)) {
result.push(addItem)
}
......@@ -612,19 +613,19 @@ const CommodityDetail = (props) => {
* @param unitPricePicList
*/
const initAttributeAndValueList = (dataInfo: any) => {
let unitPricePicList = dataInfo?.unitPricePicList
const unitPricePicList = dataInfo?.unitPricePicList
if (!unitPricePicList) {
return
}
let tempAttrList = []
const tempAttrList = []
let tempImgList: any = [{
id: dataInfo.id,
commodityPic: dataInfo.mainPic
}]
for (let item of unitPricePicList) {
for (const item of unitPricePicList) {
// 初始化商品图片-》 商品主图加上商品属性图片
if (item.commodityPic) {
let tempCommodityPic = item.commodityPic.map((picItem, picIndex) => {
const tempCommodityPic = item.commodityPic.map((picItem, picIndex) => {
return {
id: `${item.id}-${picIndex}`,
commodityPic: picItem
......@@ -633,7 +634,7 @@ const CommodityDetail = (props) => {
tempImgList = deleteRepeatImg(tempImgList, tempCommodityPic)
}
for (let attrListItem of item.attributeAndValueList) {
for (const attrListItem of item.attributeAndValueList) {
if (judgeAttrInList(tempAttrList, attrListItem.customerAttribute.id)) {
let tempAttrListIndex = 0
tempAttrList.map((item, index) => {
......@@ -648,7 +649,7 @@ const CommodityDetail = (props) => {
tempAttrList[tempAttrListIndex].customerAttributeValueList = [...tempAttrList[tempAttrListIndex].customerAttributeValueList, attrListItem.customerAttributeValue]
}
} else {
let temp: any = {}
const temp: any = {}
temp.id = attrListItem.id
temp.customerAttribute = attrListItem.customerAttribute
......@@ -674,7 +675,7 @@ const CommodityDetail = (props) => {
return
}
let total = 0
for (let item of unitPricePicList) {
for (const item of unitPricePicList) {
total += item.stockCount
}
setStockCount(total)
......@@ -691,7 +692,7 @@ const CommodityDetail = (props) => {
if (Object.keys(priceObj).length <= 1) {
return priceObj
}
let tempList = []
const tempList = []
Object.keys(priceObj).forEach(key => {
tempList.push({
key,
......@@ -700,13 +701,13 @@ const CommodityDetail = (props) => {
})
for (let i = 0; i < tempList.length; i++) {
if (tempList[i + 1] && tempList[i].value < tempList[i + 1].value) {
let temp = tempList[i]
const temp = tempList[i]
tempList[i] = tempList[i + 1]
tempList[i + 1] = temp
}
}
let result = {}
for (let tempItem of tempList) {
const result = {}
for (const tempItem of tempList) {
result[tempItem.key] = tempItem.value
}
return result
......@@ -717,12 +718,12 @@ const CommodityDetail = (props) => {
* @param uniPrice
*/
const setCurrentPriceRange = (uniPrice) => {
let initPriceRange = uniPrice
let tempPriceRange = []
const initPriceRange = uniPrice
const tempPriceRange = []
Object.keys(initPriceRange).forEach((key) => {
let keyArr = key.split('-')
let min = keyArr[0]
let max = keyArr[1]
const keyArr = key.split('-')
const min = keyArr[0]
const max = keyArr[1]
tempPriceRange.push({
range: key,
min,
......@@ -755,13 +756,13 @@ const CommodityDetail = (props) => {
// return
// }
if (judgeSelectAttrInList(selectAttrVal, attrId, 'attrId')) {
let result = []
for (let item of selectAttrVal) {
const result = []
for (const item of selectAttrVal) {
if (item.attrId === attrId && item.attrValId !== attrValId) {
item.attrValId = attrValId
result.push(item)
} else if (item.attrId === attrId && item.attrValId === attrValId) {
console.log('')
} else {
result.push(item)
}
......@@ -784,11 +785,11 @@ const CommodityDetail = (props) => {
if (commodityPriceInfo.length <= 1) {
unitPrice = commodityPriceInfo[0]?.price
} else {
let temp = commodityPriceInfo.filter(item => {
const temp = commodityPriceInfo.filter(item => {
return Number(buyCount) >= Number(item.min) && Number(buyCount) <= Number(item.max)
})
if (isEmpty(temp)) {
let maxItem = getMaxCountRange()
const maxItem = getMaxCountRange()
unitPrice = maxItem.price
} else {
unitPrice = temp[0]?.price
......@@ -807,8 +808,8 @@ const CommodityDetail = (props) => {
* 获取合计金额
*/
const getAmount = (state = true) => {
let unitPrice = getUnitPrice()
let amount = unitPrice * (Number(buyCount) || 0)
const unitPrice = getUnitPrice()
const amount = unitPrice * (Number(buyCount) || 0)
return state ? priceFormat(amount) : amount
}
......@@ -817,7 +818,7 @@ const CommodityDetail = (props) => {
*/
const getMaxCountRange = () => {
let maxItem: any = {}
for (let item of commodityPriceInfo) {
for (const item of commodityPriceInfo) {
if (Number(item.max) > Number(maxItem.max || 0)) {
maxItem = item
}
......@@ -830,13 +831,13 @@ const CommodityDetail = (props) => {
*/
const judgeHasAttr = (attrId: number, attrValId: number) => {
let result = true
let newSelectAttrVal = JSON.parse(JSON.stringify(selectAttrVal))
const newSelectAttrVal = JSON.parse(JSON.stringify(selectAttrVal))
if (selectAttrVal.length > 0) {
// newSelectAttrVal.pop()
if (commodityDetail?.unitPricePicList) {
let tempList = []
for (let item of commodityDetail?.unitPricePicList) {
let temp = item.attributeAndValueList.map(attrItem => {
const tempList = []
for (const item of commodityDetail?.unitPricePicList) {
const temp = item.attributeAndValueList.map(attrItem => {
return {
attrId: attrItem.customerAttribute.id,
attrValId: attrItem.customerAttributeValue.id
......@@ -859,8 +860,8 @@ const CommodityDetail = (props) => {
* 判断选的的数组是有在商品属性数组中
*/
const judegeListInList = (mainList, subList) => {
let result = subList.every(listItem => {
let subRes = mainList.some(item => {
const result = subList.every(listItem => {
const subRes = mainList.some(item => {
return JSON.stringify(item) === JSON.stringify(listItem)
})
return subRes
......
......@@ -48,7 +48,11 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
}, [categoryIds])
const fetchPurchaseList = (initState = false) => {
/**
* 获取进货单数据
* @param initState
*/
const fetchPurchaseList = () => {
let getFn
switch (layoutType) {
case LAYOUT_TYPE.channel:
......@@ -62,7 +66,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
getFn && getFn().then(res => {
if (res.code === 1000) {
initPurchaseList(res.data, initState)
initPurchaseList(res.data)
getCategoryIds(res.data)
}
})
......@@ -73,9 +77,9 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
* @param purchaseList
*/
const getCategoryIds = (purchaseList) => {
let ids = []
for (let item of purchaseList) {
let categoryId = item.commodityUnitPrice.commodity.customerCategory.id
const ids = []
for (const item of purchaseList) {
const categoryId = item.commodityUnitPrice.commodity.customerCategory.id
if (!ids.includes(categoryId)) {
ids.push(categoryId)
}
......@@ -83,54 +87,71 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
setCategoryIds(ids)
}
const initPurchaseList = (list: GetSearchShopPurchaseGetPurchaseListResponse, initState) => {
/**
* 初始化进货单数据
* @param list
* @param initState
*/
const initPurchaseList = async (list: GetSearchShopPurchaseGetPurchaseListResponse) => {
let result = []
for (let item of list) {
for (const item of list) {
// 判断店铺id是否已存在数组中
if (result.some(resItem => resItem.id === item.commodityUnitPrice.commodity.storeId)) {
result = result.map(tempItem => {
const tempResult = []
for(const tempItem of result) {
if (tempItem.id === item.commodityUnitPrice.commodity.storeId) {
let tempPriceRange = []
let unitPrice = item.commodityUnitPrice.unitPrice
const tempPriceRange = []
const unitPrice = item.commodityUnitPrice.unitPrice
let parameter: any = 1
const isMemberPrice = item.commodityUnitPrice.commodity.isMemberPrice
// 如果可以使用会员折扣
if(isMemberPrice) {
parameter = await getMemberCredit(item.commodityUnitPrice.commodity.memberId, item.commodityUnitPrice.commodity.memberRoleId)
}
Object.keys(unitPrice).forEach(key => {
let keyArr = key.split('-')
let min = keyArr[0]
let max = keyArr[1]
const keyArr = key.split('-')
const min = keyArr[0]
const max = keyArr[1]
tempPriceRange.push({
range: key,
min,
max,
price: unitPrice[key]
price: isMemberPrice ? Number(unitPrice[key]) * Number(parameter) : unitPrice[key]
})
})
// TODO 暂时给个库存数量
item.stockCount = item.stockCount
item.commodityUnitPrice['priceRange'] = tempPriceRange
tempItem.orderList = [...tempItem.orderList, item]
tempResult.push(tempItem)
}
return tempItem
})
}
result = tempResult
} else {
let temp: any = {}
const temp: any = {}
temp.id = item.commodityUnitPrice.commodity.storeId
temp.memberId = item.commodityUnitPrice.commodity.memberId
temp.memberRoleId = item.commodityUnitPrice.commodity.memberRoleId
temp.shopname = item.commodityUnitPrice.commodity.memberName
let tempPriceRange = []
let unitPrice = item.commodityUnitPrice.unitPrice
const tempPriceRange = []
const unitPrice = item.commodityUnitPrice.unitPrice
let parameter: any = 1
const isMemberPrice = item.commodityUnitPrice.commodity.isMemberPrice
// 如果可以使用会员折扣
if(isMemberPrice) {
parameter = await getMemberCredit(item.commodityUnitPrice.commodity.memberId, item.commodityUnitPrice.commodity.memberRoleId)
}
Object.keys(unitPrice).forEach(key => {
let keyArr = key.split('-')
let min = keyArr[0]
let max = keyArr[1]
const keyArr = key.split('-')
const min = keyArr[0]
const max = keyArr[1]
tempPriceRange.push({
range: key,
min,
max,
price: unitPrice[key]
price: isMemberPrice ? Number(unitPrice[key]) * Number(parameter) : unitPrice[key]
})
})
item.stockCount = item.stockCount
item.commodityUnitPrice['priceRange'] = tempPriceRange
temp.orderList = [item]
result.push(temp)
......@@ -140,7 +161,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
const initData = (list: any, initChecked?: any) => {
let result = list.map(item => {
const result = list.map(item => {
return Object.assign(item, {
checkedList: initChecked ? initChecked : item.orderList.map(item => item.id),
defaultCheckedList: item.orderList.map(item => item.id)
......@@ -167,10 +188,10 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
const handleChildGroupChange = (list, id: number) => {
let flag = false
let result = orderList.map(item => {
const result = orderList.map(item => {
if (item.id === id) {
if (list.length === item.defaultCheckedList.length) {
let temp = [...checkedList, id]
const temp = [...checkedList, id]
setCheckedList(temp)
if (temp.length === getAllKeys().length) {
setIndeterminate(false)
......@@ -190,7 +211,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
if (list.length === 0) {
let index = checkedList.indexOf(id)
const index = checkedList.indexOf(id)
checkedList.splice(index, 1)
setCheckedList(checkedList)
}
......@@ -201,7 +222,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
const onCheckChildAllChange = (e: any, id: number) => {
let result = orderList.map((item: any) => {
const result = orderList.map((item: any) => {
if (item.id === id) {
return e.target.checked ? Object.assign(item, { checkedList: item.defaultCheckedList }) : Object.assign(item, { checkedList: [] })
} else {
......@@ -216,12 +237,14 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
* @param count
* @param id
*/
const handleCountChange = (count: number, id: number) => {
const handleCountChange = (count: number, id: number, type: string) => {
handleChangeFinishCount(count, id)
if(type === 'click' || type === 'blur') {
if (countState) {
countState = false
let param: any = {
const param: any = {
id,
count
count: Number(count)
}
let postFn
......@@ -240,8 +263,6 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
countState = true
if (res.code === 1000) {
message.destroy()
// fetchPurchaseList()
handleChangeFinishCount(count, id)
}
}).catch(() => {
countState = true
......@@ -249,8 +270,15 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
}
}
const handleBlur = (count: number, id: number) => {
console.log(countState, count, "handleBlur")
}
const handleChangeFinishCount = (count, id) => {
let result = orderList.map(item => {
const result = orderList.map(item => {
item.orderList = item.orderList.map(childItem => {
if (childItem.id === id) {
childItem.count = count
......@@ -273,7 +301,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
return parseFloat(priceRange[0].price) * count
} else {
let priceItem: any = {}
for (let item of priceRange) {
for (const item of priceRange) {
if (Number(item.min) <= count && count <= Number(item.max)) {
priceItem = item
}
......@@ -330,7 +358,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
*/
const handleBatchDelete = () => {
let idList = []
for (let item of orderList) {
for (const item of orderList) {
idList = [...idList, ...item.checkedList]
}
if (idList.length <= 0) {
......@@ -364,10 +392,10 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
* @param ids
*/
const deleteListItems = (ids: number[]) => {
let newOrderList = JSON.parse(JSON.stringify(orderList))
let result = []
for (let item of newOrderList) {
let newItem = item
const newOrderList = JSON.parse(JSON.stringify(orderList))
const result = []
for (const item of newOrderList) {
const newItem = item
newItem.orderList = newItem.orderList.filter(orderItem => !ids.includes(orderItem.id))
if (newItem.orderList.length > 0) {
result.push(newItem)
......@@ -381,8 +409,8 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
*/
const handleComputeSelectCount = () => {
let count = 0
for (let item of orderList) {
for (let orderItem of item.orderList) {
for (const item of orderList) {
for (const orderItem of item.orderList) {
if (item.checkedList.includes(orderItem.id)) {
count += orderItem.count
}
......@@ -397,10 +425,10 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
*/
const handleComputeSelectPrice = () => {
let price = 0
for (let item of orderList) {
for (let orderItem of item.orderList) {
for (const item of orderList) {
for (const orderItem of item.orderList) {
if (item.checkedList.includes(orderItem.id)) {
let commodityPrice = computeItemPrice(orderItem.commodityUnitPrice.priceRange, orderItem.count)
const commodityPrice = computeItemPrice(orderItem.commodityUnitPrice.priceRange, orderItem.count)
price += commodityPrice
}
}
......@@ -415,7 +443,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
*/
const getMemberCredit = (memberId, memberRoleId) => {
return new Promise((resolve) => {
let param = {
const param = {
parentMemberId: memberId,
parentMemberRoleId: memberRoleId
}
......@@ -433,8 +461,10 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
resolve([])
return
}
//@ts-ignore
PublicApi.getPayPayWayList({ memberId }).then(res => {
const param: any = {
memberId
}
PublicApi.getPayPayWayList(param).then(res => {
if (res.code === 1000) {
resolve(initPayWayList(res.data))
}
......@@ -447,7 +477,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
return []
}
let result = []
for (let item of data) {
for (const item of data) {
if (result.some(tempItem => tempItem.payType === item.payType)) {
result = result.map(resItem => {
if (resItem.payType === item.payType) {
......@@ -495,18 +525,18 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
const selectList = orderList.filter(item => item.checkedList.length > 0)
const selectItem = selectList[0]
let productIds = []
let buyOrderlist = []
const productIds = []
const buyOrderlist = []
const selectOrderList = selectItem.orderList.filter(item => selectItem.checkedList.includes(item.id))
let commonLogistics = {}
setConfirmLoading(true)
let purchaseIds = []
for (let item of selectOrderList) {
const purchaseIds = []
for (const item of selectOrderList) {
purchaseIds.push(item.id)
productIds.push(item.commodityUnitPrice.id)
commonLogistics = item.commodityUnitPrice.commodity.logistics
let buyCommodityInfo: any = {
const buyCommodityInfo: any = {
id: item.commodityUnitPrice.id,
purchaseId: item.id,
count: item.count,
......@@ -529,7 +559,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
buyOrderlist.push(buyCommodityInfo)
}
let buyOrderInfo: any = {
const buyOrderInfo: any = {
purchaseOrder: true, // 是否进货单下单
idList: purchaseIds,
productType: (layoutType === LAYOUT_TYPE.channel || layoutType === LAYOUT_TYPE.ichannel) ? 2 : 1,
......@@ -546,7 +576,6 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
buyOrderInfo.payWayList = await getPayWayListByMemberId(selectItem.memberId)
//@ts-ignore
PublicApi.postOrderIsWorkFlow({ productIds, memberId: selectItem.memberId }).then(res => {
setConfirmLoading(false)
if (res.code === 1000) {
......@@ -554,7 +583,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
PublicApi.postOrderDirectPayment({ productId: productIds[0], memberId: selectItem.memberId }).then(res => {
if (res.code === 1000) {
message.destroy()
let sessionKey = `${selectItem.id}${new Date().getTime()}`
const sessionKey = `${selectItem.id}${new Date().getTime()}`
updateOrderInfo(buyOrderInfo, sessionKey).then(() => {
if (res.data) {
......@@ -591,11 +620,11 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
if (detail.priceRange.length <= 1) {
unitPrice = detail.priceRange[0]?.price
} else {
let temp = detail.priceRange.filter(item => {
const temp = detail.priceRange.filter(item => {
return Number(count) >= Number(item.min) && Number(count) <= Number(item.max)
})
if (isEmpty(temp)) {
let maxItem = getMaxCountRange(detail.priceRange)
const maxItem = getMaxCountRange(detail.priceRange)
unitPrice = maxItem.price
} else {
unitPrice = temp[0]?.price
......@@ -607,7 +636,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
const getMaxCountRange = (priceRange) => {
let maxItem: any = {}
for (let item of priceRange) {
for (const item of priceRange) {
if (Number(item.max) > Number(maxItem.max || 0)) {
maxItem = item
}
......@@ -647,7 +676,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
const handleCollect = (commodityId: number) => {
let param: any = {
const param: any = {
commodityId: commodityId,
type: getLayoutType()
}
......@@ -736,7 +765,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
</div>
<div className={cx(styles.order_list_item_item, styles.count)}>
<InputNumber max={childItem.stockCount || 0} disabled={childItem.stockCount === 0} min={childItem.commodityUnitPrice.commodity.minOrder || 1} value={childItem.count} onChange={(value) => handleCountChange(value, childItem.id)} />
<InputNumber max={childItem.stockCount || 0} disabled={childItem.stockCount === 0} min={childItem.commodityUnitPrice.commodity.minOrder || 1} value={childItem.count} onChange={(value, type) => handleCountChange(value, childItem.id, type)} />
<div className={styles.stock}>
<span>(库存{numFormat(childItem.stockCount)}{childItem.commodityUnitPrice.commodity.unitName})</span>
</div>
......@@ -797,3 +826,4 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
export default observer(PurchaseOrder)
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