admin
2025-11-12 2c01c99a3f770a07b2e8e85c24f69f637556f45b
HTML/js/public.js
@@ -8,34 +8,34 @@
//var IP = "http://192.168.62.200:8888/api";//bkl服务器
//运行
var IP="https://localhost:44363/api";
//本地发布
//var IP="http://localhost:8034/api";
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')
      {
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')
          {
          if (pageLimits.indexOf(pageCnt) == "-1") {
            pageLimits.push(pageCnt);
            
            pageLimits.sort(function(a,b){
              return a - b;
            })
          }
      }
    }
              return a - b;
  });
          }
        }
      }
    }
  );
}
function sendData(url, data, type, callbackFun) {
  var deferred = $.Deferred();
@@ -43,22 +43,20 @@
    data = JSON.stringify(data);
  } 
  if (url!=IP+"/WeatherForecast/Login") {
    if (!$.cookie('token')) {
    if (!$.cookie("token")) {
      callbackFun("登录人信息已失效");
      try{
        parent.window.location.href = '/views/Login.html';
      }
      catch(error){
        window.location.href = '/views/Login.html';
        parent.window.location.href = "/views/Login.html";
      } catch (error) {
        window.location.href = "/views/Login.html";
      }
      return;
    }
    if(isTokenExpired($.cookie('token'))){
    if (isTokenExpired($.cookie("token"))) {
      try{
        parent.window.location.href = '/views/Login.html';
      }
      catch(error){
        window.location.href = '/views/Login.html';
        parent.window.location.href = "/views/Login.html";
      } catch (error) {
        window.location.href = "/views/Login.html";
      }
      return;
    }
@@ -69,7 +67,7 @@
    type: type,
    headers: {
      "Content-Type": "application/json; charset=UTF-8",
      "ToKen":$.cookie('token')
      ToKen: $.cookie("token"),
    },
    timeout: 45000,
    async: true,
@@ -90,7 +88,7 @@
  });
}
function isTokenExpired(token) {
  const tokenParts = token.split('.');
  const tokenParts = token.split(".");
  if (tokenParts.length !== 3) {
    return true; // JWT 格式不正确
  }
@@ -112,7 +110,7 @@
    data = JSON.stringify(data);
  } 
  if (url!=IP+"/WeatherForecast/Login") {
    if (!$.cookie('token')) {
    if (!$.cookie("token")) {
      callbackFun("登录人信息已失效");
    }
  }
@@ -122,7 +120,7 @@
    type: type,
    headers: {
      "Content-Type": "application/json; charset=UTF-8",
      "ToKen":$.cookie('token')
      ToKen: $.cookie("token"),
    },
    timeout: 45000,
    async: false,
@@ -146,13 +144,17 @@
  if (str == null || str == "" || str == undefined) {
    return "";
  } else {
    var date = new Date(str
    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.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;
@@ -163,7 +165,8 @@
  if (str == null || str == "" || str == undefined) {
    return "";
  } else {
    var date = new Date(str
    var date = new Date(
      str
      // parseInt(str.replace("/Date(", "").replace(")/", ""), 10)
    );
    Y = date.getFullYear() + "-";
@@ -234,7 +237,7 @@
  // console.log(centerHeight);
  
  var hh = bodyHeight - topHeight -centerHeight - 26 ;//6是body上内边距、20是layui-card-body上下内边距
  var h1 = parseInt(hh*0.6)
  var h1 = parseInt(hh * 0.6);
  return h1;
}
//获取除搜索条件外40%高度
@@ -243,9 +246,8 @@
  var topHeight = $("#top").outerHeight();  
  var centerHeight = $("#center").outerHeight();
  var hh = bodyHeight - topHeight-centerHeight - 26 ;//6是body上内边距 
  var h2 = parseInt(hh*0.4)
  var h2 = parseInt(hh * 0.4);
  return h2;
}
//获取除搜索条件以及页签外高度
@@ -268,53 +270,56 @@
  var regPos = /^\d+$/;
  //var regNeg = /^\-[1-9][0-9]"*$/;
  
  if (regPos.test(val))//&&regNeg.test(val))
  {
  if (regPos.test(val)) {
    //&&regNeg.test(val))
     return true;
  }
  else
  {
  } 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')
      {
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 target = $("#" + tableId + "")
      .next()
      .find(".layui-table-header");
    target.on("click", ".layui-table-cell", function () {
      var that=this;               
      var colText=that.innerText;//找到所点击列的列名
      if(colText==''){
      if (colText == "") {
        return;
      }
      var colWidth=that.clientWidth+"";//找到所点击列的列宽
      ColsSysArr = decodeURIComponent(decodeURIComponent(ColsSysArr));
      var param5={
        Href:Href,
        ColsJson:'',
        ColsJson: "",
        ColsSysArr:ColsSysArr,
        ColText:colText,
        ColWidth:colWidth
        ColWidth: colWidth,
      };  
      sendData(IP + "/Sys/SaveClosUser", param5, 'post', function(res){
      sendData(IP + "/Sys/SaveClosUser", param5, "post", function (res) {
        if(res.code === 0){
        }else { //不成功
        } else {
          //不成功
        }                  
      });
    });
@@ -322,13 +327,13 @@
}
//深拷贝
function deepClone(source) {
  if (typeof source !== 'object' || source == null) {
  if (typeof source !== "object" || source == null) {
    return source;
  }
  const target = Array.isArray(source) ? [] : {};
  for (const key in source) {
    if (Object.prototype.hasOwnProperty.call(source, key)) {
      if (typeof source[key] === 'object' && source[key] !== null) {
      if (typeof source[key] === "object" && source[key] !== null) {
        target[key] = deepClone(source[key]);
      } else {
        target[key] = source[key];
@@ -346,23 +351,23 @@
  var $form = $(formSelector);
  $.each(data, function(key, value) {
      var $field = $form.find('[name=' + key + ']');
    var $field = $form.find("[name=" + key + "]");
      if ($field.length > 0) {
          var fieldType = $field.attr('type');
      var fieldType = $field.attr("type");
          switch (fieldType) {
              case 'checkbox':
        case "checkbox":
                  if (Array.isArray(value)) {
                      $field.each(function() {
                          $(this).prop('checked', value.includes($(this).val()));
              $(this).prop("checked", value.includes($(this).val()));
                      });
                  } else {
                      $field.prop('checked', value);
            $field.prop("checked", value);
                  }
                  break;
              case 'radio':
                  $field.filter('[value=' + value + ']').prop('checked', true);
        case "radio":
          $field.filter("[value=" + value + "]").prop("checked", true);
                  break;
              default:
                  $field.val(value);
@@ -375,27 +380,27 @@
//分页格式化
var FnParseData = function (res) {
  return {
    "code": res.code == 0 ? 0 : res.code, // 解析接口状态
    "msg": res.msg, // 解析提示文本
    "count": res.data.Total, // 解析数据长度
    "data": res.data.Items // 解析数据列表
    code: res.code == 0 ? 0 : res.code, // 解析接口状态
    msg: res.msg, // 解析提示文本
    count: res.data.Total, // 解析数据长度
    data: res.data.Items, // 解析数据列表
  };
}
};
//调用打印
function openPrintDialog(printData, printType){
  layer.open({
    type: 2,
    title: '打印',
    title: "打印",
    // content: '../../js/hiprint/custom.html',
    content: '/views/SystemSettings/PrintModule.html',
    content: "/views/SystemSettings/PrintModule.html",
    maxmin: true,
    area: ['100%', '100%'],
    area: ["100%", "100%"],
    data: printData,
    success: function (layero, index) {
      var body = layer.getChildFrame('body',index);
      body.find('#printData').val(JSON.stringify(printData));
      body.find('#printType').val(printType);
    }
      var body = layer.getChildFrame("body", index);
      body.find("#printData").val(JSON.stringify(printData));
      body.find("#printType").val(printType);
    },
  });
}