import { rulesHelper } from '@/common'; import { Apis } from '@/gen/Apis'; import { ProColumns, ProFormColumnsType } from '@ant-design/pro-components'; type ReturnType = ProColumns & ProFormColumnsType; type PropsType = { required?: boolean } & ReturnType; export const Selects = { Agents(props?: PropsType): ReturnType { const { title = '代理', key = 'agents_id', dataIndex = ['agent', 'name'], required = false, hideInTable = false, ...rest } = props ?? {}; return { title: title, key: key, dataIndex: dataIndex, valueType: 'select', hideInTable: hideInTable, formItemProps: { ...(required ? rulesHelper.number : {}) }, fieldProps: { showSearch: false, fieldNames: { label: 'name', value: 'id', }, }, request: async () => (await Apis.Select.Agents()).data, ...rest, }; }, LoanCompany(props?: PropsType): ReturnType { const { title = '资金方', key = 'loan_companies_id', dataIndex = ['loan_company', 'name'], required = false, hideInTable = false, ...rest } = props ?? {}; return { title: title, key: key, dataIndex: dataIndex, valueType: 'select', hideInTable: hideInTable, formItemProps: { ...(required ? rulesHelper.number : {}) }, fieldProps: { showSearch: false, fieldNames: { label: 'name', value: 'id', }, }, request: async () => (await Apis.Select.LoanCompanies()).data, ...rest, }; }, Markets(props?: PropsType): ReturnType { const { title = '选择上游', key = 'markets_id', dataIndex = ['market', 'name'], required = false, hideInTable = false, ...rest } = props ?? {}; return { title: title, key: key, dataIndex: dataIndex, valueType: 'select', hideInTable: hideInTable, formItemProps: { ...(required ? rulesHelper.number : {}) }, fieldProps: { showSearch: false, fieldNames: { label: 'name', value: 'id', }, }, request: async () => (await Apis.Select.Markets()).data, ...rest, }; }, Bosses(props?: PropsType): ReturnType { const { title = '老板', key = 'bosses_id', dataIndex = ['boss', 'name'], required = false, hideInTable = false, ...rest } = props ?? {}; return { title: title, key: key, dataIndex: dataIndex, valueType: 'select', hideInTable: hideInTable, formItemProps: { ...(required ? rulesHelper.number : {}) }, fieldProps: { showSearch: false, fieldNames: { label: 'name', value: 'id', }, }, request: async () => (await Apis.Select.Bosses()).data, ...rest, }; }, Factories(props?: PropsType): ReturnType { const { title = '下游厂家', key = 'factories_id', dataIndex = ['factory', 'name'], required = false, hideInTable = false, ...rest } = props ?? {}; return { title: title, key: key, dataIndex: dataIndex, valueType: 'select', hideInTable: hideInTable, formItemProps: { ...(required ? rulesHelper.number : {}) }, fieldProps: { showSearch: false, fieldNames: { label: 'name', value: 'id', }, }, request: async () => (await Apis.Select.Factories()).data, ...rest, }; }, Platforms(props?: PropsType): ReturnType { const { title = '平台', key = 'platforms_id', dataIndex = ['platform', 'name'], required = false, hideInTable = false, ...rest } = props ?? {}; return { title: title, key: key, dataIndex: dataIndex, valueType: 'select', hideInTable: hideInTable, formItemProps: { ...(required ? rulesHelper.number : {}) }, fieldProps: { showSearch: false, fieldNames: { label: 'name', value: 'id', }, }, request: async () => (await Apis.Select.Platforms()).data, ...rest, }; }, Merchants(props?: PropsType): ReturnType { const { title = '商户', key = 'merchants_id', dataIndex = ['merchant', 'name'], required = false, hideInTable = false, ...rest } = props ?? {}; return { title: title, key: key, dataIndex: dataIndex, valueType: 'select', hideInTable: hideInTable, formItemProps: { ...(required ? rulesHelper.number : {}) }, fieldProps: { showSearch: false, fieldNames: { label: 'name', value: 'id', }, }, request: async () => (await Apis.Select.Merchants()).data, ...rest, }; }, };