import { CreateCrudOptionsProps, CreateCrudOptionsRet, dict, compute } from '@fast-crud/fast-crud'; import * as api from '../../api'; import { ElMessage } from 'element-plus'; import { Session } from '/@/utils/storage'; export const createAsideCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet { const pageRequest = async (query: any) => { const params = { ...query, tenant_id: Session.get('tenant_id'), job_id: query.form?.job_id || '' }; return api.GetDocumentList(params); }; return { crudOptions: { request: { pageRequest }, actionbar: { buttons: { add: { show: true, click: () => { // 打开添加问题对话框 crudExpose.openAdd(); } } } }, rowHandle: { width: 300, buttons: { view: { size: 'small', icon: "View", type: 'text', click: ({ row }: any) => { const event = new CustomEvent('viewDocumentDetail', { detail: row }); window.dispatchEvent(event); } }, uploadVideo: { text: '上传视频', type: 'text', icon: "upload", size: 'small', click: ({ row }: any) => { const event = new CustomEvent('openVideoUploadDialog', { detail: row }); window.dispatchEvent(event); } }, edit: { type: 'text', icon: "Edit", size: 'small', }, remove: { type: 'text', icon: "Delete", size: 'small', }, sort: { type: 'text', icon: "sort", size: 'small', text: '修改排序', click: ({ row }: any) => { const event = new CustomEvent('openSortDialog', { detail: row }); window.dispatchEvent(event); } } } }, columns: { id: { title: 'ID', column: { show: true, width: 80 }, search: { show: false }, form: { show: false }, }, question: { title: '题目内容', search: { show: true }, column: { sortable: 'custom', showOverflowTooltip: true, width: 300 }, 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: '选择问题的类型分类' }, }, 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: '选择题目的难度级别' }, }, sequence_number: { title: '排序', search: { show: false }, column: { show: true }, form: { show: true }, }, digital_human_video_url: { title: '视频链接', search: { show: false }, column: { show: true, width: 120, formatter: ({ row }: any) => { return row.digital_human_video_url ? '已上传' : '未上传'; } }, form: { show: false }, }, digital_human_video_subtitle: { title: '字幕', search: { show: false }, column: { show: true, width: 120, formatter: ({ row }: any) => { return row.digital_human_video_subtitle ? '已上传' : '未上传'; } }, form: { show: false }, }, } } }; };