Commit b0eb5b2247867b09e0192b032f342bc3f2ec66eb

Authored by 赖素文
1 parent b2d1864b

-

web/WebMvc/Views/Shared/_Layout.cshtml
... ... @@ -59,13 +59,13 @@
59 59 top.location.href = window.location.href;
60 60 }
61 61 if (window.top.IsDevelopment) {
62   - /*全局Js错误监听 */
  62 + /*全局Js错误监听、正式环境 */
63 63 window.onerror = function (msg, url, l) {
64 64 const txt = `本页中存在错误\n
65   - 错误:${msg}\n
66   - 地址:${url}\n
67   - 行:${l}\n
68   - 点击任意空白处继续或刷新浏览器,问题频繁出现请联系管理员。`;
  65 + 错误:${msg}\n
  66 + 地址:${url}\n
  67 + 行:${l}\n
  68 + 点击任意空白处继续或刷新浏览器,问题频繁出现请联系管理员。`;
69 69 alert(txt, { icon: 2, shadeClose: true, title: "系统错误" });
70 70 console.error(txt);
71 71 return true;
... ...
web/WebMvc/wwwroot/productjs/equipment/BusEquipmenMaintenanOverview.js 0 → 100644
  1 +let action = null;
  2 +layui.config({
  3 + base: "/js/",
  4 + version: 1
  5 +}).use(['system'], function () {
  6 + var form = layui.form,
  7 + $ = layui.jquery,
  8 + element = layui.element,
  9 + table = layui.table,
  10 + system = layui.system,
  11 + sysU = new system.u(),
  12 + sendDataWhere = null,
  13 + paramData = {
  14 + eqCode: null,
  15 + eqType: null,
  16 + otherCoce: null,
  17 + eqImg: null,
  18 + eqName: "",
  19 + projectName: ""
  20 + },
  21 +
  22 + areaName = "equipment",
  23 + controllerName = "BaseEquipment",
  24 + app = null;
  25 +
  26 +
  27 + action = {
  28 + //表格行点击事件
  29 + customTableCelClick: function (obj, tableId) {
  30 + if (tableId == app.data.tableColsEqPartElem) {
  31 + app.methods.initEqPartMaintainDataList(obj.data.PartCode);
  32 + }
  33 + },
  34 + }
  35 +
  36 + app = {
  37 + data: {
  38 + //部件列表
  39 + colsEqPart: [[
  40 + { field: "id", width: 80, hide: true, title: "Id", noExel: true },
  41 + { field: "TopKeys", width: 80, hide: true, title: "topKeys", noExel: true },
  42 + { field: "HeadKeys", width: 80, hide: true, title: "headKeys", noExel: true },
  43 + { field: "PartCode", width: 100, title: "部件编码", hide: true },
  44 + { field: "PartName", width: 250, title: "部件名称" },
  45 + { field: "LastMaintainTime", title: "上次保养时间", width: 200 },
  46 + {
  47 + field: "NextMaintainTime", title: "下次保养时间", width: 350, templet: function (d) {
  48 + const nextMaintenanceTime = moment(d.NextMaintainTime); // 下一次保养时间
  49 + const currentTime = moment();
  50 + const diffInDays = nextMaintenanceTime.diff(currentTime, 'days'); // 计算未来的时间差
  51 +
  52 + if (diffInDays >= 5) {
  53 + return `${d.NextMaintainTime}<span style='color:red;'>,还有 ${diffInDays} 天到下次保养</span>`;
  54 + } else if (diffInDays < 0) {
  55 + return `${d.NextMaintainTime}<span style='color:red;'>,逾期 ${Math.abs(diffInDays)} 天</span>`;
  56 + }
  57 + return d.NextMaintainTime;
  58 + }
  59 + }
  60 + ]],
  61 +
  62 + //保养列表
  63 + colsEqMaintainRecord: [[
  64 + { field: "EquipmentCode", width: 80, hide: true, title: "设备编码" },
  65 + { field: "EquipmentTypeCode", width: 150, title: "设备类型编码", hide: true },
  66 + { field: "PartCode", width: 80, hide: true, title: "部件编码" },
  67 +
  68 + { field: "PartName", width: 150, title: "设备部件" },
  69 + {
  70 + field: "NextMaintainTime", title: "下次保养时间", width: 250, templet: function (d) {
  71 + const nextMaintenanceTime = moment(d.NextMaintainTime); // 下一次保养时间
  72 + const currentTime = moment();
  73 + const diffInDays = nextMaintenanceTime.diff(currentTime, 'days'); // 计算未来的时间差
  74 +
  75 + if (diffInDays >= 5) {
  76 + return `${d.NextMaintainTime}<span style='color:red;'>,还有 ${diffInDays} 天到下次保养</span>`;
  77 + } else if (diffInDays < 0) {
  78 + return `${d.NextMaintainTime}<span style='color:red;'>,逾期 ${Math.abs(diffInDays)} 天</span>`;
  79 + }
  80 + return d.NextMaintainTime;
  81 + }
  82 + },
  83 + { field: "LastMaintainTime", width: 150, title: "上次保养时间" },
  84 + { field: "MaintainTime", width: 150, title: "本次保养时间" },
  85 + { field: "Maintainer", width: 150, title: "保养人员" },
  86 + { field: "MaintainContent", width: 150, title: "保养结果" },
  87 + {
  88 + field: "PushStatus", width: 130, title: "推送状态", templet: function (d) {
  89 + return "".GetState(sysU.sysEnumData.EnumMaintainPushStatus, d.PushStatus);
  90 + }
  91 + },
  92 + {
  93 + field: 'url', width: 300, title: '保养附件', templet: function (d) {
  94 + debugger
  95 + if (d.url == null) return "";
  96 + let urlData = d.url.split(","),
  97 + target = "_blank";
  98 + const fileExtensions = ["pdf", "docx", "doc", "xlsx"];
  99 + let aContents = urlData.map((item, index) => {
  100 + if (fileExtensions.some(ext => item.includes(ext))) {
  101 + target = "_self";
  102 + }
  103 + let fileName = item.split("_")[0];
  104 + return `<a href="../../Document/${item}" target="${target}" style="color:cornflowerblue; text-decoration:underline; cursor:pointer;">${fileName}</a>`;
  105 + }).join(",");
  106 +
  107 + if (aContents) aContents = aContents.slice(0, -1); // 移除最后一个字符
  108 + return aContents
  109 + }
  110 + },
  111 + { field: "Remark", width: 150, title: "保养备注" }
  112 + ]],
  113 +
  114 + tableColsEqPartElem: "equipmentPartDt",
  115 + tableColsEqMaintainedElem: "maintainedDt",
  116 + tableColsEqUnMaintainElem: "unMaintainDt",
  117 +
  118 +
  119 + //下拉框配置
  120 + selectOption: {
  121 + //返回的数据 用于后续操作
  122 + selectData: {
  123 +
  124 + }
  125 + },
  126 + },
  127 + methods: {
  128 +
  129 + //读取设备概述、设备部件保养数据 请求数据接口
  130 + initEqMaintainDataList() {
  131 + debugger
  132 + var ajaxConfig = {
  133 + data: { equipmentCode: paramData.eqCode, equipmentTypeCode: paramData.eqType },
  134 + url: `/${areaName}/${controllerName}/GetEquipmentMaintainList`,
  135 + success: function (result) {
  136 + if (sysU.successBefore(result)) return false;
  137 + app.methods.initEqPartTable(result.Result);
  138 + }
  139 + };
  140 + sysU.ajax(ajaxConfig);
  141 + },
  142 +
  143 + //设备概述、设备部件列表 表单显示
  144 + initEqPartTable: function (val) {
  145 + var { MaintainNumber, ToBeMaintainedNumber, lastMaintainTime, sumAmount, status, seconds, ip, imgSrc } = val.main[0];
  146 + const { text: statusText, bg } = app.methods.getStatusDetails(status, seconds);
  147 + const statusHTML = `ip:<span style="display: inline-block;">${ip}</span>
  148 + <span class="${bg}" style="left: 7px;"></span>
  149 + <span style="padding-left: 8px;">${statusText}</span>`;
  150 + $('#eqStatusIP').html(statusHTML);
  151 +
  152 + app.methods.setText('#maintainNumber', MaintainNumber, "0");
  153 + app.methods.setText('#toBeMaintainNumber', ToBeMaintainedNumber, "0");
  154 + app.methods.setText('#lastMaintainTime', lastMaintainTime, "无");
  155 + app.methods.setText('#sumAmount', sumAmount, "0");
  156 + app.methods.setText('#eqCode', paramData.eqCode, ""); // 设备编码
  157 +
  158 + $('#projectInfo').text("项目: " + paramData.projectName); // 项目名称
  159 + if (imgSrc != "null") $(".eqImg").attr('src', `/images/equipment/${imgSrc}`)
  160 +
  161 + //设备部件表格
  162 + let options = {
  163 + elem: "#" + app.data.tableColsEqPartElem,
  164 + cols: app.data.colsEqPart,
  165 + data: val.eqmaintainHeadList,
  166 + page: true,
  167 + height: "full-428",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示。数字越小,高度越高
  168 + doneExtend: function (res, obj) {
  169 + //设备保养、未保养
  170 + app.methods.initEqPartMaintainDataList();
  171 + }
  172 + }
  173 + sysU.initTable(options);
  174 + },
  175 +
  176 + //设备部件保养、未保养数据 请求数据接口
  177 + initEqPartMaintainDataList(obj) {
  178 + var ajaxConfig = {
  179 + data: { eqCode: paramData.eqCode, partCode: obj },
  180 + url: `/${areaName}/${controllerName}/GetEquipmentMaintainRecordList`,
  181 + success: function (result) {
  182 + if (sysU.successBefore(result)) return false;
  183 + //加载设备部件保养、未保养 表格
  184 + app.methods.initEqMaintainedTable(result.Result.maintainList);
  185 + app.methods.initEqUnMaintainTable(result.Result.tobemaintainList);
  186 + }
  187 + };
  188 + sysU.ajax(ajaxConfig);
  189 + },
  190 +
  191 + //设备保养页签-已保养
  192 + initEqMaintainedTable: function (data) {
  193 + //设备部件表格
  194 + let options = {
  195 + elem: "#" + app.data.tableColsEqMaintainedElem,
  196 + cols: app.data.colsEqMaintainRecord,
  197 + data: data,
  198 + page: true,
  199 + height: "full-380",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
  200 + doneExtend: function (res, obj) {
  201 +
  202 + }
  203 + }
  204 + sysU.initTable(options);
  205 + },
  206 +
  207 + //设备保养页签-未保养
  208 + initEqUnMaintainTable: function (data) {
  209 + //设备部件表格
  210 + let options = {
  211 + elem: "#" + app.data.tableColsEqUnMaintainElem,
  212 + cols: app.data.colsEqMaintainRecord,
  213 + data: data,
  214 + page: true,
  215 + height: "full-380",//如果是主明细页签,列表主体高度要设置,否则分页导航不直观展示
  216 + doneExtend: function (res, obj) {
  217 +
  218 + }
  219 + }
  220 + sysU.initTable(options);
  221 + },
  222 +
  223 + getStatusDetails: function (status, seconds) {
  224 + if (status === "Failure" || status === "Error") {
  225 + return { text: "故障", bg: "layui-badge-dot layui-bg-red" };
  226 + }
  227 + if (seconds > 300 || seconds === -1) {
  228 + return { text: "离线", bg: "layui-badge-dot layui-bg-gray" };
  229 + }
  230 + return { text: "在线", bg: "layui-badge-dot layui-bg-green" };
  231 + },
  232 + setText: function (selector, value, defaultValue) {
  233 + $(selector).text(value || defaultValue);
  234 + },
  235 + //初始化表单
  236 + initFrom() {
  237 + debugger
  238 + var cacheData = localStorage.getItem("bus_maintenanceOverview");
  239 + var tempParamData = null;
  240 + if (cacheData == null) {
  241 + layer.alert("请选择一条数据", { icon: sysU.config.iconoError, shadeClose: true, title: "错误信息" });
  242 + return;
  243 + }
  244 + tempParamData = JSON.parse(cacheData);
  245 + paramData.eqCode = tempParamData.equipmentCode;
  246 + paramData.eqName = tempParamData.equipmentName;
  247 + paramData.projectName = tempParamData.projectName; }
  248 + },
  249 + registerEvent: function () {
  250 +
  251 + },
  252 + init: function () {
  253 + app.methods.initFrom();
  254 + app.registerEvent();
  255 + app.methods.initEqMaintainDataList();
  256 + }
  257 + };
  258 + app.init();
  259 +});
0 260 \ No newline at end of file
... ...