feedback.js
9.9 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
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
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
function debounce(handle, delay) {
let time = null;
return function () {
let self = this,
arg = arguments;
clearTimeout(time);
time = setTimeout(function () {
handle.apply(self, arg);
}, delay)
}
}
var feedbackIndex = new Vue({
el: "#feedbackIndex",
data() {
return {
data: [],
searchKey: '',
offset: 0,
limit: 10,
totalPage: 0,
currentPage: 1,
}
},
created() {
this.getData();
},
methods: {
getData() {
let that = this;
Fast.api.ajax({
url: 'groupon/feedback/index',
loading: true,
type: 'GET',
data: {
searchWhere: that.searchKey,
offset: that.offset,
limit: that.limit,
},
}, function (ret, res) {
that.data = res.data.rows;
that.data.forEach(i => {
i.images_arr = i.images.split(',').map(i => {
return Fast.api.cdnurl(i)
})
if(i.user.avatar){
i.user.avatar_arr=i.user.avatar.split(',').map(i=>{
return Fast.api.cdnurl(i)
})
}
})
that.totalPage = res.data.total;
return false;
})
},
operation(type, id) {
let that = this;
switch (type) {
case 'edit':
Fast.api.open('groupon/feedback/edit?id=' + id, '查看', {
callback(data) {
if (data.data) {
that.getData();
}
}
})
break;
case 'recyclebin':
Fast.api.open('groupon/feedback/recyclebin', '查看回收站')
break;
case 'del':
that.$confirm('此操作将删除反馈, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
Fast.api.ajax({
url: 'groupon/feedback/del/ids/' + id,
loading: true,
type: 'POST',
}, function (ret, res) {
that.getData();
})
return false;
}).catch(() => {
that.$message({
type: 'info',
message: '已取消删除'
});
});
break;
}
},
goUserDetail(id){
let that=this;
Fast.api.open('groupon/user/user/profile?id=' + id, '查看')
},
handleSizeChange(val) {
this.offset = 0
this.limit = val;
this.currentPage = 1;
this.getData()
},
handleCurrentChange(val) {
this.currentPage = val;
this.offset = (val - 1) * this.limit;
this.getData()
},
debounceFilter: debounce(function () {
this.getData()
}, 1000),
},
watch: {
searchKey(newVal, oldVal) {
if (newVal != oldVal) {
this.offset = 0;
this.limit = 10;
this.currentPage = 1;
this.debounceFilter();
}
},
},
})
},
recyclebin: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
'dragsort_url': ''
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: 'groupon/feedback/recyclebin' + location.search,
pk: 'id',
sortName: 'id',
columns: [
[{
checkbox: true
},
{
field: 'id',
title: __('Id')
},
{
field: 'deletetime',
title: __('Deletetime'),
operate: 'RANGE',
addclass: 'datetimerange',
formatter: Table.api.formatter.datetime
},
{
field: 'operate',
width: '130px',
title: __('Operate'),
table: table,
events: Table.api.events.operate,
buttons: [{
name: 'Restore',
text: __('Restore'),
classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
icon: 'fa fa-rotate-left',
url: 'groupon/feedback/restore',
refresh: true
},
{
name: 'Destroy',
text: __('Destroy'),
classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
icon: 'fa fa-times',
url: 'groupon/feedback/destroy',
refresh: true
}
],
formatter: Table.api.formatter.operate
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
edit: function () {
var feedbackDetail = new Vue({
el: "#feedbackDetail",
data() {
return {
detailForm: Config.row,
}
},
created() {
if(this.detailForm.images){
this.detailForm.images_arr=this.detailForm.images.split(',').map(i => {
return Fast.api.cdnurl(i)
})
}
},
methods: {
goUserDetail(id){
let that=this;
Fast.api.open('groupon/user/user/profile?id=' + id, '查看')
},
submitFrom(type) {
let that = this;
if (type == 'yes') {
Fast.api.ajax({
url: 'groupon/feedback/edit?id=' + that.detailForm.id,
loading: true,
type: 'POST',
data: {
data: JSON.stringify({
status: that.detailForm.status,
remark: that.detailForm.remark,
})
},
}, function (ret, res) {
Fast.api.close({
data: true
})
})
} else {
Fast.api.close({
data: false
})
}
},
},
})
},
add: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});