index-BqZA3dMY.js 5.7 KB

1
  1. import{d as $,u as W,r as h,V as H,D as r,e as N,i as O,o as z,w as c,h as l,p as o,S as s,g as y,q as I,x as d,z as g,P as U}from"./index-5k_MqT6o.js";import{u as G,S as M,c as C,C as Q}from"./index-Cl9RbTBn.js";import{L as j}from"./index-BDlrU7am.js";import{u as b,C as _}from"./index-BfmhdFfx.js";import"./index-BHx7dntQ.js";import"./index-CAzgmO3A.js";const oe=$({__name:"index",setup(J){const{t:f}=W(),v=h(),i=h("zh"),m=h([]),p=h([]),{register:q,tableActions:n}=G({title:"问题管理",showSelection:!0,showExport:!1,immediate:!0,api:r.questionList,apiParams:{language_code:i.value},columns:[{prop:"id",label:"ID",width:50},{prop:"question",label:"问题"},{label:"答案",prop:"answer"},{prop:"category_name",label:"分类"},{prop:"question_type_text",label:"问题库类别"},{prop:"keyword_name",label:"索引关键词"},{prop:"index_count",label:"索引次数"},{prop:"like_count",label:"点赞次数"},{prop:"dislike_count",label:"点否次数"},{prop:"weight",label:"权重"},{prop:"status",label:"状态",tagEnums:M},{prop:"created_at",label:"新增时间",width:140}],schema:[{label:"问题/关键字",prop:"question",type:"input"},{label:"问题分类",prop:"category_id",type:"sync-select",api:r.categoryList,immediate:!0,syncOptions:{label:"name",value:"category_id"},props:{filterable:!0},options:[]},{label:"问题库类别",prop:"question_type",type:"select"},{label:"时间范围",prop:"range",type:"range-time-picker",props:{},rangeFields:["start","end"]}],showAction:H(180,190,200),actionProps:{width:200,btnList:[{perm:180,label:"编辑",click:e=>{w({title:"编辑"},t=>{t.setSchema("category_id","apiParams",{language_code:i.value}),t.setSchema("keyword_id","apiParams",{language_code:i.value}),t.setSchema("question_type","options",p.value),t.setSchema("language_code","options",C(m.value,"name","code").getEnums()),t.setFormModel(e.row)})}},{perm:190,slotName:"hideBtnSlot"},{perm:200,label:"删除",type:"danger",isPopConfirm:!0,popConfirmEmits:{confirm(e){return r.questionDelete({id:e.row.id}).then(()=>{n.reload()}),!0}}}]}}),[S,{open:w,getFormActions:K}]=b({successCallBack(){n.reload()},api:r.questionUpdate,formConfig:{schema:[{label:"",prop:"id",type:"input",notShow:!0},{label:"",prop:"question_id",type:"input",notShow:!0},{label:"分类",prop:"category_id",type:"sync-select",api:r.categoryList,immediate:!0,syncOptions:{label:"name",value:"category_id"},props:{filterable:!0},options:[],required:!0},{label:"问题库类别",prop:"question_type",type:"select",required:!0},{label:"权重",prop:"weight",type:"input",required:!0},{label:"问题",prop:"question",type:"input",props:{maxlength:60,showWordLimit:!0},required:!0},{label:"答案",prop:"answer",type:"input",props:{type:"textarea",maxlength:200,showWordLimit:!0},required:!0},{label:"关键词",prop:"keyword_id",type:"sync-select",api:r.keywordList,immediate:!0,syncOptions:{label:"name",value:"keyword_id"},props:{filterable:!0},options:[]},{label:"语种",prop:"language_code",type:"select",options:[],change({value:e,setSchema:t}){t("keyword_id","apiParams",{language_code:e}),t("category_id","apiParams",{language_code:e})}}]}}),[k,L]=b({submit(e,t,u){r.questionSetQuestionType({id:n.getSelectData().map(a=>a.id),question_type:e.question_type}).then(a=>{t(),n.reload()}).catch(()=>{u.value=!1})},successCallBack(){n.reload()},formConfig:{schema:[{label:"问题库类别",prop:"question_type",type:"select",required:!0}]}}),[R,P]=b({submit(e,t,u){r.questionSetWeight({id:n.getSelectData().map(a=>a.id),weight:e.weight}).then(a=>{t(),n.reload()}).catch(()=>{u.value=!1})},successCallBack(){n.reload()},formConfig:{schema:[{label:"权重",prop:"weight",type:"input",required:!0}]}});function B(){w({title:"新增"},e=>{e.setSchema("category_id","apiParams",{language_code:i.value}),e.setSchema("keyword_id","apiParams",{language_code:i.value}),e.setSchema("question_type","options",p.value),e.setSchema("language_code","options",C(m.value,"name","code").getEnums()),e.setValues("language_code",i.value)})}function D(e){r.questionSetStatus({id:e.id}).then(()=>{n.reload()})}function x(){L.open({title:"批量修改问题库类别"},e=>{e.setSchema("question_type","options",p.value)})}function E(){P.open({title:"批量修改权重"},e=>{})}function F(e){n.getData({language_code:i.value}),v.value.searchBoxRef.setSchema("category_id","apiParams",{language_code:i.value})}function T(){r.homeGetLanguageCode().then(e=>{m.value=e})}function V(e,t){p.value=e.questionTypeList,t.setSchema("question_type","options",p.value)}return T(),(e,t)=>{const u=N("el-popconfirm");return z(),O(U,null,{default:c(()=>[l(o(Q),{onRegister:o(q),onSetCallBack:V,ref_key:"tableRef",ref:v},{customHeader:c(({selectData:a})=>[t[1]||(t[1]=y("div",null,null,-1)),y("div",null,[d(l(s,{value:"添加问题",onClick:B},null,512),[[g,e.$perm(130)]]),d(l(s,{type:"default",value:"导入"},null,512),[[g,e.$perm(140)]]),d(l(s,{value:"导出",onClick:o(n).exportTableData},null,8,["onClick"]),[[g,e.$perm(150)]]),d(l(s,{disabled:!a.length,value:"批量修改问题库类别",onClick:x},null,8,["disabled"]),[[g,e.$perm(160)]]),d(l(s,{disabled:!a.length,value:"批量修改权重",onClick:E},null,8,["disabled"]),[[g,e.$perm(170)]])])]),formTop:c(()=>[y("div",null,[l(j,{modelValue:o(i),"onUpdate:modelValue":t[0]||(t[0]=a=>I(i)?i.value=a:null),languages:o(m),onLanguageChange:F},null,8,["modelValue","languages"])])]),hideBtnSlot:c(a=>[l(u,{title:(a.row.status===1?o(f)("确认要隐藏吗"):o(f)("确认显示"))+"?",onConfirm:X=>D(a.row)},{reference:c(()=>[l(s,{value:a.row.status===1?"隐藏":"显示",link:"",style:{margin:"0 10px"}},null,8,["value"])]),_:2},1032,["title","onConfirm"])]),_:1},8,["onRegister"]),l(o(_),{onRegister:o(S)},null,8,["onRegister"]),l(o(_),{onRegister:o(k)},null,8,["onRegister"]),l(o(_),{onRegister:o(R)},null,8,["onRegister"])]),_:1})}}});export{oe as default};