import{a as D,r as v,aj as r,J as I,o as K,K as i,b as A,S as o,a7 as f,P as _}from"./vue.YrNK8sx4.js";import{C as B,a as L,S as U,G as z}from"./api.BJXIp3wZ.js";import{E as y}from"./index.BKEMpsLA.js";import{_ as E}from"./_plugin-vue_export-helper.DlAUqK2U.js";const G={class:"form-row"},P=D({__name:"index",setup($,{expose:b}){const p=v(!1),u=v(""),c=v(""),d=v([]),k=l=>{console.log("val::::::",l),c.value=l},C=()=>{u.value="",d.value=[]},V=(l,e)=>(console.log("lists::::",e),Array.isArray(e)?e.find(t=>t.check_no===l):null),m=async()=>{var t;if(!u.value||!c.value)return;const l={device_code:u.value,check_no:c.value},e=await U(l);if((e==null?void 0:e.code)===2e3){const n=await z();if((n==null?void 0:n.code)===2e3){const a=V(c.value,n.data);d.value.push({...l,productName:((t=e.data)==null?void 0:t.productName)||"未知商品",id:(a==null?void 0:a.id)||0,status_display:(a==null?void 0:a.status_display)||""}),u.value=""}}},g=async l=>{const e=await B({check_no:l.check_no});(e==null?void 0:e.code)===2e3&&(y.success("完成盘点！"),p.value=!1)},x=async l=>{const e=await L(l.id);(e==null?void 0:e.code)===2e3&&(console.log("deviceList.value::",d.value),d.value=d.value.filter(t=>t.id!==l.id),console.log("deviceList.value22222::",d.value),y.success("取消盘点成功！"),p.value=!1)};b({visible:p,setCheckNo:k});const w=()=>{c.value=""};return(l,e)=>{const t=r("el-input"),n=r("el-button"),a=r("el-table-column"),h=r("el-table"),S=r("el-dialog");return K(),I(S,{modelValue:p.value,"onUpdate:modelValue":e[2]||(e[2]=s=>p.value=s),title:"开始盘点",width:"800px",onOpen:C,onClose:w},{default:i(()=>[A("div",G,[o(t,{modelValue:u.value,"onUpdate:modelValue":e[0]||(e[0]=s=>u.value=s),placeholder:"设备ID",onKeyup:f(m,["enter"])},null,8,["modelValue"]),o(t,{modelValue:c.value,"onUpdate:modelValue":e[1]||(e[1]=s=>c.value=s),placeholder:"设备编码",onKeyup:f(m,["enter"])},null,8,["modelValue"]),o(n,{type:"primary",onClick:m},{default:i(()=>e[3]||(e[3]=[_("添加")])),_:1})]),o(h,{data:d.value,style:{"margin-top":"20px"}},{default:i(()=>[o(a,{type:"index",label:"序号",width:"60"}),o(a,{prop:"id",label:"盘点id",width:"60"}),o(a,{prop:"device_code",label:"设备ID"}),o(a,{prop:"check_no",label:"设备编码"}),o(a,{prop:"status_display",label:"状态"}),o(a,{label:"操作",width:"180"},{default:i(({row:s})=>[o(n,{type:"success",size:"small",onClick:N=>g(s)},{default:i(()=>e[4]||(e[4]=[_("完成盘点")])),_:2},1032,["onClick"]),o(n,{type:"danger",size:"small",onClick:N=>x(s)},{default:i(()=>e[5]||(e[5]=[_("取消盘点")])),_:2},1032,["onClick"])]),_:1})]),_:1},8,["data"])]),_:1},8,["modelValue"])}}}),R=E(P,[["__scopeId","data-v-9081783b"]]);export{R as default};
