crud.DIuSFz4_.js 5.1 KB

1
  1. import{r as o,n as i,W as d,J as c,E as u}from"./index.8VEyMOSu.js";import{a as m}from"./authFunction.DWw9gEPG.js";const s="/api/system/device-damage-records/";function p(t){return o({url:s+"?damage_type=0",method:"get",params:t})}function h(t){return o({url:s,method:"post",data:t})}function g(t){return o({url:s+t.id+"/",method:"put",data:t})}function f(t){return o({url:s+t+"/",method:"delete",data:{id:t}})}function R(){return o({url:s+"?damage_type=0",method:"get"})}function w(t){return o({url:s+t.id+"/cancel_damage/",method:"post",data:t})}const y=function({crudExpose:t}){return{crudOptions:{request:{pageRequest:async e=>await p(e),addRequest:async({form:e})=>await h(e),editRequest:async({form:e,row:r})=>(e.id=r.id,await g(e)),delRequest:async({row:e})=>await f(e.id)},form:{wrapper:{buttons:{ok:{text:"提交",show:i(e=>e.mode!=="view")}}}},actionbar:{buttons:{add:{show:m("area:Create")}}},toolbar:{show:!1},rowHandle:{fixed:"right",width:290,buttons:{remove:{show:!0},edit:{show:!0},cancelDamage:{text:"撤销",type:"danger",order:98,show:i(({row:e})=>e.status!==5),click({row:e}){c.confirm("确认撤销该报损记录?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(async()=>{try{const r=await w(e);console.log("res::::",r),r.code===2e3?(u.success("撤销成功"),t.doRefresh()):u.error(r.msg||"撤销失败")}catch{u.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:{title:"设备名称",type:"dict-select",column:{show:!1,minWidth:120},dict:d({url:"/api/system/device/",value:"id",label:"name"}),form:{component:{placeholder:"请填写设备名称",onChange:async e=>{console.log("onChange context:",e);const r=e;if(r)try{const a=await o({url:`/api/system/device/${r}/`,method:"get"});if(console.log("response::::",a),a.code==2e3){const n=a.data;console.log("设备数据:",n);const l=t.getFormData();l.device_code=n.code,l.device_name=n.name,t.setFormData(l)}}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:""}]}},device_code:{title:"设备编号",type:"input",column:{show:!0,minWidth:120},form:{show:!0,component:{placeholder:"请填写设备编号"},rules:[{required:!0,message:"请填写设备编号"}]},editForm:{component:{disabled:!0}},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:r}){e.quantity=Number(r)},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},damage_type:{title:"报损类型",type:"dict-select",dict:d({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:i(({form:e})=>e&&e.damage_type===1)}},reporter_name:{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:y},Symbol.toStringTag,{value:"Module"}));export{R as G,x as a,y as c};