2 lines
6.6 KiB
JavaScript
2 lines
6.6 KiB
JavaScript
var q=Object.defineProperty,z=Object.defineProperties;var $=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var w=(n,o,i)=>o in n?q(n,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[o]=i,_=(n,o)=>{for(var i in o||(o={}))j.call(o,i)&&w(n,i,o[i]);if(x)for(var i of x(o))H.call(o,i)&&w(n,i,o[i]);return n},I=(n,o)=>z(n,$(o));var m=(n,o,i)=>new Promise((v,f)=>{var g=r=>{try{d(i.next(r))}catch(p){f(p)}},b=r=>{try{d(i.throw(r))}catch(p){f(p)}},d=r=>r.done?v(r.value):Promise.resolve(r.value).then(g,b);d((i=i.apply(n,o)).next())});import{aq as O,at as R,bi as J,ay as Y,an as K,aL as Q,c6 as T,a9 as y}from"./bootstrap-CRjSNGHY.js";import"./vxe-table-uq8U2E1u.js";import{g as W}from"./index-CIc-2hgy.js";import{g as E}from"./index-y8WBv__M.js";import{b as U}from"./index-CfD5Kw90.js";import{g as X}from"./rangePickerProps-BPpM6dzr.js";import{D as L}from"./dict-enum-CaHgMaDZ.js";import{_ as Z}from"./table-action.vue_vue_type_script_setup_true_lang-BdzHKWY1.js";import{_ as ee}from"./page.vue_vue_type_script_setup_true_lang-3ywDTU7g.js";import{m as te,b9 as P,v as oe,ab as A,b2 as S,bJ as s,j as u,u as c,ad as ae,ai as D,ae as N,bp as h,L as a}from"../jse/index-index-CMeVxoEG.js";import{u as ie}from"./use-vxe-grid-BMVG5Iiw.js";import{A as M}from"./icons-CieLeI1V.js";import"./dict-tag.vue_vue_type_script_setup_true_lang-BB6x-AyV.js";import"./index-BNS265yo.js";function ne(n){return O.get("/iot/alert-record/page",{params:n})}function le(n,o){return O.put("/iot/alert-record/process",{id:n,remark:o})}function se(){return[{fieldName:"configId",label:"告警配置",component:"ApiSelect",componentProps:{api:U,labelField:"name",valueField:"id",placeholder:"请选择告警配置",allowClear:!0,showSearch:!0}},{fieldName:"configLevel",label:"告警级别",component:"Select",componentProps:{options:R(L.IOT_ALERT_LEVEL,"number"),placeholder:"请选择告警级别",allowClear:!0}},{fieldName:"productId",label:"产品",component:"ApiSelect",componentProps:{api:E,labelField:"name",valueField:"id",placeholder:"请选择产品",allowClear:!0,showSearch:!0}},{fieldName:"deviceId",label:"设备",component:"ApiSelect",componentProps:{api:W,labelField:"deviceName",valueField:"id",placeholder:"请选择设备",allowClear:!0,showSearch:!0}},{fieldName:"processStatus",label:"是否处理",component:"Select",componentProps:{options:R(L.INFRA_BOOLEAN_STRING),placeholder:"请选择是否处理",allowClear:!0}},{fieldName:"createTime",label:"创建时间",component:"RangePicker",componentProps:I(_({},X()),{allowClear:!0})}]}function re(){return[{type:"checkbox",width:40},{field:"id",title:"记录编号",minWidth:80},{field:"configName",title:"告警名称",minWidth:150},{field:"configLevel",title:"告警级别",minWidth:100,slots:{default:"configLevel"}},{field:"productId",title:"产品名称",minWidth:120,slots:{default:"product"}},{field:"deviceId",title:"设备名称",minWidth:120,slots:{default:"device"}},{field:"deviceMessage",title:"触发的设备消息",minWidth:150,slots:{default:"deviceMessage"}},{field:"processStatus",title:"是否处理",minWidth:100,cellRender:{name:"CellDict",props:{type:L.INFRA_BOOLEAN_STRING}}},{field:"processRemark",title:"处理结果",minWidth:150},{field:"createTime",title:"创建时间",minWidth:180,formatter:"formatDateTime"},{title:"操作",width:100,fixed:"right",slots:{default:"actions"}}]}const ce={class:"text-xs"},de={key:1,class:"text-gray-400"},xe=te({name:"IoTAlertRecord",__name:"index",setup(n){const o=P([]),i=P([]);function v(){B.query()}function f(){return m(this,null,function*(){o.value=yield E(),i.value=yield W()})}function g(e){return e?{1:"提示",2:"一般",3:"警告",4:"严重",5:"紧急"}[e]||`级别${e}`:"-"}function b(e){return e&&{1:"blue",2:"green",3:"orange",4:"red",5:"purple"}[e]||"default"}function d(e){if(!e)return"-";const l=o.value.find(t=>t.id===e);return(l==null?void 0:l.name)||"加载中..."}function r(e){if(!e)return"-";const l=i.value.find(t=>t.id===e);return(l==null?void 0:l.deviceName)||"加载中..."}function p(e){return m(this,null,function*(){T.confirm({title:"处理告警记录",content:a("div",[a("p","请输入处理原因:"),a("textarea",{id:"processRemark",class:"ant-input",rows:3,placeholder:"请输入处理原因"})]),onOk(){return m(this,null,function*(){const t=document.querySelector("#processRemark"),C=(t==null?void 0:t.value)||"";if(!C)throw y.warning("请输入处理原因"),new Error("请输入处理原因");const G=y.loading({content:"正在处理...",duration:0});try{yield le(e.id,C),y.success("处理成功"),v()}catch(k){throw console.error("处理失败:",k),k}finally{G()}})}})})}function F(e){T.info({title:"告警记录详情",width:600,content:a("div",{class:"space-y-2"},[a("div",[a("span",{class:"font-semibold"},"告警名称:"),a("span",e.configName||"-")]),a("div",[a("span",{class:"font-semibold"},"告警级别:"),a("span",g(e.configLevel))]),a("div",[a("span",{class:"font-semibold"},"设备消息:"),a("pre",{class:"mt-1 text-xs bg-gray-50 p-2 rounded"},e.deviceMessage||"-")]),a("div",[a("span",{class:"font-semibold"},"处理结果:"),a("span",e.processRemark||"-")]),a("div",[a("span",{class:"font-semibold"},"处理时间:"),a("span",e.processTime?new Date(e.processTime).toLocaleString("zh-CN"):"-")])])})}const[V,B]=ie({formOptions:{schema:se()},gridOptions:{columns:re(),height:"auto",keepSource:!0,proxyConfig:{ajax:{query:(t,C)=>m(null,[t,C],function*({page:e},l){return yield ne(_({pageNo:e.currentPage,pageSize:e.pageSize},l))})}},rowConfig:{keyField:"id",isHover:!0},toolbarConfig:{refresh:!0,search:!0}}});return oe(()=>{f()}),(e,l)=>(S(),A(c(ee),{"auto-content-height":""},{default:s(()=>[u(c(V),{"table-title":"告警记录列表"},{configLevel:s(({row:t})=>[u(c(Q),{color:b(t.configLevel)},{default:s(()=>[D(h(g(t.configLevel)),1)]),_:2},1032,["color"])]),product:s(({row:t})=>[N("span",null,h(d(t.productId)),1)]),device:s(({row:t})=>[N("span",null,h(r(t.deviceId)),1)]),deviceMessage:s(({row:t})=>[t.deviceMessage?(S(),A(c(J),{key:0,placement:"topLeft",trigger:"hover","overlay-style":{maxWidth:"600px"}},{content:s(()=>[N("pre",ce,h(t.deviceMessage),1)]),default:s(()=>[u(c(Y),{size:"small",type:"link"},{default:s(()=>[u(c(K),{icon:"ant-design:eye-outlined",class:"mr-1"}),l[0]||(l[0]=D(" 查看消息 ",-1))]),_:1})]),_:2},1024)):(S(),ae("span",de,"-"))]),actions:s(({row:t})=>[u(c(Z),{actions:[{label:"处理",type:"link",icon:c(M).EDIT,onClick:p.bind(null,t),ifShow:!t.processStatus},{label:"查看",type:"link",icon:c(M).VIEW,onClick:F.bind(null,t),ifShow:t.processStatus}]},null,8,["actions"])]),_:1})]),_:1}))}});export{xe as default};
|