/**
|
* 管理初始化
|
*/
|
var TQuestion = {
|
id: "TQuestionTable", //表格id
|
seItem: null, //选中的条目
|
table: null,
|
layerIndex: -1
|
};
|
TQuestion.close = function() {
|
parent.layer.close(window.parent.TQuestion.layerIndex);
|
}
|
/**
|
* 初始化表格的列
|
*/
|
TQuestion.initColumn = function () {
|
return [
|
{field: 'selectItem', checkbox: true},
|
{title: 'id', field: 'id', visible: false, align: 'center', valign: 'middle'},
|
{title: '视频类型', field: 'type', visible: true, align: 'center', valign: 'middle',
|
formatter:function (data) {
|
return {1:"课后练习",2:"运动教学视频",3:"器材教学视频"}[data]
|
}
|
},
|
{title: '视频封面', field: 'coverDrawing', visible: true, align: 'center', valign: 'middle',
|
formatter: function (value, row, index) {
|
value = typeof value == "undefined" || value == '' ? '/static/img/NoPIC.png' : value;
|
return '<img src="' + value + '" style="height: 100px;"/>'
|
}
|
},
|
{title: '视频名称', field: 'name', visible: true, align: 'center', valign: 'middle'},
|
{title: '视频简介', field: 'introduce', visible: true, align: 'center', valign: 'middle'},
|
{title: '可获积分', field: 'integral', visible: true, align: 'center', valign: 'middle'},
|
{title: '添加时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle'},
|
{title: '状态', field: 'state', visible: true, align: 'center', valign: 'middle',
|
formatter:function (data) {
|
return {1:"上架中",2:"下架中",3:"已失效"}[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 = "";
|
/**
|
* 选择视频 回显视频封面
|
* @param e
|
*/
|
TCompetition.oneChange = function (e) {
|
var oneId=$(e).val();
|
var ajax = new $ax(Feng.ctxPath + "/tCompetition/onChange", function(data){
|
if(data!=null){
|
var content='<option value="">选择市</option>';
|
$.each(data, function(k,v) {
|
content += "<option value='"+v.code+"'>"+v.name+"</option>";
|
});
|
$("#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 + '/benefits/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 + '/benefits/update/' + TQuestion.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
}
|
};
|
|
/**
|
* 上架
|
*/
|
|
TQuestion.onShelf = 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 = 1;
|
$.ajax({
|
url: Feng.ctxPath + "/benefits/changeCourseState",
|
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.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 + "/benefits/changeCourseState",
|
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/info/' + TQuestion.seItem.id
|
});
|
this.layerIndex = index;
|
}
|
}
|
};
|
|
/**
|
* 查看视频详情
|
*/
|
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/changeCourseState",
|
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.addSubmit = function(){
|
var data = {
|
benefitsVideoClassificationId:null,
|
courseId:"",
|
integral:""
|
};
|
data.courseId = $("#name").val()
|
data.benefitsVideoClassificationId = $("#id").val()
|
data.integral = $("#integral").val()
|
|
if($("#name").val()==''){
|
Feng.info("请选择视频")
|
return;
|
}
|
|
if($("#integral").val()==''){
|
Feng.info("请输入可获积分")
|
return;
|
}
|
$.ajax({
|
url: Feng.ctxPath + "/benefits/addBenefitsVideos" ,
|
type: "POST",
|
data: JSON.stringify(data),
|
contentType: "application/json",
|
success: function (response) {
|
if (response === 500){
|
Feng.error("所选视频已经存在于当前福利视频分类下!");
|
window.parent.TQuestion.table.refresh();
|
TQuestion.close();
|
|
}else{
|
Feng.success("添加成功");
|
}
|
},
|
error: function (xhr, status, error) {
|
Feng.error("添加失败!" + error);
|
}
|
});
|
};
|
// 视频详情编辑提交按钮
|
TQuestion.updateVideosSubmit = function(){
|
var data = {
|
id:null,
|
integral:null
|
};
|
data.id = $("#benefitsVideosId").val()
|
data.integral = $("#integral").val()
|
if($("#integral").val()==''){
|
Feng.info("请输入可获积分")
|
return;
|
}
|
$.ajax({
|
url: Feng.ctxPath + "/benefits/addBenefitsVideos" ,
|
type: "POST",
|
data: JSON.stringify(data),
|
contentType: "application/json",
|
success: function (response) {
|
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) {
|
Feng.success("添加成功");
|
},
|
error: function (xhr, status, error) {
|
Feng.error("添加失败!" + error);
|
}
|
});
|
TSite.search();
|
};
|
/**
|
* 查询列表
|
*/
|
TQuestion.search = function () {
|
var queryData = {};
|
queryData['name'] = $("#name").val();
|
queryData['type'] = $("#position").val();
|
queryData['state'] = $("#state").val();
|
TQuestion.table.refresh({query: queryData});
|
};
|
|
|
/**
|
* 重置搜索
|
*/
|
TQuestion.resetSearch = function () {
|
$("#name").val('');
|
$("#state").val('');
|
$("#position").val('');
|
TQuestion.search();
|
};
|
/**
|
* 关闭此对话框
|
*/
|
TQuestion.close = function() {
|
parent.layer.close(window.parent.TQuestion.layerIndex);
|
}
|
|
$(function () {
|
var val = $("#id").val();
|
var defaultColunms = TQuestion.initColumn();
|
var table = new BSTable(TQuestion.id, "/benefits/listBenefitsVideos/"+val, defaultColunms);
|
table.setPaginationType("client");
|
TQuestion.table = table.init();
|
var carPhoto = new $WebUpload("img");
|
carPhoto.setUploadBarId("progressBar");
|
carPhoto.init();
|
});
|