crud.DYeRFR5K.js 6.2 KB

1
  1. import{q as u,W as a,E as c}from"./index.C1FjL8wX.js";import{aH as p,S as o,P as n,aj as l}from"./vue.BC7RnHNA.js";import{D as d,a as m,b as h,G as f,c as w}from"./api.DokKopEN.js";const D=function({crudExpose:y}){return p(),{crudOptions:{request:{pageRequest:async e=>{f({}).then(t=>{const s={...e,tenant_id:"1",category:e.form&&e.form.category||e.category||"",job_id:t.data[0].id};return console.log("Request params:",s),w(s)})},addRequest:async({form:e})=>await h(e),editRequest:async({form:e,row:t})=>await m({...e,id:t.id}),delRequest:async({row:e})=>await d(e.id)},search:{show:!0,onSearch:e=>(console.log("Search params:",e),e),columns:{category:{title:"分类",search:{show:!0,value:""},type:"text",column:{show:!1}}}},rowHandle:{width:250,buttons:{view:{size:"small",click:({row:e})=>{const t=new CustomEvent("viewDocumentDetail",{detail:e});window.dispatchEvent(t)}},preview:{text:"预览",type:"success",size:"small",click:e=>{if(!e.row||!e.row.file_path){c.error("文件路径无效");return}const t=e.row.file_path,s=e.row.file_type;if(!["pdf","doc","docx","xls","xlsx","ppt","pptx","jpg","jpeg","png","gif","bmp","webp"].includes(s)){c.warning(`暂不支持预览该文件类型: ${s}`);return}const r=`/#/preview?url=${encodeURIComponent(t)}&type=${s}`;window.open(r,"_blank")}},edit:{type:"primary",size:"small"},remove:{type:"danger",size:"small"}}},form:{view:{disabled:!0,display:"text"}},columns:{position_id:{title:"职位",search:{show:!0},type:"dict-select",column:{value:"1",minWidth:120,show:!1},form:{show:!1}},question_id:{title:"ID",search:{show:!1},column:{value:"1",show:!1},form:{show:!1}},id:{title:"ID",column:{show:!1},search:{show:!1},form:{show:!1}},question:{title:"题目内容",search:{show:!0},column:{minWidth:120,sortable:"custom"},form:{rules:[{required:!0,message:"题目内容必填"}],component:{placeholder:"请输入题目内容"}}},question_type:{title:"问题类型",search:{show:!0},type:"dict-select",column:{minWidth:100},dict:a({data:[{value:1,label:"专业技能"},{value:2,label:"通用能力"},{value:3,label:"个人特质"}]}),form:{rules:[{required:!0,message:"问题类型必填"}],component:{placeholder:"请选择问题类型"},helper:"选择问题的类型分类"}},question_form:{title:"题目形式",search:{show:!0},type:"dict-select",column:{minWidth:100},dict:a({data:[{value:0,label:"开放问题"},{value:1,label:"单选题"},{value:2,label:"多选题"}]}),form:{rules:[{required:!0,message:"题目形式必填"}],component:{placeholder:"请选择题目形式",onChange:({form:e})=>{e.question_form===1?e.options=[{option_text:"",is_correct:!1,sort:1},{option_text:"",is_correct:!1,sort:2}]:e.question_form===2?e.options=[{option_text:"",is_correct:!1,sort:1},{option_text:"",is_correct:!1,sort:2}]:e.options=[]}},helper:"选择题目的形式:开放问题、单选题或多选题"}},position_types:{title:"适用职位",search:{show:!0},type:"dict-select",column:{minWidth:120},dict:a({data:[{value:"0",label:"技术"},{value:"1",label:"管理"}]}),form:{component:{props:{multiple:!0,filterable:!0,placeholder:"请选择适用职位类型"}},helper:"选择题目适用的职位类型,可多选"}},recommended_duration:{title:"建议时长(秒)",search:{show:!1},column:{minWidth:100},form:{component:{name:"el-input-number",props:{min:10,max:600,step:10}},helper:"建议回答此题目的时长,单位为秒"}},difficulty:{title:"难度等级",search:{show:!0},type:"dict-select",column:{minWidth:80},dict:a({data:[{value:1,label:"初级"},{value:2,label:"中级"},{value:3,label:"高级"}]}),form:{rules:[{required:!0,message:"难度等级必填"}],helper:"选择题目的难度级别"}},is_system:{title:"系统题目",search:{show:!0},column:{width:80,component:{name:"el-switch"}},form:{component:{name:"el-switch",props:{activeText:"是",inactiveText:"否"}},helper:"是否为系统预设题目"}},status:{title:"状态",search:{show:!0},type:"dict-select",column:{width:80},dict:a({data:[{value:0,label:"停用"},{value:1,label:"启用"}]}),form:{rules:[{required:!0,message:"状态必填"}],component:{placeholder:"请选择状态"},helper:"题目的启用状态"}},sort:{title:"排序",search:{show:!1},column:{width:80},form:{component:{name:"el-input-number",props:{min:1,max:999}},helper:"题目的排序值,值越小排序越靠前"}},option_items:{title:"选项列表",search:{show:!1},column:{show:!1},form:{show:u(({form:e})=>e&&(e.question_form===1||e.question_form===2)),component:{name:"el-card",children:{default:({form:e})=>(e.options||(e.options=[]),o("div",null,[o("div",{class:"option-header",style:"display: flex; margin-bottom: 10px; font-weight: bold;"},[o("span",{style:"flex: 1;"},[n("选项内容")]),o("span",{style:"width: 80px; text-align: center;"},[n("是否正确")])]),e.options.map((t,s)=>o("div",{class:"option-item",key:s,style:"display: flex; align-items: center; margin-bottom: 10px;"},[o(l("el-input"),{modelValue:t.option_text,"onUpdate:modelValue":i=>t.option_text=i,placeholder:"请输入选项内容",style:"flex: 1; margin-right: 10px;"},null),o(l("el-tooltip"),{content:"设置为正确答案",placement:"top",effect:"light"},{default:()=>[o("div",{onClick:()=>{e.question_form===1?e.options.forEach((i,r)=>{i.is_correct=r===s}):t.is_correct=!t.is_correct},style:"cursor: pointer; width: 80px; text-align: center;"},[e.question_form===1?o(l("el-radio"),{modelValue:t.is_correct,label:!0},null):o(l("el-checkbox"),{modelValue:t.is_correct},null)])]})])),o("div",{style:"display: flex; justify-content: space-between; margin-top: 10px;"},[o(l("el-button"),{type:"primary",onClick:()=>{e.options||(e.options=[]);const t=e.options.length>0?Math.max(...e.options.map(s=>s.sort||0))+1:1;e.options.push({option_text:"",is_correct:!1,sort:t})}},{default:()=>[n("添加选项")]}),e.options.length>2&&o(l("el-button"),{type:"danger",onClick:()=>{e.options.pop()}},{default:()=>[n("删除最后一项")]})])]))}},helper:u(({form:e})=>e.question_form===1?"添加单选题的选项,并标记正确答案(只能有一个正确答案)":e.question_form===2?"添加多选题的选项,并标记正确答案(可以有多个正确答案)":"")}},answer_explanation:{title:"答案解析",search:{show:!1},column:{show:!1},form:{component:{name:"el-input",type:"textarea",rows:4,placeholder:"请输入答案解析"}}}}}}};export{D as createCrudOptions};