zouyu
2023-11-13 5381292617ad40f2fc7a9266ceb964a672d25a5a
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<template>
  <div>
    <el-select
      v-model="currValue"
      filterable
      @change="changeValue"
      :disabled="isDisabled"
      placeholder="请输入"
      clearable
      class="lmes-select"
    >
      <el-option
        v-if="data.length > 0"
        class="lmes-select-head"
        key="title1"
        label="title"
        value="title"
        disabled
      >
        <span v-for="(col, j) in columns" :key="col.prop">{{ col.label }}</span>
      </el-option>
      <el-option
        class="lmes-select-body"
        v-for="(item, i) in data"
        :key="'SearchSelect-' + i"
        :label="formatter(item)"
        :value="item.id"
      >
        <span v-for="(col, j) in columns" :key="col.prop + i">{{
          col.formatter
            ? col.formatter(item[col.prop])
            : item[col.prop]
            ? item[col.prop]
            : '--'
        }}</span>
      </el-option>
    </el-select>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      currValue: null
    }
  },
  props: {
    value: null,
    columns: {
      type: Array,
      default: () => {
        return []
      }
    },
    data: {
      type: Array,
      default: () => {
        return []
      }
    },
    formatter: {
      type: Function
    },
    isDisabled: {
      type: Boolean,
      default: () => {
        return false
      }
    }
  },
  mounted() {},
  methods: {
    changeValue() {
      this.$emit('input', this.currValue)
      this.$emit('selectChange')
    }
  },
  watch: {
    value() {
      this.currValue = this.value
    }
  }
}
</script>
 
<style>
.lmes-select {
  width: 100%;
}
 
.lmes-select-nodata {
  text-align: center;
  font-size: 13px;
  line-height: 44px;
}
 
.lmes-select-head span,
.lmes-select-body span {
  display: inline-block;
  width: 150px;
  font-size: 13px;
  padding: 0 10px !important;
}
 
.lmes-select-head,
.lmes-select-body,
.lmes-select-nodata {
  padding-left: 10px !important;
  padding-right: 10px !important;
}
 
.lmes-select-head span:last-child,
.lmes-select-body span:last-child {
  /*min-width: 100px;*/
  text-align: right;
}
 
.lmes-select .el-input .el-input__inner {
  background: transparent !important;
  border-top: none;
  border-left: none;
  border-right: none;
  padding: 0;
}
</style>