workorder.js
12.7 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
define(['jquery', 'bootstrap', 'frontend', 'template', 'form'],
function ($, undefined, Frontend, Template, Form) {
$.fn.popover.Constructor.DEFAULTS.sanitize = false;
var Controller = {
create: function () {
// Controller.api.bindevent();
$('.radio_label input').on('click', function () {
var desc = $(this).data('desc');
$('.urgency_desc').html(desc);
});
Form.api.bindevent($('form[role=form]'), function (data, ret) {
setTimeout(function () {
location.href = Fast.api.fixurl(ret.url);
}, 1500);
});
},
my: function () {
Controller.api.on_del_workorder('my');
},
detail: function () {
// Controller.api.bindevent();
// 拉到页尾
// window.scrollTo(0, $('main.content').height());
Controller.api.on_del_workorder('detail');
$("[rel=engineer_popo]").popover({
trigger: 'manual',
title: this.title,
html: true,
content: function () {
let engineer_id = $(this).data('engineer_id');
return $('.engineer_info_' + engineer_id).html();
},
animation: true
}).on("mouseenter", function () {
var _this = this;
$(this).popover("show");
$(this).siblings(".popover").on("mouseleave", function () {
$(_this).popover('hide');
});
}).on("mouseleave", function () {
var _this = this;
setTimeout(function () {
if (!$(".popover:hover").length) {
$(_this).popover("hide")
}
}, 100);
});
$("[rel=userInfo_popo]").popover({
trigger: 'manual',
title: this.title,
html: true,
content: function () {
return $('.user_info').html();
},
animation: true
}).on("mouseenter", function () {
var _this = this;
$(this).popover("show");
$(this).siblings(".popover").on("mouseleave", function () {
$(_this).popover('hide');
});
}).on("mouseleave", function () {
var _this = this;
setTimeout(function () {
if (!$(".popover:hover").length) {
$(_this).popover("hide")
}
}, 100);
});
$('.urging_workorder').on('click', function () {
var order_id = $(this).data('order_id');
Fast.api.ajax({
url: 'workorder/detail',
data: {
type: 'urging',
id: order_id
}
}, function (data, ret) {
});
});
$('.close_workorder').on('click', function () {
var order_id = $(this).data('order_id');
Fast.api.ajax({
url: 'workorder/detail',
data: {
type: 'close',
id: order_id
}
}, function (data, ret) {
setTimeout(function (action) {
location.reload()
}, 1500);
});
});
$('.transfer_workorder').on('click', function () {
$('.transfer_form').toggle(100);
});
$(document).on('click', '.confidential_btn', function () {
var confidential_id = $(this).data('confidential_id');
Fast.api.ajax({
url: 'workorder/show_confidential',
data: {
confidential_id: confidential_id
}
}, function (data, ret) {
$('#confidential_' + data.id).html(data.message);
return false;
});
});
$(document).on('click', '.item_meta_text img', function (e) {
var img_obj = $(e.target)[0];
if (img_obj) {
var scrollTop = $(window).scrollTop();
layer.photos({
photos: {
"title": "图片预览",
"id": "recordimg",
data: [
{
"src": img_obj.src
}
]
},
end: function () {
$(window).scrollTop(scrollTop)
},
anim: 5
});
}
})
Form.api.bindevent($('.message_form'), function (data, ret) {
if (ret.code == 1) {
for (let i in data.recordsHtml) {
$('#message_items').append(data.recordsHtml[i]);
}
$('#message_form')[0].reset();
$('#message_form .btn-trash').click()
Controller.api.bind_message_back(Config.editor_name);
return false;
}
});
Form.api.bindevent($('.transfer_form'), function (data, ret) {
setTimeout(function () {
location.href = Fast.api.fixurl(ret.url);
}, 1500);
});
},
evaluate: function () {
var num = finalnum = tempnum = 0;
var stars = $('.workorder_star i');
for (var i = 1; i <= stars.length; i++) {
stars[i - 1].index = i;
stars[i - 1].onmouseover = function () {
Controller.light_up_star(this.index, finalnum, tempnum);
}
stars[i - 1].onmouseout = function () {
Controller.light_up_star(0, finalnum, tempnum);
}
stars[i - 1].onclick = function () {
tempnum = this.index;
$('#row_stars').val(tempnum)
}
}
Form.api.bindevent($('form[role=form]'), function (data, ret) {
setTimeout(function () {
location.href = Fast.api.fixurl(ret.url);
}, 1500);
});
},
light_up_star: function (num, finalnum, tempnum) {
var stars = $('.workorder_star i');
var finalnum = num || tempnum;
for (var i = 0; i < stars.length; i++) {
stars[i].className = i < finalnum ? "fa fa-star text-yellow" : "fa fa-star text-gray";
}
},
manage: function () {
},
kbs: function () {
$('.likes_btn').on('click', function () {
Fast.api.ajax({
url: 'workorder/kbs',
data: {
type: 'likes',
id: $(this).data('id')
}
}, function (data, ret) {
$('.likes_btn span').html(parseInt($('.likes_btn span').html()) + 1);
return false;
});
});
$('.dislikes_btn').on('click', function () {
Fast.api.ajax({
url: 'workorder/kbs',
data: {
type: 'dislikes',
id: $(this).data('id')
}
}, function (data, ret) {
$('.dislikes_btn span').html(parseInt($('.dislikes_btn span').html()) + 1);
return false;
});
});
},
api: {
bindevent: function () {
Form.api.bindevent($('form[role=form]'));
},
bind_message_back: function (editor) {
if (editor == 'nkeditor') {
var child = $('#message_form .ke-edit-iframe');
if (child[0]) {
let child_window = child[0].contentWindow
var content = child_window.document.getElementsByClassName('ke-content')
if (content[0]) {
content[0].innerHTML = '';
}
}
} else if (editor == 'none') {
$('#message_form textarea[role=reply-describe]').val('')
} else if (editor == 'summernote') {
$('#message_form .note-editable').html('');
} else if (editor == 'markdown') {
$('#message_form textarea[role=reply-describe]').val('')
} else if (editor == 'simditor') {
$('#message_form .simditor-body').html('');
$('#message_form .simditor-placeholder').show();
} else if (editor == 'umeditor') {
$('#message_form .editor').html('');
} else if (editor == 'tinymce') {
var child = $('#message_form .tox-edit-area__iframe');
if (child[0]) {
let child_window = child[0].contentWindow
child_window.document.getElementById('tinymce').innerHTML = '';
}
} else {
location.reload()
}
},
on_del_workorder: function (action) {
$('.del_workorder').on('click', function (e) {
var that = this;
e.stopPropagation();
e.preventDefault();
var order_id = $(that).data('order_id');
var order_title = $(that).data('order_title');
var layer_msg = order_title ? '您确定要删除工单 `' + order_title + '` 吗?' : '您确定要删除此工单吗?';
var top = $(that).offset().top - $(window).scrollTop();
var left = $(that).offset().left - $(window).scrollLeft() - 260;
if (top + 154 > $(window).height()) {
top = top - 154;
}
if ($(window).width() < 480) {
top = left = undefined;
}
Layer.confirm(layer_msg,
{icon: 3, title: __('Warning'), offset: [top, left], shadeClose: true},
function (index) {
Fast.api.ajax({
url: 'workorder/my',
data: {
order_id: order_id
},
type: 'delete'
}, function (data, ret) {
setTimeout(function (action) {
if (action == 'my') {
location.reload()
} else {
location.href = Fast.api.fixurl('workorder/my');
}
}, 1500, action);
});
Layer.close(index);
}
);
});
}
},
};
return Controller;
});