nidapeng
2024-03-11 81b2bbdbb92dd70ca28c9d556cd8dc4e9329584f
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<template>
    <TableLayout1 :permissions="['business:member:query']">
        <!-- 搜索表单 -->
        <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
            <el-form-item label="" prop="keyword">
                <el-input v-model="searchForm.keyword" placeholder="请输入姓名/手机号/工号" @keypress.enter.native="search"></el-input>
            </el-form-item>
            <el-form-item label="" prop="hasFace">
                <el-select v-model="searchForm.hasFace" @keypress.enter.native="search" placeholder="是否有人脸">
                    <el-option label="无" value="0"></el-option>
                    <el-option label="有" value="1"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="" prop="canVisit">
                <el-select v-model="searchForm.canVisit" @keypress.enter.native="search" placeholder="可拜访">
                    <el-option label="是" value="1"></el-option>
                    <el-option label="否" value="0"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="" prop="status">
                <el-select v-model="searchForm.status" @keypress.enter.native="search" placeholder="状态">
                    <el-option label="正常" value="0"></el-option>
                    <el-option label="禁用" value="1"></el-option>
                    <el-option label="拉黑/冻结" value="2"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="" prop="hkStatus">
                <el-select v-model="searchForm.hkStatus" @keypress.enter.native="search" placeholder="海康同步状态">
                    <el-option label="待同步" value="0"></el-option>
                    <el-option label="同步成功" value="1"></el-option>
                    <el-option label="同步失败" value="2"></el-option>
                </el-select>
            </el-form-item>
            <section>
                <el-button type="primary" @click="search">搜索</el-button>
                <el-button @click="reset">重置</el-button>
            </section>
        </el-form>
        <template v-slot:menu>
            <div style="width: 100%; height: 50px; background: rgba(242, 242, 242, 1); line-height: 50px; text-align: center; font-size: 14px;">企业组织架构</div>
            <div style="width: 100%; height: calc(100vh - 170px); overflow-y: scroll;">
                <Tree :list="companyTree" :defaultProps="{name: 'name', status: 'status', children: 'childList', id: 'id',erpId:'erpId'}" @callback="callback" />
            </div>
        </template>
        <!-- 表格和分页 -->
        <template v-slot:table-wrap>
            <ul class="toolbar" v-permissions="['business:member:delete','business:member:sync']">
<!--                <li><el-button type="primary">门禁授权</el-button></li>-->
                <li><el-button type="primary" v-permissions="['business:member:sync']" :loading="loading" @click="synchronous()">同步</el-button></li>
                <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:member:delete']">删除</el-button></li>
            </ul>
            <el-table
                v-loading="isWorking.search"
                :data="tableData.list"
                stripe
                @selection-change="handleSelectionChange"
            >
                <el-table-column type="selection" width="55"></el-table-column>
                <el-table-column prop="name" label="姓名" min-width="100px"></el-table-column>
                <el-table-column prop="phone" label="手机号" min-width="100px"></el-table-column>
                <el-table-column label="性别" min-width="100px">
                    <template slot-scope="{row}">
                        <span v-if="row.sex == 1">男</span>
                        <span v-if="row.sex == 2">女</span>
                    </template>
                </el-table-column>
              <el-table-column prop="companyName" label="所属部门" min-width="100px"></el-table-column>
                <el-table-column prop="status" label="状态" min-width="100px">
                    <template slot-scope="{row}">
                        <span v-if="row.status == 0" style="color: green">正常</span>
                        <span v-if="row.status == 1" style="color: red">禁用</span>
                        <span v-if="row.status == 2" style="color: red">拉黑/冻结</span>
                    </template>
                </el-table-column>
                <el-table-column prop="code" label="工号" min-width="100px"></el-table-column>
                <el-table-column label="可拜访" min-width="100px">
                    <template slot-scope="{row}">
                        <span v-if="row.canVisit != 1">否</span>
                        <span v-if="row.canVisit == 1">是</span>
                    </template>
                </el-table-column>
                <el-table-column label="海康同步状态" min-width="100px">
                 <template slot-scope="{row}">
                        <span v-if="row.hkStatus == 0" style="color: #435EBE">待同步</span>
                        <span v-if="row.hkStatus == 1" style="color: green">同步成功</span>
                        <span v-if="row.hkStatus == 2" style="color: red">同步失败</span>
                        <span v-if="row.hkStatus == 3" style="color: red">不符合下发条件</span>
                </template>
                </el-table-column>
                <el-table-column label="门禁角色" min-width="100px">
                    <template slot-scope="{row}">
                        <span>{{row.roleNames.join(',')}}</span>
                    </template>
                </el-table-column>
                <el-table-column fixed="right" label="人脸信息" min-width="100px">
                    <template slot-scope="{row}">
                        <el-image
                            v-if="row.faceImg"
                            style="width: 60px; height: 60px"
                            :src="row.faceImg"
                            :preview-src-list="[row.faceImg]">
                        </el-image>
                    </template>
                </el-table-column>
                <el-table-column fixed="right" label="卡片信息" min-width="100px">
                    <template slot-scope="{row}">
                        <el-button @click="$refs.cardOpeningRecord.open('开卡记录', row.id)" type="text">{{row.memberCardCount || '0'}}</el-button>
                    </template>
                </el-table-column>
                <el-table-column
                    v-if="containPermissions(['business:member:update', 'business:member:delete'])"
                    label="操作"
                    min-width="120"
                    fixed="right"
                >
                    <template slot-scope="{row}">
                        <el-button type="text" @click="empower(row.id)" v-permissions="['business:empower:create']">重新授权</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <pagination
                @size-change="handleSizeChange"
                @current-change="handlePageChange"
                :pagination="tableData.pagination"
            >
            </pagination>
            <!--    查看人员开卡记录    -->
            <cardOpeningRecord ref="cardOpeningRecord" @success="handlePageChange" />
        </template>
    </TableLayout1>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout1 from '@/layouts/TableLayout1'
import Pagination from '@/components/common/Pagination'
import cardOpeningRecord from '@/components/business/cardOpeningRecord'
import Tree from '@/components/common/Tree'
import { fetchList } from '@/api/business/company'
import { memberSync, roleAuth } from '@/api/business/member'
export default {
  name: 'internalMember',
  extends: BaseTable,
  components: { TableLayout1, Pagination, Tree, cardOpeningRecord },
  data () {
    return {
      TreeList: [],
      // 搜索
      searchForm: {
        name: '',
        status: '',
        hkStatus: '',
        canVisit: '',
        keyword: '',
        type: 2,
        erpOrgId: '',
        companyId: '',
        hasFace: ''
      },
      loading:false,
      companyTree: []
    }
  },
  created () {
    this.config({
      module: '人员信息表',
      api: '/business/member',
      'field.id': 'id',
      'field.main': 'id'
    })
    // this.search()
    this.getfindCompanyTreePage()
  },
  methods: {
    empower(id) {
      var that = this
      this.$confirm('确定重新授权吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        roleAuth(id)
          .then(res => {
            that.search()
          })
      }).catch(() => {
 
      });
    },
    // 获取组织树
    getfindCompanyTreePage () {
      fetchList(1)
        .then(res => {
          res[0].fsStatus = 1
          this.companyTree = res
          // this.searchForm.erpOrgId = res[0].erpId
          this.search()
        })
    },
    // 同步信息
    async synchronous () {
      this.$dialog.actionConfirm('操作确认提醒', '您确认同步全部信息吗?')
        .then(() => {
          this.loading = true
          memberSync({})
            .then(res => {
              this.$tip.apiSuccess(res || '同步成功')
              this.search()
            })
            .catch(e => {
              this.$tip.apiFailed(e)
            })
            .finally(() => {
              this.loading = false
            })
        })
        .catch(() => {})
    },
    callback (row) {
      this.searchForm.erpOrgId = row.erpId
      this.searchForm.companyId = row.id
      this.search()
    }
  }
}
</script>
 
<style lang="scss" scoped>
    .box {
        width: 100%;
        display: flex;
        align-items: center;
        .box_menu {
            width: 100px;
            height: 100%;
            flex-shrink: 0;
        }
        .box_tab {
            flex: 1;
            height: 100%;
        }
    }
</style>