notification.js
4.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
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
config: function () {
var notification_index = new Vue({
el: "#notification-index",
data() {
return {
tipCloseFlag: true,
notificationDialog: false,
notificationData: [],
notificationForm: {},
editIndex:null,
editPlatform:null
}
},
mounted() {
this.getnotificationData();
},
methods: {
getnotificationData(){
let that=this;
Fast.api.ajax({
url: 'groupon/notification/config',
type:'GET',
loading: true,
data: {}
}, function (ret, res) {
that.notificationData=res.data;
return false;
})
},
tipClose() {
this.tipCloseFlag = false;
},
changeStatua(platform, event, name, status) {
let that = this;
Fast.api.ajax({
url: 'groupon/notification/set_status',
loading: true,
type: "POST",
data: {
platform: platform,
event: event,
name: name,
status: status
}
}, function (ret, res) {
that.getnotificationData();
})
},
fieldDel(index){
this.notificationForm.fields.splice(index,1)
},
notificationClose(type) {
let that = this;
if(this.editPlatform!='email'){
that.notificationForm.template_id=that.notificationForm.template_id.replace(/\s*/g,"");
}
if (type == 'yes') {
let content=JSON.stringify(that.notificationForm)
if(this.editPlatform=='email'){
content=$('#c-content').val()
}
Fast.api.ajax({
url: 'groupon/notification/set_template',
loading: true,
data: {
platform: that.editMsg.platform,
event: that.editMsg.event,
name: that.editMsg.name,
content: content
}
}, function (ret, res) {
that.getnotificationData();
that.notificationDialog = false;
that.notificationForm = {};
that.editMsg={};
})
} else {
that.notificationForm = {};
that.editMsg={};
that.notificationDialog = false;
}
},
edit(index, type) {
this.editMsg=this.notificationData[index][type];
this.notificationForm = JSON.parse(JSON.stringify(this.notificationData[index][type].content_arr));
this.editPlatform=type;
if(this.editPlatform=='email'){
this.$nextTick(callback=>{
Controller.api.bindevent();
$('#c-content').html(this.notificationData[index][type].content)
})
}
this.notificationDialog = true;
},
addfield() {
this.notificationForm.fields.push({
'name': '',
'template_field': '',
'value': '',
});
},
},
})
},
};
return Controller;
});