Commit 0ddd86f1 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 修复新增属性勾选价格属性必须勾选必填项,处理前面非必填项价格属性组合出来的商品编辑出错问题

parent b2d5a596
......@@ -160,6 +160,14 @@ const AddAtttribute: React.FC<{}> = () => {
menuForm.setFieldsValue({ isDate: false })
}
const priceAttributeChange = (e) => {
if(e.target.checked) {
menuForm.setFieldsValue({"isEmpty": true})
} else {
menuForm.setFieldsValue({"isEmpty": false})
}
}
return <PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description={intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.back' })}/>}
......@@ -261,7 +269,7 @@ const AddAtttribute: React.FC<{}> = () => {
</Col> */}
<Col span={24}>
{/* 规格属性 -> 原价格属性 */}
<Form.Item name="isPrice" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled={isSee}>{intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.form.isPrice' })}</Checkbox></Form.Item>
<Form.Item name="isPrice" valuePropName="checked" initialValue={false} noStyle><Checkbox onChange={priceAttributeChange} disabled={isSee}>{intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.form.isPrice' })}</Checkbox></Form.Item>
<Tooltip title={intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.form.isPrice.tooltip' })}>
<InfoCircleOutlined />
</Tooltip>
......
......@@ -175,35 +175,19 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
let _attributeNameArr = []
let _attributeValueArr = []
if (hasAttribute.length) { // 提取价格属性 属性名数组 属性值SKU数组 /*编辑情况下直接进入此页面length为空 此时需获取调用接口返回的数据生成*/
hasAttribute.map(_item => {
_attributeNameArr.push(_item.attributeName) // 用于列header
_temp_attributeObjArr.push({ attributeName: _item.attributeName, customerAttributeId: _item.customerAttributeId })
let _tempArr = []
let _tempObjArr = [] // 取id备用 //....若为日期属性,此处应获取日期段的每一天 进行特殊处理....//
// if(_item.isDate){
// //.... 取每一天 ....//
// console.log(_item.customerAttributeValueList, _item, '特殊时间')
// if(_item.customerAttributeValueList.length>0){
// let start_time: any = moment(_item.customerAttributeValueList[0].value[0])
// let end_time: any = moment(_item.customerAttributeValueList[0].value[1]).endOf("d")
// const diff_times = end_time.diff(start_time,"d")
// console.log(start_time,end_time,diff_times)
// const arr = []
// _.times(diff_times, i => {
// const new_start_time = moment(start_time)
// arr.push(new_start_time.add(i, "days").format("YYYY-MM-DD"))
// })
// console.log(arr)
// }
// }else{
_item.customerAttributeValueList.map(__item => {
_tempArr.push(__item.value)
_tempObjArr.push({ id: __item.id, value: __item.value })
})
// }
_attributeValueArr.push(_tempArr) // 价格属性的属性值数组 用于SKU组合
_temp_attributeValObjArr.push(_tempObjArr)
hasAttribute.forEach(_item => {
if(_item.customerAttributeValueList.length) {
_attributeNameArr.push(_item.attributeName) // 用于列header
_temp_attributeObjArr.push({ attributeName: _item.attributeName, customerAttributeId: _item.customerAttributeId })
let _tempArr = []
let _tempObjArr = []
_item.customerAttributeValueList.forEach(__item => {
_tempArr.push(__item.value)
_tempObjArr.push({ id: __item.id, value: __item.value })
})
_attributeValueArr.push(_tempArr) // 价格属性的属性值数组 用于SKU组合
_temp_attributeValObjArr.push(_tempObjArr)
}
})
} else if (history.location.query?.id) { // 此时没有属性并且处于编辑状态 取接口返回的数据 [0]? (也有可能编辑情况下切换到无规格的品类)
_attributeNameArr = productInfoByEdit.unitPriceAndPicList[0]?.attributeAndValueList.map(_ => _.customerAttribute.name)
......@@ -282,7 +266,10 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
}
if (_attributeNameArr?.length > 0) {
_attributeNameArr.map(_attr => {
console.log(_attributeNameArr, _tableDataSource, '_attributeNameArr', _attributeValueArr)
_attributeNameArr.map((_attr, _i) => {
// 同索引下 属性值为空表示前面属性组合值为空
// _attributeValueArr[_i][0] &&
_col.push({
title: _attr,
dataIndex: _attr,
......@@ -333,18 +320,23 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
// 生成表格dataSource
let combineArray = SKUCombine(_attributeValueArr)
console.log(combineArray, 'combineArray')
setCombineAttributeArray(combineArray)
setAttributeObjArr(_temp_attributeObjArr)
setAttributeValObjArr(_temp_attributeValObjArr)
let _tableData: any[] = []
if (combineArray?.length > 0) { // length存在 表示表格的行数(有价格属性组合)
console.log(combineArray, selectedGoods)
combineArray.map((_rowArr: any[], i: any) => { // _rowArr 属性值数组
let _tempObj: any = { [intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.index' })]: i, [intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.name' })]: productName }
Array.isArray(_rowArr) ? _rowArr.map((__rowArr, index) => {
_tempObj[_attributeNameArr[index]] = __rowArr
}) : _tempObj[_attributeNameArr[i] || _attributeNameArr[0]] = _rowArr // 当一项变动的时候 找_attributeNameArr可能会找不到 找不到的情况下置为索引0的那项
Array.isArray(_rowArr)
?
_rowArr.forEach((__rowArr, index) => {
__rowArr && (_tempObj[_attributeNameArr[index]] = __rowArr)
})
:
_tempObj[_attributeNameArr[i] || _attributeNameArr[0]] = _rowArr // 当一项变动的时候 找_attributeNameArr可能会找不到 找不到的情况下置为索引0的那项
if (history.location.query?.id) {
// 编辑的时候,先指定数据中的货品id,如果是重新组合的不存在id就使用选择的货品中的第一个,如果没有置为0;同理,不存在单价就置为{}
if (isRecombination) {
......@@ -357,13 +349,11 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
_tempObj[intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.id' })] = productInfoByEdit.unitPriceAndPicList[i]?.id
}
if (updateFlag.current) { // 初次渲染tab 再次进入tab采用缓存数据
console.log(1, productInfoByEdit.unitPriceAndPicList[i])
if (productInfoByEdit.unitPriceAndPicList[i]?.unitPrice) {
let unitPric = productInfoByEdit.unitPriceAndPicList[i]?.unitPrice
// _tempObj[intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.unitPrice' })] = orderlyLadderPrice(unitPric)
const _price = orderlyLadderPrice(unitPric)
const _priceRate = productInfoByEdit.unitPriceAndPicList[i]?.priceRate
console.log(_price, _priceRate)
_tempObj[intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.unitPrice' })] = _price
_tempObj[intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.assistantUniquePriceRate' })] = _priceRate
setAssistantUniquePriceRate(_priceRate)
......@@ -373,13 +363,11 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
_tempObj[intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.unitPrice' })] = {}
}
} else {
console.log(2, _tableDataSource[i] && tableDataSource[i] && tableDataSource[i])
if (_tableDataSource[i] && tableDataSource[i] && tableDataSource[i][intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.unitPrice' })]) {
let unitPric = _tableDataSource[i] && tableDataSource[i] && tableDataSource[i][intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.unitPrice' })]
// _tempObj[intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.unitPrice' })] = orderlyLadderPrice(unitPric)
const _price = orderlyLadderPrice(unitPric)
const _priceRate = _tableDataSource[i] && tableDataSource[i] && tableDataSource[i][intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.assistantUniquePriceRate' })]
console.log(_price, _priceRate)
_tempObj[intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.unitPrice' })] = _price
_tempObj[intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.assistantUniquePriceRate' })] = _priceRate
setAssistantUniquePriceRate(_priceRate)
......@@ -440,32 +428,32 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
let _paramsArray: any[] = [];
Array.isArray(combineAttributeArray) ? combineAttributeArray.map((item, index) => { // 非数组情况下默认无组合 从table数据中获取 // 当属性减少的时候 这个combine数组还是之前的 /* code1 */
let _tempArr: any = []
Array.isArray(item) ? item.map((_item, _index) => { /* code2 */
let _tempObject: any = {};
_tempObject.customerAttribute = {
id: attributeObjArr[_index].customerAttributeId,
name: attributeObjArr[_index].attributeName
}
// console.log(attributeObjArr, attributeValObjArr, item, index, _item, _index, _tableDataSource, '调试属性')
// @fixed bug: 属性名称相同的情况下 只找第一个元素 会出现id异常
let filterData = null
for (let i = 0; i < attributeValObjArr.length; i++) {
const element = attributeValObjArr[i]
filterData = element.find(ele => ele.value === _item)
if (filterData) {
break;
Array.isArray(item) ? item.forEach((_item, _index) => { /* code2 */
if(_item) {
let _tempObject: any = {};
_tempObject.customerAttribute = {
id: attributeObjArr[_index].customerAttributeId,
name: attributeObjArr[_index].attributeName
}
}
_tempObject.customerAttributeValue = {
// @fixed bug: 属性名称相同的情况下 只找第一个元素 会出现id异常
id: filterData?.id ? filterData.id : null,
value: item[_index]
let filterData = null
for (let i = 0; i < attributeValObjArr.length; i++) {
const element = attributeValObjArr[i]
filterData = element.find(ele => ele.value === _item)
if (filterData) {
break;
}
}
_tempObject.customerAttributeValue = {
// @fixed bug: 属性名称相同的情况下 只找第一个元素 会出现id异常
id: filterData?.id ? filterData.id : null,
value: _item
}
_tempArr.push(_tempObject)
}
_tempArr.push(_tempObject)
}) : ( /* code3 */
// ** 可能是单一多选 attributeValObjArr可能为多个
_tempArr.push({
item && _tempArr.push({
customerAttribute: {
id: attributeObjArr[0].customerAttributeId,
name: attributeObjArr[0].attributeName
......@@ -476,7 +464,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
}
})
) /* code3 end */ /* code2 end */
console.log(_tableDataSource[index] && _tableDataSource[index][intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.assistantUniquePriceRate' })])
_paramsArray.push({
goodsId: _tableDataSource[index] ? _tableDataSource[index][intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.goodsName' })] : 0,
attributeAndValueList: _tempArr,
......@@ -491,8 +478,8 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
priceRate: _tableDataSource[0] && _tableDataSource[0][intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.assistantUniquePriceRate' })],
id: _tableDataSource[0] && _tableDataSource[0][intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.id' })],
}) /*带上货品id 带上单价*/ /* code1 end */
console.log(_tableDataSource, 'params', _paramsArray)
setPriceAttributeParams(_paramsArray)
console.log(_paramsArray, '_paramsArray')
}
/**
......@@ -547,7 +534,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
const confirmPrice = () => {
setPriceForm.validateFields().then(v => {
setPriceModalVisible(false)
console.log(v, 'v')
const { ladderPrice, ladderRange } = v
let _priceRange = {}
if (ladderPrice) { // 判断阶梯价格
......@@ -576,7 +562,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
}
_tableDataSource = newTabeData
setTableDataSource(_tableDataSource)
console.log(_tableDataSource, 'confirmPrice')
})
}
......@@ -584,7 +569,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
setIsBatchSetting(false) // 点击行操作批量置为false
setCurrentSetPriceRow(record)
setPriceModalVisible(true)
console.log(record, 'record') // 通过判断key字符串'0-0' 是否是阶梯价格 注:空对象时候{}为新建状态
setPriceForm.resetFields() // 先清空 若需要价格回显 在此处处理
if (Object.keys(record[intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.unitPrice' })])[0] === '0-0') { // 状态为非阶梯价格
setLadderPrice(false)
......@@ -690,10 +674,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
setAssistantUniquePriceRate(values['assistantUniquePriceRate'])
}
useEffect(() => {
console.log(assistantUniqueLadderPrice, 'ladder')
}, [assistantUniqueLadderPrice])
return (<>
<Form
{...layout}
......
import React, { useCallback, useRef } from 'react';
import React from 'react';
import { OrderDetailContext } from '../../../_public/order/context';
import { Button } from 'antd';
import OrderDetailHeader from '@/pages/transaction/components/orderDetailHeader';
import OrderDetailWrapper from '@/pages/transaction/components/orderDetailWrapper';
import PreLoading from '@/components/PreLoading';
import { useOrderDetail } from '../../../_public/order/effects/useOrderDetail';
import OrderHandDeleved from '../../../components/orderHandDeleved';
import OrderDetailSection from '../../../components/orderDetailSection';
import { usePageStatus } from '@/hooks/usePageStatus';
import { useIntl } from 'umi';
const ReadyConfirmDelevedOrderDetail: React.FC = () => {
const { formContext, id, detailList } = useOrderDetail({type: 's_readyConfirmDelevedOrder'})
const { batchNo } = usePageStatus()
const intl = useIntl()
// // 是否是手工发货
// const isHandDeleved = formContext.data && formContext.data.purchaseOrderInteriorState === SaleOrderInsideWorkState.HAND_DELEVED_ORDER
// // 所有发货单都是否已经发货了
// const isShowBtn = isHandDeleved || formContext.data?.orderDeliveryDetailsResponses?.some(v => v.interiorState === DeliverySideState.ADD_LOGISTICS_ORDER)
// 是否发过货
// const isHandDeleved = Number(batchNo) <= 0
const isHandDeleved = true
// 是否发货完成
const approvedRef = useRef<any>({})
const handleClick = useCallback(() => {
if (isHandDeleved) {
approvedRef.current.setVisible(true)
} else {
const deleveBox = document.querySelector('#deleveBox') as any
window.scrollTo(0, deleveBox.offsetTop)
}
}, [isHandDeleved])
const ReadyDelevedOrderDetail: React.FC = () => {
const { formContext, detailList } = useOrderDetail({type: 'purchaseOrder'})
return (
<div>
<OrderDetailContext.Provider value={formContext}>
<OrderDetailHeader detailList={detailList} detailData={formContext.data} extraRight={
<Button type='primary' onClick={handleClick}>
{ isHandDeleved ? intl.formatMessage({ id: 'saleOrder.querenshougongfa', defaultMessage: '确认手工发货' }) : intl.formatMessage({ id: 'saleOrder.qufahuo', defaultMessage: '去发货' }) }
</Button>
} />
<OrderDetailHeader detailList={detailList} detailData={formContext.data}/>
<OrderDetailWrapper>
<PreLoading loading={!formContext.data} active paragraph={{rows: 6}}>
<OrderDetailSection formContext={formContext} type='saleOrder'/>
<OrderDetailSection formContext={formContext}/>
</PreLoading>
</OrderDetailWrapper>
{/* 提交时触发的弹窗集合 */}
<OrderHandDeleved
currentRef={approvedRef}
/>
</OrderDetailContext.Provider>
</div>
);
};
export default ReadyConfirmDelevedOrderDetail;
export default ReadyDelevedOrderDetail;
......@@ -21,7 +21,7 @@ export const useSelfTable = () => {
render: (text, record) => {
// 查看订单, 需根据状态显示不同schema
return (
<EyePreview url={`/memberCenter/tranactionAbility/saleOrder/readyConfirmDelevedOrder/preview?id=${record.orderId}`}>
<EyePreview url={`/memberCenter/tranactionAbility/purchaseOrder/readyDelevedOrder/detail?id=${record.orderId}`}>
{text}
</EyePreview>
)
......
......@@ -66,7 +66,7 @@ class ProductStore implements IProductModule {
tempObj[item] = attributeValueIdArr[index]
}
else if(this.attributeLists.filter(_item => _item.id === item)[0]?.type === 3){ // 输入
tempObj[item] = attributeValueArr[index][0].value
tempObj[item] = attributeValueArr[index][0]?.value || ''
}
else{
tempObj[item] = attributeValueIdArr[index][0]
......
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