1 |
- import{x as n,s as c,W as u,p as m,E as d}from"./index.DHn9b8nY.js";import{a as p}from"./authFunction.CL7rDwVJ.js";const l="/api/system/device-damage-records/";function h(t){return n({url:l+"?damage_type=0",method:"get",params:t})}function g(t){return n({url:l,method:"post",data:t})}function f(t){return n({url:l+t.id+"/",method:"put",data:t})}function w(t){return n({url:l+t+"/",method:"delete",data:{id:t}})}function R(){return n({url:l+"?damage_type=0",method:"get"})}function y(t){return n({url:l+t.id+"/cancel_damage/",method:"post",data:t})}const v=function({crudExpose:t}){return{crudOptions:{request:{pageRequest:async e=>await h(e),addRequest:async({form:e})=>await g(e),editRequest:async({form:e,row:o})=>(e.id=o.id,await f(e)),delRequest:async({row:e})=>await w(e.id)},form:{wrapper:{buttons:{ok:{text:"提交",show:c(e=>e.mode!=="view")}}}},actionbar:{buttons:{add:{show:p("area:Create")}}},toolbar:{show:!1},rowHandle:{fixed:"right",width:290,buttons:{remove:{show:!0},edit:{show:!0},cancelDamage:{text:"撤销",type:"danger",order:98,show:c(({row:e})=>e.status!==5),click({row:e}){m.confirm("确认撤销该报损记录?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(async()=>{try{const o=await y(e);console.log("res::::",o),o.code===2e3?(d.success("撤销成功"),t.doRefresh()):d.error(o.msg||"撤销失败")}catch{d.error("请求失败")}}).catch(()=>{})}}}},pagination:{show:!0},columns:{_index:{title:"序号",form:{show:!1},column:{type:"index",align:"center",width:"70px",columnSetDisabled:!0}},search:{title:"关键字搜索",search:{show:!0,type:"input"},type:"input",form:{component:{placeholder:"请输入"},show:!1},column:{show:!1}},damage_no:{title:"编号",search:{show:!0},treeNode:!0,type:"input",column:{minWidth:120},form:{show:!1,component:{placeholder:"请输入编号"}},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},device_code:{title:"设备编号",type:"input",column:{show:!0,minWidth:120},form:{show:!0,component:{placeholder:"请填写设备编号",onBlur:async e=>{var a;const o=(a=e.target.value)==null?void 0:a.trim();if(console.log("onBlur deviceCode:",o),!!o)try{const r=await n({url:`/api/system/device/?code=${encodeURIComponent(o)}`,method:"get"});if(console.log("设备搜索响应:",r),r.code===2e3&&r.data&&r.data.length>0){const s=r.data[0];console.log("找到设备:",s);const i=t.getFormData();i.device=s.id,i.device_code=s.code,i.device_name=s.name,t.setFormData(i)}else console.log("未找到匹配的设备")}catch(r){console.error("搜索设备信息失败:",r)}}},rules:[{required:!0,message:"请填写设备编号"}]},editForm:{component:{disabled:!0}},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},device:{title:"设备名称",type:"dict-select",column:{show:!1,minWidth:120},dict:u({url:"/api/system/device/?has_inventory=1",value:"id",label:"name"}),form:{component:{placeholder:"请填写设备名称",onChange:async e=>{console.log("onChange context:",e);const o=e;if(o)try{const a=await n({url:`/api/system/device/${o}/`,method:"get"});if(console.log("response::::",a),a.code==2e3){const r=a.data;console.log("设备数据:",r);const s=t.getFormData();s.device_code=r.code,s.device_name=r.name,t.setFormData(s)}}catch(a){console.error("获取设备信息失败:",a)}}},rules:[{required:!0,message:"请填写设备名称"}]},editForm:{component:{disabled:!0}},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},device_name:{title:"设备名称",type:"input",column:{show:!0,minWidth:120},form:{show:!1,component:{placeholder:"请填写设备名称"},rules:[{required:!0,message:"请填写设备名称"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},quantity:{title:"报废数量",type:"input",column:{minWidth:120},form:{component:{placeholder:"请填写报废数量"},rules:[{required:!0,message:"请填写报废数量"}]},editForm:{component:{disabled:!0}},valueResolve({form:e,value:o}){e.quantity=Number(o)},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},damage_type:{title:"报损类型",type:"dict-select",dict:u({data:[{label:"报废",value:0}]}),column:{show:!1,minWidth:120},form:{value:0,show:!1,component:{placeholder:"请填写报损类型"},rules:[{required:!1,message:"请填写报损类型"}]},editForm:{component:{disabled:!0}},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},damage_reason:{title:"报废原因",type:"input",column:{minWidth:120},form:{component:{placeholder:"请填写报废原因"},rules:[{required:!1,message:"请填写报废原因"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},estimated_loss:{title:"维修费用",type:"input",column:{minWidth:120,show:!1},form:{show:!1,component:{placeholder:"请填写维修费用"},rules:[{required:!1,message:"请填写维修费用"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}],show:c(({form:e})=>e&&e.damage_type===1)}},reporter_person:{title:"负责人",type:"input",column:{minWidth:120},form:{show:!1,component:{placeholder:"请填写负责人"},rules:[{required:!1,message:"请填写负责人"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},status_display:{title:"状态",type:"input",column:{minWidth:120},form:{show:!1,component:{placeholder:"请填写负责人"},rules:[{required:!1,message:"请填写负责人"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},create_datetime:{title:"创建时间",type:"datetime",column:{minWidth:120},form:{show:!1}}}}}},x=Object.freeze(Object.defineProperty({__proto__:null,createCrudOptions:v},Symbol.toStringTag,{value:"Module"}));export{R as G,x as a,v as c};
|