1 |
- import{W as f,D as m,n as B,K as R,h as W,r as A,$ as g,a0 as s,s as E}from"./index.D428_EtN.js";import{D as M,U as Y,A as C,G as S,g as T,a as j,b as O,c as k,d as z}from"./api.BvnedbAn.js";import{a as q}from"./authFunction.DmqbGPwq.js";import{d as H}from"./dictionary.bU4hMAQU.js";import{r as d,S as o,a as w,P as c,aj as N,ai as x,w as y,L as v,at as b,f as U}from"./vue.YrNK8sx4.js";const $=w({props:{form:Object},setup(a){try{const r=d([]),n=d(!1),p=U(()=>r.value||[]);return y(()=>{var i;return(i=a.form)==null?void 0:i.id},async()=>{var i;if((i=a.form)!=null&&i.id){n.value=!0;try{const F=await k(a.form.id);r.value=F.data||[]}finally{n.value=!1}}},{immediate:!0}),()=>v(o(g,{data:p.value,style:"width: 100%"},{default:()=>[o(s,{prop:"application_no",label:"借用编号"},null),o(s,{prop:"borrower_name",label:"借用人"},null),o(s,{prop:"borrower_code",label:"学号/工号"},null),o(s,{prop:"record_type_label",label:"状态"},null),o(s,{prop:"borrow_type_display",label:"借用类型"},null)]}),[[b("loading"),n.value]])}catch(r){return console.error("BorrowRecords setup error:",r),()=>o("div",null,[c("组件加载失败")])}}}),L=w({props:{form:Object},setup(a){try{const r=d([]),n=d(!1);return y(()=>{var l;return(l=a.form)==null?void 0:l.id},async()=>{var l;if((l=a.form)!=null&&l.id){n.value=!0;try{const i=await O(a.form.id);r.value=i.data||[]}finally{n.value=!1}}},{immediate:!0}),()=>v(o(g,{data:r.value,style:"width: 100%"},{default:()=>[o(s,{prop:"damage_no",label:"维修编号"},null),o(s,{prop:"device_name",label:"设备名称"},null),o(s,{prop:"damage_reason",label:"损坏原因"},null),o(s,{prop:"estimated_loss",label:"损失价格"},null)]}),[[b("loading"),n.value]])}catch(r){return console.error("MaintenanceHistory setup error:",r),()=>o("div",null,[c("组件加载失败")])}}}),P=w({props:{form:Object},setup(a){try{const r=d([]),n=d(!1);return y(()=>{var l;return(l=a.form)==null?void 0:l.id},async()=>{var l;if((l=a.form)!=null&&l.id){n.value=!0;try{const i=await j(a.form.id);r.value=i.data||[]}finally{n.value=!1}}},{immediate:!0}),()=>v(o(g,{data:r.value,style:"width: 100%"},{default:()=>[o(s,{prop:"record_no",label:"保养编号"},null),o(s,{prop:"plan_name",label:"保养计划"},null),o(s,{prop:"planned_date",label:"保养日期"},null),o(s,{prop:"maintenance_person",label:"保养人员"},null),o(s,{prop:"maintenance_content",label:"保养内容"},null)]}),[[b("loading"),n.value]])}catch(r){return console.error("MaintenanceRecords setup error:",r),()=>o("div",null,[c("组件加载失败")])}}}),G=w({props:{form:Object},setup(a){try{const r=d({}),n=d(!1);return y(()=>{var l;return(l=a.form)==null?void 0:l.id},async()=>{var l;if((l=a.form)!=null&&l.id){n.value=!0;try{const i=await T(a.form.id);r.value=i.data||{},console.log(r.value)}finally{n.value=!1}}},{immediate:!0}),()=>v(o("div",{style:{padding:"20px"}},[o("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"20px"}},[o("div",{style:{background:"#f5f7fa",padding:"20px",borderRadius:"8px",textAlign:"center"}},[o("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#409eff"}},[r.value.borrow_count||0]),o("div",{style:{color:"#606266",marginTop:"8px"}},[c("总借用次数")])]),o("div",{style:{background:"#f5f7fa",padding:"20px",borderRadius:"8px",textAlign:"center"}},[o("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#67c23a"}},[r.value.maintenance_records_count||0]),o("div",{style:{color:"#606266",marginTop:"8px"}},[c("维护次数")])]),o("div",{style:{background:"#f5f7fa",padding:"20px",borderRadius:"8px",textAlign:"center"}},[o("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#e6a23c"}},[r.value.maintenance_history_count||0]),o("div",{style:{color:"#606266",marginTop:"8px"}},[c("维修次数")])]),o("div",{style:{background:"#f5f7fa",padding:"20px",borderRadius:"8px",textAlign:"center"}},[o("div",{style:{fontSize:"24px",fontWeight:"bold",color:"#f56c6c"}},[r.value.total_borrow_hours||0]),o("div",{style:{color:"#606266",marginTop:"8px"}},[c("借用时长")])])]),r.value.recent_activities&&o("div",{style:{marginTop:"30px"}},[o("h3",{style:{marginBottom:"20px",color:"#303133"}},[c("最近活动")]),o(g,{data:r.value.recent_activities,style:{width:"100%"}},{default:()=>[o(s,{prop:"activity_type",label:"活动类型"},null),o(s,{prop:"activity_date",label:"活动日期"},null),o(s,{prop:"description",label:"描述"},null)]})])]),[[b("loading"),n.value]])}catch(r){return console.error("DeviceStatistics setup error:",r),()=>o("div",null,[c("组件加载失败")])}}}),X=function({crudExpose:a}){const r=async e=>await S(e),n=async({form:e,row:t})=>(e.id=t.id,await Y(e)),p=async({row:e})=>await M(e.id),l=async({form:e})=>await C(e),i=d([]),F=e=>{console.log("selection",e),i.value=e.map(t=>t.id)};return a.selectedIds=i,{crudOptions:{request:{pageRequest:r,addRequest:l,editRequest:n,delRequest:p},table:{rowKey:"id",onSelectionChange:F},toolbar:{show:!0},rowHandle:{fixed:"right",width:220,view:{show:!0},edit:{show:!0},remove:{show:!0}},actionbar:{buttons:{add:{show:q("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,u=a.crudBinding.value.pagination;return((u.currentPage??1)-1)*u.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:""}]}},"inventory.borrowed_quantity":{title:"设备状态",type:"text",search:{show:!1},column:{show:!0,minWidth:100,formatter:({row:e})=>{const t=e.borrowed_quantity>0,u=t?(e.total_quantity-e.borrowed_quantity==0,"在借"):e.total_quantity==0?"在借":"空闲",h=t?"#FFA500":"#4CAF50";return x("span",{style:{display:"inline-block",padding:"2px 8px",border:`1px solid ${h}`,borderRadius:"4px",backgroundColor:h,color:"white",fontWeight:"bold"}},u)}},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:!0,message:""}]}},specification:{title:"规格型号",search:{show:!1},type:"input",column:{minWidth:100},form:{component:{placeholder:"请输入规格型号"}},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},serial_number:{title:"序列号",type:"input",column:{minWidth:100},form:{component:{placeholder:"请输入序列号"}},viewForm:{component:{placeholder:""},rules:[{required:!0,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:"请输入库存数量"}]}},status:{title:"是否可见",type:"dict-switch",column:{show:!1,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=>()=>{z(e.row).then(t=>{E(t.msg)})})}},dict:f({data:H("device_button_status_bool")}),form:{show:!1,rules:[{required:!0,message:"请选择是否可见"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},status_label:{title:"当前状态",search:{show:!1},form:{show:!1}},department:{title:"所属部门",search:{show:!1},type:"input",column:{minWidth:120},form:{component:{placeholder:"请输入所属部门"}},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},purchase_date:{title:"采购时间",type:"date",search:{show:!1},column:{minWidth:120,formatter:({value:e})=>e?m(e).format("YYYY-MM-DD"):""},form:{component:{placeholder:"请选择采购时间"},rules:[{required:!1,message:"请选择采购时间"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]},valueResolve({form:e,value:t}){e.purchase_date=t?m(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:!0,message:""}]}},price:{title:"价格",type:"number",search:{show:!1},column:{minWidth:100},form:{component:{placeholder:"请输入设备购入价格"},rules:[{required:!1,message:"请输入设备购入价格"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},warranty_expiration:{title:"质保到期",type:"date",search:{show:!1},column:{minWidth:120,formatter:({value:e})=>e?m(e).format("YYYY-MM-DD"):""},viewForm:{title:"质保到期",component:{render({value:e}){if(console.log("valuevaluevalue:::",e),!e)return"";const t=m(e).format("YYYY-MM-DD"),u=m(e).isBefore(m(),"day");return x("span",{style:{color:u?"red":"inherit",fontWeight:u?"bold":"normal"}},u?`${t}(已过期)`:t)},showHtml:!0}},form:{component:{placeholder:"请选择质保到期"},rules:[{required:!1,message:"请选择质保到期"}]},valueResolve({form:e,value:t}){e.warranty_expiration=t?m(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:!1},type:"dict-select",column:{show:!1,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=Array.from(String(t),Number)},valueBuilder({form:e,value:t}){t&&(e.tags=Array.isArray(t)?t.length>0?Number(t[0]):"":Number(t))}}},image:{title:"设备图片",type:"image-uploader",column:{minWidth:120,show:!1},form:{show:q("image:upload"),component:{uploader:{type:"form",limit:1,action:"/api/system/device/upload-image/",accept:".jpg,.png",uploadRequest:async({action:e,file:t,onProgress:u})=>{const h=W.get("token"),_=new FormData;return _.append("image",t),await A({url:e,method:"post",timeout:6e4,headers:{"Content-Type":"multipart/form-data",Authorization:h?`JWT ${h}`:""},data:_,onUploadProgress:D=>{u({percent:Math.round(D.loaded/D.total*100)})}})},successHandle(e){return{url:R(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=>o("span",{style:{color:e.hasError?"red":"green"}},[o(N("fs-icon"),{icon:"ion:checkmark-circle"},null),c("基础信息")])},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=a.getFormData();return console.log("currentRow::",t),o($,{form:t||{}},null)}}},maintenance:{show:!0,label:"维修记录",icon:"el-icon-warning-outline",columns:["id"],slots:{default:e=>{const t=a.getFormData();return console.log("currentRowwx::",t),o(L,{form:t||{}},null)}}},maintain:{show:!0,label:"保养记录",icon:"el-icon-warning-outline",columns:["id"],slots:{default:e=>{const t=a.getFormData();return console.log("currentRowMaintain::",t),o(P,{form:t||{}},null)}}},datastatis:{show:!0,label:"数据统计",icon:"el-icon-data-analysis",columns:["id"],slots:{default:e=>{const t=a.getFormData();return console.log("currentRowStats::",t),o(G,{form:t||{}},null)}}}}}}}}};export{X as createCrudOptions};
|