import{r as o,p as s,W as i,I as h,h as g}from"./index.BKEMpsLA.js";import{a as d}from"./authFunction.DqglRaEG.js";const a="/api/system/device-damage-records/";function w(r){return o({url:a+"?damage_type=1",method:"get",params:r})}function f(r){return o({url:a,method:"post",data:r})}function q(r){return o({url:a+r.id+"/",method:"put",data:r})}function y(r){return o({url:a+r+"/",method:"delete",data:{id:r}})}function O(){return o({url:a+"?damage_type=1",method:"get"})}const v=function({crudExpose:r,dialogId:m,dialogVisible:p}){return{crudOptions:{request:{pageRequest:async e=>await w(e),addRequest:async({form:e})=>await f(e),editRequest:async({form:e,row:t})=>(e.id=t.id,await q(e)),delRequest:async({row:e})=>await y(e.id)},form:{wrapper:{buttons:{ok:{text:"提交"}}}},actionbar:{buttons:{add:{show:d("area:Create")}}},toolbar:{show:!1},rowHandle:{fixed:"right",width:220,buttons:{remove:{show:!0},edit:{show:!0},updateStatus:{text:"修改状态",show:!0,order:99,type:"primary",click({row:e}){m.value=e.id,p.value=!0}}}},pagination:{show:!1},columns:{_index:{title:"序号",form:{show:!1},column:{type:"index",align:"center",width:"70px",columnSetDisabled:!0}},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:"设备id",type:"dict-select",column:{show:!1,minWidth:120},dict:i({url:"/api/system/device/",value:"id",label:"name"}),form:{component:{placeholder:"请填写设备id"},rules:[{required:!0,message:"请填写设备id"}]},editForm:{component:{disabled:!0}},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},device_code:{title:"设备编码",type:"input",column:{show:!1,minWidth:120},form:{show:!0,component:{placeholder:"请填写设备编码"},rules:[{required:!0,message:"请填写设备编码"}]},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:!1,message:"请填写库存数量"}]},editForm:{component:{disabled:!0}},valueResolve({form:e,value:t}){e.quantity=Number(t)},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},damage_type:{title:"维修类型",type:"dict-select",dict:i({data:[{label:"维修",value:1}]}),column:{minWidth:120},form:{value:1,show:!0,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:s(({form:e})=>e&&e.damage_type===1)},form:{component:{placeholder:"请填写维修费用"},rules:[{required:!1,message:"请填写维修费用"}],show:s(({form:e})=>e&&e.damage_type===1)},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}],show:s(({form:e})=>e&&e.damage_type===1)}},responsible_person:{title:"负责人",type:"input",column:{minWidth:120},form:{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:""}]}},remark:{title:"备注",type:"input",column:{minWidth:120},form:{show:!0,component:{placeholder:"请填写备注"},rules:[{required:!1,message:"请填写备注"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},damage_images:{title:"附件",type:"image-uploader",column:{minWidth:120},form:{show:d("image:upload"),component:{uploader:{type:"form",limit:1,action:"/api/system/device/upload-image/",accept:".jpg,.png",uploadRequest:async({action:e,file:t,onProgress:c})=>{const u=g.get("token"),l=new FormData;return l.append("image",t),await o({url:e,method:"post",timeout:6e4,headers:{"Content-Type":"multipart/form-data",Authorization:u?`JWT ${u}`:""},data:l,onUploadProgress:n=>{c({percent:Math.round(n.loaded/n.total*100)})}})},successHandle(e){return{url:h(e.data.image_url),key:e.data.id,...e.data}}}}},valueBuilder({row:e,key:t}){return e[t]?[e[t]]:[]},valueResolve({form:e,key:t}){console.log("form[key]:::",e[t]),e[t]=Array.isArray(e[t])?e[t][0]:e[t]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}}}}}},j=Object.freeze(Object.defineProperty({__proto__:null,createCrudOptions:v},Symbol.toStringTag,{value:"Module"}));export{O as G,j as a,v as c};
