2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
var _=(z,C,m)=>new Promise((n,i)=>{var c=l=>{try{p(m.next(l))}catch(k){i(k)}},M=l=>{try{p(m.throw(l))}catch(k){i(k)}},p=l=>l.done?n(l.value):Promise.resolve(l.value).then(c,M);p((m=m.apply(z,C)).next())});import{g as q,r as Q}from"./index-BvAci9nf.js";import{R as N}from"./data-Dg2RhqW8.js";import{_ as W}from"./device-config-modal.vue_vue_type_script_setup_true_lang-BSWzpuV1.js";import{_ as X}from"./device-select-modal.vue_vue_type_script_setup_true_lang-DITdw-Pq.js";import{ay as y,c7 as Z,bE as R,aL as ee,cF as te,a9 as B,ac as oe}from"./bootstrap-CRjSNGHY.js";import{m as re,b9 as T,aa as j,ad as E,b2 as v,j as u,bJ as a,ae as e,bp as w,u as s,ai as f,ac as h,ab as L,I as ae}from"../jse/index-index-CMeVxoEG.js";import{u as se}from"./use-drawer-7swngGBs.js";import{u as O}from"./use-modal-BABce5hC.js";import{v as ne}from"./AlertBuilder-BVlldnPG.js";import"./code-editor.vue_vue_type_script_setup_true_lang-Br1_X9dM.js";import"./vxe-table-uq8U2E1u.js";import"./dict-tag.vue_vue_type_script_setup_true_lang-BB6x-AyV.js";import"./index-CIc-2hgy.js";import"./index-Bljc00Y4.js";import"./use-vxe-grid-BMVG5Iiw.js";import"./x-CpZ5_sBZ.js";import"./circle-check-big-DP26Iidw.js";const ie={class:"mb-6 grid grid-cols-1 gap-4 md:grid-cols-3"},le={class:"rounded-lg border border-gray-200 bg-gradient-to-br from-blue-50 to-white p-4 dark:border-gray-700 dark:from-blue-950/30 dark:to-gray-900"},de={class:"flex items-center justify-between"},ue={class:"mt-1 text-2xl font-bold text-gray-900 dark:text-white"},me={class:"rounded-lg border border-gray-200 bg-gradient-to-br from-green-50 to-white p-4 dark:border-gray-700 dark:from-green-950/30 dark:to-gray-900"},ge={class:"flex items-center justify-between"},ce={class:"mt-1 text-2xl font-bold text-gray-900 dark:text-white"},pe={class:"rounded-lg border border-gray-200 bg-gradient-to-br from-orange-50 to-white p-4 dark:border-gray-700 dark:from-orange-950/30 dark:to-gray-900"},ke={class:"flex items-center justify-between"},ve={class:"mt-1 text-2xl font-bold text-gray-900 dark:text-white"},we={class:"mb-4 flex items-center justify-between rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-800"},fe={class:"rounded-lg border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-900"},be={key:0,class:"flex items-center gap-2"},xe={class:"font-medium"},ye={key:3,class:"flex gap-2"},he=re({__name:"device-bind-drawer-enhanced",emits:["refresh"],setup(z,{emit:C}){const m=C,n=T(null),i=T([]),c=T(!1),[M,p]=se({onOpenChange(o){if(!o){n.value=null,i.value=[];return}const t=p.getData();n.value=t!=null?t:null,t!=null&&t.id&&b(t.id)}}),[l,k]=O({connectedComponent:W,destroyOnClose:!0}),[V,$]=O({connectedComponent:X,destroyOnClose:!0});function D(){const o=n.value;o!=null&&o.id&&$.setData({areaId:o.id}).open()}function F(o){k.setData(o).open()}function K(){const o=n.value;o!=null&&o.id&&b(o.id),m("refresh")}function P(){const o=n.value;o!=null&&o.id&&b(o.id),m("refresh")}function H(o){return _(this,null,function*(){var d;const t=o.nickname||o.deviceKey||"该设备";try{yield ne(`确认解除设备【${t}】与该区域的绑定吗?`)}catch(r){return}const g=B.loading({content:"解除中...",duration:0});try{yield Q(o.id),B.success("已解除绑定");const r=n.value;r!=null&&r.id&&(yield b(r.id)),m("refresh")}catch(r){B.error((r==null?void 0:r.message)||((d=r==null?void 0:r.data)==null?void 0:d.msg)||"操作失败")}finally{g()}})}const G=j(()=>{const o=n.value;return o?`${o.areaName} - 设备绑定管理`:"设备绑定管理"}),I=j(()=>i.value.length),A=j(()=>i.value.filter(o=>o.enabled).length);function b(o){return _(this,null,function*(){c.value=!0;try{const t=yield q(o);i.value=Array.isArray(t)?t:[]}catch(t){i.value=[]}finally{c.value=!1}})}const U=[{title:"设备昵称",dataIndex:"nickname",key:"nickname",width:140,ellipsis:!0,customRender:({record:o})=>(o==null?void 0:o.nickname)||"-"},{title:"设备 Key",dataIndex:"deviceKey",key:"deviceKey",width:140,ellipsis:!0},{title:"产品",key:"product",width:120,customRender:({record:o})=>(o==null?void 0:o.productName)||(o==null?void 0:o.productKey)||"-"},{title:"关联类型",dataIndex:"relationType",key:"relationType",width:120,customRender:({text:o})=>{const t=N.find(g=>g.value===o);return t?t.label:o||"-"}},{title:"状态",dataIndex:"enabled",key:"enabled",width:100},{title:"操作",key:"actions",width:180,fixed:"right"}];function J(o){return{TRAFFIC_COUNTER:"blue",BEACON:"purple",BADGE:"orange"}[o]||"default"}return(o,t)=>(v(),E(ae,null,[u(s(M),{title:G.value,class:"device-bind-drawer",width:"900px"},{default:a(()=>{var g;return[e("div",ie,[e("div",le,[e("div",de,[e("div",null,[t[0]||(t[0]=e("p",{class:"text-xs font-medium text-gray-600 dark:text-gray-400"}," 绑定设备 ",-1)),e("p",ue,w(I.value),1)]),t[1]||(t[1]=e("div",{class:"rounded-lg bg-blue-100 p-2 dark:bg-blue-900/50"},[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5 text-blue-600 dark:text-blue-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 10V3L4 14h7v7l9-11h-7z"})])],-1))])]),e("div",me,[e("div",ge,[e("div",null,[t[2]||(t[2]=e("p",{class:"text-xs font-medium text-gray-600 dark:text-gray-400"}," 启用设备 ",-1)),e("p",ce,w(A.value),1)]),t[3]||(t[3]=e("div",{class:"rounded-lg bg-green-100 p-2 dark:bg-green-900/50"},[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5 text-green-600 dark:text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})])],-1))])]),e("div",pe,[e("div",ke,[e("div",null,[t[4]||(t[4]=e("p",{class:"text-xs font-medium text-gray-600 dark:text-gray-400"}," 停用设备 ",-1)),e("p",ve,w(I.value-A.value),1)]),t[5]||(t[5]=e("div",{class:"rounded-lg bg-orange-100 p-2 dark:bg-orange-900/50"},[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5 text-orange-600 dark:text-orange-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})])],-1))])])]),e("div",we,[t[8]||(t[8]=e("div",{class:"flex items-center gap-2"},[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5 text-gray-600 dark:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]),e("span",{class:"text-sm text-gray-700 dark:text-gray-300"},"管理区域内所有绑定的IoT设备及其配置")],-1)),u(s(y),{type:"primary",disabled:!((g=n.value)!=null&&g.id),onClick:D,class:"shadow-sm transition-shadow hover:shadow-md"},{icon:a(()=>[...t[6]||(t[6]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})],-1)])]),default:a(()=>[t[7]||(t[7]=f(" 绑定设备 ",-1))]),_:1},8,["disabled"])]),e("div",fe,[u(s(Z),{columns:U,"data-source":i.value,loading:c.value,pagination:{pageSize:10,showSizeChanger:!0,showTotal:d=>`共 ${d} 条`},"row-key":"id",size:"middle",scroll:{x:800}},{bodyCell:a(({column:d,record:r})=>[d.key==="nickname"?(v(),E("div",be,[t[9]||(t[9]=e("div",{class:"flex h-8 w-8 items-center justify-center rounded-lg bg-blue-100 dark:bg-blue-900/50"},[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 text-blue-600 dark:text-blue-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})])],-1)),e("span",xe,w(r.nickname||"-"),1)])):h("",!0),d.key==="relationType"?(v(),L(s(ee),{key:1,color:J(r.relationType)},{default:a(()=>{var x,S;return[f(w((S=(x=s(N).find(Y=>Y.value===r.relationType))==null?void 0:x.label)!=null?S:r.relationType),1)]}),_:2},1032,["color"])):h("",!0),d.key==="enabled"?(v(),L(s(te),{key:2,status:r.enabled?"success":"error",text:r.enabled?"启用":"停用"},null,8,["status","text"])):h("",!0),d.key==="actions"?(v(),E("div",ye,[u(s(y),{type:"link",size:"small",onClick:x=>F(r),class:"text-blue-600 hover:text-blue-700 dark:text-blue-400"},{icon:a(()=>[...t[10]||(t[10]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})],-1)])]),default:a(()=>[t[11]||(t[11]=f(" 配置 ",-1))]),_:1},8,["onClick"]),u(s(y),{type:"link",size:"small",danger:"",onClick:x=>H(r),class:"hover:bg-red-50 dark:hover:bg-red-950/30"},{icon:a(()=>[...t[12]||(t[12]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"})],-1)])]),default:a(()=>[t[13]||(t[13]=f(" 解绑 ",-1))]),_:1},8,["onClick"])])):h("",!0)]),emptyText:a(()=>[u(s(R),{image:s(R).PRESENTED_IMAGE_SIMPLE,description:"该区域暂无绑定设备",class:"py-8"},{default:a(()=>[u(s(y),{type:"primary",onClick:D,class:"mt-4"},{icon:a(()=>[...t[14]||(t[14]=[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 6v6m0 0v6m0-6h6m-6 0H6"})],-1)])]),default:a(()=>[t[15]||(t[15]=f(" 立即绑定设备 ",-1))]),_:1})]),_:1},8,["image"])]),_:1},8,["data-source","loading","pagination"])]),t[16]||(t[16]=e("div",{class:"mt-4 rounded-lg border-l-4 border-amber-500 bg-amber-50 p-4 dark:bg-amber-950/30"},[e("div",{class:"flex items-start gap-3"},[e("svg",{xmlns:"http://www.w3.org/2000/svg",class:"mt-0.5 h-5 w-5 flex-shrink-0 text-amber-600 dark:text-amber-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]),e("div",null,[e("p",{class:"text-sm font-medium text-amber-800 dark:text-amber-300"}," 设备绑定说明 "),e("ul",{class:"mt-2 space-y-1 text-xs text-amber-700 dark:text-amber-400"},[e("li",null,"• 客流计数设备用于监测区域人流量,触发保洁任务"),e("li",null,"• 信标设备用于人员定位和到岗判定"),e("li",null,"• 工牌设备用于保洁人员任务通知")])])])],-1))]}),_:1},8,["title"]),u(s(V),{onSuccess:K}),u(s(l),{onSuccess:P})],64))}}),Fe=oe(he,[["__scopeId","data-v-a47f2307"]]);export{Fe as default};
|