crud.BYbUfmb1.js 18 KB

1
  1. import{ac as p,W as d,B as f,s as x}from"./index.BQUvI64x.js";import{a as C,G as k,b as z,c as T,d as U,D as V,U as R,A as D,e as B,f as O,B as W,g as j,h as G}from"./api.D-Pqh482.js";import{a as w}from"./authFunction.DdZbrv5n.js";import{S as t,P as o,aj as l,r as A,q as L,w as S}from"./vue.D1BjjNmv.js";const Q=function({crudExpose:m,context:c}){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=>(e.question&&(e.keyword=e.question,delete e.question),await O(e)),addRequest:async({form:e})=>{e.competency_tags&&e.competency_tags.length>0&&e.competency_tags_config?e.competency_tags=e.competency_tags_config.map(s=>({id:s.id,weight:s.weight||100,importance:s.importance||1,remark:s.remark||""})):e.competency_tags_config=[];let a;return e.question_form===6?a=await D(e):a=await B(e),a.code===2e3&&(e.question_form===0||e.question_form),a},editRequest:async({form:e,row:a})=>{e.id=a.id,e.competency_tags&&e.competency_tags.length>0&&e.competency_tags_config?e.competency_tags=e.competency_tags_config.map(n=>({id:n.id,weight:n.weight||100,importance:n.importance||1,remark:n.remark||""})):e.competency_tags_config=[];const s=await R(e);return s.code===2e3&&(e.question_form===0||e.question_form),s},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:w("role:Create")},batchBindTags:{text:"批量绑定标签",type:"primary",size:"small",show:!0,order:2,click:()=>{const e=c.selectedRows||[];if(console.log("选中的行:",e),!e||e.length===0){f("请先选择要操作的题目");return}c.openBatchTagsDialog(e)}},batchSetCategory:{text:"批量设置分类",type:"primary",show:!0,size:"small",order:3,click:()=>{const e=c.selectedRows||[];if(console.log("选中的行:",e),!e||e.length===0){f("请先选择要操作的题目");return}c.openBatchCategoryDialog(e)}},batchBindCompetencyTags:{text:"批量绑定胜任力标签",type:"primary",size:"small",show:!0,order:4,click:()=>{const e=c.selectedRows||[];if(!e||e.length===0){f("请先选择要操作的题目");return}c.openBatchCompetencyTagsDialog(e)}}}},rowHandle:{fixed:"right",width:259,buttons:{view:{show:!0,size:"small",icon:"View",type:"text"},edit:{show:w("role:Update"),size:"small",icon:"Edit",type:"text"},remove:{show:w("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},component:{name:"el-input",props:{placeholder:"请输入题目内容搜索",clearable:!0}}},column:{showOverflowTooltip:!0,width:300,sortable:"custom"},form:{rules:[{required:!0,message:"题目内容必填"}],component:{placeholder:"请输入题目内容"}}},competency_tags:{title:"胜任力标签",search:{show:!0,size:"small",component:{props:{multiple:!1,filterable:!0}},col:{span:3}},type:"dict-select",column:{minWidth:230,component:{name:"fs-component",render:({row:e})=>{if(!e.competency_tags||e.competency_tags.length===0)return t("span",null,[o("-")]);const a=e.competency_tags.slice(0,2),s=e.competency_tags.length-2;return t("div",{style:"display: flex; gap: 4px; align-items: center;"},[a.map(n=>t(l("el-tag"),{key:n.id,type:"warning",effect:"plain",size:"mini",style:"overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",title:n.name},{default:()=>[n.name.length>4?n.name.slice(0,4)+"...":n.name]})),s>0&&t(l("el-tooltip"),{placement:"top",effect:"light","popper-class":"tag-tooltip"},{default:()=>t(l("el-tag"),{type:"info",effect:"plain",size:"mini"},{default:()=>[o("+"),s]}),content:()=>t("div",null,[t("div",{style:"font-weight: bold; margin-bottom: 5px"},[o("剩余"),s,o("个标签:")]),e.competency_tags.slice(2).map(n=>t("div",{key:n.id,style:"margin: 3px 0"},[n.name]))])})])}}},dict:d({getData:async()=>{const e=await U({page:1,limit:100,tenant_id:1});return window.competencyTagsOptions=e.data.items||[],e.data.items},label:"name",value:"id"}),form:{component:{props:{multiple:!0,filterable:!0,placeholder:"请选择胜任力标签"},value:p(({form:e})=>e.competency_tags?(console.log("form.competency_tags",e.competency_tags),Array.isArray(e.competency_tags)?e.competency_tags.map(s=>typeof s=="object"&&s!==null?(e.competency_tags_config||(e.competency_tags_config=[],e.competency_tags=[]),e.competency_tags_config.find(i=>i.id===s.id)||(e.competency_tags_config.push({id:s.id,competency_name:s.name,weight:s.weight||100,importance:s.importance||1,remark:""}),e.competency_tags.push(s.id)),s.id):s):e.competency_tags):[]),onValueChange:({value:e,form:a})=>{a.competency_tags=e,a.competency_tags_config||(a.competency_tags_config=[]);const s=a.competency_tags_config.map(i=>i.id),n=window.competencyTagsOptions||[];e.forEach(i=>{if(!s.includes(i)){const y=n.find(_=>_.id===i);y&&a.competency_tags_config.push({id:i,competency_name:y.name,weight:y.weight||100,importance:y.importance||1,remark:""})}}),a.competency_tags_config=a.competency_tags_config.filter(i=>e.includes(i.id))}},helper:"选择题目关联的胜任力标签,可多选"}},competency_tags_config:{title:"胜任力配置",search:{show:!1},column:{show:!1},form:{show:p(({form:e})=>e&&e.competency_tags&&e.competency_tags.length>0),component:{name:"el-card",children:{default:({form:e})=>{e.competency_tags_config||(e.competency_tags_config=[]);const a=A(!1);L(()=>{!a.value&&e.competency_tags&&e.competency_tags.length>0&&(s(),a.value=!0)}),S(()=>[...e.competency_tags||[]],(n,i)=>{JSON.stringify(n)!==JSON.stringify(i)&&s()});const s=()=>{const n=e.competency_tags_config.map(u=>u.id),i=[...e.competency_tags_config],y=window.competencyTagsOptions||[];e.competency_tags.forEach(u=>{var b;if(!n.includes(u)){const v=((b=y.find(q=>q.id===u))==null?void 0:b.name)||"未知标签";i.push({id:u,competency_name:v,weight:100,importance:1,remark:""})}});const _=i.filter(u=>e.competency_tags.includes(u.id));e.competency_tags_config=_};return t("div",null,[t(l("el-table"),{border:!0,style:"width: 100%",data:e.competency_tags_config},{default:()=>[t(l("el-table-column"),{label:"标签",width:"200"},{default:({row:n})=>t("span",null,[n.competency_name])}),t(l("el-table-column"),{label:"权重",width:"100"},{default:({row:n})=>t("div",{class:"weight-input",style:"display: flex; align-items: center;"},[t(l("el-input-number"),{modelValue:n.weight,"onUpdate:modelValue":i=>n.weight=i,min:0,max:100,step:1,precision:0,controls:!1,style:"width: calc(100% - 20px)"},null),t("span",{style:"margin-left: 4px;"},[o("%")])])}),t(l("el-table-column"),{label:"级别",width:"100"},{default:({row:n})=>t(l("el-input-number"),{modelValue:n.importance,"onUpdate:modelValue":i=>n.importance=i,min:1,controls:!1,style:"width: 100%"},null)})]})])}}},helper:"配置每个胜任力标签的权重、重要性和备注"}},question_form:{title:"题目形式",search:{show:!0,size:"small",col:{span:3}},type:"dict-select",column:{minWidth:120},dict:d({getData:async()=>(await T()).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.question_form===6?(e.blank_answer_template=[{blank_index:1,correct_answer:"",score: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,maxTagCount:1},dict:d({getData:async()=>{const e=await z({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,[o("-")]):t(l("el-tag"),{key:e.category.id,type:"warning",effect:"plain",size:"mini",style:"overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"},{default:()=>[e.category.name.length>4?e.category.name.slice(0,4)+"...":e.category.name]})}},dict:d({getData:async()=>(await k({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:220,component:{name:"fs-component",render:({row:e})=>{if(!e.tags||e.tags.length===0)return t("span",null,[o("-")]);const a=e.tags.slice(0,2),s=e.tags.length-2;return t("div",{style:"display: flex; gap: 4px; align-items: center;"},[a.map(n=>t(l("el-tag"),{key:n.id,type:"warning",effect:"plain",size:"mini",style:"overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",title:n.name},{default:()=>[n.name.length>4?n.name.slice(0,4)+"...":n.name]})),s>0&&t(l("el-tooltip"),{placement:"top",effect:"light","popper-class":"tag-tooltip"},{default:()=>t(l("el-tag"),{type:"info",effect:"plain",size:"mini"},{default:()=>[o("+"),s]}),content:()=>t("div",null,[t("div",{style:"font-weight: bold; margin-bottom: 5px"},[o("剩余"),s,o("个标签:")]),e.tags.slice(2).map(n=>t("div",{key:n.id,style:"margin: 3px 0"},[n.name]))])})])}}},dict:d({getData:async()=>(await C({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:d({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:d({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,[o("-")]):e.is_required_correct?t(l("el-tag"),{type:"danger",size:"small"},{default:()=>[o("是")]}):t(l("el-tag"),{type:"info",size:"small"},{default:()=>[o("否")]})}},dict:d({data:[{value:!0,label:"是"},{value:!1,label:"否"}]}),form:{value:!1,show:p(({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:p(({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;"},[o("选项内容")]),t("span",{style:"width: 120px; text-align: center;"},[o("分值")])]),e.options.map((a,s)=>t("div",{class:"option-item",key:s,style:"display: flex; align-items: center; margin-bottom: 10px;"},[t(l("el-input"),{modelValue:a.option_text,"onUpdate:modelValue":n=>a.option_text=n,placeholder:"请输入选项内容",style:"flex: 1; margin-right: 10px;"},null),t(l("el-input-number"),{modelValue:a.score,"onUpdate:modelValue":n=>a.score=n,min:0,max:10,style:"width: 120px;",placeholder:"分值"},null)])),t("div",{style:"display: flex; justify-content: space-between; margin-top: 10px;"},[t(l("el-button"),{type:"primary",onClick:()=>{e.options||(e.options=[]);const a=e.options.length>0?Math.max(...e.options.map(s=>s.sort||0))+1:1;e.options.push({option_text:"",score:0,sort:a})}},{default:()=>[o("添加选项")]}),e.options.length>2&&t(l("el-button"),{type:"danger",onClick:()=>{e.options.pop()}},{default:()=>[o("删除最后一项")]})])]):t("div",null,[t("div",{class:"option-header",style:"display: flex; margin-bottom: 10px; font-weight: bold;"},[t("span",{style:"flex: 1;"},[o("选项内容")]),t("span",{style:"width: 80px; text-align: center;"},[o("是否正确")])]),e.options.map((a,s)=>t("div",{class:"option-item",key:s,style:"display: flex; align-items: center; margin-bottom: 10px;"},[t(l("el-input"),{modelValue:a.option_text,"onUpdate:modelValue":n=>a.option_text=n,placeholder:"请输入选项内容",style:"flex: 1; margin-right: 10px;"},null),t(l("el-tooltip"),{content:"设置为正确答案",placement:"top",effect:"light"},{default:()=>[t("div",{onClick:()=>{e.question_form===1?e.options.forEach((n,i)=>{n.is_correct=i===s}):a.is_correct=!a.is_correct},style:"cursor: pointer; width: 80px; text-align: center;"},[e.question_form===1?t(l("el-radio"),{modelValue:a.is_correct,label:!0},null):t(l("el-checkbox"),{modelValue:a.is_correct},null)])]})])),t("div",{style:"display: flex; justify-content: space-between; margin-top: 10px;"},[t(l("el-button"),{type:"primary",onClick:()=>{e.options||(e.options=[]);const a=e.options.length>0?Math.max(...e.options.map(s=>s.sort||0))+1:1;e.options.push({option_text:"",is_correct:!1,sort:a})}},{default:()=>[o("添加选项")]}),e.options.length>2&&t(l("el-button"),{type:"danger",onClick:()=>{e.options.pop()}},{default:()=>[o("删除最后一项")]})])]))}},helper:p(({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:p(({form:e})=>(e&&e.question_form===4,"请输入评分标准说明"))},helper:p(({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(l("el-tag"),{type:"success",size:"small"},{default:()=>[o("是")]}):t(l("el-tag"),{type:"info",size:"small"},{default:()=>[o("否")]})}},form:{show:!1}},blank_answer_template:{title:"填空答案模板",search:{show:!1},column:{show:!1},form:{show:p(({form:e})=>e&&e.question_form===6),component:{name:"el-card",children:{default:({form:e})=>{e.blank_answer_template||(e.blank_answer_template=[{blank_index:1,correct_answer:"",score:5}]);const a=(e.question||"").split("___").length-1;return a>0&&e.blank_answer_template.length!==a&&(e.blank_answer_template=Array.from({length:a},(s,n)=>({blank_index:n+1,correct_answer:"",score:5}))),t("div",null,[t("div",{class:"blank-header",style:"display: flex; margin-bottom: 10px; font-weight: bold;"},[t("span",{style:"width: 80px;"},[o("填空序号")]),t("span",{style:"flex: 1;"},[o("正确答案")]),t("span",{style:"width: 120px; text-align: center;"},[o("分值")])]),e.blank_answer_template.map((s,n)=>t("div",{class:"blank-item",key:n,style:"display: flex; align-items: center; margin-bottom: 10px;"},[t("span",{style:"width: 80px;"},[s.blank_index]),t(l("el-input"),{modelValue:s.correct_answer,"onUpdate:modelValue":i=>s.correct_answer=i,placeholder:"请输入正确答案",style:"flex: 1; margin: 0 10px;"},null),t(l("el-input-number"),{modelValue:s.score,"onUpdate:modelValue":i=>s.score=i,min:0,max:100,style:"width: 120px;",placeholder:"分值"},null)])),t("div",{style:"color: #666; font-size: 12px; margin-top: 10px;"},[o('提示:在题目中使用"___"(三个下划线)表示填空位置,系统会自动识别填空数量')])])}}},helper:"设置每个填空的正确答案和分值"}}},table:{selection:!0,onSelectionChange:e=>{c.selectedRows=e}}}}},F=m=>({batchUpdateTags:async(g,h)=>{try{(await W({question_ids:g,tags:h,tenant_id:1})).code===0&&(x("批量更新标签成功"),m.doRefresh())}catch(r){console.error("批量更新标签失败",r)}}}),H=m=>({batchUpdateCategory:async(g,h)=>{try{(await j({question_ids:g,category_id:h,tenant_id:"1"})).code===0&&(x("批量更新分类成功"),m.doRefresh())}catch(r){console.error("批量更新分类失败",r)}}}),I=m=>({batchUpdateCompetencyTags:async(g,h)=>{try{(await G({question_ids:g,competency_tags:h,tenant_id:1})).code===0&&(x("批量更新胜任力标签成功"),m.doRefresh())}catch(r){console.error("批量更新胜任力标签失败",r)}}});export{Q as createCrudOptions,H as useBatchUpdateCategory,I as useBatchUpdateCompetencyTags,F as useBatchUpdateTags};