OrgRelStaff.vue
2.88 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
<template>
<el-dialog :title="$t('org.relatedStaff')" :visible.sync="visible" width="70%" @close="handleClose">
<el-row :gutter="20">
<el-col :span="18" :offset="12">
<el-input v-model="queryParams.staffName" :placeholder="$t('org.name')" clearable style="width: 300px">
<el-button slot="append" icon="el-icon-search" @click="handleQuery" />
</el-input>
</el-col>
</el-row>
<el-table ref="multipleTable" :data="staffList" style="width: 100%; margin-top: 20px"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column prop="name" :label="$t('org.name')" align="center" />
<el-table-column prop="tel" :label="$t('org.phone')" align="center" />
<el-table-column prop="userId" :label="$t('org.staffId')" align="center" />
</el-table>
<el-pagination v-show="total > 0" :total="total" :current-page.sync="queryParams.page"
:page-size.sync="queryParams.rows" @current-change="getList" @size-change="getList"
layout="total, sizes, prev, pager, next, jumper" />
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{ $t('org.close') }}</el-button>
<el-button type="primary" @click="handleSubmit">{{ $t('org.submit') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { listStaffsNoInOrg, saveStaffOrgRel } from '@/api/org/orgApi'
export default {
name: 'OrgRelStaff',
data() {
return {
visible: false,
queryParams: {
page: 1,
row: 10,
staffName: ''
},
orgId: '',
staffList: [],
total: 0,
selectedStaffs: []
}
},
methods: {
show(_orgId) {
this.visible = true
this.orgId = _orgId
this.getList()
},
getList() {
listStaffsNoInOrg({
...this.queryParams,
orgId: this.orgId
}).then(response => {
this.staffList = response.data
this.total = response.total
})
},
handleQuery() {
this.queryParams.page = 1
this.getList()
},
handleReset() {
this.queryParams.staffName = ''
this.getList()
},
handleSelectionChange(val) {
this.selectedStaffs = val.map(item => item.userId)
},
handleSubmit() {
if (this.selectedStaffs.length === 0) {
this.$message.warning(this.$t('org.selectStaffFirst'))
return
}
saveStaffOrgRel({
orgId: this.orgId,
staffIds: this.selectedStaffs.join(',')
}).then(response => {
console.log(response)
this.$message.success(this.$t('common.operationSuccess'))
this.visible = false
this.$emit('refresh')
})
},
handleClose() {
this.queryParams = {
page: 1,
rows: 10,
staffName: ''
}
this.$refs.multipleTable.clearSelection()
}
}
}
</script>