zjf
2023-02-24 3f9bad03f4fbca2d5c5be86e904ae832475634d8
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<template>
  <el-popover
    class='pop'
    :disabled="item.disabled"
    :offset="250"
    placement="right"
    popper-class="no-padding-popover"
    width="500"
    trigger="click">
    <div class="container">
      <flexbox class="header">
        <div class="name">联系人</div>
        <!--<div class="detail"></div>-->
        <img
          class="close"
          src="@/assets/img/task_close.png"
          @click="hidenView" >
      </flexbox>
      <flexbox class="content">
        <div class="cropper-box">
          <span class='searchTitle'>查找内容:</span>
          <el-input class='searchInput' v-model='popSearch' placeholder='请输入联系人名称'></el-input>
          <el-button  type="primary" class='searchBtn' @click='getCustomerTable'>立即查找</el-button>
        </div>
      </flexbox>
      <el-table
        v-loading="loading"
        :data="popData"
        :cell-style="popCellStyle"
        :header-cell-style="headerCellStyle"
        height="250"
        style="margin-right:3px;"
        highlight-current-row
        @row-click="handlePopRowClick">
        <el-table-column
          v-for="(item, index) in popFieldList"
          :key="index"
          :prop="item.field"
          :label="item.value"
          align="center"
          header-align="center"
          show-overflow-tooltip/>
      </el-table>
      <div class="p-contianer">
        <el-pagination
          :current-page="currentPopPage"
          :page-sizes="pagePopSizes"
          :page-size.sync="pagePopSize"
          :total="totalPop"
          class="p-bar"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handlePopSizeChange"
          @current-change="handlePopCurrentChange"/>
      </div>
    </div>
    <el-input slot="reference" :disabled='true' v-model='contacterChosed' placeholder='请点击选择联系人'></el-input>
  </el-popover>
</template>
<script type="text/javascript">
import { GetPersonalContacterList } from '@/api/customermanagement/contacts'
export default {
  name: 'XhRelativeInputS', // 新建 XhRelativeInput
  components: {},
  props: {
    item: {
      type: Object,
      default: () => {
        return {}
      }
    },
    customerId: {
      type: String,
      default: () => {
        return ''
      }
    }
  },
  data () {
    return {
      loading: false,
      popData: [],
      currentPopPage: 1,
      pagePopSize: 15,
      pagePopSizes: [15, 30, 60, 100],
      contacterChosed: '',
      popSearch: '',
      totalPop: 0
    }
  },
  computed: {
    popFieldList () {
      if (this.item && this.item.field === 'ContacterId') {
        return [
          { field: 'ContacterNumber', value: '联系人编号', width: '20' },
          { field: 'CustomerName', value: '联系人名称', width: '20' },
          { field: 'RealName', value: '联系人真实姓名', width: '10' },
          { field: 'Sex', value: '性别', width: '10' },
          { field: 'MobilePhone', value: '联系人方式', width: '30' },
          { field: 'JobPosition', value: '联系人职位', width: '10' },
          { field: 'OwerUserName', value: '负责人', width: '10' }
        ]
      }
    }
  },
  watch: {
  },
  mounted () {
    if (this.item && this.item.field === 'ContacterId') {
      this.contacterChosed = this.item.chosedCusName ? this.item.chosedCusName : ''
      this.getCustomerTable()
    }
  },
  methods: {
    /** 通过回调控制style */
    popCellStyle ({ row, column, rowIndex, columnIndex }) {
      return { fontSize: '12px', textAlign: 'center', cursor: 'pointer' }
    },
    headerCellStyle ({ row, column, rowIndex, columnIndex }) {
      return { fontSize: '12px', textAlign: 'center' }
    },
    handlePopSizeChange (newSize) {
      this.pagePopSizes = newSize
      this.getCustomerTable()
    },
    handlePopCurrentChange (newPage) {
      this.currentPopPage = newPage
      this.getCustomerTable()
    },
    getCustomerTable () {
      let params = {
        Name: this.popSearch,
        PageIndex: this.currentPopPage,
        PageSize: this.pagePopSize,
        CustomerId: this.customerId
      }
      if (this.item && this.item.field === 'ContacterId') {
        GetPersonalContacterList(params).then(res => {
          if (res.data.ErrorCode === 200 && res.data.Result !== 0) {
            this.popData = res.data.Result.List || []
            this.totalPop = res.data.Result.Count
          } else {
            this.$message.error(res.data.Message)
            this.loading = false
          }
        })
      }
    },
    hidenView () {
      document.querySelector('#app').click()
      this.$emit('close', this.$el, this.data)
    },
    // 当某一行被点击时会触发该事件
    handlePopRowClick (row, column, event) {
      this.$emit('value-change', {index: this.item.field,
        value: row.Id})
      this.contacterChosed = row.RealName
      this.hidenView()
    }
 
  }
}
</script>
<style lang="scss" scoped>
.container {
  position: relative;
}
 
.header {
  height: 40px;
  padding: 0 10px;
  flex-shrink: 0;
  .name {
    font-size: 13px;
    padding: 0 10px;
    color: #333;
  }
  .detail {
    font-size: 12px;
    padding: 0 10px;
    color: #aaaaaa;
    border-left: 1px solid #aaaaaa;
  }
  .close {
    position: absolute;
    width: 40px;
    height: 40px;
    top: 0;
    right: 10px;
    padding: 10px;
  }
}
.content{
  .cropper-box{
    display:flex;
    flex-direction: row;
    align-items: center;
    padding: 0 20px;
    .searchTitle{
      font-size: 14px;
      width: 124px;
      color: #333;
    }
    .searchInput{
      margin-right: 20px;
    }
  }
}
.p-contianer .p-bar{
  margin: 5px 0 0 14px;
}
.pop /deep/ .el-input.is-disabled .el-input__inner{
  cursor: pointer;
}
</style>