crud.Bqgj0T7O.js 3.7 KB

1
  1. import{x as s,V as u,W as c}from"./index.BfsImp5e.js";import{a as d}from"./authFunction.CRwUiM64.js";const i="/api/system/articles/";function m(t){return s({url:i+"device-manuals/",method:"get",params:t})}function p(t){return s({url:i+"add-device-manual/",method:"post",data:t})}function h(t){return s({url:"/api/system/device-manuals/"+t.id+"/",method:"put",data:t})}function w(t){return s({url:i+t+"/",method:"delete",data:{id:t}})}const{compute:l}=u(),f=function({crudExpose:t}){return{crudOptions:{request:{pageRequest:async e=>await m(e),addRequest:async({form:e})=>(e.device_id=Number(e.device),e.title=e.article_title,e.content=e.article_content,await p(e)),editRequest:async({form:e,row:r})=>(e.id=r.id,e.device_id=Number(e.device),e.title=e.article_title,e.content=e.article_content,await h(e)),delRequest:async({row:e})=>await w(e.id)},actionbar:{buttons:{add:{show:d("area:Create")}}},form:{wrapper:{buttons:{ok:{text:"提交",show:l(e=>e.mode!=="view")}}}},toolbar:{show:!1},rowHandle:{buttons:{remove:{show:!0},edit:{show:!0}}},pagination:{show:!0},columns:{_index:{title:"序号",form:{show:!1},column:{show:!1,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}},device:{title:"设备名称",search:{show:!1},treeNode:!0,type:"dict-select",column:{show:!1,minWidth:120},dict:c({url:"/api/system/device/",value:"id",label:"name"}),form:{show:!0,component:{placeholder:"请选择设备名称",onChange:async e=>{console.log("onChange context:",e);const r=e;if(r)try{const o=await s({url:`/api/system/device/${r}/`,method:"get"});if(console.log("response::::",o),o.code==2e3){const a=o.data;console.log("设备数据:",a);const n=t.getFormData();n.device_code=a.code,n.device_name=a.name,t.setFormData(n)}}catch(o){console.error("获取设备信息失败:",o)}}},rules:[{required:!0,message:"请选择设备名称"}]}},article:{title:"文章id",search:{show:!1},type:"input",column:{show:!1,minWidth:120},form:{show:!1}},device_code:{title:"设备编号",search:{show:!1},treeNode:!0,type:"input",column:{minWidth:120},form:{show:!0}},article_title:{title:"文章标题",search:{show:!0},treeNode:!0,type:"input",column:{minWidth:120},form:{show:!0,rules:[{required:!0,message:"名称必填项"}],component:{placeholder:"请输入名称"}},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},device_name:{title:"设备名称",type:"input",column:{minWidth:120},form:{show:!1,component:{placeholder:"请填发布人"},rules:[{required:!1,message:"请填写发布人"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},article_content:{title:"内容",type:"editor-wang5",column:{show:!0,minWidth:120},form:{show:!0,col:{span:24},rules:[{required:!0,message:"内容为必填项"}],component:{disabled:!1,id:"1",editorConfig:{readOnly:l(e=>{const{mode:r}=e;return r!=="add"})},uploader:{type:"form",buildUrl(e){return console.log("res::::",e),e.url}}}},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},create_datetime:{title:"发布时间",type:"input",column:{minWidth:120},form:{show:!1,component:{placeholder:"请填写发布时间"},rules:[{required:!1,message:"请填写发布时间"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}},is_default:{title:"状态",type:"input",column:{show:!1,minWidth:120},form:{value:!0,show:!1,component:{placeholder:"请填写状态"},rules:[{required:!1,message:"请填写状态"}]},viewForm:{component:{placeholder:""},rules:[{required:!0,message:""}]}}}}}},W=Object.freeze(Object.defineProperty({__proto__:null,createCrudOptions:f},Symbol.toStringTag,{value:"Module"}));export{m as G,W as a,f as c};