bklLiudl
2025-04-07 4e8f58cb41c7b6d570fd1979d80f74ab8a4d00c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
//var IP = "http://47.104.149.73:1991";//接口IP
// var IP = "http://172.16.71.101:8082/";//接口IP
//var IP = "http://localhost:13243/api";
var IP = "http://localhost:50515/api";  //本地
// var IP = "http://localhost:44318/api";
//var IP = "http://192.168.1.6:8017";
//var IP = "http://192.168.1.226:8086";  
// var IP = "http://192.168.62.200:8888/api";  //bkl服务器
 
var pageCnt = 15;
var pageLimits = [10, 15, 20, 30, 50, 70, 100];
function pageCntFirst()
{
  sendData(IP + "/Basis/GetFunSettingByNo?funSetNo="+"Fun013", {}, 'get', function (res) {
    console.log(res.data.SetValue)
    if (res.code == 0) { //成功 
      if(res.data.IsEnable == 'NO')
      {
          pageCnt = parseInt(res.data.SetValue);
          // console.log(pageLimits.indexOf(pageCnt) == '-1')
          if (pageLimits.indexOf(pageCnt) == '-1')
          {
            pageLimits.push(pageCnt);
            
            pageLimits.sort(function(a,b){
              return a - b;
            })
          }
      }
    }
  });
}
function sendData(url, data, type, callbackFun) {
  var deferred = $.Deferred();
  if (type != "get") {
    data = JSON.stringify(data);
  } 
  if (url!=IP+"/WeatherForecast/Login") {
    if (!$.cookie('token')) {
      callbackFun("登录人信息已失效");
    }
  } 
  $.ajax({
    url: url,
    data: data,
    type: type,
    headers: {
      "Content-Type": "application/json; charset=UTF-8",
      "ToKen":$.cookie('token')
    },
    timeout: 45000,
    async: true,
    cache: false,
    beforeSend: function (xhr, settings) {},
    success: function (res, status, xhr) {
      // console.log(res);
      // console.log(status);
 
      callbackFun(res);
    },
    error: function (res, status, error) {  
      // console.log(res);
      // console.log(status);
      callbackFun(res, status, error);
      // layer.msg(res.statusText, {
      //   icon: 2,
      //   time: 2000 //2秒关闭(如果不配置,默认是3秒)
      // }, function() {});
    },
  });
}
function synData(url, data, type, callbackFun) {
  var deferred = $.Deferred();
  if (type != "get") {
    data = JSON.stringify(data);
  } 
  if (url!=IP+"/WeatherForecast/Login") {
    if (!$.cookie('token')) {
      callbackFun("登录人信息已失效");
    }
  }
  $.ajax({
    url: url,
    data: data,
    type: type,
    headers: {
      "Content-Type": "application/json; charset=UTF-8",
      "ToKen":$.cookie('token')
    },
    timeout: 45000,
    async: false,
    cache: false,
    beforeSend: function (xhr, settings) {},
    success: function (res, status, xhr) {
      callbackFun(res);
    },
    error: function (res, status, error) { 
      callbackFun(res, status, error);
      // layer.msg(res.statusText, {
      //   icon: 2,
      //   time: 2000 //2秒关闭(如果不配置,默认是3秒)
      // }, function() {});
    },
  });
}
 
// 根据时间戳转换为时间格式
function formatDate(str) {
  if (str == null || str == "" || str == undefined) {
    return "";
  } else {
    var date = new Date(str
      //parseInt(str.replace("/Date(", "").replace(")/", ""), 10)
    );
    Y = date.getFullYear();
    M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1);
    D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate());
    h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours());
    m = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
    s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
    return Y +"-"+ M +"-" +D+" " + h+":" + m + ":" + s;
  }
}
// 根据时间戳转换为时间格式:年-月-日
function formatDate2(str) {
  if (str == null || str == "" || str == undefined) {
    return "";
  } else {
    var date = new Date(str
      // parseInt(str.replace("/Date(", "").replace(")/", ""), 10)
    );
    Y = date.getFullYear() + "-";
    M =
      (date.getMonth() + 1 < 10
        ? "0" + (date.getMonth() + 1)
        : date.getMonth() + 1) + "-";
    D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
    h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
    m = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
    s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
    return Y + M + D;
  }
}
 
//获取浏览器参数
function getQueryString(name) {
  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  var r = window.location.search.substr(1).match(reg);
  if (r != null) return unescape(r[2]);
  return null;
}
 
// 同步方法
function sendDataAsync(url, data, type, callbackFun) {
  var deferred = $.Deferred();
  data = JSON.stringify(data);
  $.ajax({
    url: url,
    data: data,
    type: type,
    headers: {
      "Content-Type": "application/json",
    },
    timeout: 45000,
    async: false,
    cache: false,
    beforeSend: function (xhr, settings) {},
    success: function (res, status, xhr) {
      callbackFun(res);
    },
    error: function (xhr, status, error) {
      console.log("失败了");
      console.log(xhr);
    },
  });
}
 
//获取除搜索条件外高度
function GetTableHeight() {
  var bodyHeight = $("#body").outerHeight();
  var topHeight = $("#top").outerHeight();
  var centerHeight = $("#center").outerHeight();
//   console.log(bodyHeight);
//   console.log(topHeight);
//   console.log(centerHeight);
 
  var hh = bodyHeight - topHeight-centerHeight - 26 ;//6是body上内边距 
  return hh;
}
//获取除搜索条件外60%高度
function GetTableTopHeight() {
  var bodyHeight = $("#body").outerHeight();
  var topHeight = $("#top").outerHeight();
  var centerHeight = $("#center").outerHeight();
  // console.log(bodyHeight);
  // console.log(topHeight);
  // console.log(centerHeight);
  
  var hh = bodyHeight - topHeight -centerHeight - 26 ;//6是body上内边距、20是layui-card-body上下内边距
  var h1 = parseInt(hh*0.6) 
  return h1;
}
//获取除搜索条件外40%高度
function GetTableBottomHeight() {
  var bodyHeight = $("#body").outerHeight();
  var topHeight = $("#top").outerHeight();  
  var centerHeight = $("#center").outerHeight();
 
 
  var hh = bodyHeight - topHeight-centerHeight - 26 ;//6是body上内边距 
  var h2 = parseInt(hh*0.4)
  return h2;
}
//获取除搜索条件以及页签外高度
function GetTableTabHeight() {
    var bodyHeight = $("#body").outerHeight();
    var topHeight = $("#top").outerHeight();
    var centerHeight = $("#center").outerHeight();
    var tabHeight = $("#tab").outerHeight();
    // console.log(bodyHeight);
    // console.log(topHeight);
    // console.log(centerHeight);
    // console.log(tabHeight);
  
    var hh = bodyHeight - topHeight-centerHeight-tabHeight - 57 ;//6是body上内边距 
    return hh;
}
 
//判断是否正整数 true 正整数 false 其他
function isIntNum(val){
  var regPos = /^\d+$/;
  //var regNeg = /^\-[1-9][0-9]"*$/;
  
  if (regPos.test(val))//&&regNeg.test(val))
  {
     return true;
  }
  else
  {
    return false;
  }
}
//判断是否开启table列表列宽调整功能。
var isSetColW=false;
function GetIsSetColW()
{
  sendData(IP + "/Basis/GetFunSettingByNo?funSetNo="+"Fun014", {}, 'get', function (res) {
    if (res.code == 0) { //成功 
      if(res.data.IsEnable == 'NO')
      {
        isSetColW=true;
      }
    }
  });
}
//自定义列宽功能,tableId:表格id,Href:表格获取数据方法,ColsSysArr:自定列表头url编码后数据
function SetTableColW(tableId,Href,ColsSysArr){
  if(isSetColW){
    //通过表格id获取表格表头的点击事件
    var target= $('#'+tableId+'').next().find('.layui-table-header');
    target.on('click', '.layui-table-cell', function(){
      var that=this;                    
      var colText=that.innerText;//找到所点击列的列名
      if(colText==''){
        return;
      }
      var colWidth=that.clientWidth+"";//找到所点击列的列宽
      ColsSysArr = decodeURIComponent(decodeURIComponent(ColsSysArr));
      var param5={
        Href:Href,
        ColsJson:'',
        ColsSysArr:ColsSysArr,
        ColText:colText,
        ColWidth:colWidth            
      };  
      sendData(IP + "/Sys/SaveClosUser", param5, 'post', function(res){
        if(res.code === 0){
        
        }else { //不成功
 
        }                        
      });
    });
  }  
}