import { BasicColumn } from '/@/components/Table'; import { FormSchema } from '/@/components/Table'; import { rules } from '/@/utils/helper/validator'; import { render } from '/@/utils/common/renderUtils'; import { getWeekMonthQuarterYear } from '/@/utils'; import { getInsureList, getSprotProject } from '/@/api/common/api'; import { defHttp } from '/@/utils/http/axios'; import { getCoachList } from './courses.api'; import { useUserStore } from '/@/store/modules/user'; import ZtCustomTable from '/@/components/ZtCustomTable/index.vue'; import { h } from 'vue'; import { Business } from '../gymnasiumBag/gymnasiumBag.api'; import { storeToRefs } from 'pinia'; const { userInfo } = storeToRefs(useUserStore()); //列表数据 export const columns: BasicColumn[] = [ { title: '课程名称', align: 'center', dataIndex: 'name', }, { title: '课程封面', align: 'center', dataIndex: 'cover', slots: { customRender: 'img', }, }, { title: '课时节数及时间', align: 'center', dataIndex: 'totalNum', slots: { customRender: 'totalNum' }, }, { title: '上课地点', align: 'center', dataIndex: 'address', }, { title: '销售价/原价(元)', align: 'center', dataIndex: 'categoryId', slots: { customRender: 'price' }, }, { title: '上下架状态', align: 'center', dataIndex: 'rackingStatus', slots: { customRender: 'priceType' }, }, { title: '课程类型', align: 'center', dataIndex: 'categoryIds', }, ]; //查询数据 export const searchFormSchema: FormSchema[] = [ { field: 'name', label: '课程名称', component: 'Input', colProps: { span: 6 }, }, { field: '上下架状态', label: '上下架状态', component: 'Select', colProps: { span: 6 }, componentProps: { options: [ { label: '上架', value: 0 }, { label: '下架', value: 1 }, ], }, }, { field: 'coursesStatus', label: '课程进展', component: 'Select', colProps: { span: 6 }, componentProps: { options: [ { label: '全部', value: '' }, // 全部、未开始、正常上课中、休息中、补课中、已结束 { label: '未开始', value: 0 }, { label: '正常上课中', value: 1 }, { label: '休息中', value: 2 }, { label: '补课中', value: 3 }, { label: '已结束', value: 4 }, ], }, }, { field: 'categoryId', label: '课程类型', component: 'ApiSelect', colProps: { span: 6 }, componentProps: { api: () => defHttp.get({ url: '/app/appCategory/list' }), labelField: 'name', valueField: 'id', resultField: 'records', }, }, ]; //表单数据 export const formSchema: FormSchema[] = [ { label: 'title1', field: 'orgCode', colSlot: 'title1', component: 'Input', }, { label: '课程类型', field: 'categoryId', component: 'ApiSelect', required: true, componentProps: { api: getSprotProject, labelField: 'name', valueField: 'id', mode: 'tags', resultField: 'records', }, }, { label: '课程名称', required: true, field: 'name', component: 'Input', }, { label: '课程封面', field: 'cover', component: 'JImageUpload', componentProps: { tipText: '支持单张上传;宽高比为5:4,且宽高均大于480px,大小5M以内。', }, required: true, }, { label: '上课地点', field: 'addressSiteId', component: 'ApiSelect', required: true, componentProps: { api: Business, labelField: 'name', valueField: 'tenantId', params: { orgCode: 'A01', type: 0, }, }, }, { label: '教练', field: 'userId', component: 'ApiSelect', required: true, componentProps: { api: getCoachList, labelField: 'name', valueField: 'userId', params: { orgCode: useUserStore().userInfo?.orgCode }, }, }, { label: 'title2', field: 'title2', component: 'Input', colSlot: 'title2', }, { label: '原价', field: 'originalPrice', component: 'InputNumber', }, { label: '销售价', field: 'sellingPrice', component: 'InputNumber', required: true, }, { label: '限购', field: 'limitNum', required: true, component: 'InputNumber', componentProps: { addonBefore: '每人限制购买', addonAfter: '张', }, }, { label: '正常课表', field: 'priceRulesList', component: 'InputNumber', slot: 'ZtCustomTable1', required: true, }, { label: 'title3', field: 'sellingPrice', component: 'InputNumber', colSlot: 'title3', }, { label: '视频', field: 'video', component: 'JUpload', slot: 'VideoUpload', componentProps: { fileType: 'video', bizPath: 'video', }, }, { label: '图片', field: 'backgroundImage', component: 'JImageUpload', componentProps: { tipText: '支持单张上传;宽高比为5:4,且宽高均大于480px,大小5M以内。', }, required: true, }, { label: '使用须知', field: 'reminder', component: 'InputTextArea', required: true, }, { label: '配套保险', field: 'insureIds', component: 'ApiSelect', required: true, componentProps: { api: getInsureList, resultField: 'data', labelField: 'name', valueField: 'id', mode: 'multiple', }, }, { label: '图文详情', field: 'details', component: 'JEditor', required: true, }, { label: '上架状态', field: 'rackingStatus', component: 'Switch', required: true, componentProps: { //非选中时的内容 unCheckedChildren: '下架', //非选中时的值 unCheckedValue: 1, //选中时的内容 checkedChildren: '上架', //选中时的值 checkedValue: 0, }, defaultValue: 0, }, // TODO 主键隐藏字段,目前写死为ID { label: '', field: 'id', component: 'Input', show: false, }, ]; /** * 流程表单调用这个方法获取formSchema * @param param */ export function getBpmFormSchema(_formData): FormSchema[] { // 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema return formSchema; } export const publishcoursesColums: BasicColumn[] = [ { title: '时间段', dataIndex: 'time', editComponent: 'RangePicker', editRule: true, editComponentProps: { showTime: true, size: 'middle', placeholder: ['开始时间', '结束时间'], valueFormat: 'YYYY-MM-DD HH:mm:ss', }, width: 450, editRow: true, editable: true, }, { title: '课时名称', dataIndex: 'name', editComponent: 'Input', editRule: true, editRow: true, editable: true, width: 500, editComponentProps: { size: 'middle', }, }, { key: 'op', dataIndex: 'operation', title: 'operation', fixed: 'right', ellipsis: true, width: 80, }, ]; export const coursesForm: FormSchema[] = [ { label: '课程名称', field: 'name', component: 'Input', componentProps: { disabled: true, }, required: true, }, { label: '补课课表', field: 'dtoList', component: 'Input', required: true, render({ model, field }) { return h(ZtCustomTable, { tableColumn: [ { dataIndex: 'time', title: '时间', editComponent: 'RangePicker', editRule: true, editComponentProps: { placeholder: ['开始时间', '结束时间'], size: 'middle', valueFormat: 'YYYY-MM-DD HH:mm:ss', showTime: true, }, width: 350, editRow: true, editable: true, }, { dataIndex: 'name', title: '名称', editComponent: 'Input', editRule: true, editComponentProps: { size: 'middle', }, width: 350, editRow: true, editable: true, }, { dataIndex: 'operation', title: 'operation', fixed: 'right', }, ], value: model[field], showIndex: true, showAction: true, }); }, defaultValue: [], }, { label: '课程名称', field: 'id', component: 'Input', show: false, }, ];