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