/**
|
* 跨城站点管理管理初始化
|
*/
|
var TSite = {
|
id: "TSiteTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1,
|
picture:"",
|
fileUrl:"",
|
img:"",
|
plan:"",
|
goodsPicArray:[],
|
validateFields: {
|
}
|
};
|
var objectType =$("#objectType").val()
|
/**
|
* 初始化表格的列
|
*/
|
TSite.initColumn = function () {
|
return [
|
{field: 'selectItem', checkbox: true},
|
{title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
|
{title: '所在省', field: 'province', visible: objectType==1?true:false, align: 'center', valign: 'middle',width:'20%',
|
},
|
{title: '所在市', field: 'city', visible: objectType==1?true:false, align: 'center', valign: 'middle',
|
},
|
{title: '所属账号', field: 'nameAndPhone', visible: true, align: 'center', valign: 'middle'},
|
{title: '教练类型', field: 'coachTypeName', visible: true, align: 'center', valign: 'middle',
|
},
|
{title: '姓名', field: 'name', visible: true, align: 'center', valign: 'middle',
|
},
|
{title: '性别', field: 'gender', visible: true, align: 'center', valign: 'middle',
|
formatter:function (data) {
|
return {1:"男",2:"女"}[data]
|
}
|
},
|
{title: '生日', field: 'birthday', visible: true, align: 'center', valign: 'middle',
|
},
|
{title: '联系电话', field: 'phone', visible: true, align: 'center', valign: 'middle',
|
},
|
{title: '状态', field: 'state', visible: true, align: 'center', valign: 'middle',
|
formatter:function (data) {
|
return {1:"正常",2:"冻结"}[data]
|
}
|
}
|
];
|
};
|
|
/**
|
* 检查是否选中
|
*/
|
TSite.check = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length == 0){
|
Feng.info("请先选中表格中的某一记录!");
|
return false;
|
}else{
|
TSite.seItem = selected[0];
|
return true;
|
}
|
};
|
/**
|
* 上架
|
*/
|
|
TSite.onShelf = function () {
|
if (this.check()){
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
const data1 = {
|
siteIds:[],
|
type:null
|
};
|
selected.forEach(function(obj) {
|
var id = obj.id;
|
data1.siteIds.push(id);
|
});
|
data1.type = 1;
|
|
$.ajax({
|
url: Feng.ctxPath + "/tSite/changeState",
|
type: "POST",
|
contentType: "application/json", // 设置请求头的 Content-Type
|
data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
|
success: function(response) {
|
Feng.success("上架成功!");
|
TSite.search();
|
},
|
error: function(xhr, status, error) {
|
var errorMessage = xhr.responseText ? xhr.responseText : "上架失败!";
|
Feng.error("您的网络异常!");
|
}
|
});
|
}
|
};
|
/**
|
* 下架
|
*/
|
TSite.offShelf = function () {
|
if (this.check()){
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
const data1 = {
|
siteIds:[],
|
type:null
|
};
|
selected.forEach(function(obj) {
|
var id = obj.id;
|
data1.siteIds.push(id);
|
});
|
data1.type = 2;
|
$.ajax({
|
url: Feng.ctxPath + "/tSite/changeState",
|
type: "POST",
|
contentType: "application/json", // 设置请求头的 Content-Type
|
data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
|
success: function(response) {
|
Feng.success("下架成功!");
|
TSite.search();
|
},
|
error: function(xhr, status, error) {
|
var errorMessage = xhr.responseText ? xhr.responseText : "下架失败!";
|
Feng.error("您的网络异常!");
|
}
|
});
|
}
|
};
|
TSite.uploadFile = function(){
|
var elementById = document.getElementById("uploadFile");
|
var file = elementById.files[0];
|
var formData = new FormData();
|
formData.append('file',file);
|
$.ajax({
|
url: Feng.ctxPath + "/tCouponManage/uploadPic" ,
|
type: "POST",
|
data: formData,
|
contentType: false, // 设置为false,让浏览器自动识别并设置请求头
|
processData: false, // 设置为false,不处理发送的数据(因为FormData对象已经包含了文件数据)
|
success: function (response) {
|
TSite.fileUrl = response;
|
console.log(TSite.fileUrl);
|
Feng.success("文件上传成功");
|
},
|
error: function (xhr, status, error) {
|
Feng.error("文件上传失败!" + error);
|
}
|
});
|
};
|
TSite.getChange = function(e){
|
var oneId=$(e).val();
|
var selectedValue = e.value;
|
var citySelect = document.getElementById("cCode");
|
|
var ajax = new $ax(Feng.ctxPath + "/tSite/getChange", function(data){
|
if(data!=null){
|
var content='<option value="">选择市</option>';
|
$.each(data, function(k,v) {
|
content += "<option value='"+v.name+"'>"+v.name+"</option>";
|
});
|
$("#cCode").empty().append(content);
|
}
|
});
|
if (selectedValue === ""){
|
citySelect.innerHTML = '<option value="">请先选择省</option>';
|
}
|
ajax.set("province",oneId);
|
ajax.start();
|
};
|
// 场地管理首页 选择对应的省市
|
// 传1是场地管理首页 传2是场地管理添加页面
|
TSite.oneChange = function () {
|
var province = $('#pCode option:selected').text();
|
var citySelect = document.getElementById("cCode");
|
var ajax = new $ax(Feng.ctxPath + "/tSite/getCity", function(data){
|
if(data!=null){
|
var content='<option value="">选择市</option>';
|
$.each(data, function(k,v) {
|
content += "<option value='"+v.cityCode+"'>"+v.city+"</option>";
|
});
|
$("#cCode").empty().append(content);
|
}
|
});
|
if (province === ""){
|
citySelect.innerHTML = '<option value="">请先选择省</option>';
|
$("#cCode").innerHTML = '<option value="">请先选择省/市</option>';
|
}
|
|
ajax.set("province",province);
|
ajax.start();
|
};
|
|
TSite.oneChangeNext = function (e) {
|
var oneId=$(e).val();
|
var city = $('#cCode option:selected').text();
|
var ajax = new $ax(Feng.ctxPath + "/tSite/accountChangeNext", function(data){
|
if(data!=null){
|
var content='<option value="">选择账号</option>';
|
$.each(data, function(k,v) {
|
content += "<option style='width: 300px' value='"+v.id+"'>"+v.name+"</option>";
|
});
|
$("#account").empty().append(content);
|
}
|
});
|
if (oneId === ""){
|
$("#account").innerHTML = '<option style="width: 300px" value="">请先选择省/市</option>';
|
|
}
|
ajax.set("oneId",city);
|
ajax.start();
|
|
// var ajax1 = new $ax(Feng.ctxPath + "/tSite/storeChangeNext", function(data){
|
// if(data!=null && data.length !== 0){
|
// var content='<option value="">选择门店</option>';
|
// $.each(data, function(k,v) {
|
// content += "<option style='width: 300px' value='"+v.id+"'>"+v.name+"</option>";
|
// });
|
// $("#store").empty().append(content);
|
// }else {
|
// storeSelect.innerHTML = '<option value="">当前所选市没有门店</option>';
|
// }
|
// });
|
// ajax1.set("oneId",oneId);
|
// ajax1.start();
|
};
|
|
/**
|
* 跳转添加场地页面
|
*/
|
TSite.openAddTSite = function () {
|
|
var index = layer.open({
|
type: 2,
|
title: "添加场地",
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tSite/add'
|
});
|
this.layerIndex = index;
|
};
|
/**
|
* 跳转锁定场地页面
|
*/
|
TSite.lock = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length >1 ){
|
Feng.info("只能选择一个场地进行锁定!");
|
}else {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: "锁定场地",
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tSite/lockSite/' + TSite.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
}
|
};
|
/**
|
* 打开场地管理查看详情
|
*/
|
TSite.openInfo = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length >1 ){
|
Feng.info("只能选择一个问题进行编辑!");
|
}else {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: "查看详情",
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tSite/openInfoTSite/' + TSite.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
}
|
};
|
/**
|
* 打开场地管理编辑
|
*/
|
TSite.openEditTSite = function () {
|
var selected = $('#' + this.id).bootstrapTable('getSelections');
|
if(selected.length >1 ){
|
Feng.info("只能选择一个问题进行编辑!");
|
}else {
|
if (this.check()) {
|
var index = layer.open({
|
type: 2,
|
title: "编辑场地",
|
area: ['100%', '100%'], //宽高
|
fix: false, //不固定
|
maxmin: true,
|
content: Feng.ctxPath + '/tSite/openEditTSite/' + TSite.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
}
|
};
|
/**
|
* 关闭此对话框
|
*/
|
TSite.close = function() {
|
parent.layer.close(window.parent.TSite.layerIndex);
|
}
|
|
var sh = ""; // 门店经营开始时间:小时
|
var sm = "";// 门店经营开始时间:分钟
|
var eh = "";// 门店经营结束时间:小时
|
var em = "";// 门店经营结束时间:分钟
|
|
TSite.addSubmit = function(){
|
|
|
var data = {
|
id:null,
|
province:"",
|
provinceCode:"",
|
city:"",
|
cityCode:"",
|
cityManagerId:null,
|
coachTypeId:null,
|
name:"",
|
birthday:"",
|
gender:null,
|
phone:"",
|
idcard:"",
|
height:null,
|
weight:null,
|
graduateSchool:"",
|
diploma:"",
|
certificate:"",
|
certificateImg:"",
|
};
|
if ($("#dataId").val()!=="undefined"){
|
data.id = $("#dataId").val();
|
}
|
data.provinceCode = $("#pCode").val()
|
data.province = $('#pCode option:selected').text();
|
data.cityCode = $("#cCode").val()
|
data.city = $('#cCode option:selected').text();
|
data.cityManagerId = $("#account").val()
|
data.coachTypeId = $("#coachTypeId").val()
|
data.name = $("#name").val()
|
data.birthday = $("#birthday").val()
|
data.gender = $("#gender").val()
|
data.phone = $("#phone").val()
|
data.idcard = $("#idcard").val()
|
data.height = $("#height").val()
|
data.weight = $("#weight").val()
|
data.graduateSchool = $('#graduateSchool').val()
|
data.diploma = $('#img').val()
|
data.certificate = $('#certificate').val()
|
|
var temp = ""
|
|
for (let i = 0; i < TSite.goodsPicArray.length; i++) {
|
console.log("循环")
|
console.log(TSite.goodsPicArray[i])
|
temp = temp+","+TSite.goodsPicArray[i];
|
}
|
data.certificateImg = temp
|
|
if($("#pCode").val()==''){
|
Feng.info("请选择省")
|
return;
|
}
|
if($("#cCode").val()==''){
|
Feng.info("请选择市")
|
return;
|
}
|
if($("#account").val()=='' ){
|
Feng.info("请选择账号")
|
return;
|
}
|
if($("#coachTypeId").val()=='' ){
|
Feng.info("请选择教练类型")
|
return;
|
}
|
if($("#name").val()=='' ){
|
Feng.info("请输入教练名称")
|
return;
|
}
|
if($("#birthday").val()==''){
|
Feng.info("请输入教练生日")
|
return;
|
}
|
if($("#gender").val()=='' ){
|
Feng.info("请选择教练性别")
|
return;
|
}
|
if($("#phone").val()==''){
|
Feng.info("请输入教练电话")
|
return;
|
}
|
if($("#idcard").val()==''){
|
Feng.info("请输入教练身份证号")
|
return;
|
}
|
if($("#height").val()==''){
|
Feng.info("请输入教练身高")
|
return;
|
}
|
if($("#weight").val()==''){
|
Feng.info("请输入教练体重")
|
return;
|
}
|
if($("#graduateSchool").val()==''){
|
Feng.info("请输入毕业院校")
|
return;
|
}
|
if($("#img").val()==''){
|
if ($("#diploma").val()==""){
|
Feng.info("请输入毕业证图片")
|
return;
|
|
}
|
|
}
|
if($("#certificate").val()==''){
|
|
Feng.info("请输入资格证书")
|
return;
|
}
|
if(TSite.goodsPicArray.length === 0){
|
Feng.info("请上传资格证书图片")
|
return;
|
}
|
$.ajax({
|
url: Feng.ctxPath + "/tCoach/add" ,
|
type: "POST",
|
data: JSON.stringify(data),
|
contentType: "application/json",
|
success: function (response) {
|
window.parent.TSite.table.refresh();
|
TSite.close();
|
Feng.success("添加成功");
|
|
},
|
error: function (xhr, status, error) {
|
Feng.error("添加失败!" + error);
|
}
|
});
|
};
|
TSite.editSubmit = function(){
|
|
|
var data = {
|
id:null,
|
province:"",
|
provinceCode:"",
|
city:"",
|
cityCode:"",
|
cityManagerId:null,
|
coachTypeId:null,
|
name:"",
|
birthday:"",
|
gender:null,
|
phone:"",
|
idcard:"",
|
height:null,
|
weight:null,
|
graduateSchool:"",
|
diploma:"",
|
certificate:"",
|
certificateImg:"",
|
};
|
if ($("#dataId").val()!=="undefined"){
|
data.id = $("#dataId").val();
|
}
|
data.provinceCode = $("#pCode").val()
|
data.province = $('#pCode option:selected').text();
|
data.cityCode = $("#cCode").val()
|
data.city = $('#cCode option:selected').text();
|
data.cityManagerId = $("#account").val()
|
data.coachTypeId = $("#coachTypeId").val()
|
data.name = $("#name").val()
|
data.birthday = $("#birthday").val()
|
data.gender = $("#gender").val()
|
data.phone = $("#phone").val()
|
data.idcard = $("#idcard").val()
|
data.height = $("#height").val()
|
data.weight = $("#weight").val()
|
data.graduateSchool = $('#graduateSchool').val()
|
data.diploma = $('#img').val()
|
data.certificate = $('#certificate').val()
|
|
var temp = ""
|
|
for (let i = 0; i < TSite.goodsPicArray.length; i++) {
|
console.log("循环")
|
console.log(TSite.goodsPicArray[i][`fileName`])
|
temp = temp+","+TSite.goodsPicArray[i][`fileName`];
|
}
|
data.certificateImg = temp
|
|
if($("#pCode").val()==''){
|
Feng.info("请选择省")
|
return;
|
}
|
if($("#cCode").val()==''){
|
Feng.info("请选择市")
|
return;
|
}
|
if($("#account").val()=='' ){
|
Feng.info("请选择账号")
|
return;
|
}
|
if($("#coachTypeId").val()=='' ){
|
Feng.info("请选择教练类型")
|
return;
|
}
|
if($("#name").val()=='' ){
|
Feng.info("请输入教练名称")
|
return;
|
}
|
if($("#birthday").val()==''){
|
Feng.info("请输入教练生日")
|
return;
|
}
|
if($("#gender").val()=='' ){
|
Feng.info("请选择教练性别")
|
return;
|
}
|
if($("#phone").val()==''){
|
Feng.info("请输入教练电话")
|
return;
|
}
|
if($("#idcard").val()==''){
|
Feng.info("请输入教练身份证号")
|
return;
|
}
|
if($("#height").val()==''){
|
Feng.info("请输入教练身高")
|
return;
|
}
|
if($("#weight").val()==''){
|
Feng.info("请输入教练体重")
|
return;
|
}
|
if($("#graduateSchool").val()==''){
|
Feng.info("请输入毕业院校")
|
return;
|
}
|
if($("#img").val()==''){
|
if ($("#diploma").val()==""){
|
Feng.info("请输入毕业证图片")
|
return;
|
|
}
|
|
}
|
if($("#certificate").val()==''){
|
|
Feng.info("请输入资格证书")
|
return;
|
}
|
if(TSite.goodsPicArray.length === 0){
|
Feng.info("请上传资格证书图片")
|
return;
|
}
|
$.ajax({
|
url: Feng.ctxPath + "/tCoach/add" ,
|
type: "POST",
|
data: JSON.stringify(data),
|
contentType: "application/json",
|
success: function (response) {
|
window.parent.TSite.table.refresh();
|
TSite.close();
|
Feng.success("添加成功");
|
|
},
|
error: function (xhr, status, error) {
|
Feng.error("添加失败!" + error);
|
}
|
});
|
};
|
|
TSite.search = function () {
|
var queryData = {};
|
queryData['province'] = $('#pCode option:selected').text();
|
queryData['city'] = $('#cCode option:selected').text();
|
queryData['name'] = $("#name").val();
|
queryData['phone'] = $("#phone").val();
|
TSite.table.refresh({query: queryData});
|
};
|
|
TSite.resetSearch = function () {
|
$("#pCode").val("");
|
$("#cCode").val("");
|
$("#name").val("");
|
$("#phone").val("");
|
TSite.search();
|
};
|
|
function UploadFileFn(){
|
$('#upFile').click();
|
}
|
|
$(function () {
|
|
var defaultColunms = TSite.initColumn();
|
var table = new BSTable(TSite.id, "/tCoach/list", defaultColunms);
|
table.setPaginationType("client");
|
TSite.table = table.init();
|
var carPhoto = new $WebUpload("img");
|
carPhoto.setUploadBarId("progressBar");
|
carPhoto.init();
|
});
|