liuxiaolong
2019-05-06 d380e76ec9783bcd80eb42e495d6f8e1af0827b4
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
<template>
  <!-- 布控列表 start -->
  <div class="px-4 py-4 person-list">
    <div class="row">
      <div
        class="col-lg-3 col-md-4 col-sm-6 pb-2"
        v-for="(item,index) in newTableList"
        :key="index"
      >
        <div class="person-list-item d-flex px-2 py-3 border">
          <div class="person-list-item-check pr-2">
            <el-checkbox v-model="item.checked" @change="checkboxChange"/>
          </div>
          <div class="person-list-item-img flex-center">
            <httpImg :src="item.imgUrl" width="100px" height="100px" alt/>
          </div>
          <div class="person-list-item-info px-2">
            <p class="mb-1" :title="item.isControl" v-if="tableType==='already'">{{item.isControl}}</p>
            <h6 class="mb-1 text-danger" :title="item.taskName">{{item.taskName}}</h6>
            <p class="mb-1" :title="item.userInfo">{{item.userInfo}}</p>
            <p class="mb-1" :class="tableType!=='already'?'visibility':'none'">已布控占位</p>
            <div class="btns">
              <fTemplate authority="ctrl:person:addCtrl">
                <i class="ion ion-ios-add-circle-outline" @click="$emit('add',item)"></i>
              </fTemplate>
              <fTemplate authority="ctrl:person:stop">
                <i
                  v-if="item.isControl==='布控中'"
                  class="far fa-stop-circle"
                  @click="$emit('stop',item)"
                ></i>
              </fTemplate>
              <fTemplate authority="ctrl:person:del">
                <i class="ion ion-md-close" @click="$emit('del',item)"></i>
              </fTemplate>
              <fTemplate authority="ctrl:person:editPerson">
                <i class="far fa-edit" @click="$emit('edit',item)"></i>
              </fTemplate>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="pt15 pb20">
      <b-pagination
        class="justify-content-center justify-content-sm-end m-0"
        v-if="total"
        v-model="activePage"
        :total-rows="total"
        :per-page="pageSize"
      />
    </div>
  </div>
  <!-- 布控列表 end -->
</template>
<script>
import { Checkbox } from 'element-ui'
export default {
  name: 'CtrlTask',
  metaInfo: {
    title: '布控人员'
  },
  props: [
    'total',
    'activePage',
    'pageSize',
    'tableList',
    'selectOpts',
    'tableType',
    'multipleSelection'
  ],
  data() {
    return {}
  },
  computed: {
    newTableList() {
      let list = this.tableList.map(item => {
        item.checked = this.multipleSelection.includes(item.id)
        // 处理布控状态 语义化
        for (let s of this.selectOpts) {
          if (item.isControl === s.value) {
            item.isControl = s.name
          }
        }
        // userInfo 拼接用户信息
        if (item.sex > -1) {
          item.sexName = item.sex > 0 ? '男' : item.sex === 0 ? '女' : ''
        }
        const arr = ['username', 'sexName', 'idCard', 'mobile']
        let userInfo = ''
        for (let [index, name] of arr.entries()) {
          if (item[name]) {
            userInfo += item[name] + `${index !== arr.length - 1 ? '/' : ''}`
          }
        }
        item.userInfo = userInfo
        return item
      })
      return list
    }
  },
  methods: {
    checkboxChange(data) {
      const ids = this.newTableList
        .filter(item => item.checked)
        .map(item => item.id)
      this.$emit('handleTableCheck', ids)
      console.log(data, 'check', ids)
    }
  },
  watch: {
    activePage(newVal, oldVal) {
      if (newVal !== oldVal) {
        this.handleSearch()
      }
    }
  },
  components: {
    elCheckbox: Checkbox
  }
}
</script>
<style lang="scss" scoped>
.person-list {
  .person-list-item {
    overflow: auto;
    .person-list-item-check {
      display: flex;
      align-items: center;
    }
    .person-list-item-img {
      flex: 1 1 auto;
      text-align: center;
    }
    .person-list-item-info {
      flex: 1 1 auto;
      h6 {
        font-size: 16px;
        font-weight: 900;
      }
      h6,
      p {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin: 0 auto;
      }
      p.visibility {
        visibility: hidden;
      }
      p.none {
        display: none;
      }
      .btns {
        max-width: 100px;
        margin: 0 auto;
      }
      .btns span {
        padding: 0 2px;
        font-size: 15px;
        cursor: pointer;
        color: #35bde7;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
      }
    }
  }
}
</style>