import { BasicColumn, FormSchema } from '/@/components/Table'; import { requestMagicApi } from '/@/api/magicApi'; import { getDataOption } from '/@/api/system/dic'; import { getSubjectGroupInfo } from '/@/services/apis/SubjectGroupController'; import { getTextbookInfoByissn } from '/@/services/apis/TextbookController'; import { getMajorSetOption } from '/@/api/userMagic'; export const type = { 0: '菜单', 1: '目录', }; export const TableColumns: BasicColumn[] = [ { title: '书号(ISSN)', dataIndex: 'issn', customRender: ({ text }) => { return text ? text : '/'; }, }, { title: '书名', dataIndex: 'bookName', customRender: ({ text }) => { return text ? text : '/'; }, }, { title: '出版社', dataIndex: 'publishingHouse', customRender: ({ text }) => { return text ? text : '/'; }, }, { title: '作者(主编)', dataIndex: 'editorInChief', customRender: ({ text }) => { return text ? text : '/'; }, }, { title: '学科组', dataIndex: 'groupName', customRender: ({ text }) => { return text ? text : '/'; }, }, // { // title: '使用学期', // dataIndex: 'semesterName', // customRender: ({ text }) => { // return text ? text : '/'; // }, // }, // { // title: '使用班级', // dataIndex: 'useClass', // customRender: ({ text }) => { // return text ? text : '/'; // }, // }, { title: '对应课程', dataIndex: 'courseName', customRender: ({ text }) => { return text ? text : '/'; }, }, { title: '规划教材', dataIndex: 'isTextbookPlanCn', customRender: ({ text }) => { return text ? text : '/'; }, }, { title: '类型', dataIndex: 'textbookTypeCn', customRender: ({ text }) => { return text ? text : '/'; }, }, { title: '规格型号', dataIndex: 'specificationsModels', customRender: ({ text }) => { return text ? text : '/'; }, }, { title: '估价(元)', dataIndex: 'appraisalPrice', customRender: ({ text }) => { return text ? text : '/'; }, }, { title: '定价(元)', dataIndex: 'price', customRender: ({ text }) => { return text ? text : '/'; }, }, { title: '折扣(折)', dataIndex: 'discount', customRender: ({ text }) => { return text ? text : '/'; }, }, { title: '小计(元)', dataIndex: 'subtotal', customRender: ({ text }) => { return text ? text : '/'; }, }, { title: '库存(本、册)', dataIndex: 'stock', customRender: ({ text }) => { return text ? text : '/'; }, }, { title: '操作', dataIndex: 'action', width: 220, fixed: 'right', slots: { customRender: 'action' }, }, ]; export const formSchema: FormSchema[] = [ { field: 'id', component: 'Input', label: 'id', show: false, }, { label: '书号', field: 'issn', component: 'Input', componentProps: ({ formModel, formActionType }) => { return { onBlur: async (_) => { if (!formModel.issn) { return false; } const data = await getTextbookInfoByissn({ issn: formModel.issn }); data && formActionType.setFieldsValue(Object.keys(data).length ? data : {}); await formActionType.setFieldsValue({ classId: data.textbookClassRelationList.map((item) => item.classId), }); }, }; }, required: true, colProps: { span: 12 }, }, { label: '书名', field: 'bookName', component: 'Input', required: true, colProps: { span: 12 }, }, { label: '类型', field: 'textbookType', component: 'ApiSelect', componentProps: { api: getDataOption, params: { code: 'textbook_type' }, }, required: true, colProps: { span: 12 }, }, { label: '出版社名称', field: 'publishingHouse', component: 'Input', required: true, colProps: { span: 12 }, }, { label: '作者(主编)', field: 'editorInChief', component: 'Input', required: true, colProps: { span: 12 }, }, { label: '规划教材', field: 'isTextbookPlan', component: 'ApiSelect', componentProps: { api: getDataOption, params: { code: 'judgment_method_1' }, }, required: true, colProps: { span: 12 }, }, { label: '定价(元)', field: 'price', component: 'InputNumber', defaultValue: 0, required: true, componentProps: ({ formModel }) => { return { min: 0, onChange: (e) => { if (e !== 0) { formModel.discount = ((formModel.subtotal / e) * 10).toFixed(1); } else { formModel.discount = 0; } }, }; }, colProps: { span: 12 }, }, { label: '估价(元)', field: 'appraisalPrice', component: 'InputNumber', componentProps: { min: 0, }, colProps: { span: 12 }, }, { label: '使用类型', field: 'useType', component: 'Select', required: true, componentProps: { options: [ { label: '一学期', value: 1 }, { label: '二学期', value: 2 }, { label: '三学期', value: 3 }, { label: '四学期', value: 4 }, { label: '五学期', value: 5 }, { label: '六学期', value: 6 }, ], }, colProps: { span: 12 }, }, { field: 'subtotal', label: '小计(元)', component: 'InputNumber', defaultValue: 0, required: true, colProps: { span: 12 }, componentProps: ({ formModel }) => { return { min: 0, onChange: (e) => { if (!e) { return false; } if (formModel.price !== 0) { formModel.discount = ((e / formModel.price) * 10).toFixed(1); } else { formModel.discount = 0; } }, }; }, }, { label: '折扣(折)', field: 'discount', component: 'InputNumber', componentProps: ({ formModel }) => { return { onChange: (e) => { if (e < 1) { e = 1; } if (e > 10) { e = 10; } if (formModel.price && formModel.subtotal) { formModel.subtotal = (formModel.price * e).toFixed(2); } }, }; }, dynamicDisabled: true, colProps: { span: 12 }, }, { label: '学科组', field: 'subjectGroupId', component: 'ApiSelect', required: true, ifShow: ({ values }) => { return values.textbookType == 't_textbook'; }, componentProps: { api: requestMagicApi, params: { url: '/educational/subjectGroup/list' }, }, colProps: { span: 12 }, }, { label: '对应课程', field: 'courseSubjectId', required: true, component: 'ApiSelect', ifShow: ({ values }) => { return values.textbookType == 't_textbook'; }, componentProps: ({ formModel }) => { return { api: async () => { if (!formModel.subjectGroupId) { return []; } const data = await getSubjectGroupInfo({ id: formModel.subjectGroupId }); return data.subjectGroupCourseList.map((item) => { return { label: item.courseSubjectIdCN, value: item.courseSubjectId, }; }); }, showSearch: true, // 搜索参考 filterOption: (input, option) => { return ( option?.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 || option?.value.toLowerCase().indexOf(input.toLowerCase()) >= 0 ); }, }; }, colProps: { span: 12 }, }, // { // label: '使用年级', // field: 'gradeId', // component: 'ApiSelect', // componentProps: { // api: requestMagicApi, // params: { url: '/baseData/grade/option' }, // }, // colProps: { span: 12 }, // }, // { // label: '使用班级', // field: 'classId', // required: true, // component: 'ApiSelect', // componentProps: ({ formModel }) => { // return { // api: requestMagicApi, // params: { // url: `educational/class/gradeid?grade_id=${formModel.gradeId ? formModel.gradeId : ''}`, // }, // showSearch: true, // mode: 'multiple', // // 搜索参考 // filterOption: (input, option) => { // return ( // option?.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 || // option?.value.toLowerCase().indexOf(input.toLowerCase()) >= 0 // ); // }, // }; // }, // colProps: { span: 12 }, // }, // { // label: '使用学期', // field: 'baseSemesterId', // component: 'ApiSelect', // required: true, // componentProps: { // api: requestMagicApi, // params: { url: 'baseData/semester/option' }, // }, // colProps: { span: 12 }, // }, ]; export const searchFormSchema: FormSchema[] = [ { label: '教材类型', field: 'textbookType', component: 'ApiSelect', componentProps: { getPopupContainer: () => document.body, api: getDataOption, params: { code: 'textbook_type' }, }, colProps: { span: 6 }, }, { label: '学期', field: 'baseSemesterId', component: 'ApiSelect', componentProps: { getPopupContainer: () => document.body, api: requestMagicApi, params: { url: 'baseData/semester/option' }, }, colProps: { span: 6 }, }, { label: '学科组', field: 'subjectGroupId', component: 'ApiSelect', componentProps: { getPopupContainer: () => document.body, api: requestMagicApi, params: { url: '/educational/subjectGroup/list' }, }, colProps: { span: 6 }, }, { label: '书号', field: 'issn', component: 'Input', colProps: { span: 6 }, }, { label: '书名', field: 'bookName', component: 'Input', colProps: { span: 6 }, }, // { // label: '出版社名称', // field: 'publishingHouse', // component: 'Input', // colProps: { span: 6 }, // }, { field: 'majorSetId', label: '专业方向', component: 'ApiSelect', componentProps: ({}) => { return { getPopupContainer: () => document.body, api: getMajorSetOption, }; }, colProps: { span: 6 }, }, // { // label: '作者(主编)', // field: 'editorInChief', // component: 'Input', // colProps: { span: 6 }, // }, { label: '规划教材', field: 'isTextbookPlan', component: 'ApiSelect', componentProps: { getPopupContainer: () => document.body, api: getDataOption, params: { code: 'judgment_method_1' }, }, colProps: { span: 6 }, }, { label: '对应课程', field: 'courseSubjectId', component: 'ApiSelect', componentProps: ({ formModel }) => { return { getPopupContainer: () => document.body, api: async () => { if (!formModel.subjectGroupId) { return []; } const data = await getSubjectGroupInfo({ id: formModel.subjectGroupId }); return data.subjectGroupCourseList.map((item) => { return { label: item.courseSubjectIdCN, value: item.courseSubjectId, }; }); }, showSearch: true, // 搜索参考 filterOption: (input, option) => { return ( option?.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 || option?.value.toLowerCase().indexOf(input.toLowerCase()) >= 0 ); }, }; }, colProps: { span: 6 }, }, // { // label: '使用年级', // field: 'gradeId', // component: 'ApiSelect', // componentProps: { // getPopupContainer: () => document.body, // api: requestMagicApi, // params: { url: '/baseData/grade/option' }, // }, // colProps: { span: 6 }, // }, // { // label: '使用班级', // field: 'classId', // component: 'ApiSelect', // componentProps: ({ formModel }) => { // return { // getPopupContainer: () => document.body, // api: requestMagicApi, // params: { url: `educational/class/gradeid?grade_id=${formModel.gradeId}` }, // showSearch: true, // mode: 'multiple', // // 搜索参考 // filterOption: (input, option) => { // return ( // option?.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 || // option?.value.toLowerCase().indexOf(input.toLowerCase()) >= 0 // ); // }, // }; // }, // colProps: { span: 6 }, // }, ]; export const pushFormSchema: FormSchema[] = [ { field: 'textbookId', component: 'Input', label: '教材管理编号', show: false, }, { field: 'issn', label: '书号', component: 'Input', dynamicDisabled: true, colProps: { span: 24 }, }, { field: 'bookName', label: '书名', component: 'Input', required: true, dynamicDisabled: true, colProps: { span: 24 }, }, { field: 'stock', label: '库存', component: 'Input', defaultValue: 0, dynamicDisabled: true, colProps: { span: 24 }, }, { field: 'warehouseNumber', label: '入库数量', component: 'InputNumber', componentProps: ({ formModel }) => { return { min: 0, onChange: (e) => { if (!e || !formModel.price) { formModel.totalPrice = undefined; return false; } formModel.totalPrice = ( e * formModel.price * (formModel.discount ? formModel.discount / 10 : 1) ).toFixed(2); }, }; }, required: true, colProps: { span: 24 }, }, { field: 'source', label: '来源', component: 'Input', required: true, colProps: { span: 24 }, }, { field: 'price', label: '单价', component: 'InputNumber', required: true, componentProps: ({ formModel }) => { return { min: 0, onChange: (e) => { if (!e || !formModel.warehouseNumber) { formModel.totalPrice = undefined; return false; } formModel.totalPrice = ( e * formModel.warehouseNumber * (formModel.discount ? formModel.discount / 10 : 1) ).toFixed(2); }, }; }, colProps: { span: 24 }, }, { label: '折扣(折)', field: 'discount', component: 'InputNumber', colProps: { span: 24 }, componentProps: ({ formModel }) => { return { onChange: (e) => { if (e < 1) { e = 1; } if (e > 10) { e = 10; } if (!e || !formModel.warehouseNumber || !formModel.price) { formModel.totalPrice = undefined; return false; } formModel.totalPrice = ( formModel.price * formModel.warehouseNumber * (e ? e / 10 : 1) ).toFixed(2); }, }; }, }, { field: 'totalPrice', label: '总价(元)', component: 'InputNumber', componentProps: { min: 0, }, required: true, colProps: { span: 24 }, }, ]; export const infoEumns = { issn: '书号', bookName: '书名', textbookTypeCn: '类型', publishingHouse: '出版社', editorInChief: '作者(主编)', isTextbookPlanCn: '是否为规划教材', price: '定价(元)', appraisalPrice: '估价(元)', discount: '折扣(折)', stock: '库存', }; export const textbookInfoEumns = { groupName: '对应学科组', courseName: '对应课程', useGrade: '使用年级', useClass: '使用班级', }; export const SubscriptionsColumns: BasicColumn[] = [ { title: '征订时间', dataIndex: 'createDate', }, { title: '征订人', dataIndex: 'applicantUser', }, { title: '书号(ISSN)', dataIndex: 'issn', }, { title: '书名', dataIndex: 'bookName', }, { title: '出版社', dataIndex: 'publishingHouse', }, { title: '作者(主编)', dataIndex: 'editorInChief', }, { title: '学科组', dataIndex: 'subjectGroupIdCN', }, { title: '使用年级', dataIndex: 'gradeName', }, { title: '使用班级', dataIndex: 'useClass', }, { title: '对应课程', dataIndex: 'courseName', }, { title: '规划教材', dataIndex: 'isTextbookPlanCn', }, { title: '估价(元)', dataIndex: 'appraisalPrice', }, { title: '学生用书征订数量', dataIndex: 'studentSubscriptionNumber', }, { title: '教师教材用书征订数量', dataIndex: 'teacherSubscriptionNumber', }, { title: '教师教参用书征订数量', dataIndex: 'teacherReferenceNumber', }, { title: '有无配套资源', dataIndex: 'isSupportResourcesCn', }, ]; export const pushListColumns: BasicColumn[] = [ { title: '入库时间', dataIndex: 'warehouseDate', }, { title: '入库数量', dataIndex: 'warehouseNumber', }, { title: '入库人员', dataIndex: 'warehouseUser', }, { title: '来源', dataIndex: 'source', customRender: ({ text }) => { return text ? text : '/'; }, }, ]; export const popListColumns: BasicColumn[] = [ { title: '出库时间', dataIndex: 'issueDate', }, { title: '出库数量', dataIndex: 'issueNumber', }, { title: '出库方式', dataIndex: 'issueMode', }, { title: '出库人员', dataIndex: 'issueUser', }, { title: '去处', dataIndex: 'remark', customRender: ({ text }) => { return text ? text : '/'; }, }, ]; export const receiveColumns: BasicColumn[] = [ { title: '领取时间', dataIndex: 'claimDate', }, { title: '领取人身份', dataIndex: 'claimIdentity', }, { title: '班级', dataIndex: 'className', }, { title: '领取人员', dataIndex: 'name', }, { title: '学期', dataIndex: 'semesterName', }, { title: '学号/工号', dataIndex: 'userName', }, ];