部分js代码放在js外部文件里 失效了 本来能显示出来的表格 数据都拿不到了 求大神看看
//获取编号 UUid
function uuid(len, radix) {
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
var uuid = [], i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];
} else {
// rfc4122, version 4 form
var r;
// rfc4122 requires these characters
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
// Fill in random data. At i==19 set the high bits of clock sequence as
// per rfc4122, sec. 4.1.5
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random()*16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
//删除和编辑连接
function rowformater(value,row,index){
return "<a href='javascript:void(0);' onclick='updatesal("+index+");'>编辑</a> <a href='javascript:void(0);' onclick='deletes("+row.id+");'>删除</a>";
}
//删除
function deletes(id){
$.messager.confirm('确认对话框', '您确定要删除本条信息吗?', function(r){
if (r){
$.getJSON('${pageContext.request.contextPath }/deletesal.action',{'id':id},function(result){
if(result.rul=='删除成功'){
alert("删除成功");
getalll();
}else if(result.rul=='删除失败'){
alert("删除失败");
}else{
alert("删除失败,您不是本机会的创建人");
};
});
};
});
};
//编辑更新
function updatesal(index){
//API提供的getDate方法
var arr=$('#dg2').datagrid('getData');
var id=arr.rows[index].id;
var client_name=arr.rows[index].client_name;
var source=arr.rows[index].source;
var succ_probability=arr.rows[index].succ_probability;
var introduction=arr.rows[index].introduction;
var contact_name=arr.rows[index].contact_name;
var contact_phone=arr.rows[index].contact_phone;
var description=arr.rows[index].description;
$("#id2").html("销售机会管理 > 编辑销售机会");
$("#dg").html("");
$("#div2").html("");
$("#div3").html("");
var htmls = "<form method='post' id='fmm'><table id='fm1'><a id='btn4' href='#'>帮助</a><a id='btn5' href='#'>返回</a><a id='btn7' href='#'>保存</a></table><table id='fm2'><tr><td>编号:</td><td><input type='text' name='id' readonly= 'true' placeholder='"+id+"' value='"+id+"'style='width:200px;'/></td><td>机会来源:</td><td><input type='text' name='source' placeholder='"+source+"'/></td></td><tr><td>客户名称:</td><td><input type='text' name='client_name' placeholder='"+client_name+"'/><td>成功几率:</td><td><input type='text' name='succ_probability' placeholder='"+succ_probability+"'/></td></tr><tr><td>概要:</td><td><input type='text' name='introduction' placeholder='"+introduction+"'/></td></tr><tr><td>联系人:</td><td><input type='text' name='contact_name' data-options='required:true' placeholder='"+contact_name+"'/></td><td>联系人电话:</td><td><input type='text' name='contact_phone' placeholder='"+contact_phone+"'/></td></tr><tr><td>机会描述:</td><td><input type='text' name='description' placeholder='"+description+"'/></td></tr><tr><td>创建人:</td><td><input type='text' name='creat_nmae' placeholder='${username}' value='${username}'/></td><td>创建时间</td><td><input id='dt' type='text'name='creat_time' /> </td></tr><tr><td>指派给:</td><td><input id='cc' name='username'> </td><td>指派时间:</td><td><input id='dt2' type='text' name='crea_time'></td></tr></tr></table></form>";
$("#div1").html(htmls);
$('#dt,#dt2').datetimebox({
value: '3/4/2010 2:3',
required: true,
showSeconds: false
});
$('#cc').combobox({
url:'${pageContext.request.contextPath }/getclient.action',
valueField:'username',
textField:'username'
});
$('#btn4').linkbutton({
iconCls: 'icon-help'
});
$('#btn5').linkbutton({
iconCls: 'icon-back'
});
$('#btn7').linkbutton({
iconCls: 'icon-save'
});
};
//获取指派的机会列表
function getalll(){
$("#div3").html("<tr><td>客户名称:</td><td><input type='text' id='d1' name='client_name' style='width:200px;'/></td><td>概要:</td><td><input type='text' id='d2' name='introduction' style='width:200px;'/></td><td>联系人:</td><td><input type='text' id='d3' name='contact_name' style='width:200px;'/></td></tr>");
$('#dg2').datagrid({
url:'${pageContext.request.contextPath }/getall.action',
columns:[[
{field:'id',title:'编号',width:50,sortable:true},
{field:'client_name',title:'客户名称',width:100,sortable:true},
{field:'introduction',title:'概要',width:100,sortable:true},
{field:'contact_name',title:'联系人',width:50,sortable:true},
{field:'contact_phone',title:'联系人电话',width:80,sortable:true},
{field:'crea_time',title:'创建时间',width:80,sortable:true},
{field:'caozuo',title:'操作',width:80,sortable:true,formatter: rowformater}
]],
fitColumns:true,
striped:true,
loadMsg:'正在下载...',
pagination:true,
rownumbers:true,
});
var htmls = "<a id='btn1' href='#'>帮助</a><a id='btn2' href='#'>新建</a><a id='btn3' href='#'>查询</a>";
$("#dg").html(htmls);
$('#btn1').linkbutton({
iconCls: 'icon-help'
});
$('#btn2').linkbutton({
iconCls: 'icon-add'
});
$('#btn3').linkbutton({
iconCls: 'icon-search'
});
};
///////////////////////////////////////////////////////////////////////////////
$(function(){
//坚听查询按钮
$('#dg').on('click','#btn3', function(){
var a=$('#d1').val();
var b=$('#d2').val();
var c=$('#d3').val();
$('#dg2').datagrid({
url:'${pageContext.request.contextPath }/getoneall.action?client_name='+a+'&introduction='+b+'&contact_name='+c+'',
columns:[[
{field:'id',title:'编号',width:50,sortable:true},
{field:'client_name',title:'客户名称',width:100,sortable:true},
{field:'introduction',title:'概要',width:100,sortable:true},
{field:'contact_name',title:'联系人',width:50,sortable:true},
{field:'contact_phone',title:'联系人电话',width:80,sortable:true},
{field:'crea_time',title:'创建时间',width:80,sortable:true},
{field:'caozuo',title:'操作',width:80,sortable:true,formatter:rowformater }
]],
fitColumns:true,
striped:true,
loadMsg:'正在下载...',
pagination:true,
rownumbers:true,
});
var htmls = "<a id='btn1' href='#'>帮助</a><a id='btn2' href='#'>新建</a><a id='btn3' href='#'>查询</a>";
$("#dg").html(htmls);
$('#btn1').linkbutton({
iconCls: 'icon-help'
});
$('#btn2').linkbutton({
iconCls: 'icon-add'
});
$('#btn3').linkbutton({
iconCls: 'icon-search'
});
});
//坚听帮助按钮
$('#div1').on('click','#btn4', function(){
alert("本管理网站由李哲师傅搭建,有不懂得地方请加微信1192884015 或拨打电话18249091523!");
});
$('#dg').on('click','#btn1', function(){
alert("本管理网站由李哲师傅搭建,有不懂得地方请加微信1192884015 或拨打电话18249091523!");
});
//坚听保存按钮
$('#div1').on('click','#btn6', function(){
$.ajax({
cache: true,
dataType:'json',
type: "POST",
url:'${pageContext.request.contextPath}/salesoppadd.action' ,
data:$('#fm').serialize(),// 你的formid
async: false,
error: function(request) {
alert("Connection error");
},
success: function(data) {
alert(data.rul);
document.getElementById('fm').reset();
}
});
});
//坚听保存按钮
$('#div1').on('click','#btn7', function(){
var id=$("#fmm [name=id]").val();
$.ajax({
cache: true,
dataType:'json',
type: "POST",
url:'${pageContext.request.contextPath}/updatesal.action',
data:$('#fmm').serialize(),// 你的formid
async: false,
error: function(request) {
alert("Connection error");
},
success: function(data) {
alert(data.rul);
}
});
});
//坚听返回按钮
$('#div1').on('click','#btn5', function(){
$("#id2").html("销售机会管理");
$("#div2").html("<table id='dg2'></table>");
$("#div1").html("");
getalll();
});
//树的操作
$('#tt').tree({
onClick: function(node){
if(node.id==222){
$("#id2").html("销售机会管理");
var sum="";
$("#div2").html("<table id='dg2'></table> ");
$("#div1").html("");
getalll();
}
}
});
});