123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498 |
- var flag=false;
- var isNew=false; //是否是新增记录
- var editingRow; // 双击的当前编辑行
- var isValida=true; //是否需要验证
- var dpids = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
-
- var realname = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
- var deptName = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_names();
-
- var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
- var g;
- function initComplete(){
- var loadParams = {
- "listId" : '781',
- "condition":"is_del='0' and user_id='"+userId+"'",
- };
- initGrid(loadParams);
- //getSelGroupName();
- setTimeout(changeHeight, 400);
-
-
- }
- function changeHeight(){
- var $parent = $(parent.document.body);
- $parent.find("#frmrightChild").height($(window.document.body).height()+30);
- $(top.document.body).find("#frmright").height($(window.document.body).height()+30);
-
- }
- function initGrid(condition) {
- g = $("#maingrid").quiGrid({
- columns : [
- {
- display : '常用联系组',
- name : 'GROUP_NAME_781',
- align : 'center',
- width : '20%',
- /* editor: { type: 'text',maxlength:'20'}*/
- }, {
- display : '组人员名字',
- name : 'GROUP_PEOPLE_781',
- align : 'center',
- width : '20%',
- editor: { type: 'text',maxlength:'15'}
- }, {
- display : '组人员电话',
- name : 'GROUP_PEOPLE_TEL_781',
- align : 'center',
- width : '20%',
- editor: { type: 'text',maxlength:'11'}
- }, {
- display : '组人员公司',
- name : 'GROUP_PEOPLE_COMP_781',
- align : 'center',
- width : '20%',
- editor: { type: 'text',maxlength:'15'}
-
- },{
-
- display: '操作', isSort: false, width: "20%", render: function (rowdata, rowindex, value,column)
- {
- var h = "";
- var json = JSON.stringify(rowdata);
- if (!rowdata._editing)
- {
- flag=false;
- h += "<a onclick='onDeleteGroup("+rowindex+","+rowdata._editing+","+json+")' id='del'><span class='icon_delete'>删除常用联系人</span></a> ";
- }
- else
- {
- flag=true;
-
- h += "<a onclick='endEdits(" + rowindex + ","+json+")' id='sure'><span class='icon_ok'>确认</span></a> ";
- h += "<a onclick='onDeleteGroup("+rowindex+","+rowdata._editing+","+json+") ' id='cancle'><span class='icon_delete'>取消</span></a> ";
- }
- return h;
- }
- } ],
- url : $.pathname() + '/ws/crud/CRUDService/queryQui',
- params:condition,
- sortName : 'UPDATEDATE ',
- sortOrder : 'desc',
- rownumbers : true,
- checkbox : true,
- width : "98%",
- pageSize : 10,
- async : true,
- usePager: false,
- enabledSort:false,
- percentWidthMode : true,
- enabledEdit: true,
- clickToEdit: false,
- onDblClickRow:function(rowdata, rowindex){
- if(flag){
- top.Dialog.alert("请先完成当前记录的编辑!");
- return;
- }
- editingRow=parseInt(rowindex.slice(1))-1001;
- g.beginEdit(rowindex);
- },
- // 顶部图标按钮栏
- toolbar : {
- items : [ {
- text : '新增',
- click : addUser,
- iconClass : 'add1_tem',
- disabled : false
- } ,{
- line : true
- },{
- text:"删除",
- click:onDelete,
- iconClass:"delete_tem",
- disabled:false
- },{
- line:true
- },{
- text:"返回短信管理",
- click:goback,
- iconClass:"back_tem",
- disabled:false
- },{
- line:true
- }]
- }
- });
- }
- //新增
-
- function addUser(){
- if(flag){
- top.Dialog.alert("请先完成当前记录的编辑!");
- return;
- }
- $("#flag").val("1");
- editingRow=0;
- isNew=true;
- var row = g.getRow(0);
- var groupName = $("#groupNames").val();
- if(groupName==""|| groupName=="常用组联系人"){
- parent.Dialog.alert("请选择组别再进行添加");
- $("#flag").val("0");
- return ;
- }
-
- if(groupName=="组名含有特殊字符"){
- $("#flag").val("0");
- // parent.Dialog.alert("组名不能含有特殊字符");
- return;
- }
-
- if(groupName=="组名称为空"){
- $("#flag").val("0");
- //parent.Dialog.alert("请输入组名称再添加");
- return;
- }
- if(groupName=="此组名已存在"){
- $("#flag").val("0");
- // parent.Dialog.alert("此组名已存在,请另起组名");
- return;
- }
-
- var rowData={
- duty_way:0,
- GROUP_NAME_781:groupName
- };
- g.addEditRow(rowData, row, true);
- g.setNewPage(1);
- $(parent.document.body).find("#frmrightChild").height($(window.document.body).height()+30);
- $(top.document.body).find("#frmright").height($(parent.document.body).height()+30);
- }
-
- function onDelete(){
- var row = g.getSelectedRows();
- if(row.length==0){
- top.Dialog.alert("请选择要删除的联系人");
- return;
- }
- if(flag){
- top.Dialog.alert("请完成编辑再删除");
- return;
- }
-
- var fd_id="";
- for(var i=0;i<row.length;i++){
- fd_id+=row[i].FD_OBJECTID_781+",";
-
- }
- var url = $.pathname() +"/ws/crud/CRUDService/delete/";
- var params={
- objectIDs : fd_id,
- classid : 781
- };
- top.Dialog.confirm("确定要删除吗?|删除",function(){
-
-
- $.ajax({
- url : url,
- type : 'post',
- timeout : 15000,
- data : params,
- dataType : 'json',
- success : function(data) {
- if (data.Msg.sucsess == true) {
-
- top.Dialog.alert("删除成功!");
- g.loadData();
- } else {
- top.Dialog.alert("删除失败!");
- }
- },
- error : function(e) {
- $.messager.alert('获取ID失败!', '访问服务失败!', 'error');
- }
- });
- });
-
- }
- function endEdits(rowid,group){
- var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]");
- var newData = g.getAdded();
- var checkAdd = true;
- if(newData.length>0){
- checkAdd = false;
- }
-
- var name = $("#maingrid .textinput").eq(0).val();
- var comp =$("#maingrid .textinput").eq(2).val();
- var tel = $("#maingrid .textinput").eq(1).val();
- var groupnames = $("#groupNames").val();
- if(groupnames==""||groupnames=="常用组联系人"){
- groupnames = group.GROUP_NAME_781;
- }
- var fd_id = group.FD_OBJECTID_781;
- if(name.trim()==""||name.trim()==null){
- parent.Dialog.alert("联系人名字不能为空");
- return;
- }
- if(tel.trim()==""||tel.trim()==null){
- parent.Dialog.alert("组人员电话不能为空");
- return;
- }
- var text = /^(13[0-9]|14[0-9]|15[0-9]|18[0-9])\d{8}$/i;
- if(!text.test(tel)){
- parent.Dialog.alert("请输入正确的手机号码");
- return;
- }
-
- if(pattern.test(comp)){
- top.Dialog.alert("公司名称不能包含特殊字符 ");
- return;
- }
-
- if(pattern.test(name)){
- top.Dialog.alert("名字不能包含特殊字符");
- return;
- }
-
- if(checkAdd){
- var telArr = getPeopleTelss(groupnames).rows;
- if(!checkTel(tel,telArr)&&group.GROUP_PEOPLE_TEL_781!=tel){
- top.Dialog.alert("此联系人已存在");
- return;
- }else{
-
- parent.Dialog.confirm("确定要修改常用联系人信息吗?|修改", function(){
- $.ajax({
- url:$.pathname() + '/ws/getContactGroup/ContactService/updateGroupInfo',
- type : 'post',
- timeout : 15000,
- async : false,
- data : {
- userId:userId,
- fd_id:fd_id,
- comp:comp,
- people:name,
- tel:tel,
- groupName:groupnames
- },
- dataType : 'text',
- success:function(data){
- parent.Dialog.alert("更改成功");
- g.endEdit(rowid);
- parent.creteGroupTree();
- },
- error : function(e) {
- $.messager.alert('更改成功!', '更改成功!', 'error');
- }
-
- });
- });
- }
-
- }else{
- var telArr = getPeopleTelss(groupnames).rows;
- if(!checkTel(tel,telArr)){
- top.Dialog.alert("此联系人已存在");
- return;
- }else{
- parent.Dialog.confirm("确定要新增常用联系人信息吗?|新增", function(){
- $("#flag").val("0");
- $.ajax({
- url:$.pathname() + '/ws/getContactGroup/ContactService/addGroupPerson',
- type : 'post',
- timeout : 15000,
- async : false,
- data : {
- userId:userId,
- comp:comp,
- name:name,
- tel:tel,
- groupName:groupnames
- },
- dataType : 'text',
- success:function(data){
- parent.Dialog.alert("新增成功");
- g.endEdit(rowid);
- parent.creteGroupTree();
- g.loadData();
- },
- error : function(e) {
- $.messager.alert('新增成功!', '新增成功!', 'error');
- }
-
- });
- });
-
- }
- }
- }
-
-
- function getPeopleTelss(val){
- var pep_tel = "";
- $.ajax({
- url:$.pathname() + '/ws/getContactGroup/ContactService/getGroupTel',
- type : 'post',
- timeout : 15000,
- async : false,
- data : {
- userId:userId,
- groupName:val
- },
- dataType : 'json',
- success:function(data){
-
- pep_tel = data;
- },
- error : function(e) {
- $.messager.alert('查询失败!', '查询失败!', 'error');
- }
-
- });
- return pep_tel;
- }
- function checkTel(str,arr){
- if(arr.length==0){
- return true;
- }
- for(var i=0;i<arr.length;i++){
- if(str==arr[i].GROUP_PEOPLE_TEL){
- return false;
- }
- }
- return true;
- }
- function onDeleteGroup(index,edit,json){
-
- var checkAdd = true;
- var fd_id = json.FD_OBJECTID_781;
- var newData = g.getAdded();
- if(newData.length>0){
- checkAdd = false;
- }
-
- if(checkAdd&&edit==undefined){
- parent.Dialog.confirm("确定要删除常用联系组的人员信息?|删除", function(){
- $.ajax({
- url:$.pathname() +"/ws/crud/CRUDService/delete/",
- type : 'post',
- timeout : 15000,
- async : false,
- data : {
- objectIDs : fd_id,
- classid : 781
- },
- dataType : 'text',
- success:function(data){
- parent.Dialog.alert("删除成功");
- g.loadData();
- },
- error : function(e) {
- $.messager.alert('删除成功!', '删除成功!', 'error');
- }
-
- });
- });
- }else if(checkAdd&&edit==true){
- $("#flag").val("0");
- /*$("#maingrid .textinput").eq(0).val(json.GROUP_PEOPLE_781);
- $("#maingrid .textinput").eq(1).val(json.GROUP_PEOPLE_TEL_781);
- $("#maingrid .textinput").eq(2).val(json.GROUP_PEOPLE_COMP_781);
- g.endEdit(index);*/
- cancelEdit(index);
-
- }else{
- parent.Dialog.confirm("确定要删除新增联系人记录吗?|删除", function(){
- $("#flag").val("0");
- isValida=false;
- flag=false;
- g.endEdit(index);
- //删除记录
- var row = g.getRow(index);
- g.deleteRow(row);
- return false;
-
- });
- }
- }
- //取消编辑
- function cancelEdit(rowid) {
- g.cancelEdit(rowid);
- }
- function searchInfo(){
- var people = $("#people").val().trim();
- var name = $("#groupNames").val();
-
- var mob = $("#mob").val().trim();
- var condition="";
- var text = /\d+$/i;
- if(name=="常用组联系人"||name==undefined||name=="undefined"||name==""){
- condition = "is_del='0' and user_id='"+userId+"'";
- }else{
- condition = "is_del='0' and user_id='"+userId+"' and group_name='"+name+"'";
- }
-
- if(people=="请输入组人员姓名"){
- people ="";
- }
- if(people!=""){
- condition +="AND GROUP_PEOPLE LIKE '%"+people+"%'";
- }
-
- if(mob!=""&&!text.test(mob)){
- top.Dialog.alert("请输入正确的手机号或数字");
- return;
- }
- var searchCondition = getSelectCon(conditionData);
- g.setOptions({//重置加载列表的参数
- params : {
- "listId" :'781' ,
- "condition" : searchCondition.condition+condition,
- }
- });
- setTimeout(changeHeight, 200);
- g.loadData();//刷新列表
- }
- function changeHeight(){
-
- $(parent.document.body).find("#frmrightChild").height($(window.document.body).height()+60);
- $(top.document.body).find("#frmright").height($(parent.document.body).height()+60);
- }
- function check(event) {
- if (event.keyCode == 13) {
- searchInfo();
- }
- }
- $("#searchButt").live("click",function(){
- searchInfo();
- });
- function goback(){
- window.parent.parent.document.getElementById("frmright").setAttribute("src", "/nwyj/page/system/sms/msg_manage.html");
- }
|