/** * 管理初始化 */ 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'}, ]; }; /** * 检查是否选中 */ 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('') $("#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/getCity1", function(data){ data.forEach(province => { var content=''; $.each(data, function(k,v) { content += ""; }); $("#city").empty().append(content); }); },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(); });