var Y=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var I=(r,v)=>{var p={};for(var n in r)F.call(r,n)&&v.indexOf(n)<0&&(p[n]=r[n]);if(r!=null&&Y)for(var n of Y(r))v.indexOf(n)<0&&J.call(r,n)&&(p[n]=r[n]);return p};import{j as L,k as G,S as Q,l as Z,_ as q}from"./index.js";import{u as X,B as ee}from"./useTable-0c2ce3c4.js";import{T as te}from"./useForm-9b8a2c16.js";import{N as ne,O as se,Q as ae,R as ie,j as k}from"./antd-029ed741.js";import{r as oe,s as le,c as re,a as O}from"./schema-149c1808.js";import{u as de}from"./index-e0942325.js";import ce from"./drawer-cd4ccbfd.js";import{d as ue,f as _,c as me,o as pe,b as fe,a6 as ve,Z as W,_ as be,$ as b,k as c,u as o,a5 as m,l as h,G as g,a4 as he,a8 as ge}from"./vue-72a104e4.js";import"./index-5157bbb9.js";import"./useWindowSizeFn-46f0db92.js";import"./onMountedOrActivated-ee461833.js";import"./sortable.esm-15c0a34e.js";import"./copyTextToClipboard-8577151f.js";import"./deviceApi-260fcde9.js";const Se={class:"header"},we=ue({__name:"index",setup(r){const{hasPermission:v}=L(),p=G(),n=_([]),N=e=>{n.value=e.filter(t=>typeof t!="undefined")},[P,{openDrawer:S}]=de(),[A,{reload:w}]=X({api:e=>le(B(e)),columns:re,formConfig:{labelWidth:0,schemas:O,showAdvancedButton:!1},rowSelection:{type:"checkbox",onChange:N,getCheckboxProps:e=>({disabled:e.state!==0})},useSearchForm:!0,showTableSetting:!1,bordered:!0,showIndexColumn:!1,canResize:!1,rowKey:e=>e.id,actionColumn:{width:420,title:"操作",dataIndex:"action",fixed:void 0}}),B=e=>{const V=e,{pageNum:t,pageSize:s,field:f="id",order:a="descend"}=V,K=I(V,["pageNum","pageSize","field","order"]),d={pageNum:t,pageSize:s,orderByClause:`${f} ${a==="descend"?"desc":"asc"}`};return Object.keys(K).forEach(y=>{const u=O.find(z=>z.field===y),i=e[y];let l=y;u?i!==void 0&&i!==""&&(u.component==="Input"?d[l]=`%${i.trim()}%`:["Select","ApiSelect","ApiTreeSelect"].includes(u.component)?d[l]=Z(i)?i.value:i:u.component==="RangePicker"?(l==="startTimeQuery"&&(l="startTime"),d[`${l}From`]=k(i[0]).startOf("d").format("YYYY-MM-DD HH:mm:ss"),d[`${l}To`]=k(i[1]).endOf("d").format("YYYY-MM-DD HH:mm:ss")):u.component==="DatePicker"?d[l]=k(i).format(u.componentProps.format||"YYYY-MM-DD"):d[l]=i):d[l]=i}),d},E=()=>{S(!0,{isUpdate:!1})},R=e=>{S(!0,{record:e,isUpdate:!0})},$=e=>{oe(e.id).then(t=>{w()})},j=()=>{w()},H=e=>{p("/data/task/"+e.id)},U=()=>{WebViewService.importExcel().then(e=>{WebViewService.setMessage("数据导入成功!","success").then(()=>{});const t=JSON.parse(e);if(t.length===0)return;const s=t[0].name;t.forEach(a=>{delete a.name});const f={name:s,paramJson:JSON.stringify(t)};S(!0,{record:f,isUpdate:!1})},e=>{WebViewService.setMessage("数据导入失败!","error").then(()=>{})})},D=e=>{const t=[...new Set([...e.id?[e.id]:[],...n.value.map(s=>s)])];DeviceClientService.assignTasks(t).then(()=>{WebViewService.setMessage("下发任务成功!","success").then(()=>{})},s=>{WebViewService.setMessage("下发任务失败!","error").then(()=>{})})},x=e=>{const t=[...new Set([...e.id?[e.id]:[],...n.value.map(s=>s)])];DeviceClientService.syncTasks(t).then(()=>{WebViewService.setMessage("同步任务成功!","success").then(()=>{}),w()},s=>{WebViewService.setMessage("同步任务失败!","error").then(()=>{})})},C=_([]),T=me(()=>e=>C.value[e]?C.value[e]:!1),M=_(0);return pe(()=>{M.value=setInterval(()=>{DeviceClientService.getDeviceConnected().then(e=>{C.value=e},e=>{WebViewService.setMessage("获取设备连接出错","error").then(()=>{})})},300),WebViewService.setIsLoading(!1).then(()=>{})}),fe(()=>{clearInterval(M.value)}),(e,t)=>{const s=ve("a-button");return W(),be("div",null,[b("div",Se,[c(o(Q),{size:"19",name:"list"}),t[0]||(t[0]=b("div",{class:"title"},"任务列表",-1))]),c(o(ee),{onRegister:o(A)},{toolbar:m(()=>[c(s,{type:"primary",onClick:E,icon:h(o(ne))},{default:m(()=>t[1]||(t[1]=[g("新增")])),_:1},8,["icon"]),t[5]||(t[5]=b("div",{style:{width:"5px"}},null,-1)),c(s,{type:"default",onClick:U,icon:h(o(se))},{default:m(()=>t[2]||(t[2]=[g("导入数据")])),_:1},8,["icon"]),t[6]||(t[6]=b("div",{style:{width:"5px"}},null,-1)),c(s,{type:"default",onClick:D,icon:h(o(ae)),disabled:n.value.length===0},{default:m(()=>t[3]||(t[3]=[g("下发数据")])),_:1},8,["icon","disabled"]),c(s,{type:"default",onClick:x,icon:h(o(ie)),disabled:n.value.length===0},{default:m(()=>t[4]||(t[4]=[g("同步数据")])),_:1},8,["icon","disabled"])]),bodyCell:m(({column:f,record:a})=>[f.dataIndex==="action"?(W(),he(o(te),{key:0,actions:[{label:"编辑",icon:"clarity:note-edit-line",onClick:R.bind(null,a),divider:!0,disabled:a.state!==0},{label:"删除",icon:"ant-design:delete-outlined",color:"error",popConfirm:{title:"是否确认删除",confirm:$.bind(null,a),placement:"topRight"},ifShow:o(v)("AUTH_DATA_TASK:DELETE"),disabled:a.state!==0,divider:!0},{label:"详情",icon:"ant-design:eye-outlined",onClick:H.bind(null,a),divider:!0},{label:"下发数据",icon:"ant-design:download-outlined",onClick:D.bind(null,a),divider:!0,disabled:a.state!==0||!T.value(a.deviceSn)},{label:"同步数据",icon:"ant-design:sync-outlined",onClick:x.bind(null,a),divider:!0,disabled:!T.value(a.deviceSn)}]},null,8,["actions"])):ge("",!0)]),_:1},8,["onRegister"]),c(ce,{onRegister:o(P),onSuccess:j},null,8,["onRegister"])])}}});const Ae=q(we,[["__scopeId","data-v-ac0b0ada"]]);export{Ae as default};