You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

526 lines
14 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

var ue2;
$(function() {
//datagrid初始化
$('#dataList').datagrid({
title:'书画列表',
iconCls:'icon-more',//图标
border: true,
collapsible:false,//是否可折叠的
fit: true,//自动大小
method: "post",
url:"ShuhuaServlet?method=ShuhuaList&t="+new Date().getTime(),
idField:'id',
singleSelect:false,//是否单选
pagination:true,//分页控件
rownumbers:true,//行号
sortName:'id',
sortOrder:'DESC',
remoteSort: false,
columns: [[
{field:'chk',checkbox: true,width:50},
{field:'id',title:'ID',width:50, sortable: true},
{field:'title',title:'标题',width:200},
{field:'name',title:'分类',width:150},
{field:'shijian',title:'时间',width:100},
{field:'tupian',title:'图片',width:150,formatter:function(value,row,index){
return '<img style="width:50px;height:50px;" src="pic/'+row.tupian+'"/>';
}},
]],
toolbar: "#toolbar",
onBeforeLoad : function(){
try{
$("#FenleiList").combobox("getData")
}catch(err){
preLoadFenlei();
}
}
});
//设置分页控件
var p = $('#dataList').datagrid('getPager');
$(p).pagination({
pageSize: 10,//每页显示的记录条数默认为10
pageList: [10,20,30,50,100],//可以设置每页记录条数的列表
beforePageText: '第',//页数文本框前显示的汉字
afterPageText: '页 共 {pages} 页',
displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录',
});
//设置工具类按钮
$("#add").click(function(){
$("#addDialog").dialog("open");
});
//修改
$("#edit").click(function(){
var selectRows = $("#dataList").datagrid("getSelections");
if(selectRows.length != 1){
$.messager.alert("消息提醒", "请选择一条数据进行操作!", "warning");
} else{
$("#editDialog").dialog("open");
}
});
//删除
$("#delete").click(function(){
var selectRows = $("#dataList").datagrid("getSelections");
var selectLength = selectRows.length;
if(selectLength == 0){
$.messager.alert("消息提醒", "请选择数据进行删除!", "warning");
} else{
var numbers = [];
$(selectRows).each(function(i, row){
numbers[i] = row.sn;
});
var ids = [];
$(selectRows).each(function(i, row){
ids[i] = row.id;
});
$.messager.confirm("消息提醒", "删除书画信息,确认继续?", function(r){
if(r){
$.ajax({
type: "post",
url: "ShuhuaServlet?method=DeleteShuhua",
data: {sns: numbers, ids: ids},
success: function(msg){
if(msg == "success"){
$.messager.alert("消息提醒","删除成功!","info");
//刷新表格
$("#dataList").datagrid("reload");
$("#dataList").datagrid("uncheckAll");
} else{
$.messager.alert("消息提醒","删除失败!","warning");
return;
}
}
});
}
});
}
});
//班级下拉框
/*$("#FenleiList").combobox({
width: "150",
height: "25",
valueField: "id",
textField: "name",
multiple: false, //可多选
editable: false, //不可编辑
method: "post",
url: "FenleiServlet?method=getFenleiList&t="+new Date().getTime()+"&from=combox",
onChange: function(newValue, oldValue){
//加载班级下的书画
$('#dataList').datagrid("options").queryParams = {Fenleiid: newValue};
$('#dataList').datagrid("reload");
}
});*/
function preLoadFenlei(){
$("#FenleiList").combobox({
width: "150",
height: "25",
valueField: "id",
textField: "name",
multiple: false, //可多选
editable: false, //不可编辑
method: "post",
url: "FenleiServlet?method=getFenleiList&t="+new Date().getTime()+"&from=combox",
onChange: function(newValue, oldValue){
//加载班级下的书画
//$('#dataList').datagrid("options").queryParams = {Fenleiid: newValue};
//$('#dataList').datagrid("reload");
}
});
}
$("#add_fenleiid").combobox({
url: "FenleiServlet?method=getFenleiList&t="+new Date().getTime()+"&from=combox",
width: "200",
height: "30",
valueField: "id",
textField: "name",
multiple: false, //可多选
editable: false, //不可编辑
method: "post",
onLoadSuccess: function(){
//默认选择第一条数据
var data = $(this).combobox("getData");;
$(this).combobox("setValue", data[0].id);
}
});
$("#edit_fenleiid").combobox({
url: "FenleiServlet?method=getFenleiList&t="+new Date().getTime()+"&from=combox",
width: "200",
height: "30",
valueField: "id",
textField: "name",
multiple: false, //可多选
editable: false, //不可编辑
method: "post",
onLoadSuccess: function(){
//默认选择第一条数据
var data = $(this).combobox("getData");
$(this).combobox("setValue", data[0].id);
}
});
//设置添加书画窗口
$("#addDialog").dialog({
title: "添加书画",
width: 750,
height: 560,
iconCls: "icon-add",
modal: true,
collapsible: false,
minimizable: false,
maximizable: false,
draggable: true,
closed: true,
buttons: [
{
text:'添加',
plain: true,
iconCls:'icon-user_add',
handler:function(){
if($('#fsimgtitle').val()!='')
{
try
{
var form = document.getElementById('addForm');
//再次修改input内容
form.submit();
}
catch(e)
{
}
}
var ueaa = UE.getEditor('editor');
var validate = $("#addForm").form("validate");
if(!validate){
$.messager.alert("消息提醒","请检查你输入的数据!","warning");
return;
} else{
var Fenleiid = $("#add_fenleiid").combobox("getValue");
$.ajax({
type: "post",
url: "ShuhuaServlet?method=AddShuhua",
//data: $("#addForm").serialize(),
data:{
title:$('#add_title').val(),
fenleiid:$('#add_fenleiid').combobox('getValue'),
shijian:$("#add_shijian").datetimebox("getValue"),
neirong:ueaa.getContent(),
fsimgtitle:$('#fsimgtitle').val()
},
success: function(msg){
alert('操作成功');
window.location.href="view/Shuhua/ShuhuaList.jsp";
if(msg == "success"){
$.messager.alert("消息提醒","添加成功!","info");
//关闭窗口
$("#addDialog").dialog("close");
//清空原表格数据
$("#title").textbox('setValue', "");
$("#shijian").textbox('setValue', "");
//重新刷新页面数据
$('#dataList').datagrid("options").queryParams = {Fenleiid: Fenleiid};
$('#dataList').datagrid("reload");
setTimeout(function(){
$("#add_fenleiid").combobox('setValue', Fenleiid);
}, 100);
} else{
$.messager.alert("消息提醒","添加失败!","warning");
return;
}
}
});
}
}
},
{
text:'重置',
plain: true,
iconCls:'icon-reload',
handler:function(){
$("#title").textbox('setValue', "");
$("#shijian").textbox('setValue', "");
//重新加载年级
$("#fenleiid").combobox("clear");
}
},
]
});
//设置编辑书画窗口
$("#editDialog").dialog({
title: "修改书画信息",
width: 750,
height: 560,
iconCls: "icon-edit",
modal: true,
collapsible: false,
minimizable: false,
maximizable: false,
draggable: true,
closed: true,
buttons: [
{
text:'提交',
plain: true,
iconCls:'icon-user_add',
handler:function(){
if($('#fsimgtitle2').val().trim()!='')
{
try
{
var form = document.getElementById('editForm');
//再次修改input内容
form.submit();
}
catch(e)
{
}
}
// var ueaa = UE.getEditor('editor2');
var validate = $("#editForm").form("validate");
if(!validate){
$.messager.alert("消息提醒","请检查你输入的数据!","warning");
return;
} else{
$.ajax({
type: "post",
url: "ShuhuaServlet?method=EditShuhua&t="+new Date().getTime(),
//data: $("#editForm").serialize(),
data:{
id:$('#edit-id').val(),
title:$('#edit_title').val(),
fenleiid:$('#edit_fenleiid').combobox('getValue'),
shijian:$("#edit_shijian").datetimebox("getValue"),
neirong:ue2.getContent(),
fsimgtitle:$('#fsimgtitle2').val()
},
success: function(msg){
alert('操作成功');
window.location.href="view/Shuhua/ShuhuaList.jsp";
if(msg == "success"){
$.messager.alert("消息提醒","更新成功!","info");
//关闭窗口
$("#editDialog").dialog("close");
//刷新表格
$('#dataList').datagrid("options").queryParams = {fenleiid: fenleiid};
$("#dataList").datagrid("reload");
$("#dataList").datagrid("uncheckAll");
setTimeout(function(){
$("#FenleiList").combobox('setValue', Fenleiid);
}, 100);
} else{
$.messager.alert("消息提醒","更新失败!","warning");
return;
}
}
});
}
}
},
{
text:'重置',
plain: true,
iconCls:'icon-reload',
handler:function(){
//清空表单
$("#title").textbox('setValue', "");
$("#edit_shijian").datetimebox('setValue', "");
$("#edit_qq").textbox('setValue', "");
$("#edit_fenleiid").combobox("clear");
$("#edit_gradeList").combobox("reload");
}
}
],
onBeforeOpen: function(){
var selectRow = $("#dataList").datagrid("getSelected");
//设置值
$("#edit_title").textbox('setValue', selectRow.title);
$("#edit_shijian").textbox('setValue', selectRow.shijian);
$("#edit-id").val(selectRow.id);
//$("#edit_photo").attr("src", selectRow.photo);
$("#edit_photo")[0].src='pic/'+selectRow.tupian;
ue2 = UE.getEditor('editor2');
// editor准备好之后才可以使用
ue2.addListener("ready", function () {
//赋值
ue2.setContent(selectRow.neirong);
//取值
//var content = ue2.getContent();
})
var fenleiid = selectRow.fenleiid;
setTimeout(function(){
$("#edit_fenleiid").combobox('setValue', fenleiid);
}, 100);
}
});
//搜索按钮监听事件
$("#search-btn").click(function(){
$('#dataList').datagrid('load',{
name: $('#search_Shuhua_name').val(),
aaa: $("#FenleiList").combobox('getText')
});
});
});
function uploadPhoto()
{
try
{
var form = document.getElementById('editForm');
//再次修改input内容
form.submit();
}
catch(e)
{
}
}
function addddd()
{
var Fenleiid = $("#add_FenleiList").combobox("getValue");
$.ajax({
type: "post",
url: "ShuhuaServlet?method=AddShuhua",
//data: $("#addForm").serialize(),
data:{
title:$('#add_title').val(),
fenleiid:$('#add_fenleiid').combobox('getValue'),
shijian:$("#add_shijian").datetimebox("getValue"),
neirong:123123,
fsimgtitle:$('#fsimgtitle').val()
},
success: function(msg){
alert('操作成功');
window.location.href="view/Shuhua/ShuhuaList.jsp";
if(msg == "success"){
$.messager.alert("消息提醒","添加成功!","info");
//关闭窗口
$("#addDialog").dialog("close");
//清空原表格数据
$("#title").textbox('setValue', "");
$("#shijian").textbox('setValue', "");
//重新刷新页面数据
//$('#dataList').datagrid("options").queryParams = {Fenleiid: Fenleiid};
$('#dataList').datagrid("reload");
setTimeout(function(){
$("#FenleiList").combobox('setValue', Fenleiid);
}, 100);
} else{
$.messager.alert("消息提醒","添加失败!","warning");
return;
}
}
});
/*
$.ajax({
type: "post",
url: "ShuhuaServlet?method=AddShuhua",
data:{
},
success: function(msg){
alert('操作成功');
}
});
*/
}
function myformatter(date){
var y = date.getFullYear();
var m = date.getMonth()+1;
var d = date.getDate();
return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
}
function myparser(s){
if (!s) return new Date();
var ss = (s.split('-'));
var y = parseInt(ss[0],10);
var m = parseInt(ss[1],10);
var d = parseInt(ss[2],10);
if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
return new Date(y,m-1,d);
} else {
return new Date();
}
}