puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
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
/**
 * 初始化详情对话框
 */
var language =$("#language").val()
var SysCouponRecordInfoDlg = {
    sysCouponRecordInfoData : {},
    validateFields: {
        name: {
            validators: {
                notEmpty: {
                    message: language==1?'名称不能为空':(language==2?"The name cannot be empty!":"Nama itu tidak bisa kosong!")
                }
            }
        },
        money: {
            validators: {
                notEmpty: {
                    message: language==1?'金额不能为空':(language==2?"The amount cannot be empty!":"Jumlah tidak dapat kosong!")
                },
                regexp: {
                    regexp: /^(([1-9]{1}\d*)|(0{1}))(\.\d{1,2})?$/,
                    message: language==1?'金额格式不正确':(language==2?"The amount format is incorrect!":"Format jumlah tidak benar!")
                }
            }
        }
    }
};
 
/**
 * 验证数据是否为空
 */
SysCouponRecordInfoDlg.validate = function () {
    $('#sysCouponRecordInfoForm').data("bootstrapValidator").resetForm();
    $('#sysCouponRecordInfoForm').bootstrapValidator('validate');
    return $("#sysCouponRecordInfoForm").data('bootstrapValidator').isValid();
};
/**
 * 清除数据
 */
SysCouponRecordInfoDlg.clearData = function() {
    this.sysCouponRecordInfoData = {};
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
SysCouponRecordInfoDlg.set = function(key, val) {
    this.sysCouponRecordInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
SysCouponRecordInfoDlg.get = function(key) {
    return $("#" + key).val();
}
 
/**
 * 关闭此对话框
 */
SysCouponRecordInfoDlg.close = function() {
    parent.layer.close(window.parent.SysCouponRecord.layerIndex);
}
 
/**
 * 收集数据
 */
SysCouponRecordInfoDlg.collectData = function() {
    this
    .set('id')
    .set('money')
    .set('fullMoney')
    .set('insertTime')
    .set('companyId')
    .set('couponUseType')
    .set('couponType')
    .set('name')
    .set('effective');
}
 
SysCouponRecordInfoDlg.immediately=function(){
    var remark = $("#remark").val();
    if (remark.length > 250){
        if(language==1){
            Feng.info("备注不能超过250个字");
        }else if(language==2){
            Feng.info("Remarks should not exceed 250 words");
        }else {
            Feng.info("Perhatian seharusnya tidak melebihi 250 kata");
        }
        return;
    }
    // 3通过  2拒绝
    var state = $("input[name='state']:checked").val();
 
    var ajax = new $ax(Feng.ctxPath + "/sysCouponRecord/audit", function(data){
        if(language==1){
            Feng.success("操作成功!");
        }else if(language==2){
            Feng.success("Successfully!");
        }else {
            Feng.success("Sukses!");
        }
        window.parent.SysCouponRecord.table.refresh();
        SysCouponRecordInfoDlg.close();
    },function(data){
        if(language==1){
            Feng.error("操作失败!" + data.responseJSON.message + "!");
        }else if(language==2){
            Feng.error("Fail!" + data.responseJSON.message + "!");
        }else {
            Feng.error("Gagal!" + data.responseJSON.message + "!");
        }
    });
    ajax.set("id",$("#id").val());
    ajax.set("remark",remark);
    ajax.set("state",state);
    ajax.start();
}
/**
 * 提交添加
 */
SysCouponRecordInfoDlg.addSubmit = function() {
 
    this.clearData();
    this.collectData();
    if(!this.validate()){
        return ;
    }
    if ($("#name").val().length > 20){
        if(language==1){
            Feng.info("名称不能超过20个字");
        }else if(language==2){
            Feng.info("The name cannot exceed 20 characters");
        }else {
            Feng.info("Nama tidak dapat melebihi 20 karakter");
        }
 
        return;
    }
    if ( $("#money").val() > 99999   ){
        if(language==1){
            Feng.info("金额最多不能超过5位数");
        }else if(language==2){
            Feng.info("The amount cannot exceed 5 figures");
        }else {
            Feng.info("Jumlah tidak dapat melebihi 5 angka");
        }
 
        return;
    }
    if($("couponType").val()==2 && $("#fullMoney").val() > 99999){
        if(language==1){
            Feng.info("金额最多不能超过5位数");
        }else if(language==2){
            Feng.info("The amount cannot exceed four figures");
        }else {
            Feng.info("Jumlah tidak dapat melebihi empat angka");
        }
        return;
    }
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/sysCouponRecord/add", function(data){
          Feng.success("添加成功!");
        window.parent.SysCouponRecord.table.refresh();
        SysCouponRecordInfoDlg.close();
    },function(data){
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.sysCouponRecordInfoData);
    ajax.set("language",$("#yy").val());
    ajax.start();
}
 
/**
 * 提交修改
 */
SysCouponRecordInfoDlg.editSubmit = function() {
 
    this.clearData();
    this.collectData();
 
    //提交信息
    var ajax = new $ax(Feng.ctxPath + "/sysCouponRecord/update", function(data){
        Feng.success("修改成功!");
        window.parent.SysCouponRecord.table.refresh();
        SysCouponRecordInfoDlg.close();
    },function(data){
        Feng.error("修改失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.sysCouponRecordInfoData);
    ajax.set("language",$("#yy").val());
    ajax.start();
}
 
$(function() {
    Feng.initValidator("sysCouponRecordInfoForm", SysCouponRecordInfoDlg.validateFields);
});