crud.JUc7DugG.js 11 KB

1
  1. import{a9 as u,W as i,F as h,s as g}from"./index.BYVAoVgk.js";import{a as _,G as w,b as x,c as b,d as q,D as v,U as B,A as z,e as C,B as R,f as D}from"./api.Czm6r23e.js";import{a as f}from"./authFunction.Dqnr9sqy.js";import{S as t,aj as a,P as l}from"./vue.YrNK8sx4.js";const V=function({crudExpose:p,context:o}){return{crudOptions:{toolbar:{buttons:{search:{show:!1},refresh:{show:!1},compact:{show:!1},export:{text:"导出",type:"primary",size:"small",icon:"upload",circle:!1,display:!0},columns:{show:!1}}},request:{pageRequest:async e=>await C(e),addRequest:async({form:e})=>await z(e),editRequest:async({form:e,row:s})=>(e.id=s.id,await B(e)),delRequest:async({row:e})=>await v(e.id)},pagination:{show:!0},search:{show:!0,buttons:{search:{size:"small"},reset:{size:"small"}}},actionbar:{buttons:{add:{size:"small",show:f("role:Create")},batchBindTags:{text:"批量绑定标签",type:"primary",size:"small",show:!0,order:2,click:()=>{const e=o.selectedRows||[];if(console.log("选中的行:",e),!e||e.length===0){h("请先选择要操作的题目");return}o.openBatchTagsDialog(e)}},batchSetCategory:{text:"批量设置分类",type:"primary",show:!0,size:"small",order:3,click:()=>{const e=o.selectedRows||[];if(console.log("选中的行:",e),!e||e.length===0){h("请先选择要操作的题目");return}o.openBatchCategoryDialog(e)}},batchBindCompetencyTags:{text:"批量绑定胜任力标签",type:"primary",size:"small",show:!0,order:4,click:()=>{const e=o.selectedRows||[];if(!e||e.length===0){h("请先选择要操作的题目");return}o.openBatchCompetencyTagsDialog(e)}}}},rowHandle:{fixed:"right",width:259,buttons:{view:{show:!0,size:"small",icon:"View",type:"text"},edit:{show:f("role:Update"),size:"small",icon:"Edit",type:"text"},remove:{show:f("role:Delete"),size:"small",type:"text",icon:"Delete"}}},form:{col:{span:24},labelWidth:"100px",wrapper:{is:"el-dialog",width:"600px"}},columns:{_selection:{title:"选择",form:{show:!1},column:{type:"selection",align:"center",width:50,fixed:"left",columnSetDisabled:!0}},id:{title:"ID",column:{show:!0,width:80},search:{show:!1},form:{show:!1}},question:{title:"题目内容",search:{show:!0,size:"small",col:{span:3}},column:{showOverflowTooltip:!0,width:300,sortable:"custom"},form:{rules:[{required:!0,message:"题目内容必填"}],component:{placeholder:"请输入题目内容"}}},competency_tags:{title:"胜任力标签",search:{show:!0,size:"small",col:{span:3}},type:"dict-select",column:{minWidth:150,component:{name:"fs-component",render:({row:e})=>!e.competency_tags||e.competency_tags.length===0?t("span",null,[l("-")]):t("div",{style:"display: flex; flex-wrap: wrap; gap: 4px;"},[e.competency_tags.map(s=>t(a("el-tag"),{key:s.id,type:"warning",effect:"plain",size:"mini"},{default:()=>[s.name]}))])}},dict:i({getData:async()=>(await q({page:1,limit:1e3,tenant_id:1})).data.items,label:"name",value:"id"}),form:{component:{props:{multiple:!0,filterable:!0,placeholder:"请选择胜任力标签"}},helper:"选择题目关联的胜任力标签,可多选"}},question_form:{title:"题目形式",search:{show:!0,size:"small",col:{span:3}},type:"dict-select",column:{minWidth:100},dict:i({getData:async()=>(await b()).data.question_forms||[],label:"label",value:"value"}),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.question_form===4?(e.options=[{option_text:"无",score:0,sort:1},{option_text:"轻度",score:1,sort:2},{option_text:"中度",score:2,sort:3},{option_text:"偏重",score:3,sort:4},{option_text:"严重",score:4,sort:5}],e.scoring_reference||(e.scoring_reference="该评分反映了症状表现的频率与严重程度。")):e.options=[]}},helper:"选择题目的形式:开放问题、单选题、多选题、色盲题或追加型开放问题"}},position_types:{title:"适用职位",search:{show:!0,size:"small",col:{span:3}},type:"dict-select",column:{minWidth:120},dict:i({getData:async()=>{const e=await x({page:1,limit:1e3,tenant_id:1});return console.log(e.data),e.data||[]},label:"title",value:"id"}),form:{component:{props:{multiple:!0,filterable:!0,placeholder:"请选择适用职位类型"}},helper:"选择题目适用的职位类型,可多选"}},category_id:{title:"分类",search:{show:!0,size:"small",col:{span:2}},type:"dict-select",column:{minWidth:120,component:{render:({row:e})=>!e.category||e.category.length===0?t("span",null,[l("-")]):t(a("el-tag"),{key:e.category.id,type:"warning",effect:"plain",size:"mini"},{default:()=>[e.category.name]})}},dict:i({getData:async()=>(await w({page:1,limit:1e3,tenant_id:1})).data.items,label:"name",value:"id"}),form:{component:{placeholder:"请选择题目分类"},helper:"选择所属的分类"}},tags:{title:"标签",search:{show:!0,size:"small",col:{span:3},component:{props:{multiple:!1,filterable:!0,placeholder:"请选择标签搜索"}}},type:"dict-select",column:{minWidth:150,component:{name:"fs-component",render:({row:e})=>!e.tags||e.tags.length===0?t("span",null,[l("-")]):t("div",{style:"display: flex; flex-wrap: wrap; gap: 4px;"},[e.tags.map(s=>t(a("el-tag"),{key:s.id,type:"warning",effect:"plain",size:"mini"},{default:()=>[s.name]}))])}},dict:i({getData:async()=>(await _({page:1,limit:1e3,tenant_id:1})).data.items,label:"name",value:"id"}),form:{component:{props:{multiple:!0,filterable:!0,placeholder:"请选择标签"}},helper:"选择题目关联的标签,可多选"}},recommended_duration:{title:"建议时长(秒)",search:{show:!1},column:{minWidth:100},form:{value:60,component:{name:"el-input-number",props:{min:10,max:600,step:10}},helper:"建议回答此题目的时长,单位为秒"}},is_system:{title:"系统题目",search:{show:!1},type:"dict-select",column:{width:100},dict:i({data:[{value:!0,label:"是"},{value:!1,label:"否"}]}),form:{value:!1,component:{placeholder:"请选择是否为系统题目"},helper:"是否为系统预设题目"}},status:{title:"状态",search:{show:!0,size:"small",col:{span:2}},type:"dict-select",column:{width:80},dict:i({data:[{value:0,label:"停用"},{value:1,label:"启用"}]}),form:{value:1,rules:[{required:!0,message:"状态必填"}],component:{placeholder:"请选择状态"},helper:"题目的启用状态"}},is_required_correct:{title:"红线问题",search:{show:!0,size:"small",col:{span:2}},type:"dict-select",column:{width:100,component:{name:"fs-component",render:({row:e})=>e.question_form!==1&&e.question_form!==2?t("span",null,[l("-")]):e.is_required_correct?t(a("el-tag"),{type:"danger",size:"small"},{default:()=>[l("是")]}):t(a("el-tag"),{type:"info",size:"small"},{default:()=>[l("否")]})}},dict:i({data:[{value:!0,label:"是"},{value:!1,label:"否"}]}),form:{value:!1,show:u(({form:e})=>e&&(e.question_form===1||e.question_form===2)),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||e.question_form===4)),component:{name:"el-card",children:{default:({form:e})=>(e.options||(e.options=[]),e.question_form===4?t("div",null,[t("div",{class:"option-header",style:"display: flex; margin-bottom: 10px; font-weight: bold;"},[t("span",{style:"flex: 1;"},[l("选项内容")]),t("span",{style:"width: 120px; text-align: center;"},[l("分值")])]),e.options.map((s,n)=>t("div",{class:"option-item",key:n,style:"display: flex; align-items: center; margin-bottom: 10px;"},[t(a("el-input"),{modelValue:s.option_text,"onUpdate:modelValue":r=>s.option_text=r,placeholder:"请输入选项内容",style:"flex: 1; margin-right: 10px;"},null),t(a("el-input-number"),{modelValue:s.score,"onUpdate:modelValue":r=>s.score=r,min:0,max:10,style:"width: 120px;",placeholder:"分值"},null)])),t("div",{style:"display: flex; justify-content: space-between; margin-top: 10px;"},[t(a("el-button"),{type:"primary",onClick:()=>{e.options||(e.options=[]);const s=e.options.length>0?Math.max(...e.options.map(n=>n.sort||0))+1:1;e.options.push({option_text:"",score:0,sort:s})}},{default:()=>[l("添加选项")]}),e.options.length>2&&t(a("el-button"),{type:"danger",onClick:()=>{e.options.pop()}},{default:()=>[l("删除最后一项")]})])]):t("div",null,[t("div",{class:"option-header",style:"display: flex; margin-bottom: 10px; font-weight: bold;"},[t("span",{style:"flex: 1;"},[l("选项内容")]),t("span",{style:"width: 80px; text-align: center;"},[l("是否正确")])]),e.options.map((s,n)=>t("div",{class:"option-item",key:n,style:"display: flex; align-items: center; margin-bottom: 10px;"},[t(a("el-input"),{modelValue:s.option_text,"onUpdate:modelValue":r=>s.option_text=r,placeholder:"请输入选项内容",style:"flex: 1; margin-right: 10px;"},null),t(a("el-tooltip"),{content:"设置为正确答案",placement:"top",effect:"light"},{default:()=>[t("div",{onClick:()=>{e.question_form===1?e.options.forEach((r,y)=>{r.is_correct=y===n}):s.is_correct=!s.is_correct},style:"cursor: pointer; width: 80px; text-align: center;"},[e.question_form===1?t(a("el-radio"),{modelValue:s.is_correct,label:!0},null):t(a("el-checkbox"),{modelValue:s.is_correct},null)])]})])),t("div",{style:"display: flex; justify-content: space-between; margin-top: 10px;"},[t(a("el-button"),{type:"primary",onClick:()=>{e.options||(e.options=[]);const s=e.options.length>0?Math.max(...e.options.map(n=>n.sort||0))+1:1;e.options.push({option_text:"",is_correct:!1,sort:s})}},{default:()=>[l("添加选项")]}),e.options.length>2&&t(a("el-button"),{type:"danger",onClick:()=>{e.options.pop()}},{default:()=>[l("删除最后一项")]})])]))}},helper:u(({form:e})=>e.question_form===1?"添加单选题的选项,并标记正确答案(只能有一个正确答案)":e.question_form===2?"添加多选题的选项,并标记正确答案(可以有多个正确答案)":e.question_form===4?"添加心理评估题的选项,并设置每个选项的分值":"")}},scoring_reference:{title:"评分标准",search:{show:!1},column:{show:!1},form:{component:{name:"el-input",type:"textarea",rows:4,placeholder:u(({form:e})=>(e&&e.question_form===4,"请输入评分标准说明"))},helper:u(({form:e})=>e&&e.question_form===4?"评分标准说明,例如:该评分反映了症状表现的频率与严重程度。":"题目的评分标准")}},digital_human_video_url:{title:"视频是否生成",search:{show:!1},column:{width:120,component:{name:"fs-component",render:({row:e})=>e.digital_human_video_url?t(a("el-tag"),{type:"success",size:"small"},{default:()=>[l("是")]}):t(a("el-tag"),{type:"info",size:"small"},{default:()=>[l("否")]})}},form:{show:!1}}},table:{selection:!0,onSelectionChange:e=>{o.selectedRows=e}}}}},W=p=>({batchUpdateTags:async(d,m)=>{try{(await R({question_ids:d,tags:m,tenant_id:1})).code===0&&(g("批量更新标签成功"),p.doRefresh())}catch(c){console.error("批量更新标签失败",c)}}}),G=p=>({batchUpdateCategory:async(d,m)=>{try{(await D({question_ids:d,category_id:m,tenant_id:"1"})).code===0&&(g("批量更新分类成功"),p.doRefresh())}catch(c){console.error("批量更新分类失败",c)}}});export{V as createCrudOptions,G as useBatchUpdateCategory,W as useBatchUpdateTags};