|
|
@@ -34,7 +34,7 @@
|
|
|
|
|
|
<script>
|
|
|
export default {
|
|
|
- props:['sa_logistics_boxid','addList','type'],
|
|
|
+ props:['sa_logistics_boxid','addList','type','delList'],
|
|
|
data () {
|
|
|
return {
|
|
|
params:{
|
|
|
@@ -66,9 +66,38 @@ export default {
|
|
|
e.remarks = ''
|
|
|
});
|
|
|
if (this.type == 'edit'){
|
|
|
- this.tableData = res.data
|
|
|
+ // console.log(this.addList,'11111删除的数据是什么')
|
|
|
+ // this.tableData = res.data
|
|
|
+ // if (this.addList && this.addList.length > 0){
|
|
|
+ // this.tableData = [...this.tableData,...this.addList]
|
|
|
+ // console.log(this.tableData,'输出数据******11111111')
|
|
|
+ // }
|
|
|
if (this.addList && this.addList.length > 0){
|
|
|
- this.tableData = [...this.tableData,...this.addList]
|
|
|
+ let indexof = 0
|
|
|
+ let dataNew = []
|
|
|
+ res.data.forEach((t,indexs)=>{
|
|
|
+ let float = 0
|
|
|
+ this.addList.forEach((i,index)=>{
|
|
|
+ if (t.sa_dispatch_itemsid == i.sa_dispatch_itemsid){
|
|
|
+ float = 1
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (float != 1){
|
|
|
+ dataNew[indexof] = res.data[indexs]
|
|
|
+ indexof = indexof + 1
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (this.delList && this.delList.length > 0){
|
|
|
+ this.tableData = [...dataNew,...this.delList]
|
|
|
+ }else {
|
|
|
+ this.tableData = dataNew
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if (this.delList && this.delList.length > 0){
|
|
|
+ this.tableData = [...res.data,...this.delList]
|
|
|
+ }else {
|
|
|
+ this.tableData = res.data
|
|
|
+ }
|
|
|
}
|
|
|
}else {
|
|
|
if (this.addList && this.addList.length > 0){
|
|
|
@@ -92,7 +121,7 @@ export default {
|
|
|
this.tableData = res.data
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ this.deduplicateObjects()
|
|
|
// this.tableData = res.data
|
|
|
// this.total = res.total
|
|
|
// this.currentPage = res.pageNumber
|
|
|
@@ -110,14 +139,26 @@ export default {
|
|
|
selectionChange (val) {
|
|
|
this.tableSelectData = val
|
|
|
},
|
|
|
+ deduplicateObjects(){
|
|
|
+ const uniqueItems = [];
|
|
|
+ this.tableData = this.tableData.filter(item => {
|
|
|
+ const isExist = uniqueItems.some(uniqueItem => uniqueItem.sa_dispatch_itemsid === item.sa_dispatch_itemsid);
|
|
|
+ if (!isExist) {
|
|
|
+ uniqueItems.push(item);
|
|
|
+ }
|
|
|
+ return !isExist;
|
|
|
+ });
|
|
|
+ console.log(this.tableData,'tableData')
|
|
|
+ },
|
|
|
onConfirm () {
|
|
|
- // this.tableSelectData.forEach((item,index) => {
|
|
|
- // this.tableData.forEach((item2,indexs) => {
|
|
|
- // if (item.itemid == item2.itemid) {
|
|
|
- // this.tableData.splice(indexs,1)
|
|
|
- // }
|
|
|
- // })
|
|
|
- // })
|
|
|
+ this.tableSelectData.forEach((item,index) => {
|
|
|
+ this.tableData.forEach((item2,indexs) => {
|
|
|
+ if (item.sa_dispatch_itemsid == item2.sa_dispatch_itemsid) {
|
|
|
+ this.tableData.splice(indexs,1)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ console.log(this.tableData,'111111')
|
|
|
this.$emit('onConfirm',this.tableSelectData)
|
|
|
},
|
|
|
},
|