easyUI网页datagrid的增删改查(1)
网页的前台展示和查询分页,增删改相关代码(后台分页)
-
网页html相关代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109<div title="客户来访信息记录">
<div id="dg_uservisithistory_tol">
<a class="easyui-linkbutton c5" onclick="finduservisithistory();">查询</a>
<c:if test="${loginButtonResource!=null && loginButtonResource.httz !=null
&& loginButtonResource.httz.children.httz_baojiadan !=null
&& loginButtonResource.httz.children.httz_baojiadan.children.httz_baojiadan_xinzeng !=null}">
<a class="easyui-linkbutton c1" onclick="saveuservisithistoryOpen();">新增</a>
</c:if>
<c:if test="${loginButtonResource!=null && loginButtonResource.httz !=null
&& loginButtonResource.httz.children.httz_baojiadan !=null
&& loginButtonResource.httz.children.httz_baojiadan.children.httz_baojiadan_xiugai !=null}">
<a class="easyui-linkbutton c6" onclick="updateuservisithistoryOpen();">修改</a>
</c:if>
<c:if test="${loginButtonResource!=null && loginButtonResource.httz !=null
&& loginButtonResource.httz.children.httz_baojiadan !=null
&& loginButtonResource.httz.children.httz_baojiadan.children.httz_baojiadan_shanchu !=null}">
<a class="easyui-linkbutton c6" onclick="deleteuservisithistory();">删除</a>
</c:if>
</div>
<table id="dg_uservisithistory" class="easyui-datagrid" data-options="rownumbers:true,fit:true,singleSelect:true,checkOnSelect:true,toolbar:'#dg_uservisithistory_tol',pagination:true">
<thead>
<tr>
<th data-options="field:'lf_riqi',align:'center'" width="200px;">日期</th>
<th data-options="field:'c_COMPANY',align:'center'" width="200px;">公司名称</th>
<th data-options="field:'lf_lianxiren',align:'center'" width="200px;">联系人</th>
<th data-options="field:'lf_lianxidianhua',align:'center'" width="200px;">联系电话</th>
<th data-options="field:'lf_xiangmudiqu',align:'center'" width="200px;">项目地区</th>
<th data-options="field:'lf_xiangmumingcheng',align:'center'" width="200px;">项目名称</th>
<th data-options="field:'lf_xuqiu',align:'center'" width="200px;">需求</th>
<th data-options="field:'lf_beizhu',align:'center'" width="200px;">备注</th>
<th data-options="field:'lf_gongsifuzeren',align:'center'" width="200px;">公司负责人</th>
<th data-options="field:'lf_createTime',align:'center',formatter:shijiangeshi" width="200px;">创建时间</th>
<th data-options="field:'lf_createName',align:'center'" width="200px;">创建人</th>
</tr>
</thead>
</table>
</div>
<div id="dig_saveuservisithistory" class="easyui-dialog" title="客户来访信息记录新增" style="width: 700px; height: 500px; padding: 10px" data-options="closed:true">
<div style="margin: 10px;display: inline-block;">
<input id="uvh_gongsimingcheng_s" name="uvh_gongsimingcheng_s" class="easyui-combobox" style="width: 300px;" data-options="label:'公司名称:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_lianxiren_s" name="uvh_lianxiren_s" class="easyui-combobox" style="width: 300px;" data-options="label:'联系人:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_lianxifangshi_s" name="uvh_lianxifangshi_s" class="easyui-textbox" style="width: 300px;" data-options="label:'联系方式:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_riqi_s" name="uvh_riqi_s" class="easyui-datebox" style="width: 300px;" data-options="label:'日期:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_xiangmudiqu_s" name="uvh_xiangmudiqu_s" class="easyui-textbox" style="width: 300px;" data-options="label:'项目地区:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_xiangmumingcheng_s" name="uvh_xiangmumingcheng_s" class="easyui-textbox" style="width: 300px;" data-options="label:'项目名称:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_xiangmuxuqiu_s" name="uvh_xiangmuxuqiu_s" class="easyui-textbox" style="width: 300px;" data-options="label:'需求:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_gongsifuzeren_s" name="uvh_gongsifuzeren_s" class="easyui-textbox" style="width: 300px;" data-options="label:'公司负责人:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_beizhu_save_ht" name="uvh_beizhu_save_ht" class="easyui-textbox" style="width: 600px;height: 100px" data-options="label:'备注:',labelWidth:'130px',multiline:true, panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<footer>
<div style="text-align:center;" >
<a href="javascript:void(0)" style="width:100px;" class="easyui-linkbutton" onclick="saveuservisithistory()">保存</a>
</div>
</footer>
</div>
<div id="dig_updateuservisithistory" class="easyui-dialog" title="客户来访信息记录修改" style="width: 700px; height: 500px; padding: 10px" data-options="closed:true">
<div style="margin: 10px;display: inline-block;">
<input id="uvh_gongsimingcheng_u" name="uvh_gongsimingcheng_u" class="easyui-textbox" style="width: 300px;" data-options="label:'公司名称:',readonly:true,labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_lianxiren_u" name="uvh_lianxiren_u" class="easyui-textbox" style="width: 300px;" data-options="label:'联系人:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_lianxifangshi_u" name="uvh_lianxifangshi_u" class="easyui-textbox" style="width: 300px;" data-options="label:'联系方式:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_riqi_u" name="uvh_riqi_u" class="easyui-datebox" style="width: 300px;" data-options="label:'日期:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_xiangmudiqu_u" name="uvh_xiangmudiqu_u" class="easyui-textbox" style="width: 300px;" data-options="label:'项目地区:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_xiangmumingcheng_u" name="uvh_xiangmumingcheng_u" class="easyui-textbox" style="width: 300px;" data-options="label:'项目名称:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_xiangmuxuqiu_u" name="uvh_xiangmuxuqiu_u" class="easyui-textbox" style="width: 300px;" data-options="label:'需求:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_gongsifuzeren_u" name="uvh_gongsifuzeren_u" class="easyui-textbox" style="width: 300px;" data-options="label:'公司负责人:',labelWidth:'130px', panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<div style="margin: 10px;display: inline-block;">
<input id="uvh_beizhu_update_ht" name=""uvh_beizhu_update_ht"" class="easyui-textbox" style="width: 600px;height: 100px" data-options="label:'备注:',labelWidth:'130px',multiline:true, panelHeight:'auto',panelMaxHeight:'300px'">
</div>
<footer>
<div style="text-align:center;" >
<a href="javascript:void(0)" style="width:100px;" class="easyui-linkbutton" onclick="updateuservisithistory()">保存</a>
</div>
</footer>
</div> -
网页js相关代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229var pager_dg_uservisithistory = $("#dg_uservisithistory").datagrid("getPager");
if(pager_dg_uservisithistory){
$(pager_dg_uservisithistory).pagination({
pageSize : 30,
pageList : [30,50,100],
onSelectPage:function (pageNumber,pageSize){
finduservisithistory();
}
});
}
//页面显示时分秒
function shijiangeshi(val,row){
return val.substr(0,19);
}
//easyUI的datebox日期查询条件加上时分秒
if(htlc_jichushijian_bt != "" && htlc_jichushijian_et != ""){
htlc_jichushijian_bt = htlc_jichushijian_bt+" 00:00:00";
htlc_jichushijian_et = htlc_jichushijian_et+" 23:59:59";
}
if(htlc_chuangjianshijian_bt != "" && htlc_chuangjianshijian_et != ""){
htlc_chuangjianshijian_bt = htlc_chuangjianshijian_bt +" 00:00:00";
htlc_chuangjianshijian_et = htlc_chuangjianshijian_et +" 23:59:59";
}
//客户来访信息记录的查找
function finduservisithistory(){
var companyid = $('#toolbarKhqy_findCustomerName').combobox('getValue');
//var companymingcheng = $('#toolbarKhqy_findCustomerName').combobox('getText');
if(companyid ==""){
companyid = 0;
}
var bNum = 0;
var page = $('#dg_uservisithistory').datagrid('getPager').data("pagination").options.pageNumber;
var rows = $('#dg_uservisithistory').datagrid('getPager').data("pagination").options.pageSize;
if(page>0){
bNum = (page - 1) * rows;
}
debugger;
$("#dg_uservisithistory").datagrid("loading");
$.post(BASE_PATH + "/taizhang/finduservisithistory.do",
{
companyid:companyid,
bNum:bNum,
rows:rows
},function(res){
var temp = eval('(' + res + ')');
var total=temp.total;
if(total<bNum){
$('#dg_uservisithistory').datagrid('getPager').pagination('select', 1);
}
$("#dg_uservisithistory").datagrid("loaded");
$('#dg_uservisithistory').datagrid('loadData', temp);
}, 'text');
}
//打开新增客户来访记录的对话框
function saveuservisithistoryOpen(){
$('#dig_saveuservisithistory').dialog({closed:false});
}
//新增客户来访记录的对话框的选择公司下拉框然后给联系人,电话赋值
$('#uvh_gongsimingcheng_s').combobox({
url:BASE_PATH+"/taizhang/findsupplierAll.do?",
valueField:'c_id',
textField:'c_company',
onLoadSuccess:function (res){
},
groupFormatter: function(group){
return '<span style="">' + group+ '</span>';
},
onChange : function(){
var gongsiid = $('#uvh_gongsimingcheng_s').combobox('getValue');
$('#uvh_lianxiren_s').combobox({
url:BASE_PATH+"/taizhang/findlianxiren_baojiadan.do?gongsiid="+gongsiid,
valueField:'id',
textField:'name',
onLoadSuccess:function (res){
},
groupFormatter: function(group){
return '<span style="">' + group+ '</span>';
},
onChange : function(){
var lianxirenid = $('#uvh_lianxiren_s').combobox('getValue');
$.post(BASE_PATH + "/taizhang/findlianxifangshi_baojiadan.do?lianxirenid="+lianxirenid,
{
lianxirenid:lianxirenid,
},function(res){
$('#uvh_lianxifangshi_s').textbox('setValue',res);
}, 'text');
}
});
}
});
//新增客户来访记录的对话框的保存事件
function saveuservisithistory(){
var uvh_gongsiid = $('#uvh_gongsimingcheng_s').combobox('getValue');
var uvh_lianxiren = $('#uvh_lianxiren_s').combobox('getText');
var uvh_lianxifangshi = $('#uvh_lianxifangshi_s').textbox('getValue');
var uvh_riqi = $('#uvh_riqi_s').datebox('getValue');
var uvh_xiangmudiqu = $('#uvh_xiangmudiqu_s').textbox('getValue');
var uvh_xiangmumingcheng = $('#uvh_xiangmumingcheng_s').textbox('getValue');
var uvh_xiangmuxuqiu = $('#uvh_xiangmuxuqiu_s').textbox('getValue');
var uvh_beizhu= $('#uvh_beizhu_save_ht').textbox('getValue');
var uvh_gongsifuzeren = $('#uvh_gongsifuzeren_s').textbox('getValue');
$.post(BASE_PATH + "/taizhang/saveuservisithistory.do",
{
lf_riqi:uvh_riqi,
lf_gongsi:uvh_gongsiid,
lf_lianxiren:uvh_lianxiren,
lf_lianxidianhua:uvh_lianxifangshi,
lf_xiangmudiqu:uvh_xiangmudiqu,
lf_xiangmumingcheng:uvh_xiangmumingcheng,
lf_xuqiu:uvh_xiangmuxuqiu,
lf_beizhu:uvh_beizhu,
lf_gongsifuzeren:uvh_gongsifuzeren
},function(res){
$.messager.alert('提示',res);
$('#dig_saveuservisithistory').dialog({closed:true});
finduservisithistory();
}, 'text');
}
//打开修改客户来访记录的对话框
function updateuservisithistoryOpen(){
var node = $('#dg_uservisithistory').datagrid('getSelected');
if(node == "" || node == null){
$.messager.alert('提示',"请选择一条数据");
return;
}
if(node.isdelete == 1 ){
$.messager.alert('提示',"无效数据,不能修改");
return;
}
$('#dig_updateuservisithistory').dialog({closed:false});
$('#uvh_gongsimingcheng_u').textbox('setValue',node.lf_gongsi);
$('#uvh_gongsimingcheng_u').textbox('setText',node.c_COMPANY);
//修改框的公司名称的下拉框
$('#uvh_lianxiren_u').textbox('setValue',node.lf_lianxiren);
$('#uvh_lianxifangshi_u').textbox('setValue',node.lf_lianxidianhua);
$('#uvh_riqi_u').datebox('setValue',node.lf_riqi);
$('#uvh_xiangmudiqu_u').textbox('setValue',node.lf_xiangmudiqu);
$('#uvh_xiangmumingcheng_u').textbox('setValue',node.lf_xiangmumingcheng);
$('#uvh_xiangmuxuqiu_u').textbox('setValue',node.lf_xuqiu);
$('#uvh_gongsifuzeren_u').textbox('setValue',node.lf_gongsifuzeren);
$('#uvh_beizhu_update_ht').textbox('setValue',node.lf_beizhu);
debugger;
}
//修改客户来访记录的对话框的保存
function updateuservisithistory(){
var node = $('#dg_uservisithistory').datagrid('getSelected');
if(node == "" ||node == null){
$.messager.alert('提示',"请选择一条数据");
return;
}
var uvh_gongsiid = $('#uvh_gongsimingcheng_u').textbox('getValue');
var uvh_lianxiren = $('#uvh_lianxiren_u').textbox('getValue');
var uvh_lianxifangshi = $('#uvh_lianxifangshi_u').textbox('getValue');
var uvh_riqi = $('#uvh_riqi_u').datebox('getValue');
var uvh_xiangmudiqu = $('#uvh_xiangmudiqu_u').textbox('getValue');
var uvh_xiangmumingcheng = $('#uvh_xiangmumingcheng_u').textbox('getValue');
var uvh_xiangmuxuqiu = $('#uvh_xiangmuxuqiu_u').textbox('getValue');
var uvh_beizhu= $('#uvh_beizhu_update_ht').textbox('getValue');
var uvh_gongsifuzeren = $('#uvh_gongsifuzeren_u').textbox('getValue');
debugger;
$.post(BASE_PATH + "/taizhang/updateuservisithistory.do",
{
id:node.id,
lf_riqi:uvh_riqi,
lf_gongsi:uvh_gongsiid,
lf_lianxiren:uvh_lianxiren,
lf_lianxidianhua:uvh_lianxifangshi,
lf_xiangmudiqu:uvh_xiangmudiqu,
lf_xiangmumingcheng:uvh_xiangmumingcheng,
lf_xuqiu:uvh_xiangmuxuqiu,
lf_beizhu:uvh_beizhu,
lf_gongsifuzeren:uvh_gongsifuzeren
},function(res){
$.messager.alert('提示',res);
$('#dig_updateuservisithistory').dialog({closed:true});
finduservisithistory();
}, 'text');
debugger;
}
//删除客户来访记录
function deleteuservisithistory(){
var node = $('#dg_uservisithistory').datagrid('getSelected');
if(node == "" || node == null){
$.messager.alert('提示',"请选择一条数据");
return;
}
$.messager.confirm('提示', '您当前的操作是删除,是否确认删除?', function(r){
if (r){
$.post(BASE_PATH + "/taizhang/deleteuservisithistory.do",
{
id:node.id
},function(res){
if(res == "1"){
$.messager.alert('提示',"修改成功");
}else{
$.messager.alert('提示',"修改失败");
}
finduservisithistory();
}, 'text');
}
});
}
注意:textbox的text不存在时显示value值.
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 WeiJia_Rao!