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
<template>
<div class="user" v-loading="loading">
<el-form ref="searchFrom" :model="searchFrom" label-width="80px" inline>
<el-form-item label="设备名称">
<el-select
filterable placeholder="请选择" clearable
v-model="searchFrom.teacher_id" @change="getData" :disabled="!teacherList.length">
<el-option
v-for="(data,index) in teacherList"
:key="index"
:label="data.name"
:value="data.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="顾问名称">
<el-select
filterable placeholder="请选择" clearable
v-model="searchFrom.staff_id" @change="getData" :disabled="!staffList.length">
<el-option
v-for="(data,index) in staffList"
:key="index"
:label="data.name"
:value="data.id">
</el-option>
</el-select>
</el-form-item>
<!--<el-form-item label="入职日期">
<el-date-picker
v-model="startTime"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00','23:59:59']"
@change="onSearch">
</el-date-picker>
</el-form-item>-->
<el-form-item>
<el-button @click="getData" type="primary" plain>搜索</el-button>
</el-form-item>
</el-form>
<el-tabs v-model="searchFrom.type" type="card" style="background: white;padding-top: 10px" @tab-click="getData">
<el-tab-pane label="全部使用记录" name="-1"></el-tab-pane>
<el-tab-pane label="当前使用记录" name="1"></el-tab-pane>
<el-tab-pane label="历史使用记录" name="2"></el-tab-pane>
</el-tabs>
<el-table :data="tableData">
<el-table-column prop="id" label="ID"></el-table-column>
<el-table-column label="设备名称">
<template slot-scope="scope">
<span @click="onSearch('teacher', scope.row.teacher_id)" class="cell-link">{{scope.row.teacher_name}}</span>
</template>
</el-table-column>
<el-table-column prop="staff_name" label="当前顾问">
<template slot-scope="scope">
<span @click="onSearch('staff', scope.row.staff_id)" class="cell-link">{{scope.row.staff_name}}</span>
</template>
</el-table-column>
<el-table-column label="移交原因">
<template slot-scope="scope">
{{scope.row.reason | reasonFormat}}
</template>
</el-table-column>
<el-table-column prop="start_at" label="设备开始使用时间"></el-table-column>
<el-table-column label="设备使用结束时间">
<template slot-scope="scope">
{{scope.row.over_at == '0000-00-00 00:00:00' ? '-' : scope.row.over_at}}
</template>
</el-table-column>
<el-table-column prop="created_at" label="创建时间"></el-table-column>
</el-table>
<page :total="total" :limit="limit" @pageChange="onPageChange" @sizeChange="onSizeChange"/>
</div>
</template>
<script>
import {getStaffRecordApi,getTeacherListApi,getStaffListApi} from "../../service/api";
import page from '../framework/page'
export default {
name: "index",
data() {
return {
searchFrom: {
type: '1',
teacher_id: '',
staff_id: ''
},
//reasonList: ,
teacherList: [],
staffList: [],
tableData: [],
total: 0,
nowPage: 1,
limit: 10,
loading: false
}
},
components: { page },
mounted() {
this.getTeacherList();
this.getStaffList();
this.getData()
},
filters: {
reasonFormat(val) {
var arr = [{
id: 0,
name: '人员入职',
},{
id: 1,
name: '人员离职',
},{
id: 2,
name: '请假',
},{
id: 3,
name: '其它',
}];
var res = '';
arr.forEach(value => {
if (value.id == val) {
res = value.name
}
})
return res
},
},
methods: {
getTeacherList() {
let json = { page: 1, limit: 1000 };
getTeacherListApi(json).then(res => {
this.teacherList = res.list;
});
},
getStaffList() {
let json = { page: 1, limit: 1000 };
getStaffListApi(json).then(res => {
this.staffList = res.list;
});
},
getData() {
let json = {
limit: this.limit,
page: this.nowPage,
};
this.searchFrom.teacher_id ? json.teacher_id = this.searchFrom.teacher_id : '';
this.searchFrom.staff_id ? json.staff_id = this.searchFrom.staff_id : '';
this.searchFrom.type!=-1 ? json.type = this.searchFrom.type : '';
getStaffRecordApi(json).then(res => {
this.tableData = res.list;
this.total = res.total
});
},
onSearch(type, id){
if (type) {
this.searchFrom[`${type}_id`] = id;
}
this.getData();
},
onPageChange(val) {
this.nowPage = val
this.getData()
},
onSizeChange(val) {
this.limit = val;
this.nowPage = 1;
this.getData()
},
}
}
</script>
<style lang="less" scoped>
.user {
/*height: 100%;*/
overflow: auto;
padding: 20px 0;
.btn-content {
text-align: center;
}
.page-div {
padding-top: 20px;
}
}
</style>