This commit is contained in:
parent
6b1eb6c829
commit
aa31f8b9ba
|
@ -57,6 +57,8 @@ export default class exchangedit extends React.Component{
|
|||
reseller:null,
|
||||
payment_direction:["对私账户","对公账户","预付款扣除"],
|
||||
isAudit:false,
|
||||
approvalsStatus:false,
|
||||
oldTable:[]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,6 +72,7 @@ export default class exchangedit extends React.Component{
|
|||
|
||||
let code_batch_id = sessionStorage.getItem("code_id")
|
||||
let approval_id = sessionStorage.getItem("approval_id")
|
||||
let approval_status = sessionStorage.getItem("approval_status")
|
||||
if(approval_id > 0)
|
||||
{
|
||||
getApprovalsInfo(approval_id).then(res=>{
|
||||
|
@ -92,9 +95,25 @@ export default class exchangedit extends React.Component{
|
|||
range:req.update_product
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(req.new_product.length > 0)
|
||||
{
|
||||
|
||||
if(approval_status == 7)
|
||||
{
|
||||
req.new_product = _.map(req.new_product,(item)=>{
|
||||
item.checked = false
|
||||
return item
|
||||
})
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
codeInfo.range = codeInfo.range.concat(req.new_product);
|
||||
|
||||
}
|
||||
|
||||
let new_ids = _.map(req.new_product,(o)=>{
|
||||
|
@ -109,22 +128,45 @@ export default class exchangedit extends React.Component{
|
|||
handelResponse(res,(req,msg)=>{
|
||||
codeInfo.stock = req.stock;
|
||||
|
||||
this.setState({oldTable:req.code_batch_stock})
|
||||
console.log("老数据",this.state.oldTable)
|
||||
|
||||
let deleteArr = []
|
||||
|
||||
for(let i =0;i < delete_product.length;i++)
|
||||
{
|
||||
let deleteData = req.code_batch_stock.find(o=>o.product_id == delete_product[i])
|
||||
deleteData.checked = false;
|
||||
deleteArr.push(deleteData)
|
||||
}
|
||||
|
||||
|
||||
|
||||
console.log("删除数组",deleteArr)
|
||||
|
||||
this.setState({codeInfo:codeInfo})
|
||||
this.setState({isload:true});
|
||||
codeInfo.range = codeInfo.range.concat(deleteArr)
|
||||
|
||||
|
||||
|
||||
|
||||
let table = _.map(codeInfo.range,(res)=>{
|
||||
let obj = req.code_batch_stock.find(o=>o.product_id == res.product_id);
|
||||
|
||||
|
||||
res.usage = obj ? obj.usage : 0;
|
||||
res.stock =obj ? obj.stock : res.quantity - res.usage;
|
||||
res.checked = true;
|
||||
res.checked = res.hasOwnProperty("checked") ? res.checked : true;
|
||||
if(approval_status == 7 && obj)
|
||||
{
|
||||
res.checked = true
|
||||
}
|
||||
|
||||
return res
|
||||
});
|
||||
|
||||
|
||||
this.setState({deleteProduct:delete_product})
|
||||
this.setState({deleteProduct:[]})
|
||||
|
||||
this.setState({tempdata:codeInfo.range})
|
||||
|
||||
|
@ -134,11 +176,17 @@ export default class exchangedit extends React.Component{
|
|||
let obj = {};
|
||||
obj.key = res.product_id;
|
||||
obj.text= res.product_name;
|
||||
if(new_ids.indexOf(res.product_id) < 0)
|
||||
{
|
||||
this.state.oldProduct.push(res.product_id);
|
||||
}
|
||||
arr.push(obj)
|
||||
return obj;
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
this.setState({rankoptions:arr})
|
||||
this.setState({rank:arr})
|
||||
|
||||
|
@ -317,33 +365,31 @@ export default class exchangedit extends React.Component{
|
|||
let temp = addProduct.filter((item)=>{
|
||||
return deleteProduct.indexOf(item.product_id) > -1
|
||||
})
|
||||
let tempIds = _.map(temp,(item)=>{
|
||||
return item.product_id
|
||||
})
|
||||
// let tempIds = _.map(temp,(item)=>{
|
||||
// return item.product_id
|
||||
// })
|
||||
|
||||
if(temp.length > 0)
|
||||
{
|
||||
// if(temp.length > 0)
|
||||
// {
|
||||
|
||||
|
||||
addProduct = addProduct.filter((item)=>{
|
||||
return tempIds.indexOf(item.product_id) < 0
|
||||
})
|
||||
// // addProduct = addProduct.filter((item)=>{
|
||||
// // return tempIds.indexOf(item.product_id) < 0
|
||||
// // })
|
||||
|
||||
console.log("新增",addProduct)
|
||||
// // let updateAdd =_.filter(addProduct,(item)=>{
|
||||
|
||||
let updateAdd =_.filter(addProduct,(item)=>{
|
||||
|
||||
return deleteProduct.indexOf(item.product_id) > -1
|
||||
})
|
||||
// // return deleteProduct.indexOf(item.product_id) > -1
|
||||
// // })
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
updateProduct = updateProduct.concat(updateAdd);
|
||||
// // updateProduct = updateProduct.concat(updateAdd);
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
@ -420,6 +466,28 @@ export default class exchangedit extends React.Component{
|
|||
}
|
||||
let code_batch_id = sessionStorage.getItem("code_id")
|
||||
let data = this.buildData()
|
||||
|
||||
let approval_id = sessionStorage.getItem("approval_id")
|
||||
|
||||
if(approval_id <= 0)
|
||||
{
|
||||
this.setState({audit_visible:true})
|
||||
}
|
||||
else{
|
||||
getApprovalsStatus(approval_id).then((res)=>{
|
||||
handelResponse(res,(req,msg)=>{
|
||||
if(req.status == 0)
|
||||
{
|
||||
this.setState({approvalsStatus:true})
|
||||
this.setState({recall_visible:true})
|
||||
}
|
||||
if(req.status == 1)
|
||||
{
|
||||
Notify.error("进行中的批次不能提交审核")
|
||||
|
||||
}
|
||||
if(req.status == 2 || req.status == 3){
|
||||
|
||||
getIsRequireApproval(code_batch_id,data).then((res)=>{
|
||||
handelResponse(res,(req,msg)=>{
|
||||
|
||||
|
@ -430,52 +498,41 @@ export default class exchangedit extends React.Component{
|
|||
else{
|
||||
this.submitCodeData();
|
||||
}
|
||||
|
||||
|
||||
},(err)=>{
|
||||
Notify.error(err)
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
},(err)=>{
|
||||
Notify.error(err)
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
onConfirm(){
|
||||
let approval_id = sessionStorage.getItem("approval_id")
|
||||
|
||||
this.setState({audit_visible:false})
|
||||
if(approval_id <= 0)
|
||||
{
|
||||
this.submitCodeData();
|
||||
}else{
|
||||
// if(approval_id <= 0)
|
||||
// {
|
||||
// this.submitCodeData();
|
||||
// }else{
|
||||
// if(this.state.approvalsStatus==true)
|
||||
// {
|
||||
// this.setState({recall_visible:true})
|
||||
// }
|
||||
|
||||
getApprovalsStatus(approval_id).then((res)=>{
|
||||
handelResponse(res,(req,msg)=>{
|
||||
if(req.status == 0)
|
||||
{
|
||||
this.setState({recall_visible:true})
|
||||
}
|
||||
if(req.status == 1)
|
||||
{
|
||||
Notify.error("进行中的批次不能提交审核")
|
||||
setTimeout(()=>{
|
||||
this.props.history.push('/home/key-list/');
|
||||
},2000)
|
||||
|
||||
}
|
||||
if(req.status == 2 || req.status == 3){
|
||||
|
||||
this.submitCodeData();
|
||||
|
||||
}
|
||||
},(err)=>{
|
||||
Notify.error(err)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
@ -727,6 +784,11 @@ export default class exchangedit extends React.Component{
|
|||
clearInterval(timer_c)
|
||||
this.setState({approvalLoading:false})
|
||||
Notify.success("撤销成功,请重新提交审核")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
let time = this.state.timer - 1;
|
||||
this.setState({timer:time})
|
||||
|
|
|
@ -175,6 +175,7 @@ export default class acclist extends React.Component{
|
|||
sessionStorage.setItem("code_id",rowData.id)
|
||||
sessionStorage.setItem('breaknav',JSON.stringify(activerou));
|
||||
sessionStorage.setItem("approval_id",rowData.approval_id)
|
||||
sessionStorage.setItem("approval_status",rowData.status)
|
||||
window.open('#/home/exchangecode-edit');
|
||||
}
|
||||
tabFn(index){
|
||||
|
|
Loading…
Reference in New Issue