import{_ as T,b as j,u as M,a as H,J,ah as C,r as g,e as K,aH as O,n as o,o as G,c as Q,p as l,q as s,P as m,x as d,aj as W,v,s as k,l as X,k as Y,j as Z,m as ee,bH as ae,D as te}from"./index.8d733f79.js";import{_ as le}from"./dialogContent.8cf6deaf.js";import{E as oe}from"./el-progress.ee3fa77d.js";import{d as se,a as ne,b as ie,c as de}from"./systemLink.0379a9eb.js";import re from"./addParams.f8effa23.js";const pe={class:"apiParams_wrap","element-loading-background":"rgba(0,0,0,0)"},ce={class:"importDialog"},me={class:"tit"},ue={style:{position:"relative"}},fe={class:"download"},_e=["href"],ge={__name:"apiParams",setup(ve){const{t:$}=j(),{proxy:i}=te();M();const P=H(),w=J.session.getJSON("enums").purpose,_=C({total:0,tableData:[],columns:[{prop:"name",label:"name"},{prop:"unit",label:"unit"},{prop:"dataFrom",label:"systemName"},{prop:"purpose",label:"dataPurpose",formatter:e=>{var a;return(a=w.find(t=>t.key===e.purpose))==null?void 0:a.desc}},{prop:"subDeviceCodeThird",label:"subDeviceCode3"},{prop:"params",label:"apiParams"},{label:"action",type:"action",width:180,fixed:"right"}]}),r=C({factoryId:P.query.factoryId,code:"",pageNo:1,pageSize:10}),D=g([]),u=g(!1),f=g(),h=g([]),y=g(!1);K(()=>{p()});async function p(){const e=await se(r);_.total=e.data.totalElements,_.tableData=e.data.content}const S=e=>{var a,t;(a=f.value)==null||a.clearFiles(),(t=f.value)==null||t.handleStart(e[0])},R=e=>{const a=e.file,t=new FormData;t.append("file",a),t.append("factoryId",P.query.factoryId),y.value=!0,ne(t).then(c=>{var b;i.$modal.msgSuccess(c.msg),p(),(b=f.value)==null||b.clearFiles(),u.value=!1,y.value=!1}).catch(()=>{var c;(c=f.value)==null||c.clearFiles(),u.value=!1,y.value=!1})},I=()=>{var e;h.value.length||i.$modal.msgError($("uploadFileP")),(e=f.value)==null||e.submit()},E=e=>{D.value=e.map(a=>a.id)},F=()=>{i.$refs.formRef.resetFields(),p()},N=()=>{i.$refs.addParamsRef.showModal({})},A=e=>{i.$refs.addParamsRef.showModal(e)},V=e=>{i.$modal.confirm($("confirmDelete")).then(()=>{ie(e.id).then(a=>{i.$modal.msgSuccess(a.msg),p()})}).catch(()=>{})},x=()=>{i.$modal.confirm($("confirmBatchDelete")).then(()=>{de({ids:D.value.join(",")}).then(e=>{i.$modal.msgSuccess(e.msg),p(),i.$refs.tableRef.clearSelection()})}).catch(()=>{})};return(e,a)=>{const t=X,c=Y,b=Z,B=ee,U=oe,q=le,z=ae;return O((G(),Q("div",pe,[l(B,{ref:"formRef",model:o(r),inline:!0,"label-width":"68px"},{default:s(()=>[l(c,null,{default:s(()=>[l(t,{type:"primary",onClick:N},{default:s(()=>[m(d(e.$t("add")),1)]),_:1}),l(t,{type:"primary",onClick:a[0]||(a[0]=n=>u.value=!0)},{default:s(()=>[m(d(e.$t("batchAdd")),1)]),_:1}),l(t,{type:"primary",onClick:x,disabled:!o(D).length},{default:s(()=>[m(d(e.$t("batchDelete")),1)]),_:1},8,["disabled"])]),_:1}),l(c,{label:"",prop:"code"},{default:s(()=>[l(b,{modelValue:o(r).code,"onUpdate:modelValue":a[1]||(a[1]=n=>o(r).code=n),placeholder:e.$t("inputP"),style:{width:"236px"}},null,8,["modelValue","placeholder"])]),_:1}),l(c,null,{default:s(()=>[l(t,{type:"primary",onClick:p},{default:s(()=>[m(d(e.$t("query")),1)]),_:1}),l(t,{onClick:F},{default:s(()=>[m(d(e.$t("reset")),1)]),_:1})]),_:1})]),_:1},8,["model"]),l(o(W),{class:"f-h",ref:"tableRef",selection:"",rowKey:"id",columns:o(_).columns,tableData:o(_).tableData,total:o(_).total,pageNum:o(r).pageNo,"onUpdate:pageNum":a[2]||(a[2]=n=>o(r).pageNo=n),pageSize:o(r).pageSize,"onUpdate:pageSize":a[3]||(a[3]=n=>o(r).pageSize=n),onPagination:p,onChangeSelection:E},{action:s(({scope:n})=>[l(t,{link:"",type:"primary",onClick:L=>A(n.row)},{default:s(()=>[m(d(e.$t("edit")),1)]),_:2},1032,["onClick"]),l(t,{link:"",type:"danger",onClick:L=>V(n.row)},{default:s(()=>[m(d(e.$t("delete")),1)]),_:2},1032,["onClick"])]),_:1},8,["columns","tableData","total","pageNum","pageSize"]),l(o(re),{ref:"addParamsRef",onRefesh:p},null,512),l(q,{modelValue:o(u),"onUpdate:modelValue":a[5]||(a[5]=n=>k(u)?u.value=n:null),title:e.$t("batchAdd"),onConfirm:I,onCancel:a[6]||(a[6]=n=>u.value=!1)},{main:s(()=>[v("div",ce,[v("div",me,d(e.$t("uploadFile")),1),v("div",ue,[l(U,{ref_key:"uploadRef",ref:f,"file-list":o(h),"onUpdate:file-list":a[4]||(a[4]=n=>k(h)?h.value=n:null),accept:".xlsx,.xls",action:"#","http-request":R,limit:1,"on-exceed":S,"auto-upload":!1},{default:s(()=>[l(t,{type:"primary"},{default:s(()=>[m(d(e.$t("selectImportFile")),1)]),_:1})]),_:1},8,["file-list"]),v("div",fe,[v("a",{href:"/template/apiParamTemplate.xlsx",download:"\u65B0\u589E\u63A5\u53E3\u53C2\u6570\u6A21\u677F.xlsx"},d(e.$t("downImportTemplate")),9,_e)])])])]),_:1},8,["modelValue","title"])])),[[z,o(y)]])}}},Pe=T(ge,[["__scopeId","data-v-40d76e41"]]);export{Pe as default};
