templetList.jsp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
  2. <jsp:include page="../../common/include.jsp" />
  3. <% String basePath = request.getScheme()+ "://" + request.getServerName() + ":" +request.getServerPort() + request.getContextPath(); %>
  4. <script type="text/javascript">
  5. //性别
  6. var templetTypeObj = null;
  7. var templetType_array = null;
  8. var editor = null;
  9. var editor_up = null;
  10. KindEditor.ready(function(K) {
  11. editor = K.create('#editor_content');
  12. editor_up = K.create('#editor_content2');
  13. });
  14. $(function() {
  15. //模板类型
  16. $.ajax({
  17. type: "post",//使用post方法访问后台
  18. dataType: "json",//返回json格式的数据
  19. url: "aa10Action_listAa10All",//要访问的后台地址
  20. data:{"aa10.letter":"templetType" ,"aa10.name":"模板类型" },
  21. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  22. success: function(msg){//msg为返回的数据,在这里做数据绑定
  23. if(msg.success){
  24. templetTypeObj = msg.obj.rows;
  25. var select_arr = [];
  26. var data = templetTypeObj;
  27. for(var nItem = 0; nItem < data.length; nItem++ ){
  28. select_arr.push("<option value="+data[nItem].code+">"+data[nItem].value+"</option>");
  29. }
  30. templetType_array = select_arr.join("");
  31. $("#templetType").append(templetType_array);
  32. }
  33. }
  34. });
  35. $.ajax({
  36. type: "post",
  37. dataType: "json",
  38. url: "columnSetAction_listColumn?tname=templet",
  39. complete :function(){$("#load").hide();},
  40. success: function(msg){
  41. if(msg.success){
  42. setId();
  43. var data = msg.obj;
  44. for(var i = 0;i<data.length;i++){
  45. if("1"==data[i].type){
  46. if(typeof(data[i].formatter)!="undefined"){
  47. data[i].formatter=eval(data[i].formatter);
  48. }
  49. user_columns.push(data[i]);
  50. }else{
  51. user_frozenColumns.push(data[i]);
  52. }
  53. }
  54. columns.push(user_columns);
  55. frozenColumns.push(user_frozenColumns);
  56. $('#templetDataGrid').datagrid({
  57. rownumbers:true,
  58. fit:true,
  59. pageSize:20,
  60. pageList : [ 10, 20, 30, 40, 50 ],
  61. fitColumns:false,
  62. border:false,
  63. sortOrder:'desc',
  64. pagination:true,
  65. idField:'id',
  66. url:whzl.basePath + '/templetAction_List',
  67. toolbar:'#searchtool',
  68. checkOnSelect:true,
  69. selectOnCheck:true,
  70. singleSelect:true,
  71. showFooter: true,
  72. columns:columns,
  73. frozenColumns:frozenColumns,
  74. loadFilter:function(result){
  75. if(result.success){
  76. return result.obj;
  77. }else{
  78. $.messager.alert("提示",result.message);
  79. return ;
  80. }
  81. }
  82. });
  83. toolBar("templetDataGrid","setTempletDialog","templet");
  84. }
  85. }
  86. });
  87. /**合同模板信息列表**/
  88. /*$('#templetDataGrid').datagrid({
  89. rownumbers:true,
  90. fit:true,
  91. pageSize:10,
  92. pageList : [ 10, 20, 30, 40, 50 ],
  93. fitColumns:false,
  94. border:false,
  95. sortOrder:'desc',
  96. pagination:true,
  97. idField:'id',
  98. toolbar:'#searchtool',
  99. checkOnSelect:true,
  100. selectOnCheck:true,
  101. nowrap:true,
  102. singleSelect: true,
  103. loadFilter:function(result){
  104. if(result.success){
  105. return result.obj;
  106. }else{
  107. alert(result.message);
  108. return ;
  109. }
  110. }
  111. }
  112. );*/
  113. //searchFun();
  114. });
  115. /**查询**/
  116. function searchFun(){
  117. $("#templetDataGrid").datagrid("load", {
  118. "templet.title":trim($("#title").val()),
  119. "templet.templetType":trim($('#templetType').val())
  120. });
  121. $('#templetDataGrid').datagrid({url:whzl.basePath + '/templetAction_List',pageNumber:1});
  122. $('#templetDataGrid').datagrid({
  123. columns:columns,
  124. frozenColumns:frozenColumns
  125. });
  126. toolBar("templetDataGrid","setTempletDialog","templet");
  127. /*var params = encodeURI("templet.title="+ trim($("#tblQuery").find("input[id='title']").val())
  128. + "&templet.templetType=" + trim($("#tblQuery").find("select[id='templetType']").val())
  129. );
  130. $('#templetDataGrid').datagrid({url:whzl.basePath + '/templetAction_List?'+params,pageNumber:1});*/
  131. }
  132. /*清除查询条件**/
  133. function ClearQuery() {
  134. $("#tblQuery").find("input").val("");
  135. $("#tblQuery").find("select").val("-1");
  136. }
  137. /**增加功能**/
  138. function templetAdd(){
  139. $('#addTempletDialog').dialog(
  140. {
  141. buttons : [
  142. {
  143. text : '生成',
  144. iconCls : 'icon-ok',
  145. handler : function(){
  146. $('#addTempletForm').form('submit',
  147. {
  148. url : whzl.basePath+'/templetAction_add',
  149. onSubmit:function(){
  150. var flag = $('#addTempletForm').form('validate');
  151. if(flag){
  152. parent.$.messager.progress({
  153. title : '提示',
  154. text : '请稍候....'
  155. });
  156. }
  157. return flag;
  158. },
  159. success : function(result){
  160. var parseResult = $.parseJSON(result);
  161. if(parseResult.success){
  162. parent.$.messager.progress('close');
  163. $("#addTempletDialog").dialog("close");
  164. searchFun();
  165. }else{
  166. parent.$.messager.progress('close');
  167. $.messager.alert("提示",parseResult.message);
  168. }
  169. }
  170. }
  171. );
  172. }
  173. },
  174. {
  175. text : '取消',
  176. iconCls : 'icon-cancel',
  177. handler : function(){
  178. $("#addTempletDialog").dialog("close");
  179. }
  180. }
  181. ],
  182. onLoad : function(){
  183. $("#templetType_add").append(templetType_array);
  184. }
  185. }
  186. );
  187. }
  188. var createdByFormatter = function(value , row , index){
  189. return row.createUser.fullName;
  190. }
  191. /**删除**/
  192. var delFormatter = function(value , row , index){
  193. return "<img src='<%=basePath%>/images/edit_remove.png' title='删除' onclick=deleteRow(" + row.id + ") style='cursor:pointer' />";
  194. };
  195. /**删除功能**/
  196. function deleteRow(){
  197. var row = $('#templetDataGrid').datagrid('getSelected');
  198. if(row == null){
  199. $.messager.alert("提示","请先选择要修改的模板内容!");
  200. }
  201. var id = row.id;
  202. $.messager.confirm('删除提示', '确定删除这条记录吗?', function(r){
  203. if (r){
  204. $.ajax({
  205. type: "post",//使用get方法访问后台
  206. dataType: "json",//返回json格式的数据
  207. url: "templetAction_delete",//要访问的后台地址
  208. data: "templet.id="+id,//要发送的数据
  209. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  210. success: function(msg){//msg为返回的数据,在这里做数据绑定
  211. if(msg.success){
  212. $.messager.alert('提示','删除成功!');
  213. $('#templetDataGrid').datagrid('reload');
  214. }else{
  215. $.messager.alert('提示',msg.message);
  216. }
  217. }
  218. });
  219. }
  220. });
  221. }
  222. /**标题连接*/
  223. var titleFormatter = function(value , row , index)
  224. {
  225. return "<a href='javascript:' title='查看详情' onclick=templetDetails(" + row.id + ") >" + row.title + "</a>";
  226. };
  227. var templetTypeFormatter = function(value , row , index){
  228. var templetType = "";
  229. for(var nItem = 0; nItem < templetTypeObj.length; nItem++ ){
  230. if(templetTypeObj[nItem].code == value){
  231. templetType = templetTypeObj[nItem].value;
  232. }
  233. }
  234. return templetType;
  235. }
  236. /**详细页面对话框*/
  237. var templetDetails = function(id){
  238. $("#detailTempletDialog").dialog(
  239. {
  240. maximizable: true,
  241. buttons : [
  242. {
  243. text : '确定',
  244. iconCls : 'icon-ok',
  245. handler : function(){
  246. $("#detailTempletDialog").dialog("close");
  247. }
  248. }
  249. ],
  250. onLoad : function(){
  251. $.ajax({
  252. type: "post",//使用get方法访问后台
  253. dataType: "json",//返回json格式的数据
  254. url: "templetAction_findById",//要访问的后台地址
  255. data: {"templet.id":id},//要发送的数据
  256. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  257. success: function(msg){//msg为返回的数据,在这里做数据绑定
  258. $("#title_detail").text(msg.obj.title);
  259. $("#content_detail").html(msg.obj.content);
  260. var templetType = "";
  261. for(var nItem = 0; nItem < templetTypeObj.length; nItem++ ){
  262. if(templetTypeObj[nItem].code == msg.obj.templetType){
  263. templetType = templetTypeObj[nItem].value;
  264. }
  265. }
  266. $("#templetType_detail").text(templetType);
  267. }
  268. });
  269. }
  270. }
  271. );
  272. };
  273. /**编辑**/
  274. var updateFormatter = function(value , row , index){
  275. return "<img src='<%=basePath%>/images/pencil.png' title='编辑' onclick=updateRow(" + row.id + ") style='cursor:pointer' />";
  276. };
  277. /**编辑功能**/
  278. function updateRow(){
  279. //var updateIndex = $('#templetDataGrid').datagrid('getRowIndex',id);
  280. var row = $('#templetDataGrid').datagrid('getSelected');
  281. if(row == null){
  282. $.messager.alert("提示","请先选择要修改的模板内容!");
  283. }
  284. var id = row.id;
  285. $('#updateTempletDialog').dialog(
  286. {
  287. maximizable: true,
  288. buttons : [
  289. {
  290. text : '提交',
  291. iconCls : 'icon-ok',
  292. handler : function(){
  293. $('#updateTempletForm').form('submit',
  294. {
  295. url : whzl.basePath+'/templetAction_update',
  296. onSubmit:function(){
  297. var flag = $('#updateTempletForm').form('validate');
  298. if(flag){
  299. parent.$.messager.progress({
  300. title : '提示',
  301. text : '请稍候....'
  302. });
  303. }
  304. return flag;
  305. },
  306. success : function(result){
  307. parent.$.messager.progress('close');
  308. var parseResult = $.parseJSON(result);
  309. if(parseResult.success){
  310. //修改完数据,更新对应行的数据
  311. $("#templetDataGrid").datagrid('reload');
  312. $("#updateTempletDialog").dialog("close");
  313. }else{
  314. parent.$.messager.progress('close');
  315. $.messager.alert("提示",parseResult.message);
  316. }
  317. }
  318. }
  319. );
  320. }
  321. },
  322. {
  323. text : '取消',
  324. iconCls : 'icon-cancel',
  325. handler : function(){
  326. $("#updateTempletDialog").dialog("close");
  327. }
  328. }
  329. ],
  330. onLoad : function(){
  331. $.ajax({
  332. type: "post",//使用get方法访问后台
  333. dataType: "json",//返回json格式的数据
  334. url: "templetAction_findById",//要访问的后台地址
  335. data: "templet.id="+id,//要发送的数据
  336. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  337. success: function(msg){//msg为返回的数据,在这里做数据绑定
  338. if(msg.success){
  339. $("#id_update").val(msg.obj.id);
  340. dealSelect(templetTypeObj,msg.obj.templetType,"templetType_update");
  341. editor_up.html(msg.obj.content);
  342. var json = {
  343. 'templet.title' : msg.obj.title
  344. };
  345. $('#updateTempletForm').form('load', json);
  346. }else{
  347. $.messager.alert("提示", msg.message);
  348. $("#updateTempletDialog").dialog("close");
  349. }
  350. }
  351. });
  352. }
  353. });
  354. }
  355. function valueReplace(v) {
  356. v = v.toString().replace(new RegExp('(["\"])', 'g'), "\\\"");
  357. return v;
  358. }
  359. var dateFormatter = function(value , row , index){
  360. return dealDate(row.createDate);
  361. };
  362. </script>
  363. <div class="easyui-layout" data-options="fit:true,border:false" style="margin: 0px;padding: 0px;">
  364. <div data-options="region:'center',border:false">
  365. <div id="searchtool" data-options="region:'north' , border:false">
  366. <table id="tblQuery" style="width:100%;">
  367. <tr>
  368. <td align="right" style="width: 10%"><span>标题</span></td>
  369. <td style="width: 10%">
  370. <input id="title" type="text"/>
  371. </td>
  372. <td align="right" style="width: 8%"><span>模板类型</span></td>
  373. <td style="width: 14%">
  374. <select id="templetType" onchange="searchFun();" >
  375. <option value="">请选择</option>
  376. </select>
  377. </td>
  378. <td style="width: 58%">
  379. <a href="javascript:searchFun();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">查询</a>
  380. <a href="javascript:ClearQuery();" class="easyui-linkbutton" data-options="iconCls:'icon-emptied',plain:true">清空</a>
  381. <a href="javascript:templetAdd();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">增加</a>
  382. <a href="javascript:updateRow();" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改</a>
  383. <a href="javascript:deleteRow();" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true">删除</a>
  384. </td>
  385. </tr>
  386. </table>
  387. </div>
  388. <table id="templetDataGrid">
  389. <!--<thead frozen="true">
  390. <tr>
  391. <th data-options="field:'id',checkbox:true,width:50">ID</th>
  392. </tr>
  393. </thead>
  394. <thead>
  395. <tr>
  396. <th data-options="field:'title',sortable:false,width:250,formatter:titleFormatter">标题</th>
  397. <th data-options="field:'createdBy',width:80">创建人</th>
  398. <th data-options="field:'createdOn',width:140">创建时间</th>
  399. <th data-options="field:'templetType',width:140,formatter:templetTypeFormatter">模板类型</th>
  400. <th data-options="field:'update',align:'center',formatter:updateFormatter,width:50">编辑</th>
  401. <th data-options="field:'del',align:'center',formatter:delFormatter,width:50">删除</th>
  402. </tr>
  403. </thead>-->
  404. </table>
  405. </div>
  406. </div>
  407. <div id="addTempletDialog" data-options="title:'&nbsp;新增合同模板信息',iconCls:'icon-edit',width:800,height:400,modal:true,href:'<%=basePath %>/templetAction_toAdd'">
  408. </div>
  409. <div id="detailTempletDialog" data-options="title:'&nbsp;合同模板详细信息',iconCls:'icon-details',width:800,height:400,modal:true,href:'<%=basePath %>/templetAction_toDetail'">
  410. </div>
  411. <div id="updateTempletDialog" data-options="title:'&nbsp;更新合同模板信息',iconCls:'icon-edit',width:800,height:400,modal:true,href:'<%=basePath %>/templetAction_toUpdate'">
  412. </div>
  413. <div id="setTempletDialog" data-options="title:'&nbsp;个性化设置',iconCls:'icon-cog',width:500,height:370,modal:true,href:'<%=basePath %>/columnSetAction_toSet?tname=templet'">
  414. </div>
  415. <script type="text/javascript">
  416. <!--
  417. $(function(){
  418. parent.$.messager.progress('close');
  419. });
  420. //-->
  421. </script>