Commit 852c62ff authored by 陈卓's avatar 陈卓

代码提交

parent 272eb81d
......@@ -73,7 +73,7 @@ class DstributorOnTheWayQuery extends React.Component {
this.setState({
data:res.result,
onthewayinfoshow:true,
onthewayinfoshowtype:1
onthewayinfoshowtype:2
})
}else{
Toast.info('没有查询到在途信息')
......
......@@ -49,6 +49,8 @@ export default class Tab2 extends Component {
this.handleInputChange = this.handleInputChange.bind(this)
this.checkboxs = this.checkboxs.bind(this)
this.Scan = this.Scan.bind(this)
this.allNum = 0
}
handleInputChange(event) {
......@@ -107,7 +109,7 @@ export default class Tab2 extends Component {
<div className="table-container">
{this.state.data.map((item, index) => (
<div key={index} className="table-item">
<div className="table-item-icon-letf" onClick={() => { this.selectAllBox2()}}>
<div className="table-item-icon-letf" onClick={() => { this.selectAllBox2(index)}}>
</div>
<div className="table-item-left-float">
......@@ -119,7 +121,7 @@ export default class Tab2 extends Component {
<div className="table-item-left-boxnum">{'箱数:'+item.box_num}</div>
<div className="table-item-icon-right" onClick={() => { this.selectAllBox2()}}>
<div className="table-item-icon-right" onClick={() => { this.selectAllBox2(index)}}>
<img style={{ marginTop: '.15rem' }} src={item.statuscode == 0 ? checkon : checkoff} />
</div>
......@@ -127,7 +129,7 @@ export default class Tab2 extends Component {
<div key={indexs} style={{ display: (item.boxshow) ? "block" : "none",width:'100%',height: '0.8rem'}}>
<div className="table-item-left-icon" onClick={() => { row.status == 0 ? this.delboxnumshow(indexs) : this.delboxnum(indexs) }}>
<div className="table-item-left-icon" onClick={() => { row.status == 0 ? this.delboxnumshow(indexs,index) : this.delboxnum(indexs,index) }}>
</div>
......@@ -135,7 +137,7 @@ export default class Tab2 extends Component {
<div className="table-item-right-row">
{row.box_number}</div>
<div className="table-item-left-row"></div>
<div className="table-item-right-icon" onClick={() => { row.status == 0 ? this.delboxnumshow(indexs) : this.delboxnum(indexs) }}>
<div className="table-item-right-icon" onClick={() => { row.status == 0 ? this.delboxnumshow(indexs,index) : this.delboxnum(indexs,index) }}>
<img style={{ marginTop: '.15rem' }} src={row.statuscode == 0 ? checkon : checkoff} />
</div>
......@@ -147,7 +149,7 @@ export default class Tab2 extends Component {
</div>
</div>
</div>
<div className="prompt">已扫描箱数量:{this.state.data[0]?this.state.data[0].box_list.length:0} 已选箱数量:{this.state.num}</div>
<div className="prompt">已扫描箱数量:{this.allNum} 已选箱数量:{this.state.num}</div>
<div className="submitContainer">
<Button
className="submit"
......@@ -315,20 +317,24 @@ export default class Tab2 extends Component {
}
}
//20220316 全选或者反选所有箱号
selectAllBox(){
selectAllBox(){
if(this.state.checked){
return
}
let data = this.state.data;
var box_total = 0
if(this.state.data){
box_total = this.state.data[0]['box_list'].length;
var fdata = this.state.data
for(var i=0;i<fdata.length;i++){
box_total = box_total + this.state.data[i]['box_list'].length;
}
}else{
box_total = 0
}
console.log(box_total);
let flag = this.state.allSelectFlag;
console.log(flag);
//如果flag等于0,表示当前的状态是未全选的状态,需要将所有的数据全选(statuscode == 0)
if(flag == 0){
for(var i = 0;i< data.length;i++){
......@@ -367,21 +373,14 @@ export default class Tab2 extends Component {
})
}
//20220316 全选或者反选所有箱号
selectAllBox2(){
selectAllBox2(index){
if(this.state.checked){
return
}
let data = this.state.data;
var box_total = 0
if(this.state.data!=null){
box_total = this.state.data[0]['box_list'].length;
}else{
box_total = 0
}
console.log(box_total);
let flag = this.state.data[0].statuscode;
let datas = this.state.data[0]['box_list'];
let flag = this.state.data[index].statuscode;
let datas = this.state.data[index]['box_list'];
//如果flag等于0,表示当前的状态是未全选的状态,需要将所有的数据全选(statuscode == 0)
if(flag==undefined||flag == 1){
for(var i = 0;i< datas.length;i++){
......@@ -391,6 +390,8 @@ export default class Tab2 extends Component {
flag = 0;
}
}else{
this.state.allSelectFlag = 0
for(var i = 0;i< datas.length;i++){
//取消全选数据
datas[i].statuscode = 1;
......@@ -399,10 +400,11 @@ export default class Tab2 extends Component {
}
}
//设置数据
this.state.data[0].statuscode = flag
box_total = this.getnumbox()
this.state.data[index].statuscode = flag
this.setState({
data: data,
num:flag == 0 ? box_total: 0
num:box_total
})
}
//20220316 检查全选或者反选的状态,每次在更改过箱号状态,或者扫描后都调用该方法
......@@ -427,12 +429,27 @@ export default class Tab2 extends Component {
})
}
getnumbox(){
let data = this.state.data
var num = 0
data.map((row, index) => {
var boxList = row['box_list']
boxList.map((item, index) => {
if (item.statuscode == 0) {
num+=1
}
})
})
return num
}
//根据交接单号获取箱号,详细信息
checkboxs() {
//GJ20180929001
if (this.state.deliverid) {
var sitecode = this.state.userInfo.code || ""//站点
var sitecode = 'CMAL/SP.50140'
// var sitecode = this.state.userInfo.code || ""//站点
var ho = this.state.deliverid//交接单号
Toast.loading('Loading...', 0, () => {
},true);
......@@ -444,8 +461,14 @@ export default class Tab2 extends Component {
console.log('根据交接单号,获取箱号详细信息', res);
if (res.code == 1 && res.result.length != 0) {
var tempdata = this.state.data
var allNum = this.allNum
var isok = false
if(tempdata.length == 0){
isok = true
}
res.result.map((item, index) => {
if (tempdata.length == 0) {
if (isok) {
if (item.state == "S") {
tempdata = tempdata.concat(Object.assign({}, item, { statuscode: 2 }));
} else {
......@@ -455,41 +478,34 @@ export default class Tab2 extends Component {
// })
}
} else {
for (var i = 0; i < tempdata.length; i++) {
if (tempdata[i].box_number == item.box_number) {
if (tempdata[i].statuscode == 0) {
// Toast.info('该箱号已存在')
this.setState({
repbox: true
})
return
} else {
let newObj = tempdata[i]
if (item.state == "S") {//新增状态不能选择的
newObj.statuscode = 2;
} else {
newObj.statuscode = 1;
// this.setState({
// num: this.state.num + 1
// })
}
this.state.data.splice(i, 1, newObj)
this.setState({
data: this.state.data.concat()
})
return
}
}
}
if (item.state == "S") {
tempdata = tempdata.concat(Object.assign({}, item, { statuscode: 2 }));
} else {
tempdata = tempdata.concat(Object.assign({}, item, { statuscode: 1 }));
// this.setState({
// num: this.state.num + 1
// })
}
var bj = true;
for (var i = 0; i < tempdata.length; i++) {
var boxlist = tempdata[i]['box_list']
for(var j = 0; j < boxlist.length; j++){
var box_number = boxlist[j]['box_number']
for(var n = 0; n < item.box_list.length; n++){
var itembox = item.box_list[n]['box_number']
if (box_number == itembox) {
bj = false;
this.setState({
repbox: true
})
return
}else{
}
}
}
}
if(bj){
tempdata = tempdata.concat(Object.assign({}, item, { statuscode: 1 }));
}
}
allNum+=item.box_list.length
this.allNum = allNum
})
let currentShipment = res.result[0].shipment_gid;
//20220316 增加选中状态判断,如果是第一次添加,直接将flag置位1
......@@ -539,7 +555,10 @@ export default class Tab2 extends Component {
}
//删除
delboxnumshow(index) {
delboxnumshow(index,findex) {
if(this.state.checked){
return
}
this.setState({
delisshow: true,
delindex: index
......@@ -556,15 +575,15 @@ export default class Tab2 extends Component {
})
}
//删除箱号
delboxnum(index) {
delboxnum(index,findex) {
if(this.state.checked){
return
}
let newObj = this.state.data[0].box_list[index]
let newObj = this.state.data[findex].box_list[index]
if (newObj.statuscode == 0) {
newObj.statuscode = 1
//去除上级的全选
this.state.data[0].statuscode = 1
this.state.data[findex].statuscode = 1
this.state.allSelectFlag = 0
this.setState({
num: this.state.num - 1,
......@@ -699,13 +718,17 @@ export default class Tab2 extends Component {
}
// 根据交接单签收
savebox() {
let tempdata = this.state.data[0].box_list
let tempdata = this.state.data
let newdata = []
tempdata.map((item, index) => {
if (item.statuscode == 0) {
newdata.push(item)
}
})
tempdata.map((row, index) => {
var boxList = row['box_list']
boxList.map((item, index) => {
if (item.statuscode == 0) {
newdata.push(item)
}
})
})
if (newdata.length == 0) {
// Toast.info("请先添加箱号")
this.setState({
......
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