/**
* 管理初始化
*/
var TQuestion = {
id: "TQuestionTable", //表格id
seItem: null, //选中的条目
table: null,
layerIndex: -1
};
/**
* 初始化表格的列
*/
TQuestion.initColumn = function () {
return [
{field: 'selectItem', checkbox: true},
{title: '序号', field: 'id', visible: true, align: 'center', valign: 'middle'},
{title: '所在省市', field: 'provinceAndCity', visible: true, align: 'center', valign: 'middle'},
{title: '预约门店', field: 'storeName', visible: true, align: 'center', valign: 'middle'},
{title: '家长姓名', field: 'parentName', visible: true, align: 'center', valign: 'middle'},
{title: '家长联系方式', field: 'phone', visible: true, align: 'center', valign: 'middle'},
{title: '学员姓名', field: 'learnerName', visible: true, align: 'center', valign: 'middle'},
{title: '学员年龄', field: 'learnerAge', visible: true, align: 'center', valign: 'middle'},
{title: '学员生日', field: 'birthday', visible: true, align: 'center', valign: 'middle'},
{title: '预约时间', field: 'appointmentTime', visible: true, align: 'center', valign: 'middle'},
{title: '状态', field: 'status', visible: true, align: 'center', valign: 'middle',
formatter:function (data) {
return {1:"未测试",2:"已测试"}[data]
}}
];
};
/**
* 检查是否选中
*/
TQuestion.check = function () {
var selected = $('#' + this.id).bootstrapTable('getSelections');
if(selected.length == 0){
Feng.info("请先选中表格中的某一记录!");
return false;
}else{
TQuestion.seItem = selected[0];
return true;
}
};
TQuestion.dataCount = 0;
TQuestion.phone = "";
TQuestion.phoneId = "";
TQuestion.oneChange = function (e) {
var oneId=$(e).val();
var ajax = new $ax(Feng.ctxPath + "/tCompetition/onChange", function(data){
if(data!=null){
var content='';
$.each(data, function(k,v) {
content += "";
});
$("#cCode").empty().append(content);
}
});
ajax.set("oneId",oneId);
ajax.start();
};
/**
* 点击添加
*/
TQuestion.openAdd = function () {
var index = layer.open({
type: 2,
title: '添加分类',
area: ['100%', '100%'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/bodySideAppointment/add'
});
this.layerIndex = index;
};
/**
* 点击编辑
*/
TQuestion.openChange = function () {
var selected = $('#' + this.id).bootstrapTable('getSelections');
if(selected.length >1 ){
Feng.info("只能选择一个问题进行编辑!");
}else {
if (this.check()){
var selected = $('#' + this.id).bootstrapTable('getSelections');
var index = layer.open({
type: 2,
title: '编辑分类',
area: ['100%', '100%'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/bodySideAppointment/update/' + TQuestion.seItem.id
});
this.layerIndex = index;
}
}
};
/**
* 上架
*/
TQuestion.onShelf = function () {
if (this.check()){
var selected = $('#' + this.id).bootstrapTable('getSelections');
var ids=[];
selected.forEach(function(obj) {
var id = obj.id;
ids.push(id);
});
$.ajax({
url: Feng.ctxPath + "/bodySideAppointment/changeState",
type: "POST",
contentType: "application/json", // 设置请求头的 Content-Type
data: JSON.stringify(ids), // 将数据转换为 JSON 字符串
success: function(response) {
Feng.success("修改成功!");
TQuestion.search();
},
error: function(xhr, status, error) {
var errorMessage = xhr.responseText ? xhr.responseText : "修改失败!";
Feng.error("您的网络异常!");
}
});
}
};
/**
* 下架
*/
TQuestion.offShelf = function () {
if (this.check()){
var selected = $('#' + this.id).bootstrapTable('getSelections');
const data1 = {
ids:[],
state:null
};
selected.forEach(function(obj) {
var id = obj.id;
data1.ids.push(id);
});
data1.state = 2;
$.ajax({
url: Feng.ctxPath + "/bodySideAppointment/changeState",
type: "POST",
contentType: "application/json", // 设置请求头的 Content-Type
data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
success: function(response) {
Feng.success("修改成功!");
TQuestion.search();
},
error: function(xhr, status, error) {
var errorMessage = xhr.responseText ? xhr.responseText : "修改失败!";
Feng.error("您的网络异常!");
}
});
}
};
/**
* 查看视频详情
*/
TQuestion.getInfo = function () {
var selected = $('#' + this.id).bootstrapTable('getSelections');
if(selected.length >1 ){
Feng.info("只能选择一条进行查看!");
}else {
if (this.check()){
var selected = $('#' + this.id).bootstrapTable('getSelections');
var index = layer.open({
type: 2,
title: '详情',
area: ['100%', '100%'], //宽高
fix: false, //不固定
maxmin: true,
content: Feng.ctxPath + '/benefits/getBenefitsVideos/' + TQuestion.seItem.id
});
this.layerIndex = index;
}
}
};
/**
* 删除
*/
TQuestion.delete = function () {
if (this.check()){
var selected = $('#' + this.id).bootstrapTable('getSelections');
const data1 = {
ids:[],
state:null
};
selected.forEach(function(obj) {
var id = obj.id;
data1.ids.push(id);
});
data1.state = 3;
$.ajax({
url: Feng.ctxPath + "/benefits/changeState",
type: "POST",
contentType: "application/json", // 设置请求头的 Content-Type
data: JSON.stringify(data1), // 将数据转换为 JSON 字符串
success: function(response) {
Feng.success("删除成功!");
TQuestion.search();
},
error: function(xhr, status, error) {
var errorMessage = xhr.responseText ? xhr.responseText : "删除失败!";
Feng.error(errorMessage);
}
});
}
};
TQuestion.oneChangeNext = function (e) {
var oneId=$(e).val();
var city = $('#cCode option:selected').text();
var citySelect = document.getElementById("account");
var storeSelect = document.getElementById("store");
if (oneId === ""){
citySelect.innerHTML = '';
storeSelect.innerHTML = '';
}
var ajax1 = new $ax(Feng.ctxPath + "/tSite/storeChangeNext", function(data){
if(data!=null && data.length !== 0){
var content='';
$.each(data, function(k,v) {
content += "";
});
$("#store").empty().append(content);
}else {
storeSelect.innerHTML = '';
}
});
ajax1.set("oneId",city);
ajax1.start();
};
TQuestion.addSubmit = function(){
var data = {
id:null,
province:"",
provinceCode:"",
city:"",
cityCode:"",
storeId:null,
storeName:"",
parentName:"",
phone:"",
learnerName:"",
learnerAge:null,
birthday:"",
appointmentTime:"",
status:null,
state:null
};
data.id = $("#name").val()
data.province = $('#pCode option:selected').text();
data.provinceCode = $("#pCode").val()
data.city = $('#cCode option:selected').text();
data.cityCode = $("#cCode").val()
data.storeId = $("#store").val()
data.storeName = $('#store option:selected').text();
data.parentName = $("#parentName").val()
data.phone = $("#phone").val()
data.learnerName = $("#learnerName").val()
data.learnerAge = $("#learnerAge").val()
data.birthday = $("#birthday").val()
data.appointmentTime = $("#appointmentTime").val().replace("T"," ")
console.log("看看")
console.log(data.appointmentTime);
if($("#pCode").val()==''){
Feng.info("请选择省")
return;
}
if($("#cCode").val()==''){
Feng.info("请选择市")
return;
}
if($("#store").val()=='' ){
Feng.info("请选择门店")
return;
}
if($("#parentName").val()=='' ){
Feng.info("请输入家长姓名")
return;
}
if($("#phone").val()=='' ){
Feng.info("请输入家长联系方式")
return;
}
if($("#learnerName").val()=='' ){
Feng.info("请输入学员姓名")
return;
}
if($("#learnerAge").val()=='' ){
Feng.info("请输入学员年龄")
return;
}
if($("#birthday").val()=='' ){
Feng.info("请选择学员生日")
return;
}
if($("#appointmentTime").val()=='' ){
Feng.info("请选择预约时间")
return;
}
$.ajax({
url: Feng.ctxPath + "/bodySideAppointment/addBodySideAppointments" ,
type: "POST",
data: JSON.stringify(data),
contentType: "application/json",
success: function (response) {
window.parent.TQuestion.table.refresh();
TQuestion.close();
Feng.success("添加成功");
},
error: function (xhr, status, error) {
Feng.error("添加失败!" + error);
}
});
};
TQuestion.updateSubmit = function(){
var data = {
id:null,
name:"",
position:"",
sort:"",
};
data.name = $("#name").val()
data.position = $("#position").val()
data.sort = $("#sort").val()
data.id = $("#dataId").val()
if($("#name").val()==''){
Feng.info("请输入分类名称")
return;
}
if($("#cCode").val()==''){
Feng.info("请选择所在位置")
return;
}
if($("#account").val()=='' ){
Feng.info("请输入排序")
return;
}
$.ajax({
url: Feng.ctxPath + "/benefits/addBenefits" ,
type: "POST",
data: JSON.stringify(data),
contentType: "application/json",
success: function (response) {
window.parent.TQuestion.table.refresh();
TQuestion.close();
Feng.success("添加成功");
},
error: function (xhr, status, error) {
Feng.error("添加失败!" + error);
}
});
};
/**
* 查询列表
*/
TQuestion.search = function (e) {
var queryData = {};
queryData['phone'] = $("#phone").val();
queryData['parentName'] = $("#parentName").val();
queryData['state'] = $("#state").val();
queryData['day'] = e;
TQuestion.table.refresh({query: queryData});
};
TQuestion.close = function() {
parent.layer.close(window.parent.TQuestion.layerIndex);
}
/**
* 重置搜索
*/
TQuestion.resetSearch = function () {
$("#phone").val('');
$("#parentName").val('');
$("#state").val('');
TQuestion.search(null);
};
$(function () {
var defaultColunms = TQuestion.initColumn();
var table = new BSTable(TQuestion.id, "/bodySideAppointment/listAll", defaultColunms);
table.setPaginationType("client");
TQuestion.table = table.init();
});