import{j as R,c as _,a as e,w as o,k as F,F as g,h as N,r as s,i as E,o as m,m as T,f as c,d as q,t as j,n as C,q as v,E as D}from"./index-DtJUIYo6.js";import{f as H,P as Q}from"./help-ByrA6SoP.js";const I={key:0,style:{border:"1px solid #ebeef5","border-radius":"6px",padding:"10px",margin:"8px 0"}},J={style:{margin:"12px 0"}},Y={__name:"ProcessStep",setup(K){const f=E(1),r=E([]);function h(){return{id:0,processCode:f.value,seq:r.value.length+1,name:"",collectType:"MANUAL",isTorque:!1,remark:"",criteria:[],_showCrit:!1}}function A(){r.value.push(h())}function z(n){n._showCrit=!n._showCrit}function L(n){const a=r.value.indexOf(n);a>=0&&r.value.splice(a,1)}function G(n){return n.criteria.some(a=>a.logic&&a.logic!=="RANGE")}function w(n){return n.criteria.some(a=>a.logic==="RANGE")}function S(n,a){const d=n.criteria.indexOf(a);d>=0&&n.criteria.splice(d,1)}async function y(){try{const n=await N.get("/process-steps",{params:{processCode:f.value}})||[];r.value=n.map(a=>({...a,criteria:a.criteria||[],_showCrit:!1})),r.value.length||r.value.push(h())}catch{r.value=[h()]}}async function $(){const n=r.value.map(({_showCrit:a,...d})=>d);await N.post("/process-steps",n),D.success("工艺参数已保存"),y()}return R(y),(n,a)=>{const d=s("el-option"),k=s("el-select"),U=s("el-form-item"),p=s("el-button"),B=s("el-form"),M=s("el-alert"),V=s("el-input-number"),u=s("el-table-column"),b=s("el-input"),O=s("el-switch"),x=s("el-table"),P=s("el-card");return m(),_(g,null,[e(P,null,{default:o(()=>[e(B,{inline:""},{default:o(()=>[e(U,{label:"工序号"},{default:o(()=>[e(k,{modelValue:f.value,"onUpdate:modelValue":a[0]||(a[0]=l=>f.value=l),placeholder:"请选择工序",style:{width:"140px"}},{default:o(()=>[(m(),_(g,null,T(12,l=>e(d,{key:l,value:l,label:`工序${l}`},null,8,["value","label"])),64))]),_:1},8,["modelValue"])]),_:1}),e(U,null,{default:o(()=>[e(p,{type:"primary",onClick:y},{default:o(()=>[...a[1]||(a[1]=[c("加载",-1)])]),_:1})]),_:1}),e(U,null,{default:o(()=>[e(p,{type:"success",onClick:$},{default:o(()=>[...a[2]||(a[2]=[c("保存该工序参数",-1)])]),_:1})]),_:1})]),_:1}),e(M,{type:"info",closable:!1,title:"为每道工序配置【步骤/参数】与【判定标准】,手动报工页会按此动态渲染采集框;标准可为空=仅记录不判定",style:{"margin-bottom":"12px"}}),e(x,{data:r.value,border:"",size:"small"},{default:o(()=>[e(u,{prop:"seq",label:"步骤",width:"70",align:"center"},{default:o(({row:l})=>[e(V,{modelValue:l.seq,"onUpdate:modelValue":t=>l.seq=t,min:1,size:"small","controls-position":"right",style:{width:"80px"}},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),e(u,{label:"步骤名称","min-width":"150"},{default:o(({row:l})=>[e(b,{modelValue:l.name,"onUpdate:modelValue":t=>l.name=t,placeholder:"如 拧紧扭矩"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),e(u,{label:"采集方式",width:"140"},{default:o(({row:l})=>[e(k,{modelValue:l.collectType,"onUpdate:modelValue":t=>l.collectType=t,placeholder:"请选择"},{default:o(()=>[e(d,{value:"AUTO",label:"拧紧枪自动"}),e(d,{value:"MANUAL",label:"手填"}),e(d,{value:"NONE",label:"仅记录"})]),_:1},8,["modelValue","onUpdate:modelValue"])]),_:1}),e(u,{label:"是否拧紧",width:"90",align:"center"},{default:o(({row:l})=>[e(O,{modelValue:l.isTorque,"onUpdate:modelValue":t=>l.isTorque=t},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),e(u,{label:"备注","min-width":"140"},{default:o(({row:l})=>[e(b,{modelValue:l.remark,"onUpdate:modelValue":t=>l.remark=t,placeholder:"备注(可空)"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),e(u,{label:"操作",width:"110",align:"center"},{default:o(({row:l})=>[e(p,{link:"",type:"primary",size:"small",onClick:t=>z(l)},{default:o(()=>[...a[3]||(a[3]=[c("加标准",-1)])]),_:1},8,["onClick"]),e(p,{link:"",type:"danger",size:"small",onClick:t=>L(l)},{default:o(()=>[...a[4]||(a[4]=[c("删",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"]),(m(!0),_(g,null,T(r.value,l=>(m(),_(g,{key:l.id+"-"+l.seq},[l._showCrit?(m(),_("div",I,[q("b",null,"标准:"+j(l.name),1),e(x,{data:l.criteria,border:"",size:"small",style:{"margin-top":"8px"}},{default:o(()=>[e(u,{label:"指标名","min-width":"120"},{default:o(({row:t})=>[e(b,{modelValue:t.name,"onUpdate:modelValue":i=>t.name=i,placeholder:"如 扭矩"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),e(u,{label:"单位",width:"80"},{default:o(({row:t})=>[e(b,{modelValue:t.unit,"onUpdate:modelValue":i=>t.unit=i,placeholder:"N·m"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),e(u,{label:"逻辑",width:"120"},{default:o(({row:t})=>[e(k,{modelValue:t.logic,"onUpdate:modelValue":i=>t.logic=i,placeholder:"请选择"},{default:o(()=>[e(d,{value:"GE",label:"≥"}),e(d,{value:"LE",label:"≤"}),e(d,{value:"GT",label:">"}),e(d,{value:"LT",label:"<"}),e(d,{value:"RANGE",label:"区间"}),e(d,{value:"EQUAL",label:"="})]),_:1},8,["modelValue","onUpdate:modelValue"])]),_:1}),G(l)?(m(),C(u,{key:0,label:"目标值",width:"110"},{default:o(({row:t})=>[e(V,{modelValue:t.target,"onUpdate:modelValue":i=>t.target=i,step:1,"controls-position":"right",style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue"])]),_:1})):v("",!0),w(l)?(m(),C(u,{key:1,label:"下限",width:"110"},{default:o(({row:t})=>[e(V,{modelValue:t.min,"onUpdate:modelValue":i=>t.min=i,step:1,"controls-position":"right",style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue"])]),_:1})):v("",!0),w(l)?(m(),C(u,{key:2,label:"上限",width:"110"},{default:o(({row:t})=>[e(V,{modelValue:t.max,"onUpdate:modelValue":i=>t.max=i,step:1,"controls-position":"right",style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue"])]),_:1})):v("",!0),e(u,{label:"操作",width:"80",align:"center"},{default:o(({row:t})=>[e(p,{link:"",type:"danger",size:"small",onClick:i=>S(l,t)},{default:o(()=>[...a[5]||(a[5]=[c("删",-1)])]),_:1},8,["onClick"])]),_:2},1024)]),_:2},1032,["data"]),e(p,{size:"small",style:{"margin-top":"8px"},onClick:t=>l.criteria.push({name:"",unit:"",logic:"GE",target:0,min:null,max:null})},{default:o(()=>[...a[6]||(a[6]=[c("新增标准行",-1)])]),_:1},8,["onClick"])])):v("",!0)],64))),128)),q("div",J,[e(p,{onClick:A},{default:o(()=>[...a[7]||(a[7]=[c("新增步骤",-1)])]),_:1})])]),_:1}),e(Q,{data:F(H)},null,8,["data"])],64)}}};export{Y as default};