Commit dd274a42 authored by shenshaokai's avatar shenshaokai

Merge branch 'jinfa-20221102' into 'jinfa-20221102'

fix: bugID=36488 不点击采购物料tab,直接生成合同或者保存的取值问题 See merge request project/jinfa-platform!480
parents 43abac58 db0481db
......@@ -23,11 +23,11 @@ pnpm-lock.yaml
# mockStatic
/.idea
#/config/base.config.json
/config/base.config.json
/src/services/index.ts
.vscode
#config/base.config.json
config/base.config.json
config/base.router.ts
src/global/config/global.d.ts
......
......@@ -8,6 +8,7 @@ import { getIntl } from 'umi';
import FileHt from '@/pages/contract/components/fileHt';
import UploadFiles from '@/components/UploadFiles/UploadFiles'
import { CloudUploadOutlined } from '@ant-design/icons';
import { getPurchaseList } from '../utils'
const intl = getIntl();
......@@ -25,7 +26,7 @@ const imgLimitList = [
]
const ContractText = (props: any) => {
const { currentRef, memberId, purchaseMate, roleId, basicsVO, currency, Price, tabIndex, getOtherInfo } = props;
const { currentRef, memberId, purchaseMate, roleId, basicsVO, currency, Price, tabIndex, getOtherInfo, sourceType } = props;
const [templatePage, setTemplatePage] = useState<any>([]);
const [template, setTemplate] = useState<any>({});
const [templateDemo, setTemplateDemo] = useState<any>({});
......@@ -87,9 +88,10 @@ const ContractText = (props: any) => {
/* 生成电子合同 */
const generate = async () => {
const purchaseMaterielList =
(await purchaseMate.current.length) != 0
(purchaseMate.current.length) != 0
? await purchaseMate.current.get()
: [];
: { data: { list: getPurchaseList(sourceType) } };
if (!template.id) {
message.info(intl.formatMessage({ id: 'contract.qingxianxuanzehetongmoban' }))
} else {
......@@ -221,7 +223,7 @@ const ContractText = (props: any) => {
>
</Select>
{
<Button style={{ marginLeft: 20 }} type='link' onClick={() => generate()}>{intl.formatMessage({ id: 'contract.shengchenghetong' })}</Button>
<Button style={{ marginLeft: 20 }} type='link' onClick={generate}>{intl.formatMessage({ id: 'contract.shengchenghetong' })}</Button>
}
</Form.Item>
{
......
......@@ -179,7 +179,6 @@ const FormList = (props: any) => {
i.bidAmount = (i.bidCount && i.price) ? new BigNumber(+i.bidCount).multipliedBy(i.price).toNumber().toFixed(2) : ''
})
console.log('list',newList);
setData(newList)
setIsPurchaseModalVisible(false)
......@@ -193,7 +192,7 @@ const FormList = (props: any) => {
// val_taxPoint(item)
})
setIsModalVisible(false)
setData(list)
}
......@@ -514,7 +513,7 @@ const FormList = (props: any) => {
rules={[{
required: true,
pattern: /^\d*(?:\.\d{0,5})?$/,
message: '单价仅限五位小数'
message: '单价仅限五位小数'
},
]}
>
......@@ -793,7 +792,7 @@ const FormList = (props: any) => {
}
item[idx].bidAmount = item[idx].bidCount && item[idx].price ? (new BigNumber(+item[idx].bidCount).multipliedBy(item[idx].price).toNumber()).toFixed(2) : 0;
console.log(item[idx].bidAmount,item[idx]);
setData(item)
......
......@@ -14,6 +14,7 @@ import BigNumber from 'bignumber.js'
import FreightInfo from './components/FreightInfo'
import OtherInfo from './components/OtherInfo'
import BankInfo from './components/BankInfo'
import { getPurchaseList } from './utils'
const intl = getIntl();
......@@ -235,6 +236,7 @@ const Add: React.FC<{}> = (props: any) => {
Price={Price}
tabIndex={tabIndex}
form={form}
sourceType={type}
/>
},
]
......@@ -291,7 +293,7 @@ const Add: React.FC<{}> = (props: any) => {
delete contractSourceVO.sourceId
}
/* 选择物料 */
const purchaseMaterielList = await purchaseMate.current.length != 0 ? await purchaseMate.current.get() : [];
const purchaseMaterielList = purchaseMate.current.length != 0 ? await purchaseMate.current.get() : { data: { list: getPurchaseList(sourceType) } };
if (purchaseMaterielList.length != 0) {
purchaseMaterielList.data.list.map(item => {
totalAmount += Number(item.bidAmount)
......
import BigNumber from 'bignumber.js';
//相同物料组合成同一条
const handlePurchaseData = (selectRow, sourceType: number) => {
let data = selectRow;
let newArray = data.reduce((total, cur, index) => {
let hasValue = total.findIndex(current => {
return current.productNo === cur.productNo;
});
hasValue === -1 && total.push(cur);
hasValue !== -1 &&
(total[hasValue].quantity = new BigNumber(+total[hasValue].quantity)
.plus(cur.quantity)
.toNumber());
hasValue !== -1 &&
(total[hasValue].prpIds = total[hasValue].prpIds + ',' + cur.prpIds);
return total;
}, []);
return newArray.map((item: any, index: number) => {
let num = 0;
let prpIdsList = item.prpIds.toString().split(',');
selectRow.forEach(item => {
if (
prpIdsList?.length &&
prpIdsList.indexOf(item.prpId.toString()) > -1
) {
if (
item.productNo == item.productNo &&
item.prpId == prpIdsList[prpIdsList.indexOf(item.prpId.toString())]
) {
num = new BigNumber(+item.num).plus(num).toNumber();
}
}
});
return {
id: 0,
materielId: item.id,
materielNo: sourceType != 4 ? item.code : item.productNo,
productNo: sourceType != 4 ? item.code : item.productNo,
materielName: item.name,
type: item.type,
category: item.customerCategory != null ? item.customerCategory.name : '',
brand: item.brand != null ? item.brand.name : '',
unit: item.unitName,
isHasTax: item.isHasTax,
taxRate: item.taxRate,
materialNo: item.materialNo,
deliveryType: item.deliveryType || item.deliveryMethod,
remark: item.remark,
purchaseCount: sourceType == 4 ? 0 : item.purchaseCount,
price: item.price || '',
advanceDeliveryDate: item.advanceDeliveryDate,
bidCount: String(num).replace(/^(.*\..{4}).*$/, '$1'),
bidAmount:
num && item.price
? new BigNumber(+num)
.multipliedBy(item.price)
.toNumber()
.toFixed(2)
: '',
associatedMaterielName: item.associatedMaterielName,
associatedGoods: item.associatedGoods,
associatedDataId: item.associatedDataId,
associatedMaterielNo: item.associatedMaterielNo,
associatedType: item.associatedType,
associatedCategory: item.associatedCategory,
associatedBrand: item.associatedBrand,
prpIds: sourceType == 4 ? item.prpIds?.toString().split(',') : null,
goodsPic: item.goodsPic || [],
};
});
};
// 采购物料默认取值问题
// 假如不切换到采购物料的tab的话,拿不到值默认给他那缓存的数据生成
export const getPurchaseList = (sourceType: number) => {
if (sourceType == 4) {
try {
let list = JSON.parse(sessionStorage.getItem('recordList'));
list = list?.map((item: any) => {
item.id = item.prpId;
item.customerCategory = {
name: item.category || '',
};
item.brand = {
name: item.brand || '',
};
item.unitName = item.unit;
item.type = item.spec;
item.bidCount = item.quantity;
item.num = item.quantity;
item.quantity = item.quantity;
item.prpIds = item.prpId;
item.isHasTax = !!item.taxPoint ? 1 : 0;
item.taxRate = (item.taxPoint || 0) * 100;
return item;
});
return handlePurchaseData(JSON.parse(JSON.stringify(list)), sourceType);
} catch (error) {
return [];
}
}
return [];
};
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