import{a as G,r as u,aj as f,at as L,J as V,o as w,a8 as P,K as p,b as g,S as t,P as C,L as R,a7 as x}from"./vue.D1BjjNmv.js";import{S as j,G as J,C as M,a as O}from"./api.w1hqyo_f.js";import{E as h}from"./index.Df8UJ10K.js";import{_ as T}from"./_plugin-vue_export-helper.DlAUqK2U.js";const q={class:"form-row"},z={class:"dialog-footer"},F=G({__name:"index",emits:["completed"],setup(H,{expose:N,emit:S}){const k=S,r=u(!1),d=u(""),n=u(""),y=u([]),v=u(null),m=u(!1),A=a=>{console.log("val::::::",a),n.value=a},D=()=>{d.value="",y.value=[],v.value=null},K=(a,e)=>(console.log("lists::::",e),Array.isArray(e)?e.find(s=>s.check_no===a):null),b=async()=>{var e,s,i;if(!d.value||!n.value)return;const a={device_code:d.value,check_no:n.value};m.value=!0;try{const l=await j(a);if((l==null?void 0:l.code)===2e3){const c=await J();if((c==null?void 0:c.code)===2e3){const o=K(n.value,c.data);y.value.push({...a,productName:((e=l.data)==null?void 0:e.productName)||"未知商品",id:(o==null?void 0:o.id)||0,status_display:(o==null?void 0:o.status_display)||"",device_name:((s=l.data)==null?void 0:s.device_name)||"未知设备",device_category:((i=l.data)==null?void 0:i.device_category)||"未知分类"}),d.value="",v.value=(o==null?void 0:o.id)??null}}}finally{m.value=!1}},B=async()=>{if(!n.value)return;const a=await M({check_no:n.value});(a==null?void 0:a.code)===2e3&&(h.success("完成盘点！"),r.value=!1,k("completed"))},I=async()=>{if(!v.value)return;const a=await O(v.value);(a==null?void 0:a.code)===2e3&&(h.success("取消盘点成功！"),r.value=!1,k("completed"))};N({visible:r,setCheckNo:A});const U=()=>{n.value=""};return(a,e)=>{const s=f("el-input"),i=f("el-button"),l=f("el-table-column"),c=f("el-table"),o=f("el-dialog"),E=L("loading");return w(),V(o,{modelValue:r.value,"onUpdate:modelValue":e[2]||(e[2]=_=>r.value=_),title:"开始盘点",width:"800px",onOpen:D,onClose:U},P({default:p(()=>[g("div",null,[g("div",q,[t(s,{modelValue:d.value,"onUpdate:modelValue":e[0]||(e[0]=_=>d.value=_),placeholder:"设备编号",onKeyup:x(b,["enter"]),disabled:m.value},null,8,["modelValue","disabled"]),t(s,{modelValue:n.value,"onUpdate:modelValue":e[1]||(e[1]=_=>n.value=_),placeholder:"盘点编号",onKeyup:x(b,["enter"]),disabled:!0},null,8,["modelValue"]),t(i,{type:"primary",onClick:b,loading:m.value},{default:p(()=>e[3]||(e[3]=[C("添加")])),_:1},8,["loading"])]),R((w(),V(c,{data:y.value,style:{"margin-top":"20px"}},{default:p(()=>[t(l,{type:"index",label:"序号",width:"60"}),t(l,{prop:"device_code",label:"设备编号"}),t(l,{prop:"device_name",label:"设备名称"}),t(l,{prop:"device_category",label:"设备分类"}),t(l,{prop:"check_no",label:"盘点编号"}),t(l,{prop:"status_display",label:"状态"})]),_:1},8,["data"])),[[E,m.value]])])]),_:2},[y.value.length>0?{name:"footer",fn:p(()=>[g("div",z,[t(i,{onClick:I,disabled:!v.value},{default:p(()=>e[4]||(e[4]=[C("取消盘点")])),_:1},8,["disabled"]),t(i,{type:"primary",onClick:B,disabled:!n.value},{default:p(()=>e[5]||(e[5]=[C("完成盘点")])),_:1},8,["disabled"])])]),key:"0"}:void 0]),1032,["modelValue"])}}}),Z=T(F,[["__scopeId","data-v-83c8b4fb"]]);export{Z as default};
