UserOrgPostList.vue
5.78 KB
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
<template>
<div>
<ht-table
@load="orgPostData"
:data="orgPostList"
:pageResult="orgPostPageResult"
:selection="true"
:show-export="false"
:show-custom-column="false"
:default-querys="[{property: 'account', value: data.account}]"
quick-search-props="orgName,posName"
ref="orgPostTables"
@selection-change="handleSelectionChange"
>
<template v-slot:toolbar>
<el-button
size="small"
@click="divertClick"
type="primary"
icon="icon-zhuanyi"
:disabled="isDisabled"
>转移</el-button
>
<el-button
size="small"
@click="copyClick"
icon="icon-copy"
:disabled="isDisabled"
>复制</el-button
>
<ht-delete-button
:url="delOrgUser"
:htTable="$refs.orgPostTables"
@after-delete="afterDelOrgUser"
pk="orgUserId"
:disabled="isDisabled"
>删除</ht-delete-button
>
</template>
<template>
<ht-table-column type="index" width="50" align="center" label="序号" />
<ht-table-column prop="demName" label="组织维度" width="160" />
<ht-table-column prop="orgName" label="组织名称" />
<ht-table-column prop="posName" label="岗位名称" />
<ht-table-column prop="isMaster" label="主组织/主岗位" width="140">
<template v-slot="{row}">
<el-tag type="danger" v-if="row.isMaster == '0'">否</el-tag>
<el-tag v-if="row.isMaster == '1'">是</el-tag>
</template>
</ht-table-column>
</template>
</ht-table>
<!--用户选择对话框 -->
<ht-user-dialog
ref="eipUserDialog"
@on-confirm="eipUserDialogOk"
append-to-body
/>
</div>
</template>
<script>
import utils from '@/hotent-ui-util.js'
import uc from '@/api/uc.js'
const eipUserDialog = () => import('@/components/dialog/EipUserDialog.vue')
export default {
name: 'userOrgPostList',
props: ['data'],
components: {eipUserDialog},
computed: {
delOrgUser: function() {
return window.context.uc + '/api/org/v1/orgUser/delOrgUser'
}
},
data() {
return {
orgPostList: [], //用户所属组织岗位
orgPostPageResult: {
page: 1,
pageSize: 20,
total: 0
},
selectOrgs: [], //选择的组织
selectPosts: [], //选择的岗位
type: '', //1、转移,2、复制
orgUserIds: [], //转移操作时要删除的组织岗位Id
isDisabled: true,
selectedList: []
}
},
watch: {
'data.account': {
handler(newValue, oldValue) {
if (newValue && oldValue && newValue != oldValue) {
this.$nextTick(() => {
this.$refs.orgPostTables.load()
})
}
},
deep: true,
immediate: true
},
selectedList: {
handler(val) {
this.isDisabled = val.length < 1 ? true : false
},
deep: true
}
},
methods: {
handleSelectionChange(selection) {
this.selectedList = selection
},
//转移
divertClick() {
this.type = ''
this.selectOrgs = []
this.selectPosts = []
let selectSelection = this.$refs.orgPostTables.selection
if (selectSelection && selectSelection.length == 0) {
this.$message.error('请选择要转移的组织岗位')
return
}
for (let k = 0; k < selectSelection.length; k++) {
this.orgUserIds.push(selectSelection[k].orgUserId)
if (selectSelection[k].posCode) {
this.selectPosts.push(selectSelection[k].posCode)
} else {
this.selectOrgs.push(selectSelection[k].orgCode)
}
}
this.type = '1'
this.$refs['eipUserDialog'].showDialog()
},
//复制
copyClick() {
this.type = ''
this.selectOrgs = []
this.selectPosts = []
let selectSelection = this.$refs.orgPostTables.selection
if (selectSelection && selectSelection.length == 0) {
this.$message.error('请选择要复制的组织岗位')
return
}
for (let k = 0; k < selectSelection.length; k++) {
if (selectSelection[k].posCode) {
this.selectPosts.push(selectSelection[k].posCode)
} else {
this.selectOrgs.push(selectSelection[k].orgCode)
}
}
this.type = '2'
this.$refs['eipUserDialog'].showDialog()
},
//选择用户确认事件
eipUserDialogOk(data) {
if (data && data.length > 0) {
let accounts = []
for (let k = 0; k < data.length; k++) {
if (data[k].account != this.data.account) {
accounts.push(data[k].account)
}
}
let map = {
accounts: accounts,
orgCodes: this.selectOrgs,
postCodes: this.selectPosts,
type: this.type
}
if ((this.type = '1')) {
//转移
map.orgUserIds = this.orgUserIds
}
uc.operatingUserOrgPost(map).then(res => {
if (res.state) {
this.$message.success(res.message)
this.$nextTick(() => {
this.$refs.orgPostTables.load()
})
}
})
}
},
//查询所属组织岗位
orgPostData(param, cb) {
uc.getUserOrgPage(param)
.then(response => {
this.orgPostList = response.rows
this.orgPostPageResult = {
page: response.page,
pageSize: response.pageSize,
total: response.total
}
})
.finally(() => cb())
},
afterDelOrgUser() {
this.$refs.orgPostTables.load()
}
}
}
</script>
<style scoped lang="scss">
::v-deep .el-main {
position: relative;
.toolbar-panel {
position: absolute;
right: 0;
}
}
</style>