| 1 |
- import{W as f,D as g,r as B,C as W,h as R,t as A,a4 as y,a5 as i,s as E}from"./index.BGBj-4PV.js";import{D as M,U as C,A as Y,G as S,g as T,a as O,b as j,c as k,d as z}from"./api.DbOigkoa.js";import{a as D}from"./authFunction.DC0n_p4g.js";import{r as p,S as a,a as v,P as m,ai as x,w as b,L as F,at as _,f as H}from"./vue.D1BjjNmv.js";const N=v({props:{form:Object},setup(r){try{const o=p([]),s=p(!1),w=H(()=>o.value||[]);return b(()=>{var u;return(u=r.form)==null?void 0:u.id},async()=>{var u;if((u=r.form)!=null&&u.id){s.value=!0;try{const q=await k(r.form.id);o.value=q.data||[]}finally{s.value=!1}}},{immediate:!0}),()=>F(a(y,{data:w.value,style:"width: 100%"},{default:()=>[a(i,{prop:"application_no",label:"借用编号"},null),a(i,{prop:"borrower_name",label:"借用人"},null),a(i,{prop:"borrower_code",label:"学号/工号"},null),a(i,{prop:"record_type_label",label:"状态"},null),a(i,{prop:"borrow_type_display",label:"借用类型"},null)]}),[[_("loading"),s.value]])}catch(o){return console.error("BorrowRecords setup error:",o),()=>a("div",null,[m("组件加载失败")])}}}),U=v({props:{form:Object},setup(r){try{const o=p([]),s=p(!1);return b(()=>{var l;return(l=r.form)==null?void 0:l.id},async()=>{var l;if((l=r.form)!=null&&l.id){s.value=!0;try{const u=await j(r.form.id);o.value=u.data||[]}finally{s.value=!1}}},{immediate:!0}),()=>F(a(y,{data:o.value,style:"width: 100%"},{default:()=>[a(i,{prop:"damage_no",label:"维修编号"},null),a(i,{prop:"device_name",label:"设备名称"},null),a(i,{prop:"damage_reason",label:"损坏原因"},null),a(i,{prop:"estimated_loss",label:"损失价格"},null)]}),[[_("loading"),s.value]])}catch(o){return console.error("MaintenanceHistory setup error:",o),()=>a("div",null,[m("组件加载失败")])}}}),I=v({props:{form:Object},setup(r){try{const o=p([]),s=p(!1);return b(()=>{var l;return(l=r.form)==null?void 0:l.id},async()=>{var l;if((l=r.form)!=null&&l.id){s.value=!0;try{const u=await O(r.form.id);o.value=u.data||[]}finally{s.value=!1}}},{immediate:!0}),()=>F(a(y,{data:o.value,style:"width: 100%"},{default:()=>[a(i,{prop:"record_no",label:"保养编号"},null),a(i,{prop:"plan_name",label:"保养计划"},null),a(i,{prop:"planned_date",label:"保养日期"},null),a(i,{prop:"maintenance_person",label:"保养人员"},null),a(i,{prop:"maintenance_content",label:"保养内容"},null)]}),[[_("loading"),s.value]])}catch(o){return console.error("MaintenanceRecords setup error:",o),()=>a("div",null,[m("组件加载失败")])}}}),$=v({props:{form:Object},setup(r){try{const o=p({}),s=p(!1);return b(()=>{var l;return(l=r.form)==null?void 0:l.id},async()=>{var l;if((l=r.form)!=null&&l.id){s.value=!0;try{const u=await T(r.form.id);o.value=u.data||{},console.log(o.value)}finally{s.value=!1}}},{immediate:!0}),()=>F(a("div",{style:{padding:"20px"}},[a("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"20px"}},[a("div",{style:{background:"#f5f7fa",padding:"20px",borderRadius:"8px",textAlign:"center"}},[a("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#409eff"}},[o.value.borrow_count||0]),a("div",{style:{color:"#606266",marginTop:"8px"}},[m("总借用次数")])]),a("div",{style:{background:"#f5f7fa",padding:"20px",borderRadius:"8px",textAlign:"center"}},[a("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#67c23a"}},[o.value.maintenance_records_count||0]),a("div",{style:{color:"#606266",marginTop:"8px"}},[m("维护次数")])]),a("div",{style:{background:"#f5f7fa",padding:"20px",borderRadius:"8px",textAlign:"center"}},[a("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#e6a23c"}},[o.value.maintenance_history_count||0]),a("div",{style:{color:"#606266",marginTop:"8px"}},[m("维修次数")])]),a("div",{style:{background:"#f5f7fa",padding:"20px",borderRadius:"8px",textAlign:"center"}},[a("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#f56c6c"}},[o.value.total_borrow_hours||0]),a("div",{style:{color:"#606266",marginTop:"8px"}},[m("借用时长")])])]),o.value.recent_activities&&a("div",{style:{marginTop:"30px"}},[a("h3",{style:{marginBottom:"20px",color:"#303133"}},[m("最近活动")]),a(y,{data:o.value.recent_activities,style:{width:"100%"}},{default:()=>[a(i,{prop:"activity_type",label:"活动类型"},null),a(i,{prop:"activity_date",label:"活动日期"},null),a(i,{prop:"description",label:"描述"},null)]})])]),[[_("loading"),s.value]])}catch(o){return console.error("DeviceStatistics setup error:",o),()=>a("div",null,[m("组件加载失败")])}}}),J=function({crudExpose:r}){const o=async e=>await S(e),s=async({form:e,row:t})=>(e.id=t.id,await C(e)),w=async({row:e})=>await M(e.id),l=async({form:e})=>await Y(e),u=p([]),q=e=>{console.log("selection",e),u.value=e.map(t=>t.id)};return r.selectedIds=u,{crudOptions:{request:{pageRequest:o,addRequest:l,editRequest:s,delRequest:w},table:{rowKey:"id",onSelectionChange:q},toolbar:{show:!1},rowHandle:{fixed:"right",width:220,view:{show:!0},edit:{show:!0},remove:{show:!0}},actionbar:{buttons:{add:{show:D("user:Create")}}},columns:{$checked:{title:"选择",form:{show:!1},column:{type:"selection",align:"center",width:"55px",columnSetDisabled:!0,selectable(e,t){return e.id}}},_index:{title:"序号",form:{show:!1},column:{align:"center",width:"70px",columnSetDisabled:!0,formatter:e=>{let t=e.index??1,n=r.crudBinding.value.pagination;return((n.currentPage??1)-1)*n.pageSize+t+1}}},search:{title:"关键字搜索",search:{show:!0,type:"input"},type:"input",form:{component:{placeholder:"请输入"},show:!1},column:{show:!1}},code:{title:"设备编号",search:{show:!0},type:"input",column:{minWidth:120},form:{component:{placeholder:"请输入设备编号"},rules:[{required:!0,message:"请输入设备编号"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},category_name:{title:"设备分类",search:{show:!0},type:"dict-select",dict:f({url:"/api/system/device/category/?page=1&limit=100",value:"id",label:"name"}),column:{minWidth:100},form:{show:!1,component:{placeholder:"请选择设备分类"},rules:[{required:!0,message:"请选择设备分类"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},name:{title:"设备名称",search:{show:!1},type:"input",column:{minWidth:120},form:{component:{placeholder:"请输入设备名称"},rules:[{required:!0,message:"请输入设备名称"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},status_list:{title:"设备状态",type:"dict-select",search:{show:!1},column:{show:!1,minWidth:100},dict:f({data:[{value:0,label:"停用"},{value:1,label:"正常"},{value:2,label:"维修中"},{value:3,label:"报废"}]}),form:{show:!1,component:{placeholder:"请选择设备状态"},rules:[{required:!0,message:"请选择设备状态"}]},viewForm:{show:!1,component:{placeholder:""},rules:[{required:!0,message:""}]}},"inventory.borrowed_quantity":{title:"设备状态",type:"text",search:{show:!1},column:{show:!0,minWidth:130,formatter:({row:e})=>{const t=e.inventory.borrowed_quantity>0,n=e.inventory.maintenance_quantity>0&&e.inventory.maintenance_quantity===e.inventory.total_quantity,h=e.inventory.damaged_quantity>0&&e.inventory.total_quantity==e.inventory.damaged_quantity;let d,c;return console.log(h),h?(d="报废",c="#F56C6C"):n?(d="维修",c="#E6A23C"):t?(d=(e.total_quantity-e.borrowed_quantity===0,"在借"),c="#FFA500"):(d=e.total_quantity===0?"在借":"空闲",c="#4CAF50"),x("span",{style:{display:"inline-block",padding:"2px 8px",border:`1px solid ${c}`,borderRadius:"4px",backgroundColor:c,color:"white",fontWeight:"bold"}},d)},filters:[{text:"空闲",value:"idle"},{text:"在借",value:"borrowed"},{text:"维修",value:"maintenance"},{text:"报废",value:"scrapped"}],filterMethod:(e,t)=>{const n=t.inventory,h=n.borrowed_quantity>0,d=n.maintenance_quantity>0&&n.maintenance_quantity===n.total_quantity,c=n.damaged_quantity>0&&n.total_quantity===0;return e==="scrapped"?c:e==="maintenance"?d:e==="borrowed"?h:e==="idle"?!h&&!d&&!c:!1},sortable:!0},form:{show:!1,component:{placeholder:"请选择设备状态"},rules:[{required:!0,message:"请选择设备状态"}]}},borrowed_quantity:{title:"已借出",type:"input",search:{show:!1},column:{minWidth:100},form:{show:!1,component:{placeholder:"请输入已借出"},rules:[{required:!0,message:"请输入已借出"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},brand:{title:"品牌",type:"input",column:{minWidth:100},form:{component:{placeholder:"请输入品牌"}},viewForm:{component:{placeholder:""},rules:[{required:!1,message:""}]}},specification:{title:"规格型号",search:{show:!1},type:"input",column:{minWidth:100},form:{component:{placeholder:"请输入规格型号"}},viewForm:{component:{placeholder:""},rules:[{required:!1,message:""}]}},serial_number:{title:"序列号",type:"input",column:{minWidth:100},form:{component:{placeholder:"请输入序列号"}},viewForm:{component:{placeholder:""},rules:[{required:!1,message:""}]}},available_quantity:{title:"可用库存",type:"input",column:{minWidth:100},addForm:{show:!1},viewForm:{show:!1},editForm:{show:!1},from:{show:!1,component:{placeholder:"请输入库存数量"},rules:[{required:!1,message:"请输入库存数量"}]}},total_quantity:{title:"库存数量",type:"input",column:{minWidth:100},addForm:{show:!1},viewForm:{show:!1},editForm:{show:!1},from:{show:!1,component:{placeholder:"请输入库存数量"},rules:[{required:!1,message:"请输入库存数量"}]}},warehouse:{title:"存放仓库",search:{show:!0},type:"dict-select",column:{minWidth:150},dict:f({url:"/api/system/warehouse/",value:"id",label:"name"}),form:{component:{placeholder:"请选择存放仓库"},rules:[{required:!0,message:"请选择存放仓库"}]}},status:{title:"是否可见",type:"dict-switch",search:{show:!0},column:{show:!0,minWidth:90,component:{name:"fs-dict-switch",activeText:"",inactiveText:"",style:"--el-switch-on-color: var(--el-color-primary); --el-switch-off-color: #dcdfe6",onChange:B(e=>{let t=!1;return setTimeout(()=>{t=!0},100),()=>{t&&z(e.row).then(n=>{E(n.msg)})}})}},dict:f({data:[{label:"可见",value:1},{label:"不可见",value:0}]}),form:{show:!1,rules:[{required:!0,message:"请选择是否可见"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},department:{title:"所属部门",search:{show:!1},type:"input",column:{minWidth:120},form:{component:{placeholder:"请输入所属部门"}},viewForm:{component:{placeholder:""},rules:[{required:!1,message:""}]}},purchase_date:{title:"采购时间",type:"date",search:{show:!1},column:{minWidth:120,formatter:({value:e})=>e?g(e).format("YYYY-MM-DD"):""},form:{component:{placeholder:"请选择采购时间"},rules:[{required:!1,message:"请选择采购时间"}]},viewForm:{component:{placeholder:""},rules:[{required:!1,message:""}]},valueResolve({form:e,value:t}){e.purchase_date=t?g(t).format("YYYY-MM-DD"):null},valueBuilder({form:e,value:t}){e.purchase_date=t}},supplier:{title:"供应商",type:"dict-select",search:{show:!0},column:{minWidth:120},dict:f({url:"/api/system/supplier/",value:"id",label:"name"}),form:{component:{placeholder:"请输入供应商"}},viewForm:{component:{placeholder:""},rules:[{required:!1,message:""}]}},price:{title:"价格",type:"number",search:{show:!1},column:{minWidth:100},form:{component:{placeholder:"请输入设备购入价格"},rules:[{required:!1,message:"请输入设备购入价格"}]},viewForm:{component:{placeholder:""},rules:[{required:!1,message:""}]}},warranty_expiration:{title:"质保到期",type:"date",search:{show:!1},column:{minWidth:120,formatter:({value:e})=>e?g(e).format("YYYY-MM-DD"):""},viewForm:{title:"质保到期",component:{render({value:e}){if(console.log("valuevaluevalue:::",e),!e)return"";const t=g(e).format("YYYY-MM-DD"),n=g(e).isBefore(g(),"day");return x("span",{style:{color:n?"red":"inherit",fontWeight:n?"bold":"normal"}},n?`${t}(已过期)`:t)},showHtml:!0},rules:[{required:!1,message:"请选择质保到期"}]},form:{component:{placeholder:"请选择质保到期"},rules:[{required:!1,message:"请选择质保到期"}]},valueResolve({form:e,value:t}){e.warranty_expiration=t?g(t).format("YYYY-MM-DD"):null},valueBuilder({form:e,value:t}){e.warranty_expiration=t}},tenant_id:{title:"租户id",type:"input",value:1,column:{show:!1,minWidth:120},form:{value:1,show:!1,component:{placeholder:"请填租户id"},rules:[{required:!1,message:"请填租户id"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},category:{show:!1,title:"设备类别",search:{show:!1},type:"dict-select",column:{show:!1,minWidth:120},dict:f({url:"/api/system/device/category/?page=1&limit=100",value:"id",label:"name"}),form:{component:{placeholder:"请输入设备类别",filterable:!0},rules:[{required:!0,message:"请输入设备类别"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},quantity:{show:!1,title:"库存数量",search:{show:!1},type:"input",column:{show:!1,minWidth:120},viewForm:{component:{placeholder:""}},form:{component:{placeholder:"请输入库存数量"},rules:[{required:!0,message:"请输入库存数量"}],valueResolve({form:e,value:t}){e.quantity=Number(t??0)},valueBuilder({form:e,value:t}){e.quantity=e.total_quantity}}},tags:{show:!1,title:"设备标签",search:{show:!0},type:"dict-select",column:{show:!0,minWidth:120},dict:f({url:"/api/system/device_tags/?page=1&limit=100",value:"id",label:"name"}),viewForm:{component:{placeholder:""}},form:{component:{placeholder:"请选择设备标签",filterable:!0},rules:[{required:!0,message:"请选择设备标签"}],valueResolve({form:e,value:t}){e.tags=[parseInt(t,10)],console.log(e.tags)},valueBuilder({form:e,value:t}){t&&(e.tags=Array.isArray(t)?t.length>0?Number(t[0]):"":Number(t),console.log(e.tags))}}},image:{title:"设备图片",type:"image-uploader",column:{minWidth:120,show:!1},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:n})=>{const h=R.get("token"),d=new FormData;return d.append("image",t),await A({url:e,method:"post",timeout:6e4,headers:{"Content-Type":"multipart/form-data",Authorization:h?`JWT ${h}`:""},data:d,onUploadProgress:c=>{n({percent:Math.round(c.loaded/c.total*100)})}})},successHandle(e){return{url:W(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]}},id:{title:"deviceid",search:{show:!1},type:"input",column:{show:!1,minWidth:120},form:{show:!1,component:{placeholder:"请输入维修"}},viewForm:{show:!0,component:{placeholder:""},rules:[{required:!0,message:""}]}}},viewForm:{wrapper:{buttons:{ok:{text:"提交",show:!1}}},row:{gutter:20},group:{groupType:"tabs",groups:{base:{slots:{label:e=>a("span",{style:{color:e.hasError?"red":"#409eff"}},[m("基础信息")])},icon:"el-icon-goods",columns:["code","category_name","name","status","borrowed_quantity","brand","specification","serial_number","warehouse","is_visible","department","purchase_date","supplier","price","warranty_expiration","tenant_id","category","quantity","tags","image"]},borrow:{show:!0,label:"借用记录",icon:"el-icon-price-tag",columns:["id"],slots:{default:e=>{const t=r.getFormData();return console.log("currentRow::",t),a(N,{form:t||{}},null)}}},maintenance:{show:!0,label:"维修记录",icon:"el-icon-warning-outline",columns:["id"],slots:{default:e=>{const t=r.getFormData();return console.log("currentRowwx::",t),a(U,{form:t||{}},null)}}},maintain:{show:!0,label:"保养记录",icon:"el-icon-warning-outline",columns:["id"],slots:{default:e=>{const t=r.getFormData();return console.log("currentRowMaintain::",t),a(I,{form:t||{}},null)}}},datastatis:{show:!0,label:"数据统计",icon:"el-icon-data-analysis",columns:["id"],slots:{default:e=>{const t=r.getFormData();return console.log("currentRowStats::",t),a($,{form:t||{}},null)}}}}}}}}};export{J as createCrudOptions};
|