123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992 |
- import { CreateCrudOptionsProps, CreateCrudOptionsRet, AddReq, DelReq, EditReq, dict, compute } from '@fast-crud/fast-crud';
- import * as api from './api';
- import { dictionary } from '/@/utils/dictionary';
- import { successMessage, warningMessage } from '../../../utils/message';
- import { auth } from '/@/utils/authFunction';
- import { ref, onMounted } from 'vue';
- import { ElMessage } from 'element-plus';
- /**
- *
- * @param crudExpose:index传递过来的示例
- * @param context:index传递过来的自定义参数
- * @returns
- */
- export const createCrudOptions = function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
- const pageRequest = async (query: any) => {
- return await api.GetList(query);
- };
- const editRequest = async ({ form, row }: EditReq) => {
- form.id = row.id;
- // 调用更新题目的接口
- const editResult = await api.UpdateObj(form);
-
- // 如果更新成功且题目形式为0(开放题)或5,调用数字人视频生成接口
- /* if (editResult.code === 2000 && (form.question_form === 0 || form.question_form === 5)) {
- try {
- // 构造视频生成请求参数
- const videoParams = {
- video_url: "http://data.qicai321.com/minlong/32ae7e1f-042f-4ee5-b234-be34d98d70e6.mp4",
- text: form.question, // 使用题目内容作为文本
- question_id: form.id, // 使用编辑的题目ID
- guidance_scale: 2.0, // 默认值
- inference_steps: 20, // 默认值
- seed: 1247
- };
- // 调用视频生成接口
- const videoResult = await fetch('http://192.168.66.101:7861/queue/process/text/', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(videoParams)
- });
- if (!videoResult.ok) {
- console.warn('数字人视频生成请求失败:', await videoResult.text());
- } else {
- // 只在成功时显示提示
- ElMessage({
- type: 'info',
- message: '题目已更新,数字人视频正在重新生成中...'
- });
- }
- } catch (error) {
- console.error('调用数字人视频生成接口失败:', error);
- // 这里我们只记录错误,不影响题目更新的成功状态
- }
- } */
- return editResult;
- };
- const delRequest = async ({ row }: DelReq) => {
- return await api.DelObj(row.id);
- };
- const addRequest = async ({ form }: AddReq) => {
- // 先调用添加题目的接口
- const addResult = await api.AddObj(form);
-
- // 如果添加成功且题目形式为0(开放题)或5,调用数字人视频生成接口
- /* if (addResult.code === 2000 && (form.question_form === 0 || form.question_form === 5)) {
- try {
- // 构造视频生成请求参数
- const videoParams = {
- video_url: "http://data.qicai321.com/minlong/32ae7e1f-042f-4ee5-b234-be34d98d70e6.mp4",
- text: form.question, // 使用题目内容作为文本
- question_id: addResult.data.id, // 使用新创建的题目ID
- guidance_scale: 2.0, // 默认值
- inference_steps: 20, // 默认值
- seed: 1247
- };
- // 调用视频生成接口
- const videoResult = await fetch('http://192.168.66.101:7861/queue/process/text/', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(videoParams)
- });
- if (!videoResult.ok) {
- console.warn('数字人视频生成请求失败:', await videoResult.text());
- } else {
- // 只在成功时显示提示
- ElMessage({
- type: 'info',
- message: '题目已创建,数字人视频正在生成中...'
- });
- }
- } catch (error) {
- console.error('调用数字人视频生成接口失败:', error);
- // 这里我们只记录错误,不影响题目创建的成功状态
- }
- } */
- return addResult;
- };
- /* // 修改分类和标签数据获取方式
- const categoryOptions = ref<Array<{value: number, label: string}>>([]);
- const tagOptions = ref<Array<{value: number, label: string}>>([]);
-
- // 获取分类数据
- const fetchCategories = async () => {
- try {
- const res = await api.GetcategoryList({page:1, limit:1000, tenant_id:1});
- if (res.code === 0 && res.data && res.data.items) {
- categoryOptions.value = res.data.items;
- }
- } catch (error) {
- console.error('获取分类数据失败', error);
- }
- };
-
- // 获取标签数据
- const fetchTags = async (categoryId?: number) => {
- try {
- const params = {
- page: 1,
- limit: 1000,
- tenant_id: 1
- };
- if (categoryId) {
- params.category_id = categoryId;
- }
- const res = await api.GetTagList(params);
- if (res.code === 0 && res.data && res.data.items) {
- tagOptions.value = res.data.items;
- }
- } catch (error) {
- console.error('获取标签数据失败', error);
- }
- }; */
-
- // 初始化时获取分类数据
- /* onMounted(() => {
- fetchCategories();
- fetchTags();
- }); */
- // 添加批量更新标签的方法
- const batchUpdateTags = async (questionIds: number[], tagIds: number[]) => {
- try {
- const res = await api.BatchUpdateTags({
- question_ids: questionIds,
- tags: tagIds,
- tenant_id: 1
- });
- if (res.code === 0) {
- successMessage('批量更新标签成功');
- // 刷新列表
- crudExpose.doRefresh();
- }
- } catch (error) {
- console.error('批量更新标签失败', error);
- }
- };
- // 添加批量更新分类的方法
- const batchUpdateCategory = async (questionIds: number[], categoryId: number) => {
- try {
- const res = await api.BatchUpdateCategory({
- question_ids: questionIds,
- category_id: categoryId,
- tenant_id: "1"
- });
- if (res.code === 0) {
- successMessage('批量更新分类成功');
- // 刷新列表
- crudExpose.doRefresh();
- }
- } catch (error) {
- console.error('批量更新分类失败', error);
- }
- };
- return {
- crudOptions: {
- toolbar:{
- buttons:{
- search:{show:false},
- // 刷新按钮
- refresh:{show:false},
- // 紧凑模式
- compact:{show:false},
- // 导出按钮
- export:{
- text: '导出',
- type: 'primary',
- size: 'small',
- icon: 'upload',
- circle: false,
- display: true
- },
- // 列设置按钮
- columns:{
- show:false
- },
- }
- },
- request: {
- pageRequest,
- addRequest,
- editRequest,
- delRequest,
- },
- pagination: {
- show: true,
- },
- // 添加搜索表单配置
- search: {
- show: true,
- buttons: {
- search: {
- size: 'small', // 设置查询按钮大小为small
- },
- reset: {
- size: 'small', // 设置重置按钮大小为small
- }
- }
- },
- actionbar: {
- buttons: {
- add: {
- size: 'small',
- show: auth('role:Create'),
- },
- // 添加批量绑定标签按钮
- batchBindTags: {
- text: '批量绑定标签',
- type: 'primary',
- size: 'small',
- show: true,
- order: 2,
- click: () => {
- // 使用存储的选中行
- const selection = context.selectedRows || [];
- console.log('选中的行:', selection);
-
- if (!selection || selection.length === 0) {
- warningMessage('请先选择要操作的题目');
- return;
- }
- // 打开批量绑定标签对话框
- context.openBatchTagsDialog(selection);
- },
- },
- // 添加批量设置分类按钮
- batchSetCategory: {
- text: '批量设置分类',
- type: 'primary',
- show: true,
- size: 'small',
- order: 3,
- click: () => {
- // 使用存储的选中行
- const selection = context.selectedRows || [];
- console.log('选中的行:', selection);
-
- if (!selection || selection.length === 0) {
- warningMessage('请先选择要操作的题目');
- return;
- }
- // 打开批量设置分类对话框
- context.openBatchCategoryDialog(selection);
- },
- },
- },
- },
- rowHandle: {
- //固定右侧
- fixed: 'right',
- width: 259,
- buttons: {
- view: {
- show: true,
- size: 'small',
- icon:"View",
- type: 'text',
- },
- edit: {
- show: auth('role:Update'),
- size: 'small',
- icon:"Edit",
- type: 'text',
- },
- remove: {
- show: auth('role:Delete'),
- size: 'small',
- type: 'text',
- icon:"Delete",
- },
- /* permission: {
- type: 'primary',
- text: '权限配置',
- show: auth('role:Permission'),
- click: (clickContext: any): void => {
- const { row } = clickContext;
- context.RoleDrawer.handleDrawerOpen(row);
- context.RoleMenuBtn.setState([]);
- context.RoleMenuField.setState([]);
- },
- }, */
- },
- },
- form: {
- col: { span: 24 },
- labelWidth: '100px',
- wrapper: {
- is: 'el-dialog',
- width: '600px',
- },
- },
- columns: {
- _selection: {
- title: '选择',
- form: { show: false },
- column: {
- type: 'selection',
- align: 'center',
- width: 50,
- fixed: 'left',
- columnSetDisabled: true,
- },
- },
- id: {
- title: 'ID',
- column: { show: true ,width:80,},
- search: { show: false },
- form: { show: false },
- },
- question: {
- title: '题目内容',
- search: {
- show: true,
- size: 'small',
- col:{ span:3},
- },
- column: {
- showOverflowTooltip: true, // 超出显示提示
- width: 300 ,// 固定列宽
- sortable: 'custom',
- },
- form: {
- rules: [{ required: true, message: '题目内容必填' }],
- component: {
- placeholder: '请输入题目内容',
- },
- },
- },
- /* question_type: {
- title: '问题类型',
- search: { show: true },
- type: 'dict-select',
- column: {
- minWidth: 100,
- },
- dict: dict({
- data: [
- { value: 1, label: '专业技能' },
- { value: 2, label: '通用能力' },
- { value: 3, label: '个人特质' }
- ]
- }),
- form: {
- rules: [{ required: true, message: '问题类型必填' }],
- component: {
- placeholder: '请选择问题类型',
- },
- helper: '选择问题的类型分类',
- },
- }, */
- question_form: {
- title: '题目形式',
- search: { show: true,
- size: 'small',
- col:{ span:3},
- },
- type: 'dict-select',
- column: {
- minWidth: 100,
- },
- dict: dict({
- // 使用API方式获取数据
- getData: async () => {
- const res = await api.GetQuestionTypeList();
- // 返回question_forms数组
- return res.data.question_forms || [];
- },
- label: 'label',
- value: 'value'
- }),
- form: {
- rules: [{ required: true, message: '题目形式必填' }],
- component: {
- placeholder: '请选择题目形式',
- onChange: ({ form }: { form: any }) => {
- // 重置相关字段
- if (form.question_form === 1) {
- // 单选题
- form.options = [{ option_text: '', is_correct: false, sort: 1 }, { option_text: '', is_correct: false, sort: 2 }];
- } else if (form.question_form === 2) {
- // 多选题
- form.options = [{ option_text: '', is_correct: false, sort: 1 }, { option_text: '', is_correct: false, sort: 2 }];
- } else if (form.question_form === 4) {
- // 得分题 - 初始化五个评分选项
- form.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 }
- ];
- // 初始化评分说明
- if (!form.scoring_reference) {
- form.scoring_reference = '该评分反映了症状表现的频率与严重程度。';
- }
- } else {
- // 开放问题
- form.options = [];
- }
- }
- },
- helper: '选择题目的形式:开放问题、单选题、多选题、色盲题或追加型开放问题',
- },
- },
- position_types: {
- title: '适用职位',
- search: { show: true,
- size: 'small',
- col:{ span:3}, },
- type: 'dict-select',
- column: {
- minWidth: 120,
- },
- dict: dict({
- getData: async () => {
- const res = await api.GetPositionList({page:1,limit:1000,tenant_id:1});
- console.log(res.data);
- return res.data || [];
- },
- label: 'title',
- value: 'id'
- }),
- form: {
- component: {
- /* name: 'el-select', */
- props: {
- multiple: true,
- filterable: true,
- placeholder: '请选择适用职位类型',
- /* options: [
- { value: '0', label: '技术' },
- { value: '1', label: '管理' },
- ] */
- }
- },
- helper: '选择题目适用的职位类型,可多选'
- }
- },
- category_id: {
- title: '分类',
- search: { show: true,
- size: 'small',
- col:{ span:2}, },
- type: 'dict-select',
- column: {
- minWidth: 120,
- component: {
- // 自定义渲染组件,显示彩色标签
- // name: 'fs-component',
- render: ({ row }: { row: any }) => {
- if (!row.category || row.category.length === 0) return <span>-</span>;
-
- return (
- <el-tag
- key={row.category.id}
- type="warning"
- effect="plain"
- size="mini"
- >
- {row.category.name}
- </el-tag>
- );
- }
- }
- },
- dict: dict({
- // 使用API方式获取数据
- getData: async () => {
- const res = await api.GetcategoryList({page:1, limit:1000, tenant_id:1});
- return res.data.items;
- },
- label: 'name',
- value: 'id'
- }),
- form: {
- // rules: [{ required: true, message: '题目分类必填' }],
- component: {
- placeholder: '请选择题目分类',
- /* onChange: ({ value }: { value: number }) => {
- // 当分类变化时,重新获取对应的标签
- fetchTags(value);
- } */
- },
- helper: '选择所属的分类'
- },
- },
- tags:{
- title: '标签',
- search: {
- show: true,
- size: 'small',
- col:{ span:3},
- component: {
- props: {
- multiple: false, // 在搜索表单中使用单选模式
- filterable: true,
- placeholder: '请选择标签搜索'
- }
- }
- },
- type: 'dict-select',
- column: {
- minWidth: 150,
- component: {
- // 自定义渲染组件,显示彩色标签
- name: 'fs-component',
- render: ({ row }: { row: any }) => {
- if (!row.tags || row.tags.length === 0) return <span>-</span>;
-
- return (
- <div style="display: flex; flex-wrap: wrap; gap: 4px;">
- {row.tags.map((tag: any) => (
- <el-tag
- key={tag.id}
- type="warning"
- effect="plain"
- size="mini"
- >
- {tag.name}
- </el-tag>
- ))}
- </div>
- );
- }
- }
- },
- dict: dict({
- // 使用API方式获取数据
- getData: async () => {
- const res = await api.GetTagList({page:1, limit:1000, tenant_id:1});
- return res.data.items;
- },
- label: 'name',
- value: 'id'
- }),
- form: {
- component: {
- props: {
- multiple: true, // 在编辑表单中保持多选
- filterable: true,
- placeholder: '请选择标签'
- }
- },
- helper: '选择题目关联的标签,可多选'
- }
- },
- recommended_duration: {
- title: '建议时长(秒)',
- search: { show: false },
- column: {
- minWidth: 100,
- },
- form: {
- value: 60,
- component: {
- name: 'el-input-number',
- props: {
- min: 10,
- max: 600,
- step: 10
- }
- },
- helper: '建议回答此题目的时长,单位为秒'
- }
- },
- /* difficulty: {
- title: '难度等级',
- search: { show: true },
- type: 'dict-select',
- column: {
- minWidth: 80,
- },
- dict: dict({
- data: [
- { value: 1, label: '初级' },
- { value: 2, label: '中级' },
- { value: 3, label: '高级' }
- ]
- }),
- form: {
- rules: [{ required: true, message: '难度等级必填' }],
- helper: '选择题目的难度级别'
- },
- }, */
- is_system: {
- title: '系统题目',
- search: { show: false },
- type: 'dict-select',
- column: {
- width: 100,
- /* component: {
- name: 'fs-component',
- render: ({ row }: { row: any }) => {
- return row.is_system ?
- <el-tag type="success" size="small">是</el-tag> :
- <el-tag type="info" size="small">否</el-tag>;
- }
- } */
- },
- dict: dict({
- data: [
- { value: true, label: '是' },
- { value: false, label: '否' }
- ]
- }),
- form: {
- value: false,
- component: {
- placeholder: '请选择是否为系统题目'
- },
- helper: '是否为系统预设题目'
- }
- },
- status: {
- title: '状态',
- search: { show: true,
- size: 'small',
- col:{ span:2},},
- type: 'dict-select',
- column: {
- width: 80,
- },
- dict: dict({
- data: [
- { value: 0, label: '停用' },
- { value: 1, label: '启用' }
- ]
- }),
- form: {
- value: 1,
- rules: [{ required: true, message: '状态必填' }],
- component: {
- placeholder: '请选择状态',
- },
- helper: '题目的启用状态'
- },
- },
- // 添加红线问题字段
- is_required_correct: {
- title: '红线问题',
- search: { show: true,
- size: 'small',
- col:{ span:2}, },
- type: 'dict-select',
- column: {
- width: 100,
- component: {
- name: 'fs-component',
- render: ({ row }: { row: any }) => {
- // 只有单选题和多选题才显示红线问题状态
- if (row.question_form !== 1 && row.question_form !== 2) {
- return <span>-</span>;
- }
- return row.is_required_correct ?
- <el-tag type="danger" size="small">是</el-tag> :
- <el-tag type="info" size="small">否</el-tag>;
- }
- }
- },
- dict: dict({
- data: [
- { value: true, label: '是' },
- { value: false, label: '否' }
- ]
- }),
- form: {
- value: false,
- show: compute(({ form }) => {
- // 只有单选题和多选题才显示红线问题选项
- return form && (form.question_form === 1 || form.question_form === 2);
- }),
- component: {
- placeholder: '请选择是否为红线问题'
- },
- helper: '红线问题是指必须回答正确的题目,否则可能导致面试失败'
- }
- },
- sort: {
- title: '排序',
- search: { show: false },
- column: {
- width: 80,
- },
- form: {
- component: {
- name: 'el-input-number',
- props: {
- min: 1,
- max: 999
- }
- },
- helper: '题目的排序值,值越小排序越靠前'
- }
- },
- option_items: {
- title: '选项列表',
- search: { show: false },
- column: { show: false },
- form: {
- show: compute(({ form }) => {
- return form && (form.question_form === 1 || form.question_form === 2 || form.question_form === 4);
- }),
- component: {
- name: 'el-card',
- children: {
- default: ({ form }: { form: any }) => {
- // 确保options数组已初始化
- if (!form.options) {
- form.options = [];
- }
-
- // 心理评估题的选项渲染
- if (form.question_form === 4) {
- return (
- <div>
- <div class="option-header" style="display: flex; margin-bottom: 10px; font-weight: bold;">
- <span style="flex: 1;">选项内容</span>
- <span style="width: 120px; text-align: center;">分值</span>
- </div>
- {form.options.map((option: any, index: number) => (
- <div class="option-item" key={index} style="display: flex; align-items: center; margin-bottom: 10px;">
- <el-input
- v-model={option.option_text}
- placeholder="请输入选项内容"
- style="flex: 1; margin-right: 10px;"
- />
- <el-input-number
- v-model={option.score}
- min={0}
- max={10}
- style="width: 120px;"
- placeholder="分值"
- />
- </div>
- ))}
- <div style="display: flex; justify-content: space-between; margin-top: 10px;">
- <el-button
- type="primary"
- onClick={() => {
- if (!form.options) {
- form.options = [];
- }
- const sort = form.options.length > 0 ?
- Math.max(...form.options.map((o: any) => o.sort || 0)) + 1 : 1;
- form.options.push({ option_text: '', score: 0, sort });
- }}
- >
- 添加选项
- </el-button>
-
- {form.options.length > 2 && (
- <el-button
- type="danger"
- onClick={() => {
- form.options.pop();
- }}
- >
- 删除最后一项
- </el-button>
- )}
- </div>
- </div>
- );
- }
-
- // 单选题和多选题的选项渲染(原有逻辑)
- return (
- <div>
- <div class="option-header" style="display: flex; margin-bottom: 10px; font-weight: bold;">
- <span style="flex: 1;">选项内容</span>
- <span style="width: 80px; text-align: center;">是否正确</span>
- </div>
- {form.options.map((option: any, index: number) => (
- <div class="option-item" key={index} style="display: flex; align-items: center; margin-bottom: 10px;">
- <el-input
- v-model={option.option_text}
- placeholder="请输入选项内容"
- style="flex: 1; margin-right: 10px;"
- />
- <el-tooltip
- content="设置为正确答案"
- placement="top"
- effect="light"
- >
- <div
- onClick={() => {
- if (form.question_form === 1) {
- // 单选题:只能有一个正确答案
- form.options.forEach((item: any, idx: number) => {
- item.is_correct = (idx === index);
- });
- } else {
- // 多选题:可以有多个正确答案
- option.is_correct = !option.is_correct;
- }
- }}
- style="cursor: pointer; width: 80px; text-align: center;"
- >
- {form.question_form === 1 ? (
- // 单选题使用单选按钮
- <el-radio
- modelValue={option.is_correct}
- label={true}
- />
- ) : (
- // 多选题使用复选框
- <el-checkbox
- modelValue={option.is_correct}
- />
- )}
- </div>
- </el-tooltip>
- </div>
- ))}
- <div style="display: flex; justify-content: space-between; margin-top: 10px;">
- <el-button
- type="primary"
- onClick={() => {
- // 确保options数组已初始化
- if (!form.options) {
- form.options = [];
- }
- // 添加新选项时自动设置排序值
- const sort = form.options.length > 0 ?
- Math.max(...form.options.map((o: any) => o.sort || 0)) + 1 : 1;
- form.options.push({ option_text: '', is_correct: false, sort });
- }}
- >
- 添加选项
- </el-button>
-
- {form.options.length > 2 && (
- <el-button
- type="danger"
- onClick={() => {
- form.options.pop();
- }}
- >
- 删除最后一项
- </el-button>
- )}
- </div>
- </div>
- )
- }
- }
- },
- helper: compute(({ form }) => {
- if (form.question_form === 1) {
- return '添加单选题的选项,并标记正确答案(只能有一个正确答案)';
- } else if (form.question_form === 2) {
- return '添加多选题的选项,并标记正确答案(可以有多个正确答案)';
- } else if (form.question_form === 4) {
- return '添加心理评估题的选项,并设置每个选项的分值';
- }
- return '';
- })
- }
- },
- scoring_reference: {
- title: '评分标准',
- search: { show: false },
- column: { show: false },
- form: {
- component: {
- name: 'el-input',
- type: 'textarea',
- rows: 4,
- placeholder: compute(({ form }) => {
- if (form && form.question_form === 4) {
- return '请输入评分标准说明';
- }
- return '请输入评分标准说明';
- })
- },
- helper: compute(({ form }) => {
- if (form && form.question_form === 4) {
- return '评分标准说明,例如:该评分反映了症状表现的频率与严重程度。';
- }
- return '题目的评分标准';
- })
- },
- },
- digital_human_video_url:{
- title: '视频是否生成',
- search: { show: false },
- column: {
- width: 120,
- component: {
- name: 'fs-component',
- render: ({ row }: { row: any }) => {
- return row.digital_human_video_url ?
- <el-tag type="success" size="small">是</el-tag> :
- <el-tag type="info" size="small">否</el-tag>;
- }
- }
- },
- form: {
- show: false // 在表单中不显示此字段,通常由系统自动生成
- }
- }
-
- },
- // 确保表格配置正确
- table: {
- selection: true,
- onSelectionChange: (selection: any[]) => {
- // 存储选中的行到一个全局变量中
- context.selectedRows = selection;
- },
- },
- },
- };
- };
- // 导出批量更新标签方法,供组件使用
- export const useBatchUpdateTags = (crudExpose: any) => {
- const batchUpdateTags = async (questionIds: number[], tagIds: number[]) => {
- try {
- const res = await api.BatchUpdateTags({
- question_ids: questionIds,
- tags: tagIds,
- tenant_id: 1
- });
- if (res.code === 0) {
- successMessage('批量更新标签成功');
- // 刷新列表
- crudExpose.doRefresh();
- }
- } catch (error) {
- console.error('批量更新标签失败', error);
- }
- };
-
- return { batchUpdateTags };
- };
- // 导出批量更新分类方法,供组件使用
- export const useBatchUpdateCategory = (crudExpose: any) => {
- const batchUpdateCategory = async (questionIds: number[], categoryId: number) => {
- try {
- const res = await api.BatchUpdateCategory({
- question_ids: questionIds,
- category_id: categoryId,
- tenant_id: "1"
- });
- if (res.code === 0) {
- successMessage('批量更新分类成功');
- // 刷新列表
- crudExpose.doRefresh();
- }
- } catch (error) {
- console.error('批量更新分类失败', error);
- }
- };
-
- return { batchUpdateCategory };
- };
|