123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 |
- var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
- $(function(){
-
- $("#back").hover(function(){
- $(this).attr("src","/nwyj/images/temp/back_hover.png");
- },function(){
- $(this).attr("src","/nwyj/images/temp/back.png");
- });
-
-
- $("#back").on("click",function(){
-
- window.parent.document.getElementById("frmright").setAttribute("src", "/nwyj/page/system/sms/msg_manage.html");
- });
-
-
-
- var columns = getColunms("lxr");
- initGrid(columns);
- /*var row = g.getRow(0);
- g.deleteRow(row);*/
-
-
- $("#downloadUserModel").on("click",function(){
- var intVal = $("input:radio[name=type]").filter("[checked]").val();
- var url = "";
- if(intVal=="lxr"){
- url = "/nwyj/excels/lianxiren.xls";
- }else{
- url = "/nwyj/excels/lxz.xls";
- }
- window.open(url);
- });
-
- $("#save").on("click",function(){
- g.endEdit();
- var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]");
- var text = /^(13[0-9]|14[0-9]|15[0-9]|18[0-9])\d{8}$/i;
- var peopleData = g.getData();
- var intVal = $("input:radio[name=type]").filter("[checked]").val();
- var len = peopleData.length;
- if(len==0){
- top.Dialog.alert("请导入数据再保存");
- return;
- }
- var dataUrl = "";
- var dataParams = {userId:userId};
- if("lxr"==intVal){
- dataUrl = $.pathname() + '/ws/getContactPeoples/ContactpeopleService/getTel';
-
- var cyTel = getThing(dataUrl,dataParams).rows;
- for(var i=0;i<len;i++){
- var row = i+1;
- var tel = peopleData[i]["CONTACT_TEL"];
- var name = peopleData[i]["CONTACT_USER_NAME"];
- var dept = peopleData[i]["CONTACT_DEPT"];
- var corp = peopleData[i]["CONTACT_COMP"];
- if(!checkTel(tel, cyTel)){
- top.Dialog.alert("第"+(i+1)+"行的联系人已存在");
- return;
- }
- if(tel==""){
- top.Dialog.alert("第"+row+"行的电话为空");
- return;
- }
- if(name==""){
- top.Dialog.alert("第"+row+"行的联系人名字为空");
- return;
- }
- if(!text.test(tel)){
- top.Dialog.alert("第"+row+"行的手机号码有误,请重新输入");
- return;
- }
-
- if(pattern.test(name)){
- top.Dialog.alert("第"+row+"行的联系人姓名含有特殊字符,请重新输入");
- return;
- }
- if(pattern.test(dept)){
- top.Dialog.alert("第"+row+"行的部门名称含有特殊字符,请重新输入");
- return;
- }
- if(pattern.test(corp)){
- top.Dialog.alert("第"+row+"行的公司名称含有特殊字符,请重新输入");
- return;
- }
-
- }
- }else{
- dataUrl = $.pathname() + "/ws/addContent/AddSmsContentService/getUsedGroup";
- var groupData = getThing(dataUrl,dataParams);
- for(var i=0;i<len;i++){
- var row = i+1;
- var groupName = peopleData[i]["GROUP_NAME"];
- var groupPeople = peopleData[i]["GROUP_PEOPLE"];
- var groupPeopleTel = peopleData[i]["GROUP_PEOPLE_TEL"];
- console.log(groupPeopleTel);
- var groupComp = peopleData[i]["GROUP_PEOPLE_COMP"];
-
- if(groupName==""){
- top.Dialog.alert("第"+row+"行的联系组名称为空");
- return;
- }
- if(groupPeople==""){
- top.Dialog.alert("第"+row+"行的人员名字为空");
- return;
- }
- if(groupPeopleTel==""){
- top.Dialog.alert("第"+row+"行的人员电话为空");
- return;
- }
-
- if(pattern.test(groupName)){
- top.Dialog.alert("第"+row+"行的联系组名称包含特殊字符,请重新输入");
- return;
- }
- if(pattern.test(groupPeople)){
- top.Dialog.alert("第"+row+"行的人员名字包含特殊字符,请重新输入");
- return;
- }
- if(pattern.test(groupComp)){
- top.Dialog.alert("第"+row+"行的公司名称包含特殊字符,请重新输入");
- return;
- }
-
- if(!text.test(groupPeopleTel)){
- top.Dialog.alert("第"+row+"行的手机号码有误,请重新输入");
- return;
- }
-
- if(!checkGroupTel(groupName,groupPeopleTel,groupData)){
- top.Dialog.alert("联系人"+groupPeople+"已存在"+groupName+"组中");
- return;
- }
- }
- }
-
-
-
- var saveUrl = $.pathname() + "/ws/addContent/AddSmsContentService/saveContent";
- peopleData = JSON.stringify(peopleData);
- var params = {userId:userId,json:peopleData,type:intVal};
- var flag = getThing(saveUrl,params,'text');
-
- if(flag=="true"){
- top.Dialog.alert("批量导入新增成功");
- window.parent.document.getElementById("frmright").setAttribute("src", "/nwyj/page/system/sms/msg_manage.html");
- }else{
- top.Dialog.alert("批量导入新增失败");
- }
-
- });
-
-
- $("#resetTable").on("click",function(){
- var data = g.getData();
- var len = data.length;
- if(len>0){
- top.Dialog.confirm("确定要重置?导入的信息会全部清除,请慎重选择|重置", function() {
- for(var i=0;i<len;i++){
- var row = g.getRow(0);
- g.deleteRow(row);
- }
-
- });
- }
- });
-
-
- $("#importCon").on("click",function(){
-
- var val= $("#import_report").val();
- if(val==""||val==null){
- top.Dialog.alert("请导入excel文件");
- return;
- }
- var end = val.substring(val.indexOf(".")+1);
- if(end=="xls"||end=="xlsx"){
- var intVal = $("input:radio[name=type]").filter("[checked]").val();
- addfn(intVal);
- }else{
- top.Dialog.alert("请导入正确的excel文件");
- return;
- }
- });
- });
- function addfn(intVal) {
- var $form = $("#editForm");
- fileToSave($form,intVal);
-
- };
- function change(val){
- var columns = getColunms(val);
- g.setOptions({"columns":columns,"data":""});
- g.loadData();
- }
- function fileToSave($form,intVal){
- //showProgressBar("正在提交中...");
- //表单异步提交处理
- $form.ajaxSubmit({
- url:$.pathname() + "/ws/addContent/AddSmsContentService/daoRuContent?type="+intVal,
- type : 'post',
- success: function(responseText, statusText, xhr, $form){
- responseText = eval('('+responseText+')');
- var result = responseText["rows"];
- if(result.length==0){
- top.Dialog.alert("请填写数据再导入");
- return;
- }else if(result[0]["result"]===false){
- top.Dialog.alert("导入的模板跟选择的类型不一致,请检查");
- return;
- }else{
- var data = JSON.stringify(responseText);
- g.setOptions({
- "data" :JSON.parse(decodeURI(data))
- });
- }
- },
- error : function(e) {
- top.Dialog.alert("导入文件格式不对,请重新导入");
- }
- });
-
- }
- function initGrid(columns) {
- g = $("#dataGrid").quiGrid({
- columns : columns,
- data:"",
- rownumbers : true,
- width : "98%",
- height : '500',
- pageSize : 10,
- enabledSort:false,
- percentWidthMode : true,
- enabledEdit: true,
- /* clickToEdit: false,*/
- // 顶部图标按钮栏
- toolbar :false
- });
- }
- function getColunms(val){
- var columns = "";
- if(val=="lxz"){
- columns = [
- {
- display : '常用联系组',
- name : 'GROUP_NAME',
- align : 'center',
- width : '20%',
- editor: { type: 'text',maxlength:'15'}
- }, {
- display : '组人员名字',
- name : 'GROUP_PEOPLE',
- align : 'center',
- width : '20%',
- editor: { type: 'text',maxlength:'15'}
- }, {
- display : '组人员电话',
- name : 'GROUP_PEOPLE_TEL',
- align : 'center',
- width : '20%',
- editor: { type: 'text',maxlength:'11'}
- }, {
- display : '组人员公司',
- name : 'GROUP_PEOPLE_COMP',
- align : 'center',
- width : '20%',
- editor: { type: 'text',maxlength:'15'}
-
- } ];
- }else{
- columns = [
- {
- display : '常用联系人名字',
- name : 'CONTACT_USER_NAME',
- align : 'center',
- width : '20%',
- editor: { type: 'text',maxlength:'15'}
- },{
- display : '联系人电话',
- name : 'CONTACT_TEL',
- align : 'center',
- width : '20%',
- editor: { type: 'text',maxlength:'11'}
-
- },
-
- {
- display : '联系人部门',
- name : 'CONTACT_DEPT',
- align : 'center',
- width : '20%',
- editor: { type: 'text',maxlength:'15'}
- }, {
- display : '联系人公司',
- name : 'CONTACT_COMP',
- align : 'center',
- width : '20%',
- editor: { type: 'text',maxlength:'15'}
- }];
- }
-
- var display = {
-
- display: '操作', isSort: false, width: "20%", render: function (rowdata, rowindex, value,column)
- {
- var h = "";
- if (!rowdata._editing)
- {
-
- h += "<a onclick='onDelete("+rowindex+")' id='del'><span class='icon_delete'>删除</span></a> ";
- }
-
- return h;
- }
-
- };
- columns.push(display);
- return columns;
-
-
- }
- function onDelete(rowid){
- top.Dialog.confirm("确定要删除该联系人?|删除", function() {
- var row = g.getRow(rowid);
- g.deleteRow(row);
-
- });
-
-
- }
- function checkTel(str,arr){
- if(arr.length==0){
- return true;
- }
- for(var i=0;i<arr.length;i++){
- if(str==arr[i].CONTACT_TEL){
- return false;
- }
- }
- return true;
- }
- function checkGroupTel(name,tel,arr){
- if(arr.length==0){
- return true;
- }
- name = $.trim(name);
- var groupTel = arr[0][name];
- if(groupTel==undefined){
- return true;
- }
- var groupTelArr = groupTel.split(",");
- for(var i=0;i<groupTelArr.length;i++){
- if(groupTelArr[i]==tel){
- console.log(11);
- return false;
- }
- }
- return true;
- }
|