第一种方法
使用for in 遍历
this.MaterialInfoData
[{"PurchaseId":11140,"PurchaseNo":null,"MaterialNo":"B617003/1 蓝绿色素色","HuaWen":"素色","GeKuan":12,"TiaoKuan":23,"WeiYi":23,"MenFu":145,"ChengFen":null,"LiningType":"","Nup":false,"LaLian":"0","MianXianHao":"23","Quantity":2,"PurchaseRemark":"","MaterialID":10502,"IsApplyType":null,"ApplyStatus":null,"ApplyStatusName":null,"PurchaseType":null,"ApplyCreateNO":null,"InputRemark":"","IsDelete":null,"Inputer":null,"OrderNo":null,"OrderId":163735,"InputTime":null,"PurchaseTime":null,"ImgList":[{"ImgPath":""},{"ImgPath":""}],"DefectiveImgList":[],"ShowCopyBtn":false},{"PurchaseId":11141,"PurchaseNo":null,"MaterialNo":"ST616.1648","HuaWen":"","GeKuan":12,"TiaoKuan":23,"WeiYi":23,"MenFu":0,"ChengFen":null,"LiningType":"","Nup":false,"LaLian":"0","MianXianHao":"23","Quantity":1.5,"PurchaseRemark":"","MaterialID":10503,"IsApplyType":null,"ApplyStatus":null,"ApplyStatusName":null,"PurchaseType":null,"ApplyCreateNO":null,"InputRemark":"","IsDelete":null,"Inputer":null,"OrderNo":null,"OrderId":163735,"InputTime":null,"PurchaseTime":null,"ImgList":[{"ImgPath":"https://www.mx-mtm.com/API_Upload/Images/Factory/PurchaseMail/20220324174238_6487.jpg"},{"ImgPath":"https://www.mx-mtm.com/API_Upload/Images/Factory/PurchaseMail/20220324174238_6487.jpg"}],"DefectiveImgList":[],"ShowCopyBtn":true}]
// 数组中结构出需要的项
let {GeKuan,TiaoKuan,WeiYi,MenFu,LaLian,Nup,LiningType,MianXianHao,ChengFen} = this.MaterialInfoData[data.$index-1]
let source = {GeKuan,TiaoKuan,WeiYi,MenFu,LaLian,Nup,LiningType,MianXianHao,ChengFen}
for (const key in source) {
this.MaterialInfoData[data.$index][key] = source[key]
}
第二种方法
使用for of 遍历
handleCopy(data){
// 定死需要的项
let options = ['GeKuan','TiaoKuan','WeiYi','MenFu','LaLian','Nup','LiningType','MianXianHao','ChengFen']
for (const key of options) {
this.MaterialInfoData[data.$index][key] = this.MaterialInfoData[data.$index-1][key]
}
},
网友评论