Files
bj_power/bj_power_mes/public/assets_bak_1791615921/Station-Cs8tGfHx.js
T

2 lines
12 KiB
JavaScript
Raw Normal View History

import{o as pe,j as _,c as d,b as a,w as o,l as k,F as E,k as T,r as u,e as n,f as M,q as y,h as i,t as v,p as x,v as N,A as me,E as V,z as H,m as G}from"./index-CZ641VGk.js";import{c as L}from"./perm-DCTK2KrM.js";import{i as ce,P as fe}from"./help-D7sbn63X.js";const ye={style:{"margin-bottom":"12px"}},be={key:0},_e={key:1,style:{color:"#909399"}},ve={key:0},Ne={key:1,style:{color:"#909399"}},ge={key:1,style:{color:"#909399"}},ke={key:0,style:{color:"#909399","font-size":"12px","line-height":"1.5","margin-top":"4px"}},we={key:0},Ee={key:0,style:{color:"#909399","font-size":"12px","line-height":"1.5","margin-top":"4px"}},Be={__name:"Station",setup(Te){const I=T([]),P=T([]),z=T({});async function J(){const t=await _.get("/docks"),e=Array.isArray(t)?t:(t==null?void 0:t.list)||[],c={};for(const r of e){const b=Number(r.stationNo)||0;b<=0||(c[b]=c[b]||[]).push(r.dockCode)}z.value=c}function F(t){const e=z.value[Number(t)]||[];return e.length?e.join(" / "):""}function S(t){return(z.value[Number(t)]||[]).length>0}const O=[{v:"online",l:"上线建档"},{v:"work",l:"作业"},{v:"material",l:"物料"},{v:"move",l:"产线点位(上料/下料)"},{v:"pdf",l:"工艺文件"},{v:"inspect",l:"巡检"},{v:"offline",l:"下线完工"}],K=t=>(O.find(e=>e.v===t)||{}).l||t,A=T(null),B=T(""),C=T("ENABLED"),$=T([]),Q=me(()=>[...I.value].sort((t,e)=>(t.stationNo||0)-(e.stationNo||0)).map(t=>({id:t.id,stationNo:t.stationNo,name:t.name,flowId:t.flowId,flowName:t.flowName,stationType:t.stationType,status:t.status,isBuiltin:!!t.isBuiltin,visibleTabs:Array.isArray(t.visibleTabs)?t.visibleTabs:[],productProcesses:Array.isArray(t.productProcesses)?t.productProcesses:[]})).filter(t=>A.value?t.flowId===A.value:!0).filter(t=>B.value?t.productProcesses.some(e=>e.toLowerCase().includes(B.value.toLowerCase())):!0).filter(t=>C.value?t.status===C.value:!0));function R(){A.value=null,B.value="",C.value="ENABLED",g()}async function W(t){const e=t.status==="ENABLED"?"DISABLED":"ENABLED",c=e==="DISABLED"?"停用":"启用";try{await H.confirm(`确认${c}工位${t.stationNo}「${t.name}」?`,"提示",{type:"warning"})}catch{return}await _.post("/stations/status",{id:t.id,status:e}),V.success(`已${c}`),g()}const s=G({show:!1,isAdd:!1,title:"",id:0,stationNo:1,name:"",stationType:"OFFLINE",isBuiltin:!1}),p=G({show:!1,id:0,stationNo:0,name:"",stationType:"LINE",tabs:[]});function X(t){Object.assign(p,{show:!0,id:t.id,stationNo:t.stationNo,name:t.name,stationType:t.stationType||"LINE",tabs:[...t.visibleTabs]})}async function Y(){await _.post("/stations",{id:p.id,stationNo:p.stationNo,name:p.name,stationType:p.stationType,visibleTabs:p.tabs}),V.success("页签配置已保存"),p.show=!1,g()}async function g(){I.value=await _.get("/stations")||[]}function Z(){const t=new Set(I.value.map(c=>c.stationNo));let e=14;for(;t.has(e);)e++;Object.assign(s,{show:!0,isAdd:!0,title:"新增工位",id:0,stationNo:e,name:"",stationType:"OFFLINE",isBuiltin:!1})}function ee(t){Object.assign(s,{show:!0,isAdd:!1,title:`工位${t.stationNo} - 修改`,id:t.id,stationNo:t.stationNo,name:t.name,stationType:t.stationType||"LINE",isBuiltin:!!t.isBuiltin})}async function te(){if(!s.name)return V.warning("请输入工位名称");if(s.isAdd&&I.value.some(t=>t.stationNo===s.stationNo))return V.warning(`工位${s.stationNo} 已存在,请换一个工位号`);await _.post("/stations",{id:s.id,stationNo:s.stationNo,name:s.name,stationType:s.stationType}),V.success(s.isAdd?"工位已新增":"已保存"),s.show=!1,g()}async function le(t,e){try{await _.post("/stations",{id:t.id,stationNo:t.stationNo,name:t.name,stationType:t.stationType||"LINE",flowId:e}),V.success(e?"已绑定工艺":"已解除绑定")}catch{}finally{await g()}}async function ae(t){try{await H.confirm(`确认删除工位${t.stationNo}「${t.name}」?`,"删除工位",{type:"warning"})}catch{return}try{await _.delete(`/stations/${t.id}`),V.success("工位已删除")}catch{}finally{await g()}}return pe(async()=>{var t,e;await Promise.all([g(),J()]),P.value=((t=await _.get("/process-flows",{params:{pageSize:1e3,page:1}}))==null?voi