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

<style scoped>

</style>