lisy
2023-08-02 d69f9a06fb73f9d5efea882a684d217f12e34a4f
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
296
297
298
299
300
301
302
303
304
305
306
/**
 * 初始化详情对话框
 */
var couponInfoDlg = {
    couponInfoData: {},
    goodsPicArray: [], //商品图片数组
    goodsCover: '' //商品封面图
};
 
/**
 * 清除数据
 */
couponInfoDlg.clearData = function () {
    this.couponInfoData = {};
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
couponInfoDlg.set = function (key, val) {
    this.couponInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
    return this;
}
 
/**
 * 设置对话框中的数据
 *
 * @param key 数据的名称
 * @param val 数据的具体值
 */
couponInfoDlg.get = function (key) {
    return $("#" + key).val();
}
 
/**
 * 关闭此对话框
 */
couponInfoDlg.close = function () {
    parent.layer.close(window.parent.TCoupon.layerIndex);
}
 
function ajax(serverCouponId, value, remark) {
    var ajax = new $ax(Feng.ctxPath + "/couponServer/examine", function (data) {
        Feng.success("审核成功!");
        window.parent.TCoupon.table.refresh();
        couponInfoDlg.close();
    }, function (data) {
        Feng.error("审核失败!" + data.responseJSON.message + "!");
    });
    ajax.setData({
        couponServerId: serverCouponId,
        state: value,
        remark: remark
    });
    ajax.start();
}
 
 
/**
 * 兑换方式1
 */
function exchangeMethod1() {
    $("#needAmount").hide();
    $("#needIntegral").show();
    $('#requiredPoints').val('');
    $('#requiredCash').val('');
}
 
/**
 * 兑换方式2
 */
function exchangeMethod2() {
    $("#needAmount").show();
    $("#needIntegral").show();
    $('#requiredPoints').val('');
    $('#requiredCash').val('');
}
 
/**
 * 兑换方式3
 */
function exchangeMethod3() {
    $("#needAmount").show();
    $("#needIntegral").hide();
    $('#requiredPoints').val('');
    $('#requiredCash').val('');
}
 
/**
 * 全国通用
 */
function scopeOfApplication1() {
    $("#storeSelect").hide();
    $("#citySelect").hide();
}
/**
 * 指定城市
 */
function scopeOfApplication2() {
    $("#storeSelect").hide();
    $("#citySelect").show();
}
/**
 * 指定门店
 */
function scopeOfApplication3() {
    $("#storeSelect").show();
    $("#citySelect").hide();
}
 
/**
 * 满减券
 */
function radio1() {
    $("#conditionalAmount").removeAttr("disabled");
    $("#deductionAmount").removeAttr("disabled");
 
    $("#voucherAmount").val('')
    $("#voucherAmount").attr('disabled', 'disabled');
 
    $("#experienceName").val('')
    $("#experienceName").attr('disabled', 'disabled');
}
 
/**
 * 代金券
 */
function radio2() {
    $("#voucherAmount").removeAttr("disabled");
 
    $("#conditionalAmount").val('')
    $("#deductionAmount").val('')
    $("#deductionAmount").attr('disabled', 'disabled');
    $("#conditionalAmount").attr('disabled', 'disabled');
 
    $("#experienceName").val('')
    $("#experienceName").attr('disabled', 'disabled');
 
}
 
/**
 * 体验券
 */
function radio3() {
    $("#experienceName").removeAttr("disabled");
 
    $("#conditionalAmount").val('')
    $("#deductionAmount").val('')
    $("#deductionAmount").attr('disabled', 'disabled');
    $("#conditionalAmount").attr('disabled', 'disabled');
 
    $("#voucherAmount").val('')
    $("#voucherAmount").attr('disabled', 'disabled');
 
}
 
 
function changeCity(n){
 
    var provinceSelect = null;
    if (n === undefined || n === null || n === ''){
        provinceSelect = document.getElementById("provinceData");
    }else {
        provinceSelect = document.getElementById("provinceData"+n);
    }
 
    var citySelect = null;
    if (n === undefined || n === null || n === ''){
        citySelect = document.getElementById("cityData");
    }else {
        citySelect = document.getElementById("cityData"+n);
    }
 
    var selectedProvince = provinceSelect.value;
    // 清空城市下拉框
    citySelect.innerHTML = '<option value="">请选择</option>';
    if (selectedProvince === "") {
        return;
    }
    var ajax = new $ax(Feng.ctxPath + "/tCouponManage/getCity", function(data){
        data.forEach(province => {
            var option = document.createElement("option");
            option.value = province.id;  // 根据你的数据结构确定省份的id字段
            option.text = province.name;  // 根据你的数据结构确定省份的name字段
            citySelect.appendChild(option);
        });
    },function(data){
        console.log('data:',data)
        Feng.error("获取失败!" + data.responseJSON.message + "!");
    });
    ajax.set('province',selectedProvince);
    ajax.start();
}
 
function getProvince(n){
    var ajax = new $ax(Feng.ctxPath + "/tCouponManage/getProvince", function(data){
        var provinceSelect = null;
        if (n === undefined || n === null || ''){
            provinceSelect = document.getElementById("provinceData");
        }else {
            provinceSelect = document.getElementById("provinceData"+n);
        }
        data.forEach(province => {
            var option = document.createElement("option");
            option.value = province.id;  // 根据你的数据结构确定省份的id字段
            option.text = province.name;  // 根据你的数据结构确定省份的name字段
            provinceSelect.appendChild(option);
        });
    },function(data){
        Feng.error("下拉失败!" + data.responseJSON.message + "!");
    });
    ajax.start();
}
 
function storeList(){
    var index = layer.open({
        type: 2,
        title: '门店列表',
        area: ['80%', '80%'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/tCouponManage/storeList'
    });
    this.layerIndex = index;
}
 
 
var num = 0;
couponInfoDlg.addBranch = function () {
    var a= "";
    a = "<div style=\'margin-left: 25%\' class=\"col-sm-9 control-label\">\n" +
        "                            <select class=\"col-sm-1\"  id=\'provinceData"+num+"\' style=\"margin-top: 1%;width: 25%\" onchange=\'changeCity("+num+")\'>\n" +
        "                                <option value=\"\">请选择</option>\n" +
        "                            </select>\n" +
        "                            <label class=\"col-sm-1\"  style=\"width: 9%;margin-top: 7px\">省</label>\n" +
        "                            <select  class=\"col-sm-1\" style=\"margin-top: 1%;width: 25%\" id=\'cityData"+num+"\'>\n" +
        "                                <option value=\"\">请选择</option>\n" +
        "                            </select>\n" +
        "                            <label class=\"col-sm-1\" style=\"width: 7%;margin-top: 7px\">市</label>\n" +
        "                            <label name=\"addBranch\" class=\"col-sm-1\" onclick=\"couponInfoDlg.delete(this)\" style=\"border: 0px;cursor: pointer;margin-top: 1%\"><i class=\"fa fa-trash\"></i></label>"+
        "                        </div>";
    $("#cityDemo").append($(a));
    getProvince(num);
    num=num+1
}
 
 
 
couponInfoDlg.delete = function (o) {
    $(o).parent("div").remove()
}
 
/**
 * 关闭此对话框
 */
couponInfoDlg.addSubmitCoupon = function () {
    var value = $('input:radio:checked').val();
    let couponServerId = $("#serverCouponId").val();
    let remark = $('#detail').val()
    if (value == 1) {
        //提交信息
        ajax(couponServerId, value, remark)
    } else {
        if (!remark) {
            Feng.error("请输入拒绝理由!");
            return;
        }
        ajax(couponServerId, value, remark)
    }
}
 
/**
 * 收集数据
 */
couponInfoDlg.collectData = function () {
    this
        .set('couponId')
        .set('name')
        .set('type')
        .set('typeName')
        .set('times')
        .set('sheetsNum')
        .set('auditStatus')
        .set('reason')
        .set('remark')
        .set('startTime')
        .set('endTime')
        .set('activityId')
        .set('createId')
        .set('createTime')
        .set('timeType')
        .set('expDay')
        .set('couponCode')
        .set('instructions')
        .set('belongs')
        .set('useTimes');
}
 
 
$(function () {
    getProvince(null);
 
});