bbe0fe9911acd9776bb6680712f91cdb802c87e4.svn-base 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. var flag=false;
  2. var isNew=false; //是否是新增记录
  3. var editingRow; // 双击的当前编辑行
  4. var isValida=true; //是否需要验证
  5. var dpids = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  6. var realname = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
  7. var deptName = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_names();
  8. var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  9. var g;
  10. function initComplete(){
  11. var loadParams = {
  12. "listId" : '781',
  13. "condition":"is_del='0' and user_id='"+userId+"'",
  14. };
  15. initGrid(loadParams);
  16. //getSelGroupName();
  17. setTimeout(changeHeight, 400);
  18. }
  19. function changeHeight(){
  20. var $parent = $(parent.document.body);
  21. $parent.find("#frmrightChild").height($(window.document.body).height()+30);
  22. $(top.document.body).find("#frmright").height($(window.document.body).height()+30);
  23. }
  24. function initGrid(condition) {
  25. g = $("#maingrid").quiGrid({
  26. columns : [
  27. {
  28. display : '常用联系组',
  29. name : 'GROUP_NAME_781',
  30. align : 'center',
  31. width : '20%',
  32. /* editor: { type: 'text',maxlength:'20'}*/
  33. }, {
  34. display : '组人员名字',
  35. name : 'GROUP_PEOPLE_781',
  36. align : 'center',
  37. width : '20%',
  38. editor: { type: 'text',maxlength:'15'}
  39. }, {
  40. display : '组人员电话',
  41. name : 'GROUP_PEOPLE_TEL_781',
  42. align : 'center',
  43. width : '20%',
  44. editor: { type: 'text',maxlength:'11'}
  45. }, {
  46. display : '组人员公司',
  47. name : 'GROUP_PEOPLE_COMP_781',
  48. align : 'center',
  49. width : '20%',
  50. editor: { type: 'text',maxlength:'15'}
  51. },{
  52. display: '操作', isSort: false, width: "20%", render: function (rowdata, rowindex, value,column)
  53. {
  54. var h = "";
  55. var json = JSON.stringify(rowdata);
  56. if (!rowdata._editing)
  57. {
  58. flag=false;
  59. h += "<a onclick='onDeleteGroup("+rowindex+","+rowdata._editing+","+json+")' id='del'><span class='icon_delete'>删除常用联系人</span></a> ";
  60. }
  61. else
  62. {
  63. flag=true;
  64. h += "<a onclick='endEdits(" + rowindex + ","+json+")' id='sure'><span class='icon_ok'>确认</span></a> ";
  65. h += "<a onclick='onDeleteGroup("+rowindex+","+rowdata._editing+","+json+") ' id='cancle'><span class='icon_delete'>取消</span></a> ";
  66. }
  67. return h;
  68. }
  69. } ],
  70. url : $.pathname() + '/ws/crud/CRUDService/queryQui',
  71. params:condition,
  72. sortName : 'UPDATEDATE ',
  73. sortOrder : 'desc',
  74. rownumbers : true,
  75. checkbox : true,
  76. width : "98%",
  77. pageSize : 10,
  78. async : true,
  79. usePager: false,
  80. enabledSort:false,
  81. percentWidthMode : true,
  82. enabledEdit: true,
  83. clickToEdit: false,
  84. onDblClickRow:function(rowdata, rowindex){
  85. if(flag){
  86. top.Dialog.alert("请先完成当前记录的编辑!");
  87. return;
  88. }
  89. editingRow=parseInt(rowindex.slice(1))-1001;
  90. g.beginEdit(rowindex);
  91. },
  92. // 顶部图标按钮栏
  93. toolbar : {
  94. items : [ {
  95. text : '新增',
  96. click : addUser,
  97. iconClass : 'add1_tem',
  98. disabled : false
  99. } ,{
  100. line : true
  101. },{
  102. text:"删除",
  103. click:onDelete,
  104. iconClass:"delete_tem",
  105. disabled:false
  106. },{
  107. line:true
  108. },{
  109. text:"返回短信管理",
  110. click:goback,
  111. iconClass:"back_tem",
  112. disabled:false
  113. },{
  114. line:true
  115. }]
  116. }
  117. });
  118. }
  119. //新增
  120. function addUser(){
  121. if(flag){
  122. top.Dialog.alert("请先完成当前记录的编辑!");
  123. return;
  124. }
  125. $("#flag").val("1");
  126. editingRow=0;
  127. isNew=true;
  128. var row = g.getRow(0);
  129. var groupName = $("#groupNames").val();
  130. if(groupName==""|| groupName=="常用组联系人"){
  131. parent.Dialog.alert("请选择组别再进行添加");
  132. $("#flag").val("0");
  133. return ;
  134. }
  135. if(groupName=="组名含有特殊字符"){
  136. $("#flag").val("0");
  137. // parent.Dialog.alert("组名不能含有特殊字符");
  138. return;
  139. }
  140. if(groupName=="组名称为空"){
  141. $("#flag").val("0");
  142. //parent.Dialog.alert("请输入组名称再添加");
  143. return;
  144. }
  145. if(groupName=="此组名已存在"){
  146. $("#flag").val("0");
  147. // parent.Dialog.alert("此组名已存在,请另起组名");
  148. return;
  149. }
  150. var rowData={
  151. duty_way:0,
  152. GROUP_NAME_781:groupName
  153. };
  154. g.addEditRow(rowData, row, true);
  155. g.setNewPage(1);
  156. $(parent.document.body).find("#frmrightChild").height($(window.document.body).height()+30);
  157. $(top.document.body).find("#frmright").height($(parent.document.body).height()+30);
  158. }
  159. function onDelete(){
  160. var row = g.getSelectedRows();
  161. if(row.length==0){
  162. top.Dialog.alert("请选择要删除的联系人");
  163. return;
  164. }
  165. if(flag){
  166. top.Dialog.alert("请完成编辑再删除");
  167. return;
  168. }
  169. var fd_id="";
  170. for(var i=0;i<row.length;i++){
  171. fd_id+=row[i].FD_OBJECTID_781+",";
  172. }
  173. var url = $.pathname() +"/ws/crud/CRUDService/delete/";
  174. var params={
  175. objectIDs : fd_id,
  176. classid : 781
  177. };
  178. top.Dialog.confirm("确定要删除吗?|删除",function(){
  179. $.ajax({
  180. url : url,
  181. type : 'post',
  182. timeout : 15000,
  183. data : params,
  184. dataType : 'json',
  185. success : function(data) {
  186. if (data.Msg.sucsess == true) {
  187. top.Dialog.alert("删除成功!");
  188. g.loadData();
  189. } else {
  190. top.Dialog.alert("删除失败!");
  191. }
  192. },
  193. error : function(e) {
  194. $.messager.alert('获取ID失败!', '访问服务失败!', 'error');
  195. }
  196. });
  197. });
  198. }
  199. function endEdits(rowid,group){
  200. var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]");
  201. var newData = g.getAdded();
  202. var checkAdd = true;
  203. if(newData.length>0){
  204. checkAdd = false;
  205. }
  206. var name = $("#maingrid .textinput").eq(0).val();
  207. var comp =$("#maingrid .textinput").eq(2).val();
  208. var tel = $("#maingrid .textinput").eq(1).val();
  209. var groupnames = $("#groupNames").val();
  210. if(groupnames==""||groupnames=="常用组联系人"){
  211. groupnames = group.GROUP_NAME_781;
  212. }
  213. var fd_id = group.FD_OBJECTID_781;
  214. if(name.trim()==""||name.trim()==null){
  215. parent.Dialog.alert("联系人名字不能为空");
  216. return;
  217. }
  218. if(tel.trim()==""||tel.trim()==null){
  219. parent.Dialog.alert("组人员电话不能为空");
  220. return;
  221. }
  222. var text = /^(13[0-9]|14[0-9]|15[0-9]|18[0-9])\d{8}$/i;
  223. if(!text.test(tel)){
  224. parent.Dialog.alert("请输入正确的手机号码");
  225. return;
  226. }
  227. if(pattern.test(comp)){
  228. top.Dialog.alert("公司名称不能包含特殊字符 ");
  229. return;
  230. }
  231. if(pattern.test(name)){
  232. top.Dialog.alert("名字不能包含特殊字符");
  233. return;
  234. }
  235. if(checkAdd){
  236. var telArr = getPeopleTelss(groupnames).rows;
  237. if(!checkTel(tel,telArr)&&group.GROUP_PEOPLE_TEL_781!=tel){
  238. top.Dialog.alert("此联系人已存在");
  239. return;
  240. }else{
  241. parent.Dialog.confirm("确定要修改常用联系人信息吗?|修改", function(){
  242. $.ajax({
  243. url:$.pathname() + '/ws/getContactGroup/ContactService/updateGroupInfo',
  244. type : 'post',
  245. timeout : 15000,
  246. async : false,
  247. data : {
  248. userId:userId,
  249. fd_id:fd_id,
  250. comp:comp,
  251. people:name,
  252. tel:tel,
  253. groupName:groupnames
  254. },
  255. dataType : 'text',
  256. success:function(data){
  257. parent.Dialog.alert("更改成功");
  258. g.endEdit(rowid);
  259. parent.creteGroupTree();
  260. },
  261. error : function(e) {
  262. $.messager.alert('更改成功!', '更改成功!', 'error');
  263. }
  264. });
  265. });
  266. }
  267. }else{
  268. var telArr = getPeopleTelss(groupnames).rows;
  269. if(!checkTel(tel,telArr)){
  270. top.Dialog.alert("此联系人已存在");
  271. return;
  272. }else{
  273. parent.Dialog.confirm("确定要新增常用联系人信息吗?|新增", function(){
  274. $("#flag").val("0");
  275. $.ajax({
  276. url:$.pathname() + '/ws/getContactGroup/ContactService/addGroupPerson',
  277. type : 'post',
  278. timeout : 15000,
  279. async : false,
  280. data : {
  281. userId:userId,
  282. comp:comp,
  283. name:name,
  284. tel:tel,
  285. groupName:groupnames
  286. },
  287. dataType : 'text',
  288. success:function(data){
  289. parent.Dialog.alert("新增成功");
  290. g.endEdit(rowid);
  291. parent.creteGroupTree();
  292. g.loadData();
  293. },
  294. error : function(e) {
  295. $.messager.alert('新增成功!', '新增成功!', 'error');
  296. }
  297. });
  298. });
  299. }
  300. }
  301. }
  302. function getPeopleTelss(val){
  303. var pep_tel = "";
  304. $.ajax({
  305. url:$.pathname() + '/ws/getContactGroup/ContactService/getGroupTel',
  306. type : 'post',
  307. timeout : 15000,
  308. async : false,
  309. data : {
  310. userId:userId,
  311. groupName:val
  312. },
  313. dataType : 'json',
  314. success:function(data){
  315. pep_tel = data;
  316. },
  317. error : function(e) {
  318. $.messager.alert('查询失败!', '查询失败!', 'error');
  319. }
  320. });
  321. return pep_tel;
  322. }
  323. function checkTel(str,arr){
  324. if(arr.length==0){
  325. return true;
  326. }
  327. for(var i=0;i<arr.length;i++){
  328. if(str==arr[i].GROUP_PEOPLE_TEL){
  329. return false;
  330. }
  331. }
  332. return true;
  333. }
  334. function onDeleteGroup(index,edit,json){
  335. var checkAdd = true;
  336. var fd_id = json.FD_OBJECTID_781;
  337. var newData = g.getAdded();
  338. if(newData.length>0){
  339. checkAdd = false;
  340. }
  341. if(checkAdd&&edit==undefined){
  342. parent.Dialog.confirm("确定要删除常用联系组的人员信息?|删除", function(){
  343. $.ajax({
  344. url:$.pathname() +"/ws/crud/CRUDService/delete/",
  345. type : 'post',
  346. timeout : 15000,
  347. async : false,
  348. data : {
  349. objectIDs : fd_id,
  350. classid : 781
  351. },
  352. dataType : 'text',
  353. success:function(data){
  354. parent.Dialog.alert("删除成功");
  355. g.loadData();
  356. },
  357. error : function(e) {
  358. $.messager.alert('删除成功!', '删除成功!', 'error');
  359. }
  360. });
  361. });
  362. }else if(checkAdd&&edit==true){
  363. $("#flag").val("0");
  364. /*$("#maingrid .textinput").eq(0).val(json.GROUP_PEOPLE_781);
  365. $("#maingrid .textinput").eq(1).val(json.GROUP_PEOPLE_TEL_781);
  366. $("#maingrid .textinput").eq(2).val(json.GROUP_PEOPLE_COMP_781);
  367. g.endEdit(index);*/
  368. cancelEdit(index);
  369. }else{
  370. parent.Dialog.confirm("确定要删除新增联系人记录吗?|删除", function(){
  371. $("#flag").val("0");
  372. isValida=false;
  373. flag=false;
  374. g.endEdit(index);
  375. //删除记录
  376. var row = g.getRow(index);
  377. g.deleteRow(row);
  378. return false;
  379. });
  380. }
  381. }
  382. //取消编辑
  383. function cancelEdit(rowid) {
  384. g.cancelEdit(rowid);
  385. }
  386. function searchInfo(){
  387. var people = $("#people").val().trim();
  388. var name = $("#groupNames").val();
  389. var mob = $("#mob").val().trim();
  390. var condition="";
  391. var text = /\d+$/i;
  392. if(name=="常用组联系人"||name==undefined||name=="undefined"||name==""){
  393. condition = "is_del='0' and user_id='"+userId+"'";
  394. }else{
  395. condition = "is_del='0' and user_id='"+userId+"' and group_name='"+name+"'";
  396. }
  397. if(people=="请输入组人员姓名"){
  398. people ="";
  399. }
  400. if(people!=""){
  401. condition +="AND GROUP_PEOPLE LIKE '%"+people+"%'";
  402. }
  403. if(mob!=""&&!text.test(mob)){
  404. top.Dialog.alert("请输入正确的手机号或数字");
  405. return;
  406. }
  407. var searchCondition = getSelectCon(conditionData);
  408. g.setOptions({//重置加载列表的参数
  409. params : {
  410. "listId" :'781' ,
  411. "condition" : searchCondition.condition+condition,
  412. }
  413. });
  414. setTimeout(changeHeight, 200);
  415. g.loadData();//刷新列表
  416. }
  417. function changeHeight(){
  418. $(parent.document.body).find("#frmrightChild").height($(window.document.body).height()+60);
  419. $(top.document.body).find("#frmright").height($(parent.document.body).height()+60);
  420. }
  421. function check(event) {
  422. if (event.keyCode == 13) {
  423. searchInfo();
  424. }
  425. }
  426. $("#searchButt").live("click",function(){
  427. searchInfo();
  428. });
  429. function goback(){
  430. window.parent.parent.document.getElementById("frmright").setAttribute("src", "/nwyj/page/system/sms/msg_manage.html");
  431. }