44323
2023-11-06 3caee5ce51a218f4bc1f3757a4d09b0ed18aa6df
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
/**
 * 管理初始化
 */
var TStoreProvince = {
    id: "TStoreProvinceTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1,
    storeList: []
};
 
/**
 * 初始化表格的列
 */
TStoreProvince.initColumn = function () {
    return [
        {field: 'selectItem', checkbox: true},
        {title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
        {title: '所在省市', field: 'provinceCity', visible: true, align: 'center', valign: 'middle'},
        {title: '门店名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
        {title: '闸机id', field: 'ids', visible: true, align: 'center', valign: 'middle'},
    ];
};
 
/**
 * 检查是否选中
 */
TStoreProvince.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        TStoreProvince.seItem = selected[0];
        return true;
    }
};
 
 
TStoreProvince.storeOfClosePage = function (){
    parent.layer.close(parent.layer.getFrameIndex(window.frameElement.id));
}
 
TStoreProvince.saveSelectStores = function (){
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if (selected.length == 0) {
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }
    var arr = [];
    var name ='';
    for(var i in selected){
        if(typeof selected[i].id != "undefined"){
            console.log( selected[i].ids,55555)
            name =  selected[0].accountName
            if(name!=selected[i].accountName){
                Feng.info("请选择相同运营商门店")
                return ;
            }
            arr.push({
                id: selected[i].id,
                provinceCity: typeof selected[i].provinceCity != "undefined" ? selected[i].provinceCity : "",
                accountName: typeof selected[i].accountName != "undefined" ? selected[i].accountName : "",
                name: typeof selected[i].name != "undefined" ? selected[i].name : "",
                ids:typeof selected[i].ids != "undefined" ? selected[i].ids : "",
            })
        }
    }
    window.parent.TGoodsInfoDlg.selecUserOpt(arr);
    TStoreProvince.storeOfClosePage();
}
 
 
 
/**
 * 查询列表
 */
TStoreProvince.search = function () {
    var queryData = {};
    queryData['provinceId'] = $("#province").val();
    queryData['cityId'] = $("#city").val();
    queryData['operatorId'] = $("#account").val();
    queryData['storeName'] = $("#storeName").val();
    TStoreProvince.table.refresh({query: queryData});
};
 
 
/**
 * 重置搜索
 */
TStoreProvince.resetSearch = function () {
    $("#province").val('')
    $("#city").val('')
    $("#account").val('')
    $("#storeName").val('')
    TStoreProvince.search();
};
 
function queryProvince(){
    // 发送AJAX请求到后台获取省份数据
    // 假设后台返回的数据格式为一个包含省份ID和名称的数组
    var provinceSelect = document.getElementById("province");
 
    var ajax = new $ax(Feng.ctxPath + "/tCouponManage/getProvince", function(data){
        data.forEach(province => {
            var option = document.createElement("option");
            option.value = province.code;  // 根据你的数据结构确定省份的id字段
            option.text = province.name;  // 根据你的数据结构确定省份的name字段
            provinceSelect.appendChild(option);
        });
    },function(data){
        Feng.error("下拉失败!" + data.responseJSON.message + "!");
    });
    ajax.start();
    provinceSelect.addEventListener("change", queryCity);
}
 
 
// 获取城市数据
function queryCity() {
    var selectedProvinceId = this.value; // 获取选择的省份ID
    // 发送AJAX请求到后台获取对应省份的城市数据
    // 假设后台返回的数据格式为一个包含城市ID和名称的数组
 
    var citySelect = document.getElementById("city");
    citySelect.innerHTML = "";
    var ajax = new $ax(Feng.ctxPath + "/tCouponManage/getCity", function(data){
        data.forEach(province => {
            var option = document.createElement("option");
            option.value = province.code;  // 根据你的数据结构确定省份的id字段
            option.text = province.name;  // 根据你的数据结构确定省份的name字段
            citySelect.appendChild(option);
        });
    },function(data){
        console.log('data:',data)
        Feng.error("获取失败!" + data.responseJSON.message + "!");
    });
    ajax.set('province',selectedProvinceId);
    ajax.start();
}
 
$(function () {
    var defaultColunms = TStoreProvince.initColumn();
    var table = new BSTable(TStoreProvince.id, "/tCouponManage/storeDetailsOfSearch", defaultColunms);
    table.setPaginationType("client");
    TStoreProvince.table = table.init();
 
    queryProvince();
});