| 123 |
- import{a as ce,r as V,aj as w,at as re,c as B,o as I,S as n,a8 as ve,K as m,b as k,P as S,M as G,L as pe,a7 as j,u as fe,Q as T,R as H,a9 as me,J as K,t as ge}from"./vue.D1BjjNmv.js";import{G as E,S as _e,a as ye,C as he,b as J}from"./api.DujZbZAc.js";import{s as be,E as d}from"./index.BxxZUpdu.js";import{_ as we}from"./_plugin-vue_export-helper.DlAUqK2U.js";const ke={class:"form-row"},Ce={key:0,class:"pending-list",style:{"margin-top":"15px","margin-bottom":"15px"}},Ve={class:"pending-header"},xe={class:"pending-title"},Se={class:"pending-actions"},De={class:"pending-tags"},Re={class:"dialog-footer"},$e=ce({__name:"index",emits:["completed"],setup(Ie,{expose:Q,emit:W}){const M=W,L=V(!1),$=V(""),g=V(""),D=V([]),h=V(null),R=V(!1),x=V(null),f=V([]),P=V(!1),q=V(!1),c=V({rfidLength:24,rfidPrefix:"E280",separator:" ",customSeparator:"",autoSplitSticky:!0,allowDuplicate:!0}),X=async(l,e)=>{if(console.log("checkNo::::::",l,"id::::::",e),g.value=l,e!=null)h.value=e;else try{const a=await E();if((a==null?void 0:a.code)===2e3){const s=A(l,a.data);h.value=(s==null?void 0:s.id)??null,console.log("通过 check_no 查询到的 id::",h.value)}}catch(a){console.error("查询盘点记录失败:",a),h.value=null}},F=async()=>{await ge(),setTimeout(()=>{if(!x.value||R.value)return;let l=null;if(typeof x.value.focus=="function"){x.value.focus();return}x.value.input?l=x.value.input:x.value.$el?l=x.value.$el.querySelector("input"):x.value instanceof HTMLElement&&(l=x.value.querySelector("input")),l&&(l.focus(),setTimeout(()=>{l==null||l.select()},10))},100)},Y=()=>{c.value={rfidLength:24,rfidPrefix:"E280",separator:" ",customSeparator:"",autoSplitSticky:!0,allowDuplicate:!0},d.success("已重置为默认规则")},Z=()=>{if(c.value.rfidLength<1){d.warning("RFID标签长度必须大于0");return}if(c.value.separator==="custom"&&!c.value.customSeparator){d.warning("请设置自定义分隔符");return}q.value=!1,d.success("读取规则已保存")},ee=()=>{$.value="",D.value=[],h.value=null,f.value=[],P.value=!1},le=()=>{F()},A=(l,e)=>(console.log("lists::::",e),Array.isArray(e)?e.find(a=>a.check_no===l):null),O=l=>{l.forEach(e=>{const a=D.value.findIndex(s=>s.device_code===e.device_code&&s.check_no===e.check_no);a!==-1?D.value[a]={...e,scanned_quantity:e.scanned_quantity||1}:D.value.push({...e,scanned_quantity:e.scanned_quantity||1})})},N=l=>{if(!l)return[];const{rfidLength:e,rfidPrefix:a,autoSplitSticky:s}=c.value;if(!s)return[l];if(a&&a.trim()){const u=a.length,_=e-u;if(_>0)try{const b=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),y=new RegExp(`${b}[0-9A-F]{${_}}`,"gi"),r=l.match(y);if(r&&r.length>1)return r}catch(b){console.warn("RFID前缀正则表达式构建失败:",b)}}if(l.length>e&&l.length%e===0){const u=[];for(let _=0;_<l.length;_+=e){const b=l.substring(_,_+e);b.trim()&&u.push(b)}if(u.length>1)return u}return[l]},te=l=>{const e=l.trim();if(!e)return[];const{separator:a,customSeparator:s}=c.value,u=a==="custom"?s:a;if(console.log("splitRFIDCodes - 输入:",e,"分隔符配置:",a,"实际分隔符:",u,"分隔符类型:",typeof u,"长度:",u==null?void 0:u.length),/\s/.test(e)){const y=e.split(/\s+/).filter(r=>r.trim());if(console.log("检测到空格,分割结果:",y),y.length>1){const r=[];for(const t of y){const i=t.trim();if(i){const o=N(i);r.push(...o)}}return console.log("空格分割最终结果:",r),r.length>0?r:[e]}}if(u&&u.trim()!==""&&u!==" "){let y=[],r=!1;if(u===`
- `)r=e.includes(`
- `),r&&(y=e.split(/\n+/).filter(t=>t.trim()));else if(u===" ")r=e.includes(" "),r&&(y=e.split(/\t+/).filter(t=>t.trim()));else if(r=e.includes(u),r)try{const t=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=new RegExp(t+"+","g");y=e.split(i).filter(o=>o.trim())}catch(t){console.warn("分隔符正则表达式构建失败,使用字符串分割:",t),y=e.split(u).filter(i=>i.trim())}if(r&&y.length>0){const t=[];for(const i of y){const o=i.trim();if(o){const v=N(o);t.push(...v)}}return console.log("配置分隔符分割最终结果:",t),t.length>0?t:[e]}}const b=N(e);return console.log("粘连处理结果:",b),b},U=()=>{if(!$.value||!g.value){d.warning("请输入设备编号");return}const l=$.value.trim();if(!l){d.warning("设备编号不能为空");return}const e=te(l);if(console.log("分割结果:",e,"输入:",l,"配置:",c.value),e.length===0){d.warning("未识别到有效的设备编号");return}let a=e;if(!c.value.allowDuplicate&&(a=e.filter(s=>!f.value.includes(s)),a.length<e.length)){const s=e.length-a.length;d.warning(`已过滤 ${s} 个重复的设备编号`)}if(a.length===0){d.warning("没有可添加的设备编号(可能全部重复)");return}f.value.push(...a),e.length>1?d.success(`已自动分割并添加 ${a.length} 个设备编号`):d.success("已添加到待提交列表"),$.value="",F()},ae=l=>{f.value.splice(l,1)},oe=()=>{f.value=[]},ne=async()=>{var a,s,u,_,b,y;if(f.value.length===0||!g.value){d.warning("没有待提交的设备编号");return}R.value=!0;const l=[],e=[];try{const r={check_no:g.value,device_codes:[...f.value]};try{const t=await _e(r);if((t==null?void 0:t.code)===2e3){const i=await E();if((i==null?void 0:i.code)===2e3){const o=A(g.value,i.data);h.value=(o==null?void 0:o.id)??null,t.data&&Array.isArray(t.data)?t.data.forEach(v=>{l.push({device_code:v.device_code||v.deviceCode,check_no:g.value,productName:v.productName||"未知商品",id:(o==null?void 0:o.id)||0,status_display:(o==null?void 0:o.status_display)||"",device_name:v.device_name||v.deviceName||"未知设备",device_category:v.device_category||v.deviceCategory||"未知分类",scanned_quantity:v.scanned_quantity||0})}):(a=t.data)!=null&&a.success_codes&&Array.isArray(t.data.success_codes)?(t.data.success_codes.forEach(v=>{l.push({device_code:v,check_no:g.value,productName:"未知商品",id:(o==null?void 0:o.id)||0,status_display:(o==null?void 0:o.status_display)||"",device_name:"未知设备",device_category:"未知分类",scanned_quantity:1})}),(s=t.data)!=null&&s.fail_codes&&Array.isArray(t.data.fail_codes)&&e.push(...t.data.fail_codes)):f.value.forEach(v=>{l.push({device_code:v,check_no:g.value,productName:"未知商品",id:(o==null?void 0:o.id)||0,status_display:(o==null?void 0:o.status_display)||"",device_name:"未知设备",device_category:"未知分类",scanned_quantity:1})}),O(l),l.length>0&&e.length===0?(f.value=[],d.success("提交成功")):l.length>0&&e.length>0?(f.value=e,d.warning(`成功提交 ${l.length} 个,失败 ${e.length} 个`)):(f.value=e,d.error(`提交失败,共 ${e.length} 个设备编号`));return}}else console.warn("批量提交失败,尝试逐个提交:",t)}catch(t){console.warn("批量提交接口不可用,使用逐个提交方式:",t)}for(const t of f.value)try{const i={device_code:t,check_no:g.value},o=await ye(i);if((o==null?void 0:o.code)===2e3){const v=await E();if((v==null?void 0:v.code)===2e3){const C=A(g.value,v.data);l.push({...i,productName:((u=o.data)==null?void 0:u.productName)||"未知商品",id:(C==null?void 0:C.id)||0,status_display:(C==null?void 0:C.status_display)||"",device_name:((_=o.data)==null?void 0:_.device_name)||"未知设备",device_category:((b=o.data)==null?void 0:b.device_category)||"未知分类",scanned_quantity:((y=o.data)==null?void 0:y.scanned_quantity)||1}),h.value=(C==null?void 0:C.id)??null}}else e.push(t)}catch(i){console.error(`提交设备编号 ${t} 失败:`,i),e.push(t)}O(l),l.length>0&&e.length===0?(f.value=[],d.success(`成功提交 ${l.length} 个设备编号`)):l.length>0&&e.length>0?(f.value=e,d.warning(`成功提交 ${l.length} 个,失败 ${e.length} 个`)):(f.value=e,d.error(`提交失败,共 ${e.length} 个设备编号`))}finally{R.value=!1,F()}},se=async()=>{if(!g.value)return;const l=await he({check_no:g.value});(l==null?void 0:l.code)===2e3&&(d.success("完成盘点!"),P.value=!0,L.value=!1,M("completed"))},ie=async()=>{if(!h.value)return;const l=await J(h.value);(l==null?void 0:l.code)===2e3&&(d.success("取消盘点成功!"),P.value=!0,L.value=!1,M("completed"))};Q({visible:L,setCheckNo:X});const ue=async()=>{if(P.value){P.value=!1,g.value="",f.value=[],D.value=[],h.value=null;return}console.log("currentRecordId.value::",h.value,"check_no.value::",g.value);let l=h.value;if(!l&&g.value)try{const e=await E();if((e==null?void 0:e.code)===2e3){const a=A(g.value,e.data);l=(a==null?void 0:a.id)??null,console.log("通过 check_no 查询到的 id::",l)}}catch(e){console.error("查询盘点记录失败:",e)}if(l)try{const e=await J(l);(e==null?void 0:e.code)===2e3?d.success("取消盘点成功!"):d.warning((e==null?void 0:e.msg)||"取消盘点失败")}catch(e){console.error("取消盘点失败:",e),d.error("取消盘点失败")}g.value="",f.value=[],D.value=[],h.value=null};return(l,e)=>{const a=w("el-input"),s=w("el-button"),u=w("el-tag"),_=w("el-table-column"),b=w("el-table"),y=w("el-dialog"),r=w("el-input-number"),t=w("el-form-item"),i=w("el-option"),o=w("el-select"),v=w("el-switch"),C=w("el-form"),de=re("loading");return I(),B(H,null,[n(y,{modelValue:L.value,"onUpdate:modelValue":e[3]||(e[3]=p=>L.value=p),title:"开始盘点",width:"800px",onOpen:ee,onOpened:le,onClose:ue},ve({default:m(()=>[k("div",null,[k("div",ke,[n(a,{ref_key:"deviceCodeInputRef",ref:x,modelValue:$.value,"onUpdate:modelValue":e[0]||(e[0]=p=>$.value=p),placeholder:"设备编号(支持扫码枪/RFID批量录入,回车添加)",onKeyup:j(U,["enter"]),disabled:R.value},null,8,["modelValue","disabled"]),n(a,{modelValue:g.value,"onUpdate:modelValue":e[1]||(e[1]=p=>g.value=p),placeholder:"盘点编号",onKeyup:j(U,["enter"]),disabled:!0},null,8,["modelValue"]),n(s,{type:"success",onClick:U,disabled:R.value},{default:m(()=>e[11]||(e[11]=[S("添加到待提交列表")])),_:1},8,["disabled"]),n(s,{type:"info",icon:fe(be),onClick:e[2]||(e[2]=p=>q.value=!0),disabled:R.value},{default:m(()=>e[12]||(e[12]=[S("读取规则")])),_:1},8,["icon","disabled"])]),f.value.length>0?(I(),B("div",Ce,[k("div",Ve,[k("div",xe,"待提交设备编号 ("+T(f.value.length)+"个):",1),k("div",Se,[n(s,{type:"primary",onClick:ne,loading:R.value,size:"small"},{default:m(()=>[S("批量提交("+T(f.value.length)+")",1)]),_:1},8,["loading"]),n(s,{type:"text",size:"small",onClick:oe},{default:m(()=>e[13]||(e[13]=[S("清空")])),_:1})])]),k("div",De,[(I(!0),B(H,null,me(f.value,(p,z)=>(I(),K(u,{key:z,closable:"",onClose:Le=>ae(z),style:{"margin-right":"8px","margin-bottom":"8px"}},{default:m(()=>[S(T(p),1)]),_:2},1032,["onClose"]))),128))])])):G("",!0),pe((I(),K(b,{data:D.value,style:{"margin-top":"20px"}},{default:m(()=>[n(_,{type:"index",label:"序号",width:"60"}),n(_,{prop:"device_code",label:"设备编号"}),n(_,{prop:"device_name",label:"设备名称"}),n(_,{prop:"device_category",label:"设备分类"}),n(_,{prop:"check_no",label:"盘点编号"}),n(_,{prop:"scanned_quantity",label:"盘点数量"}),n(_,{prop:"status_display",label:"状态"})]),_:1},8,["data"])),[[de,R.value]])])]),_:2},[D.value.length>0?{name:"footer",fn:m(()=>[k("div",Re,[n(s,{onClick:ie,disabled:!h.value},{default:m(()=>e[14]||(e[14]=[S("取消盘点")])),_:1},8,["disabled"]),n(s,{type:"primary",onClick:se,disabled:!g.value},{default:m(()=>e[15]||(e[15]=[S("完成盘点")])),_:1},8,["disabled"])])]),key:"0"}:void 0]),1032,["modelValue"]),n(y,{modelValue:q.value,"onUpdate:modelValue":e[10]||(e[10]=p=>q.value=p),title:"设置读取规则",width:"600px"},{footer:m(()=>[n(s,{onClick:Y},{default:m(()=>e[21]||(e[21]=[S("重置默认")])),_:1}),n(s,{type:"primary",onClick:Z},{default:m(()=>e[22]||(e[22]=[S("保存")])),_:1})]),default:m(()=>[n(C,{model:c.value,"label-width":"140px"},{default:m(()=>[n(t,{label:"RFID标签长度"},{default:m(()=>[n(r,{modelValue:c.value.rfidLength,"onUpdate:modelValue":e[4]||(e[4]=p=>c.value.rfidLength=p),min:1,max:100,style:{width:"100%"}},null,8,["modelValue"]),e[16]||(e[16]=k("div",{class:"form-tip"},"RFID标签的固定长度(字符数)",-1))]),_:1}),n(t,{label:"RFID标签前缀"},{default:m(()=>[n(a,{modelValue:c.value.rfidPrefix,"onUpdate:modelValue":e[5]||(e[5]=p=>c.value.rfidPrefix=p),placeholder:"例如:E280",style:{width:"100%"}},null,8,["modelValue"]),e[17]||(e[17]=k("div",{class:"form-tip"},"RFID标签的前缀(可选,留空则不限制前缀)",-1))]),_:1}),n(t,{label:"分隔符"},{default:m(()=>[n(o,{modelValue:c.value.separator,"onUpdate:modelValue":e[6]||(e[6]=p=>c.value.separator=p),placeholder:"选择分隔符",style:{width:"100%"}},{default:m(()=>[n(i,{label:"空格",value:" "}),n(i,{label:"逗号",value:","}),n(i,{label:"分号",value:";"}),n(i,{label:"制表符",value:"\\t"}),n(i,{label:"回车换行",value:"\\n"}),n(i,{label:"自定义",value:"custom"})]),_:1},8,["modelValue"]),c.value.separator==="custom"?(I(),K(a,{key:0,modelValue:c.value.customSeparator,"onUpdate:modelValue":e[7]||(e[7]=p=>c.value.customSeparator=p),placeholder:"请输入自定义分隔符",style:{width:"100%","margin-top":"10px"}},null,8,["modelValue"])):G("",!0),e[18]||(e[18]=k("div",{class:"form-tip"},"用于分割多个设备编号的分隔符",-1))]),_:1}),n(t,{label:"自动分割粘连"},{default:m(()=>[n(v,{modelValue:c.value.autoSplitSticky,"onUpdate:modelValue":e[8]||(e[8]=p=>c.value.autoSplitSticky=p)},null,8,["modelValue"]),e[19]||(e[19]=k("div",{class:"form-tip"},"是否自动分割粘连在一起的RFID标签",-1))]),_:1}),n(t,{label:"允许重复添加"},{default:m(()=>[n(v,{modelValue:c.value.allowDuplicate,"onUpdate:modelValue":e[9]||(e[9]=p=>c.value.allowDuplicate=p)},null,8,["modelValue"]),e[20]||(e[20]=k("div",{class:"form-tip"},"是否允许添加重复的设备编号",-1))]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue"])],64)}}}),Fe=we($e,[["__scopeId","data-v-7ecb90ba"]]);export{Fe as default};
|