| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- var token = $.cookie("token");
- $(document).ready(function(){
- $.ajax({
- type:"get",
- url:huayi.config.callcenter_url + 'UserAccount/GetCallForwarding',
- async:true,
- dataType:'json',
- data:{
- token: token,
- },
- success:function(res){
- if(res.state.toLowerCase()=='success'){
- $('.tables').html('');
- $(res.data).each(function(i,n){
- $('<tr>'+
- '<th><a href="javaScript:;" class="removes" onclick="del(this)"><i class="fa fa-remove"></i></a>时间段'+ parseInt(i+1) +':</th>'+
- '<td>'+
- '<div class="timeBox">'+
- '<i class="fa fa-clock-o tub"></i>'+
- '<input type="text" class="test-item" id="usestrTime2" value="'+ n.starttime+'" />'+
- '</div> '+
- '<span>至</span> '+
- '<div class="timeBox">'+
- '<i class="fa fa-clock-o tub"></i>'+
- '<input type="text" class="test-item" id="usestrTime22" value="'+ n.endtime +'" name="starttime1" />'+
- '</div>'+
- '</td>'+
- '</tr>').appendTo('.tables');
- })
- layerdate()
- }
- }
- });
- //时间赋值 layerdate
- function layerdate(){
- lay('.test-item').each(function(){
- laydate.render({
- elem: this
- ,trigger: 'click'
- ,type: 'time'
- });
- });
- }
- $('#addto').click(function(){
- var trs=$('.tables tr').length,lths=parseInt(trs+1);
- console.log(trs);
- for(var i=trs;i<lths;i++){
- $('<tr>'+
- '<th><a href="javaScript:;" class="removes" onclick="del(this)"><i class="fa fa-remove"></i></a>时间段'+ parseInt(i+1) +':</th>'+
- '<td>'+
- '<div class="timeBox">'+
- '<i class="fa fa-clock-o tub"></i>'+
- '<input type="text" class="test-item" id="usestrTime2" />'+
- '</div> '+
- '<span>至</span> '+
- '<div class="timeBox">'+
- '<i class="fa fa-clock-o tub"></i>'+
- '<input type="text" class="test-item" id="usestrTime22" />'+
- '</div>'+
- '</td>'+
- '</tr>').appendTo('.tables');
- }
- layerdate()
- })
- $('#del').click(function(){
- $('.removes').show();
- })
-
- $('#save').click(function(){
- save()
- })
-
-
-
- })
- //删除
- function del(a){
- $(a).parent().parent('tr').remove();
- save();
- }
- //拼字符串
- function str(){
- var arr='';
- $('.tables tr').each(function(i,n){
- var htmlStr='';
- // console.log($(n).find('input'))
- $($(n).find('input')).each(function(k,m){
- if(htmlStr){
- htmlStr +=','
- htmlStr +=m.value;
- }else{
- htmlStr +=m.value;
- }
- })
- if(arr){
- arr +='|'
- arr +=htmlStr;
- }else{
- arr +=htmlStr;
- }
- })
- return arr
- }
-
- //保存提交
- function save(){
- $.ajax({
- type:"get",
- url:huayi.config.callcenter_url +'UserAccount/EditCallForwarding',
- async:true,
- dataType:'json',
- data:{
- token: token,
- timestr:str()
- },
- success:function(res){
- if(res.state.toLowerCase()=='success'){
- layer.msg(res.message)
- }
-
- }
- })
- }
-
-
|