【做一点、学一点】dtree、jquery.validate我写的部分垃圾代码
2020-12-13 02:31
标签:style blog class code java tar 上一篇《【做一点、学一点】dtree、jquery.validate》里涉及到的另一部分代码!! 【做一点、学一点】dtree、jquery.validate我写的部分垃圾代码,搜素材,soscw.com 【做一点、学一点】dtree、jquery.validate我写的部分垃圾代码 标签:style blog class code java tar 原文地址:http://www.cnblogs.com/codecup/p/3718512.htmlDOCTYPE html>
html>
head>
meta charset="UTF-8">
title>考点管理title>
script type="text/javascript" src="/js/baseinfo/examinee/examinee.js">script>
head>
body>
script type="text/x-jquery-tmpl" id="specielitem">
option value="${specielId}">${specielName}/option>
script>
div class="tableWrap">
div class="searchList">
form id="selectForm">
table class="tableHead">
tr class="tableHeader">td>查询条件td>tr>
table>
table class="tableForm">
tr>
td align="center" width="20%">
select id="status" name="status" onchange="getPage(0)">
option value="-1">状态option>
option value="1">已启用option>
option value="0">未启用option>
select>
td>
td align="center" width="20%">
select id="subject" name="subject" onchange="getSpeciel(this.options[this.selectedIndex].value)">
option value="KM">科目option>
option value="YW">语文option>
option value="SX">数学option>
option value="YY">英语option>
option value="WL">物理option>
option value="HX">化学option>
option value="SW">生物option>
option value="ZZ">政治option>
option value="LS">历史option>
option value="DL">地理option>
select>
td>
td align="center" width="20%">
select id="specielId" name="specielId" onchange="getPage(0)">
option value="0">专题option>
select>
td>
tr>
table>
form>
div>
div class="searchList">
table class="tableHead">
tr class="tableHeader">td>列表信息button onclick="popExa(‘0‘)">添加button>td>tr>
table>
table class="tableEdit" id="detailTable">
tr id="indextr">
th width="10%" style="text-align:center">序号th>
th width="20%" style="text-align:center">考点名称th>
th width="20%" style="text-align:center">专题th>
th width="10%" style="text-align:center">创建时间th>
th width="15%" style="text-align:center">状态th>
th width="15%" style="text-align:center">操作th>
tr>
table>
script type="text/x-jquery-tmpl" id="detailList">
tr id="examcentreId${examcentreId}">
td style="text-align:center">${num}/td>
td style="text-align:center">${examcentreName}/td>
td style="text-align:center">${specielName}/td>
td style="text-align:center">${createtime}/td>
td style="text-align:center" id="status${examcentreId}">{{if status==0}}未启用{{else}}已启用{{/if}}/td>
td style="text-align:center">
button onclick="upStatus(‘${status}‘,‘${examcentreId}‘,this)">{{if status==0}}启用{{else}}停用{{/if}}/button>
button onclick="popExa(‘${examcentreId}‘,‘${specielId}‘)">修改/button>
button onclick="deleteExa(${examcentreId})">删除/button>
/td>
/tr>
script>
div class="formWrap hc" id="formDiv">div>
script type="text/x-jquery-tmpl" id="addVoTmpl">
form class="infoTitle" id="baseform" >
article>
fieldset class="S_line2">
legend class="tit">{{if examcentreId==0}}添加{{else}}修改{{/if}}/legend>
/fieldset>
table class="tableForm" style="table-layout:fixed">
input type="hidden" id="examcentreId" name="examcentreId" value="${examcentreId}">
{{if examcentreId==0}}
tr>
td width="40%">科目/td>
td width="60%">
select id="subject2" name="subject" onchange="getSpeciel2(this.options[this.selectedIndex].value)">
option value="KM">科目/option>
option value="YW">语文/option>
option value="SX">数学/option>
option value="YY">英语/option>
option value="WL">物理/option>
option value="HX">化学/option>
option value="SW">生物/option>
option value="ZZ">政治/option>
option value="LS">历史/option>
option value="DL">地理/option>
/select>
/td>
/tr>
tr>
td width="40%">专题/td>
td width="60%">
select id="specielId2" name="specielId">
option value="0">专题/option>
/select>
/td>
/tr>
tr>
td width="40%">考点名称/td>
td width="60%">
input type="text" maxlength="20" placeholder="最多只能输入20个字符" id="examcentreName" name="examcentreName" style="width:250px;margin-right:5px" >
/td>
/tr>
{{else}}
tr>
td width="40%">科目/td>
td width="60%">
select id="subject3" name="subject" onchange="getSpeciel3(this.options[this.selectedIndex].value)">
option value="KM">科目/option>
option value="YW">语文/option>
option value="SX">数学/option>
option value="YY">英语/option>
option value="WL">物理/option>
option value="HX">化学/option>
option value="SW">生物/option>
option value="ZZ">政治/option>
option value="LS">历史/option>
option value="DL">地理/option>
/select>
/td>
/tr>
tr>
td width="40%">专题/td>
td width="60%">
select id="specielId3" name="specielId">
option value="0">专题/option>
/select>
/td>
/tr>
tr>
td width="40%">考点名称/td>
td width="60%">
input type="text" maxlength="20" placeholder="最多只能输入20个字符" id="examcentreName2" name="examcentreName" value="${examcentreName}" style="width:250px;margin-right:5px">
/td>
/tr>
{{/if}}
/table>
/article>
p class="tc">
input type="submit" class="btnFun" value="保存" onclick="addOrUpExa(0)">
{{if examcentreId==0}}
input type="submit" class="btnFun" value="保存继续录入" onclick="addOrUpExa(1)">
{{/if}}
a href="javascript:void(0)" class="btnFun" onclick="$(‘#formDiv‘).dialog(‘close‘);">取消/a>
/p>
/form>
script>
div class="formWrap hc" id="delDiv">
form class="infoTitle" id="baseform1" >
fieldset class="S_line2">
legend class="tit">删除信息确认legend>
fieldset>
p>确认要删除吗?p>
p class="tc">
a href="#" class="btnFun" onclick="srueDel()">确认a>
a href="#" class="btnFun" onclick="$(‘#delDiv‘).dialog(‘close‘);">取消a>
p>
form>
div>
p class="page" id="pagenav">p>
script type="text/x-jquery-tmpl" id="pageitems">
a href="javascript:void(0)" onclick = "${purl}">${indexs}/a>
script>
div>
div>
body>
html>
var titlePageSize = 10;
var linkNum = 4;
var pageno = 0;
var userId;
var id;
$(function() {
checkUser();
getPage(0);
});
function getSpeciel(subject) {
$(‘#specielId‘).empty();
$(‘#specielId‘).append("");
$("#detailTable tr[id!=indextr]").remove();
if (subject != "KM") {
$.ajax({
url:‘/service/manage/examinee/getSpeciel‘,
type:‘GET‘,
async:false,
dataType:‘json‘,
data:‘subject=‘+subject,
success: function(data){
if(data!=""){
$("#specielitem").tmpl(data).appendTo("#specielId");
getPage(0);
} else {
$(‘#specielId‘).empty();
$(‘#specielId‘).append("");
$("#detailTable tr[id!=indextr]").remove();
$("#pagenav").empty();
}
}
});
} else {
getPage(0);
}
}
function getSpeciel2(subject) {
$(‘#specielId2‘).empty();
$(‘#specielId2‘).append("");
if (subject != "KM") {
$.ajax({
url:‘/service/manage/examinee/getSpeciel‘,
type:‘GET‘,
async:false,
dataType:‘json‘,
data:‘subject=‘+subject,
success: function(data){
if(data!=""){
$("#specielitem").tmpl(data).appendTo("#specielId2");
} else {
$(‘#specielId2‘).empty();
$(‘#specielId2‘).append("");
}
}
});
}
}
function getSpeciel3(subject) {
$(‘#specielId3‘).empty();
$(‘#specielId3‘).append("");
if (subject != "KM") {
$.ajax({
url:‘/service/manage/examinee/getSpeciel‘,
type:‘GET‘,
async:false,
dataType:‘json‘,
data:‘subject=‘+subject,
success: function(data){
if(data!=""){
$("#specielitem").tmpl(data).appendTo("#specielId3");
} else {
$(‘#specielId3‘).empty();
$(‘#specielId3‘).append("");
}
}
});
}
}
function getPage(currentPage){
var args = $("#selectForm").serialize()+"&pageNo="+currentPage+"&pageSize="+titlePageSize;
$.ajax({
url:‘/service/manage/examinee/getExamineePage‘,
type:‘GET‘,
async:false,
dataType:‘json‘,
data :args,
success : function(data) {
$("#detailTable tr[id!=indextr]").remove();
if(data.resultList!=""){
pageno = currentPage;
$("#detailList").tmpl(data.resultList).appendTo("#detailTable");
if(data.sum>titlePageSize){
goPageTo(currentPage,data.sum);
}else{
$("#pagenav").empty();
}
}else{
$("#pagenav").empty();
}
}
});
}
function upStatus(status,examcentreId,obj) {
var args = "status="+status+"&examcentreId="+examcentreId;
$.ajax({
url : ‘/service/manage/examinee/upStatus‘,
type : ‘POST‘,
dataType : ‘json‘,
async: false,
data :args,
success : function(data) {
if (data == 1) {
if (status == 0) {
$(‘#status‘+examcentreId).html(‘已启用‘);
$(obj).attr(‘onclick‘,‘upStatus(1,‘+examcentreId+‘,this)‘);
$(obj).html(‘停用‘);
} else {
$(‘#status‘+examcentreId).html(‘未启用‘);
$(obj).attr(‘onclick‘,‘upStatus(0,‘+examcentreId+‘,this)‘);
$(obj).html(‘启用‘);
}
}else{
alert("系统繁忙,请稍后再试!");
}
}
});
}
function deleteExa(examcentreId) {
id=examcentreId;
$("#delDiv").dialog({
modal : true,
width : 300,
height: 150,
});
}
function srueDel() {
var args = "examcentreId="+id;
$.ajax({
url : ‘/service/manage/examinee/deleteExa‘,
type : ‘POST‘,
dataType : ‘json‘,
async: false,
data :args,
success : function(data) {
if (data == 1) {
getPage(pageno);
}else{
alert("系统繁忙,请稍后再试!");
}
}
});
$(‘#delDiv‘).dialog(‘close‘);
}
function popExa(examcentreId,specielId) {
$("#formDiv").html("");
if (examcentreId == 0) {
var data = eval("[{‘examcentreId‘:‘0‘}]");
$("#addVoTmpl").tmpl(data).appendTo("#formDiv");
} else {
var args = "examcentreId="+examcentreId+"&specielId="+specielId;
$.ajax({
url : ‘/service/manage/examinee/getExa‘,
type : ‘GET‘,
dataType : ‘json‘,
async: false,
data :args,
success : function(data) {
$("#addVoTmpl").tmpl(data).appendTo("#formDiv");
$(‘#subject3‘).find(‘>option[value="‘+data.subject+‘"]‘).attr(‘selected‘,‘true‘);
getSpeciel3(data.subject);
$(‘#specielId3‘).find(‘>option[value="‘+data.specielId+‘"]‘).attr(‘selected‘,‘true‘);
}
});
}
$("#formDiv").dialog({
modal : true,
width : 646,
minHeight : 87,
});
}
function addOrUpExa(flag) {
$("#baseform").validate({
onkeyup:false,
onsubmit:true,
rules:{
"specielId" : {
min : 1,
},
"subject" : {
subjectxxx : true,
},
"examcentreName" : {
required: true,
}
},
messages:{
"specielId" : {
min : "请选择专题",
},
"subject" : {
subjectxxx : "请选择科目",
},
"examcentreName" : {
required: "不能为空",
}
},
errorElement:"font",
errorPlacement: function(error, element){
error.appendTo(element.parent());
element.next().css("color","red");
},
success:"valid",
submitHandler:function(form) {
addOrUp(flag);
}
});
}
function addOrUp(flag) {
checkUser();
var args = $("#baseform").serialize()+"&createuser="+userId;
$.ajax({
url:‘/service/manage/examinee/addOrUpExa‘,
type:‘POST‘,
async:false,
dataType:‘json‘,
data :args,
success : function(data) {
if (data == 1) {
if(flag == 0) {
$(‘#formDiv‘).dialog(‘close‘);
getPage(pageno);
} else {
$(‘#subject2‘).val("KM");
$(‘#examcentreName‘).val("");
$(‘#specielId2‘).empty();
$(‘#specielId2‘).append("");
getPage(pageno);
}
} else {
alert("系统繁忙,请稍后再试!");
}
}
});
}
function checkUser() {
var cookie_key = $.cookie("JYT_SESSION_KEY");
var args = "sessionKEY=" + cookie_key;
$.ajax({
url : ‘/service/manage/member/userinfo‘,
type : ‘GET‘,
data : args,
async : false,
dataType : ‘json‘,
success : function(data) {
if (data != null) {
userId = data.userId;
}
}
});
}
jQuery.validator.addMethod("subjectxxx", function(value, element) {
if (value == ‘KM‘) {
return false;
} else {
return true;
}
},"请选择科目");
文章标题:【做一点、学一点】dtree、jquery.validate我写的部分垃圾代码
文章链接:http://soscw.com/essay/25758.html