1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<template>
<el-table
border
:data="exportWarehouseList"
style="">
<el-table-column
width="250px"
label="始发地">
<template v-slot="{ row, column, $index }">
<el-checkbox v-model="row.checked" @change="emit">{{ $l(row, 'title') }}</el-checkbox>
</template>
</el-table-column>
<el-table-column
prop="objectiveId"
label="目的地">
<template v-slot="{ row, column, $index }">
<el-select v-model="row.objectiveIdArr" multiple placeholder="请选择" style="width:100%" @change="emit">
<el-option
v-for="item in importWarehouseList"
:key="item.id"
:label="$l(item, 'title')"
:value="item.id">
</el-option>
</el-select>
</template>
</el-table-column>
</el-table>
</template>
<script>
export default {
name: 'CustomerLineTable',
props: {
warehouseList: Array,
importCityList: Array,
value: Array,
zhongPaoType: {
type: Number,
default: 0
}
},
data() {
return {
tableData: [],
importWarehouseList: [],
exportWarehouseList: []
}
},
mounted() {
this.initLines()
},
methods: {
initLines(){
this.warehouseList.forEach(item => {
if(item.tradeType == 2 || item.tradeType == 3){
let oldItem = this.value.find(it => it.departureId == item.id)
this.exportWarehouseList.push(Object.assign({}, item, {
checked: !!oldItem,
objectiveIdArr: oldItem ? oldItem.objectiveIds.split(',').map(item => +item) : []
}))
}
if(item.tradeType == 1 || item.tradeType == 3){
this.importWarehouseList.push(Object.assign({}, item))
}
})
},
getValue(){
let arr = []
this.exportWarehouseList.forEach(item => {
if(item.checked){
arr.push({
objectiveIds: item.objectiveIdArr.join(','),
departureId: item.id,
zhongPaoType: this.zhongPaoType
})
}
})
return arr
},
emit(){
this.$emit('input', this.getValue())
}
},
watch: {
value() {
// this.freshTableData()
},
warehouseList() {
this.initLines()
}
}
}
</script>
<style scoped>
</style>