diff --git a/src/components/MomentCategories.tsx b/src/components/MomentCategories.tsx new file mode 100644 index 0000000..8822f80 --- /dev/null +++ b/src/components/MomentCategories.tsx @@ -0,0 +1,59 @@ +import { MyColumnsType } 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 MomentSelect = { + MomentCategoriesTree(props?: PropsType): ReturnType { + const { ...rest } = props ?? {}; + return { + key: 'parent_id', + title: '上级分类', + valueType: 'treeSelect', + request: async () => { + return Apis.Customer.CustomerMomentCategories.SelectTree().then( + (res) => res.data, + ); + }, + fieldProps: { + allowClear: true, + autoClearSearchValue: true, + bordered: true, + fieldNames: { + label: 'name', + value: 'id', + }, + filterTreeNode: true, + showSearch: true, + treeNodeFilterProp: 'title', + treeDefaultExpandAll: true, + }, + ...rest, + }; + }, + MomentCategoriesSelect(props?: PropsType): MyColumnsType { + const { ...rest } = props ?? {}; + return { + title: '内容分类', + dataIndex: 'moment_categories_ids', + valueType: 'cascader', + request: async () => { + return Apis.Customer.CustomerMomentCategories.SelectTree().then( + (res) => res.data, + ); + }, + hideInTable: true, + fieldProps: { + showSearch: true, + placeholder: '请选择 / 输入名称搜索', + fieldNames: { + label: 'name', + value: 'id', + children: 'children', + }, + }, + ...rest, + }; + }, +}; diff --git a/src/components/MyModal.tsx b/src/components/MyModal.tsx index 53a5164..4e47799 100644 --- a/src/components/MyModal.tsx +++ b/src/components/MyModal.tsx @@ -25,6 +25,7 @@ export function MyModal(props?: any) { setOpen(true)} /> )} diff --git a/src/components/TransferProject.tsx b/src/components/TransferProject.tsx new file mode 100644 index 0000000..0ec9189 --- /dev/null +++ b/src/components/TransferProject.tsx @@ -0,0 +1,77 @@ +import { Apis } from '@/gen/Apis'; +import { Transfer } from 'antd'; +import { useEffect, useState } from 'react'; +const MyTransferProject = (props: any) => { + const [getLoading, setLoading] = useState(false); + const [dataSource, setTransferData] = useState([]); + const [targetKeys, setTargetKeys] = useState([]); + useEffect(() => { + Apis.Asset.AssetProjects.Select({}) + .then((res) => { + setLoading(true); + const data = + res.data?.map((item: any) => ({ + key: item.value?.toString(), + title: item.label, + })) || []; + setTransferData(data); + }) + .catch(() => { + setTransferData([]); + }); + }, []); + + useEffect(() => { + console.log(props.value, 'props.value'); + if (props.value?.length) { + setTargetKeys(props.value); + } + }, [props.value]); + + return ( + getLoading && ( + { + let dataIds: any = []; + console.log(targetKeys, 'targetKeys', props.value); + targetKeys?.forEach((res: any) => { + dataSource?.forEach((k: any) => { + if (res === k.key) { + dataIds?.push(k?.key); + } + }); + }); + setTargetKeys(targetKeys as string[]); + props?.onChange?.(dataIds); + }} + render={(item) => item.title} + titles={['可选项目', '已选项目']} + showSearch + listStyle={{ + width: 250, + height: 300, + }} + operations={['选择', '移除']} + operationStyle={{ marginTop: 20 }} + locale={{ + itemUnit: '项', + itemsUnit: '项', + searchPlaceholder: '请输入搜索内容', + notFoundContent: '列表为空', + }} + onSelectChange={(sourceSelectedKeys, targetSelectedKeys) => { + console.log( + sourceSelectedKeys, + targetSelectedKeys, + 'sourceSelectedKeys', + ); + // 处理选择变化,但不触发表单提交 + }} + /> + ) + ); +}; + +export default MyTransferProject; diff --git a/src/gen/ApiTypes.d.ts b/src/gen/ApiTypes.d.ts index fe79f13..9eb1a3f 100644 --- a/src/gen/ApiTypes.d.ts +++ b/src/gen/ApiTypes.d.ts @@ -475,7 +475,11 @@ declare namespace ApiTypes { "asset_houses_id"?: number; // 资产房屋id,[ref:asset_houses] "full_name"?: string; // 模糊搜索:房屋名称 "company_name"?: string; // 模糊搜索:公司名称 +<<<<<<< HEAD "bill_status"?: string; // 账单状态,[enum:HouseBillsBillStatusEnum] +======= + "bill_status"?: string[]; // 账单状态,[enum:HouseBillsBillStatusEnum] +>>>>>>> 1ee118ed66388333954dd06d50024c67750430d4 }; type SummaryBillList = { "full_name"?: string; // 模糊搜索:房屋名称 diff --git a/src/gen/Enums.ts b/src/gen/Enums.ts index cc50d7d..b00adc5 100644 --- a/src/gen/Enums.ts +++ b/src/gen/Enums.ts @@ -154,7 +154,11 @@ export const BannersTypeEnum= { // 缓存类型 export const CacheTypeEnum= { +<<<<<<< HEAD 'MobilePhoneVerificationCode': {"text":"手机验证码","color":"#262025","value":"MobilePhoneVerificationCode"}, +======= + 'MobilePhoneVerificationCode': {"text":"手机验证码","color":"#b123bc","value":"MobilePhoneVerificationCode"}, +>>>>>>> 1ee118ed66388333954dd06d50024c67750430d4 }; // CompaniesMerchantTypeEnum @@ -176,6 +180,12 @@ export const CompanyAppsModuleEnum= { 'Customer': {"text":"客户端","color":"#10b981","value":"Customer"}, }; +// CompanyAppsWorkTypeEnum +export const CompanyAppsWorkTypeEnum= { + 'WorkWechatApp': {"text":"企微应用","color":"#00c853","value":"WorkWechatApp"}, + 'WorkWechat': {"text":"企微","color":"#0091ea","value":"WorkWechat"}, +}; + // CompanyEmployeeBacklogsStatusEnum export const CompanyEmployeeBacklogsStatusEnum= { 'Pending': {"text":"待办","color":"#FF6600","value":"Pending"}, diff --git a/src/pages/moments/classification/index.tsx b/src/pages/moments/classification/index.tsx new file mode 100644 index 0000000..3f3b7b6 --- /dev/null +++ b/src/pages/moments/classification/index.tsx @@ -0,0 +1,69 @@ +import { + MyButtons, + MyColumns, + MyPageContainer, + MyProTableProps, + usePageTabs, +} from '@/common'; +import { Apis } from '@/gen/Apis'; +import { ProTable } from '@ant-design/pro-components'; +import { Space } from 'antd'; +import Create from './modals/Create'; +import Update from './modals/Update'; + +export default function Index({ title = '朋友圈分类' }) { + // 注册当前页面为标签页 + usePageTabs({ + tabKey: 'moments-classification', + tabLabel: title, + }); + + return ( + + + MyProTableProps.request( + params, + sort, + Apis.Customer.CustomerMomentCategories.List, + ) + } + toolBarRender={(action) => [ + , + ]} + columns={[ + MyColumns.ID(), + { + title: '名称', + dataIndex: 'name', + }, + MyColumns.UpdatedAt(), + MyColumns.CreatedAt(), + MyColumns.Option({ + render: (_, item: any, index, action) => ( + + + + Apis.Customer.CustomerMomentCategories.Delete({ + id: item.id, + }).then(() => action?.reload()) + } + /> + + ), + }), + ]} + /> + + ); +} diff --git a/src/pages/moments/classification/modals/Create.tsx b/src/pages/moments/classification/modals/Create.tsx new file mode 100644 index 0000000..edbcfa5 --- /dev/null +++ b/src/pages/moments/classification/modals/Create.tsx @@ -0,0 +1,38 @@ +import { + MyBetaModalFormProps, + MyButtons, + MyModalFormProps, + rulesHelper, +} from '@/common'; +import { MomentSelect } from '@/components/MomentCategories'; +import { Apis } from '@/gen/Apis'; +import { BetaSchemaForm } from '@ant-design/pro-components'; +import { message } from 'antd'; +export default function Create(props: MyBetaModalFormProps) { + return ( + + {...MyModalFormProps.props} + title={`添加${props.title}`} + wrapperCol={{ span: 24 }} + width="500px" + trigger={} + onFinish={async (values) => + Apis.Customer.CustomerMomentCategories.Store(values) + .then(() => { + props.reload?.(); + message.success(props.title + '成功'); + return true; + }) + .catch(() => false) + } + columns={[ + MomentSelect.MomentCategoriesTree(), + { + key: 'name', + title: '分类名称', + formItemProps: { ...rulesHelper.text }, + }, + ]} + /> + ); +} diff --git a/src/pages/moments/classification/modals/Update.tsx b/src/pages/moments/classification/modals/Update.tsx new file mode 100644 index 0000000..90d16ba --- /dev/null +++ b/src/pages/moments/classification/modals/Update.tsx @@ -0,0 +1,51 @@ +import { + MyBetaModalFormProps, + MyButtons, + MyModalFormProps, + rulesHelper, +} from '@/common'; +import { MomentSelect } from '@/components/MomentCategories'; +import { Apis } from '@/gen/Apis'; +import { BetaSchemaForm } from '@ant-design/pro-components'; +import { Form, message } from 'antd'; +export default function Update(props: MyBetaModalFormProps) { + const [form] = Form.useForm(); + return ( + + {...MyModalFormProps.props} + title={`编辑${props.title}`} + trigger={} + wrapperCol={{ span: 24 }} + width="500px" + form={form} + onOpenChange={(open: any) => { + if (open && props.item) { + form.setFieldsValue({ + ...props.item, + roles_id: props.item?.roles?.map((item: any) => item.value), + }); + } + }} + onFinish={async (values) => + Apis.Customer.CustomerMomentCategories.Update({ + ...values, + id: props.item?.id ?? 0, + }) + .then(() => { + props.reload?.(); + message.success(props.title + '成功'); + return true; + }) + .catch(() => false) + } + columns={[ + MomentSelect.MomentCategoriesTree(), + { + key: 'name', + title: '分类名称', + formItemProps: { ...rulesHelper.text }, + }, + ]} + /> + ); +} diff --git a/src/pages/moments/list/index.tsx b/src/pages/moments/list/index.tsx new file mode 100644 index 0000000..84dfae9 --- /dev/null +++ b/src/pages/moments/list/index.tsx @@ -0,0 +1,69 @@ +import { + MyButtons, + MyColumns, + MyPageContainer, + MyProTableProps, + usePageTabs, +} from '@/common'; +import { Apis } from '@/gen/Apis'; +import { ProTable } from '@ant-design/pro-components'; +import { Space } from 'antd'; +import Create from './modals/Create'; +import Update from './modals/Update'; + +export default function Index({ title = '推送任务' }) { + // 注册当前页面为标签页 + usePageTabs({ + tabKey: 'moments-list', + tabLabel: title, + }); + + return ( + + + MyProTableProps.request( + params, + sort, + Apis.Customer.CustomerMoments.List, + ) + } + toolBarRender={(action) => [ + , + ]} + columns={[ + MyColumns.ID(), + { + title: '名称', + dataIndex: 'name', + }, + MyColumns.UpdatedAt(), + MyColumns.CreatedAt(), + MyColumns.Option({ + render: (_, item: any, index, action) => ( + + + + Apis.Customer.CustomerMomentCategories.Delete({ + id: item.id, + }).then(() => action?.reload()) + } + /> + + ), + }), + ]} + /> + + ); +} diff --git a/src/pages/moments/list/modals/Create.tsx b/src/pages/moments/list/modals/Create.tsx new file mode 100644 index 0000000..5e747ae --- /dev/null +++ b/src/pages/moments/list/modals/Create.tsx @@ -0,0 +1,305 @@ +import { + MyBetaModalFormProps, + MyButtons, + MyFormItems, + MyModalFormProps, + rulesHelper, +} from '@/common'; +import { MomentSelect } from '@/components/MomentCategories'; +import { MyModal } from '@/components/MyModal'; +import { Selects } from '@/components/Select'; +import MyTransferProject from '@/components/TransferProject'; +import { Apis } from '@/gen/Apis'; +import { + CustomerMomentsChannelEnum, + CustomerMomentsContentTypeEnum, + CustomerMomentsPushTypeEnum, + CustomerMomentsRangeTypeEnum, + CustomerMomentsTaskEndTypeEnum, +} from '@/gen/Enums'; +import { BetaSchemaForm } from '@ant-design/pro-components'; +import { Button, message, Space, Steps } from 'antd'; +import { useState } from 'react'; +export default function Create(props: MyBetaModalFormProps) { + const [current, setCurrent] = useState(0); + const [formData, setFormData] = useState({}); + const steps = [ + { + title: '创建任务', + columns: [ + MyFormItems.EnumRadio({ + key: 'channel', + title: '发送渠道', + valueEnum: CustomerMomentsChannelEnum, + required: true, + }), + Selects?.Companies({ + key: 'companies_id', + title: '公司', + colProps: { span: 24 }, + required: true, + }), + MomentSelect.MomentCategoriesSelect({ + title: '内容分类', + formItemProps: { ...rulesHelper.array }, + }), + { + valueType: 'group', + colProps: { span: 24 }, + columns: [ + MyFormItems.EnumRadio({ + key: 'push_type', + title: '推送类型', + valueEnum: CustomerMomentsPushTypeEnum, + required: true, + colProps: { span: 8 }, + }), + { + name: ['push_type'], + valueType: 'dependency', + columns: ({ push_type }: any) => { + return push_type === 'ScheduledPush' + ? [ + { + key: 'scheduled_time', + title: '定时发送时间', + valueType: 'dateTime', + colProps: { span: 10 }, + }, + ] + : []; + }, + }, + ], + }, + { + valueType: 'group', + colProps: { span: 24 }, + columns: [ + MyFormItems.EnumRadio({ + key: 'task_end_type', + title: '任务结束类型', + valueEnum: CustomerMomentsTaskEndTypeEnum, + required: true, + colProps: { span: 8 }, + }), + { + name: ['task_end_type'], + valueType: 'dependency', + columns: ({ task_end_type }: any) => { + return task_end_type === 'AfterNDays' + ? [ + { + key: 'task_days', + title: '任务结束天数', + colProps: { span: 10 }, + valueType: 'number', + formItemProps: { ...rulesHelper.number }, + fieldProps: { + suffix: '天结束', + }, + }, + ] + : task_end_type === 'ScheduledEnd' + ? [ + { + key: 'task_end_time', + title: '定时结束', + valueType: 'dateTime', + formItemProps: { ...rulesHelper.text }, + colProps: { span: 10 }, + }, + ] + : []; + }, + }, + ], + }, + MyFormItems.EnumSelect({ + key: 'range_type', + title: '范围类型', + valueEnum: CustomerMomentsRangeTypeEnum, + required: true, + }), + + { + name: ['range_type'], + valueType: 'dependency', + columns: ({ range_type }: any) => { + return range_type === 'Project' + ? [ + { + key: 'range_data', + title: '选择范围', + colProps: { span: 24 }, + formItemProps: { ...rulesHelper.array }, + renderFormItem: () => , + }, + ] + : []; + }, + }, + ], + }, + { + title: '创建内容', + columns: [ + MyFormItems.EnumRadio({ + key: 'content_type', + title: '内容类型', + valueEnum: CustomerMomentsContentTypeEnum, + required: true, + colProps: { span: 24 }, + }), + + { + key: 'skip_url', + title: '链接', + formItemProps: { ...rulesHelper.text }, + colProps: { span: 12 }, + }, + { + key: 'title', + title: '标题', + formItemProps: { ...rulesHelper.text }, + colProps: { span: 12 }, + }, + { + name: ['content_type'], + valueType: 'dependency', + columns: ({ content_type }: any) => { + return content_type === 'MiniProgram' + ? [ + { + key: 'mini_program_app_id', + title: '小程序APPID', + formItemProps: { ...rulesHelper.text }, + colProps: { span: 24 }, + }, + ] + : []; + }, + }, + { + key: 'content', + title: '内容', + valueType: 'textarea', + colProps: { span: 24 }, + formItemProps: { ...rulesHelper.text }, + }, + { + key: 'desc', + title: '描述', + valueType: 'textarea', + colProps: { span: 24 }, + }, + MyFormItems.UploadImages({ + key: 'cover_image', + title: '封面', + max: 1, + }), + MyFormItems.UploadImages({ + key: 'attachments', + title: '附件', + uploadType: 'file', + max: 100, + colProps: { span: 12 }, + }), + ], + }, + ]; + + const handleNext = async () => { + // 这里可以添加表单验证逻辑 + if (current < steps.length - 1) { + setCurrent(current + 1); + } + }; + + // 处理上一步 + const handlePrev = () => { + if (current > 0) { + setCurrent(current - 1); + } + }; + + return ( + + + + {...MyModalFormProps.props} + title={`添加${props.title}`} + wrapperCol={{ span: 24 }} + width="800px" + layoutType="Form" + trigger={} + onFinish={async (values) => { + setFormData(values); + console.log('提交的数据2:', values); + if (current < steps.length - 1) { + handleNext(); + } else { + let data = { ...formData, ...values }; + Apis.Customer.CustomerMoments.Store({ + ...data, + one_moment_categories_id: formData?.moment_categories_ids[0], + two_moment_categories_id: formData?.moment_categories_ids[1], + }) + .then(() => { + props.reload?.(); + message.success(props.title + '成功'); + return true; + }) + .catch(() => false); + } + }} + // onFinish={async (values) => + // Apis.Customer.CustomerMomentCategories.Store(values) + // .then(() => { + // props.reload?.(); + // message.success(props.title + '成功'); + // return true; + // }) + // .catch(() => false) + // } + columns={steps[current].columns} + submitter={{ + render: (props, dom) => { + return ( + + {current > 0 && ( + + )} + {current < steps.length - 1 ? ( + + ) : ( + + )} + + ); + }, + }} + /> + + } + /> + ); +} diff --git a/src/pages/moments/list/modals/Update.tsx b/src/pages/moments/list/modals/Update.tsx new file mode 100644 index 0000000..90d16ba --- /dev/null +++ b/src/pages/moments/list/modals/Update.tsx @@ -0,0 +1,51 @@ +import { + MyBetaModalFormProps, + MyButtons, + MyModalFormProps, + rulesHelper, +} from '@/common'; +import { MomentSelect } from '@/components/MomentCategories'; +import { Apis } from '@/gen/Apis'; +import { BetaSchemaForm } from '@ant-design/pro-components'; +import { Form, message } from 'antd'; +export default function Update(props: MyBetaModalFormProps) { + const [form] = Form.useForm(); + return ( + + {...MyModalFormProps.props} + title={`编辑${props.title}`} + trigger={} + wrapperCol={{ span: 24 }} + width="500px" + form={form} + onOpenChange={(open: any) => { + if (open && props.item) { + form.setFieldsValue({ + ...props.item, + roles_id: props.item?.roles?.map((item: any) => item.value), + }); + } + }} + onFinish={async (values) => + Apis.Customer.CustomerMomentCategories.Update({ + ...values, + id: props.item?.id ?? 0, + }) + .then(() => { + props.reload?.(); + message.success(props.title + '成功'); + return true; + }) + .catch(() => false) + } + columns={[ + MomentSelect.MomentCategoriesTree(), + { + key: 'name', + title: '分类名称', + formItemProps: { ...rulesHelper.text }, + }, + ]} + /> + ); +}