forked from love2i/echo-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RepairList.vue
265 lines (252 loc) · 7.85 KB
/
RepairList.vue
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<template>
<div>
<el-table :data="tableData.list" v-loading="isLoading">
<el-table-column v-for="(config,index) in tableConfig"
:key="index"
:prop="config.prop"
:label="config.label"
:sortable="config.sortable">
</el-table-column>
<el-table-column label="当前状态">
<template slot-scope="scope">
<el-tag v-if="scope.row.status===0" type="warning" size="medium">待处理</el-tag>
<el-tag v-else-if="scope.row.status===1" type="primary" size="medium">处理中</el-tag>
<el-tag v-else type="success" size="medium">已完成</el-tag>
</template>
</el-table-column>
<el-table-column label="状态">
<template slot-scope="scope">
<el-button type="primary" @click="fuck(scope.row)">修改状态</el-button>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button type="primary" @click="openDialog2(scope.row)">查看回复</el-button>
</template>
</el-table-column>
</el-table>
<el-dialog
title="提示"
:visible.sync="dialogVisible"
width="30%">
<el-form>
<el-form-item label="当前状态">
<el-select placeholder="当前状态" v-model="status">
<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>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="updateState()">确 定</el-button>
</span>
</el-dialog>
<el-dialog
title="对维修的回复"
:visible.sync="dialogVisible2"
width="60%">
<el-table :data="tableData2.list" ref="replyTable" v-loading="isLoading2">
<el-table-column v-for="(config,index) in tableConfig2"
:key="index"
:prop="config.prop"
:label="config.label"
:sortable="config.sortable">
</el-table-column>
</el-table>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible2 = false">取 消</el-button>
<el-button type="primary" @click="openDialog3()">回复</el-button>
</span>
</el-dialog>
<el-dialog
title="新增回复"
:visible.sync="dialogVisible3"
width="40%">
<el-input
type=" textarea"
:rows="2"
placeholder="请输入内容"
v-model=" textarea">
</el-input>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible3 = false">取 消</el-button>
<el-button type="primary" @click="updateState2()">确 定</el-button>
</span>
</el-dialog>
<div class="pagination">
<el-pagination
background
:page-size="page.pageSize"
:page-count="page.pages"
:current-page="page.pageNum"
:total="page.total"
@current-change="handleChange"
layout="prev, pager, next">
</el-pagination>
</div>
</div>
</template>
<script>
import {GET_ALL_REPAIRS} from "../../apis/complaint";
export default {
name: "RepairList",
data() {
return {
isLoading: false,
isLoading2:false,
dialogVisible2: false,
tableData: {},
tableData2: {},
tableConfig: [
// {
// label: 'id',
// prop: 'id',
// sortable: false
// },
{
label: '学生',
prop: 'student_id',
sortable: false
},
{
label: '楼号',
prop: 'building',
sortable: false
}, {
label: '宿舍',
prop: 'room',
sortable: false
}, {
label: '报修内容',
prop: 'content',
sortable: false
}, {
label: '联系电话',
prop: 'telephone',
sortable: false
}],
tableConfig2: [
{
label: '姓名',
prop: 'reply_type',
sortable: true
}, {
label: '回复内容',
prop: 'content2',
sortable: true
}, {
label: '回复时间',
prop: 'reply_time',
sortable: true
},
],
textarea: '',
dialogVisible: false,
status: '',
page: {
pageSize: 10,
pages: 1,
pageNum: 1,
total: 0
},
selected: ''
}
},
methods: {
getRepairList() {
this.isLoading = true
this.$axios.get('https://api.echo.ituoniao.net/api/web/repair/getAllRepairs?pageNum=' + this.page.pageNum + '&pageSize=' + this.page.pageSize)
.then(res => {
if (res.success) {
this.tableData = res.data
} else {
this.$message.error('获取维修列表出错')
}
})
this.isLoading = false
},
getReplys() {
this.isLoading2=true
this.$axios.get('https://api.echo.ituoniao.net/api/web/repair/getAllReplyById '+this.student_id)
.then(res => {
console.log(res)
if (res.success) {
this.tableData2 = res.data
this.reply_time = res.reply_time
this.reply_style = res.reply_style
this.content = res.content
}
})
.catch(err=>{
console.error(err)
this.$message.error('网络开了点小差哦~~')
})
.then(_ =>{
this.isLoading2=false
})
},
openDialog2(row) {
this.selected=row
this.dialogVisible2 = true
this.status = row.status
},
openDialog3(row) {
this.selected=row
this.dialogVisible3 = true
this.status = row.status
},
updateState() {
this.$axios.get('https://api.echo.ituoniao.net/api/web/repair/changeStatus?id=' + this.selected.id + '&status=' + this.status)
.then(res => {
if (res.success) {
this.$message({message: '修改成功', type: 'success'})
this.getRepairList()
} else {
this.$message.error('出错了哦:' + res.errMsg)
}
})
this.dialogVisible = false
},
updateState2() {
let postData = {
reply_type: this.reply_type,
reply_time: Date(),
content:this.textarea
}
this.$axios.post('https://api.echo.ituoniao.net/api/web/complaint/complaintReply', postData)
.then(res=>{
if (res.success){
this.$message({message:'回复成功',type:'success'})
this.getReplys()
} else{
this.$message.error('出错了哦:'+res.errMsg)
}
})
.catch(err=>{
console.error(err)
this.$message.error('网络开了点小差哦~~')
})
.then(_ =>{
})
this.dialogVisible3 = false
},
handleChange(val) {
this.pageNum.pageNum = val
this.getRepairList()
},
fuck(row) {
this.selected = row
this.status = row.status
this.dialogVisible = true
}
},
mounted() {
this.getRepairList()
this.getReplys()
}
}
</script>
<style scoped>
</style>