This commit is contained in:
parent
6ffc7bb71f
commit
1ee118ed66
59
src/components/MomentCategories.tsx
Normal file
59
src/components/MomentCategories.tsx
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import { MyColumnsType } from '@/common';
|
||||||
|
import { Apis } from '@/gen/Apis';
|
||||||
|
import { ProColumns, ProFormColumnsType } from '@ant-design/pro-components';
|
||||||
|
|
||||||
|
type ReturnType = ProColumns<any, 'text'> & ProFormColumnsType<any, 'text'>;
|
||||||
|
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,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
@ -25,6 +25,7 @@ export function MyModal(props?: any) {
|
|||||||
<MyButtons.View
|
<MyButtons.View
|
||||||
title={props.title || '详情'}
|
title={props.title || '详情'}
|
||||||
type={props.type || 'primary'}
|
type={props.type || 'primary'}
|
||||||
|
size={props.size || 'small'}
|
||||||
onClick={() => setOpen(true)}
|
onClick={() => setOpen(true)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
77
src/components/TransferProject.tsx
Normal file
77
src/components/TransferProject.tsx
Normal file
@ -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<any[]>([]);
|
||||||
|
const [targetKeys, setTargetKeys] = useState<string[]>([]);
|
||||||
|
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 && (
|
||||||
|
<Transfer
|
||||||
|
dataSource={dataSource}
|
||||||
|
targetKeys={targetKeys}
|
||||||
|
onChange={(targetKeys) => {
|
||||||
|
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;
|
||||||
20
src/gen/ApiTypes.d.ts
vendored
20
src/gen/ApiTypes.d.ts
vendored
@ -475,6 +475,7 @@ declare namespace ApiTypes {
|
|||||||
"asset_houses_id"?: number; // 资产房屋id,[ref:asset_houses]
|
"asset_houses_id"?: number; // 资产房屋id,[ref:asset_houses]
|
||||||
"full_name"?: string; // 模糊搜索:房屋名称
|
"full_name"?: string; // 模糊搜索:房屋名称
|
||||||
"company_name"?: string; // 模糊搜索:公司名称
|
"company_name"?: string; // 模糊搜索:公司名称
|
||||||
|
"bill_status"?: string[]; // 账单状态,[enum:HouseBillsBillStatusEnum]
|
||||||
};
|
};
|
||||||
type SummaryBillList = {
|
type SummaryBillList = {
|
||||||
"full_name"?: string; // 模糊搜索:房屋名称
|
"full_name"?: string; // 模糊搜索:房屋名称
|
||||||
@ -511,6 +512,9 @@ declare namespace ApiTypes {
|
|||||||
type Show = {
|
type Show = {
|
||||||
"id": number; // id
|
"id": number; // id
|
||||||
};
|
};
|
||||||
|
type SummaryShow = {
|
||||||
|
"asset_houses_id": number; // 资产房屋id,[ref:asset_houses]
|
||||||
|
};
|
||||||
type SoftDelete = {
|
type SoftDelete = {
|
||||||
"id": number; // id
|
"id": number; // id
|
||||||
};
|
};
|
||||||
@ -1334,6 +1338,19 @@ declare namespace ApiTypes {
|
|||||||
"id": number; // id
|
"id": number; // id
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
namespace HouseMeterTaskDetails {
|
||||||
|
type List = {
|
||||||
|
"house_meter_task_id"?: number; // 仪表任务id,[ref:house_meter_tasks]
|
||||||
|
"full_name"?: string; // 房屋全称
|
||||||
|
"meter_name"?: string; // 仪表名称
|
||||||
|
};
|
||||||
|
type Show = {
|
||||||
|
"id": number; // id
|
||||||
|
};
|
||||||
|
type Delete = {
|
||||||
|
"id": number; // id
|
||||||
|
};
|
||||||
|
}
|
||||||
namespace HouseMeterTasks {
|
namespace HouseMeterTasks {
|
||||||
type List = {
|
type List = {
|
||||||
"name"?: string; // 模糊搜索:名称
|
"name"?: string; // 模糊搜索:名称
|
||||||
@ -1364,11 +1381,11 @@ declare namespace ApiTypes {
|
|||||||
"name"?: string; // 模糊搜索:名称
|
"name"?: string; // 模糊搜索:名称
|
||||||
"asset_projects_id"?: number; // 项目id,[ref:asset_projects]
|
"asset_projects_id"?: number; // 项目id,[ref:asset_projects]
|
||||||
"project_name"?: string; // 模糊搜索:项目名称
|
"project_name"?: string; // 模糊搜索:项目名称
|
||||||
|
"charge_standards_id"?: number; // 房屋收费标准id,[ref:house_charge_standards]
|
||||||
};
|
};
|
||||||
type Store = {
|
type Store = {
|
||||||
"asset_projects_id": number; // 项目id,[ref:asset_projects]
|
"asset_projects_id": number; // 项目id,[ref:asset_projects]
|
||||||
"charge_standards_id"?: number; // 房屋收费标准id,[ref:house_charge_standards]
|
"charge_standards_id"?: number; // 房屋收费标准id,[ref:house_charge_standards]
|
||||||
"companies_id": number; // 机构id,[ref:companies]
|
|
||||||
"name": string; // 名称
|
"name": string; // 名称
|
||||||
"meter_type": string; // 仪表类型,[enum:HouseMetersMeterTypeEnum]
|
"meter_type": string; // 仪表类型,[enum:HouseMetersMeterTypeEnum]
|
||||||
"usage_type": string; // 使用类型,[enum:HouseMetersUsageTypeEnum]
|
"usage_type": string; // 使用类型,[enum:HouseMetersUsageTypeEnum]
|
||||||
@ -1384,7 +1401,6 @@ declare namespace ApiTypes {
|
|||||||
"id": number; // id
|
"id": number; // id
|
||||||
"asset_projects_id": number; // 项目id,[ref:asset_projects]
|
"asset_projects_id": number; // 项目id,[ref:asset_projects]
|
||||||
"charge_standards_id"?: number; // 房屋收费标准id,[ref:house_charge_standards]
|
"charge_standards_id"?: number; // 房屋收费标准id,[ref:house_charge_standards]
|
||||||
"companies_id": number; // 机构id,[ref:companies]
|
|
||||||
"name": string; // 名称
|
"name": string; // 名称
|
||||||
"meter_type": string; // 仪表类型,[enum:HouseMetersMeterTypeEnum]
|
"meter_type": string; // 仪表类型,[enum:HouseMetersMeterTypeEnum]
|
||||||
"usage_type": string; // 使用类型,[enum:HouseMetersUsageTypeEnum]
|
"usage_type": string; // 使用类型,[enum:HouseMetersUsageTypeEnum]
|
||||||
|
|||||||
@ -266,6 +266,9 @@ export const Apis = {
|
|||||||
Show(data: ApiTypes.Bill.HouseBills.Show): Promise<MyResponseType> {
|
Show(data: ApiTypes.Bill.HouseBills.Show): Promise<MyResponseType> {
|
||||||
return request('admin/bill/house_bills/show', { data });
|
return request('admin/bill/house_bills/show', { data });
|
||||||
},
|
},
|
||||||
|
SummaryShow(data: ApiTypes.Bill.HouseBills.SummaryShow): Promise<MyResponseType> {
|
||||||
|
return request('admin/bill/house_bills/summary_show', { data });
|
||||||
|
},
|
||||||
SoftDelete(data: ApiTypes.Bill.HouseBills.SoftDelete): Promise<MyResponseType> {
|
SoftDelete(data: ApiTypes.Bill.HouseBills.SoftDelete): Promise<MyResponseType> {
|
||||||
return request('admin/bill/house_bills/soft_delete', { data });
|
return request('admin/bill/house_bills/soft_delete', { data });
|
||||||
},
|
},
|
||||||
@ -789,6 +792,17 @@ export const Apis = {
|
|||||||
return request('admin/meter/house_meter_readings/delete', { data });
|
return request('admin/meter/house_meter_readings/delete', { data });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
HouseMeterTaskDetails: {
|
||||||
|
List(data?: ApiTypes.Meter.HouseMeterTaskDetails.List): Promise<MyResponseType> {
|
||||||
|
return request('admin/meter/house_meter_task_details/list', { data });
|
||||||
|
},
|
||||||
|
Show(data: ApiTypes.Meter.HouseMeterTaskDetails.Show): Promise<MyResponseType> {
|
||||||
|
return request('admin/meter/house_meter_task_details/show', { data });
|
||||||
|
},
|
||||||
|
Delete(data: ApiTypes.Meter.HouseMeterTaskDetails.Delete): Promise<MyResponseType> {
|
||||||
|
return request('admin/meter/house_meter_task_details/delete', { data });
|
||||||
|
},
|
||||||
|
},
|
||||||
HouseMeterTasks: {
|
HouseMeterTasks: {
|
||||||
List(data?: ApiTypes.Meter.HouseMeterTasks.List): Promise<MyResponseType> {
|
List(data?: ApiTypes.Meter.HouseMeterTasks.List): Promise<MyResponseType> {
|
||||||
return request('admin/meter/house_meter_tasks/list', { data });
|
return request('admin/meter/house_meter_tasks/list', { data });
|
||||||
|
|||||||
@ -154,7 +154,7 @@ export const BannersTypeEnum= {
|
|||||||
|
|
||||||
// 缓存类型
|
// 缓存类型
|
||||||
export const CacheTypeEnum= {
|
export const CacheTypeEnum= {
|
||||||
'MobilePhoneVerificationCode': {"text":"手机验证码","color":"#0a9319","value":"MobilePhoneVerificationCode"},
|
'MobilePhoneVerificationCode': {"text":"手机验证码","color":"#b123bc","value":"MobilePhoneVerificationCode"},
|
||||||
};
|
};
|
||||||
|
|
||||||
// CompaniesMerchantTypeEnum
|
// CompaniesMerchantTypeEnum
|
||||||
@ -176,6 +176,12 @@ export const CompanyAppsModuleEnum= {
|
|||||||
'Customer': {"text":"客户端","color":"#10b981","value":"Customer"},
|
'Customer': {"text":"客户端","color":"#10b981","value":"Customer"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// CompanyAppsWorkTypeEnum
|
||||||
|
export const CompanyAppsWorkTypeEnum= {
|
||||||
|
'WorkWechatApp': {"text":"企微应用","color":"#00c853","value":"WorkWechatApp"},
|
||||||
|
'WorkWechat': {"text":"企微","color":"#0091ea","value":"WorkWechat"},
|
||||||
|
};
|
||||||
|
|
||||||
// CompanyEmployeeBacklogsStatusEnum
|
// CompanyEmployeeBacklogsStatusEnum
|
||||||
export const CompanyEmployeeBacklogsStatusEnum= {
|
export const CompanyEmployeeBacklogsStatusEnum= {
|
||||||
'Pending': {"text":"待办","color":"#FF6600","value":"Pending"},
|
'Pending': {"text":"待办","color":"#FF6600","value":"Pending"},
|
||||||
|
|||||||
69
src/pages/moments/classification/index.tsx
Normal file
69
src/pages/moments/classification/index.tsx
Normal file
@ -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 (
|
||||||
|
<MyPageContainer
|
||||||
|
title={title}
|
||||||
|
enableTabs={true}
|
||||||
|
tabKey="moments-classification"
|
||||||
|
tabLabel={title}
|
||||||
|
>
|
||||||
|
<ProTable
|
||||||
|
{...MyProTableProps.props}
|
||||||
|
expandable={{
|
||||||
|
defaultExpandAllRows: true,
|
||||||
|
}}
|
||||||
|
request={async (params, sort) =>
|
||||||
|
MyProTableProps.request(
|
||||||
|
params,
|
||||||
|
sort,
|
||||||
|
Apis.Customer.CustomerMomentCategories.List,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
toolBarRender={(action) => [
|
||||||
|
<Create key="Create" reload={action?.reload} title={title} />,
|
||||||
|
]}
|
||||||
|
columns={[
|
||||||
|
MyColumns.ID(),
|
||||||
|
{
|
||||||
|
title: '名称',
|
||||||
|
dataIndex: 'name',
|
||||||
|
},
|
||||||
|
MyColumns.UpdatedAt(),
|
||||||
|
MyColumns.CreatedAt(),
|
||||||
|
MyColumns.Option({
|
||||||
|
render: (_, item: any, index, action) => (
|
||||||
|
<Space key={index}>
|
||||||
|
<Update item={item} reload={action?.reload} title={title} />
|
||||||
|
<MyButtons.Delete
|
||||||
|
onConfirm={() =>
|
||||||
|
Apis.Customer.CustomerMomentCategories.Delete({
|
||||||
|
id: item.id,
|
||||||
|
}).then(() => action?.reload())
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</MyPageContainer>
|
||||||
|
);
|
||||||
|
}
|
||||||
38
src/pages/moments/classification/modals/Create.tsx
Normal file
38
src/pages/moments/classification/modals/Create.tsx
Normal file
@ -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 (
|
||||||
|
<BetaSchemaForm<ApiTypes.Customer.CustomerMomentCategories.Store>
|
||||||
|
{...MyModalFormProps.props}
|
||||||
|
title={`添加${props.title}`}
|
||||||
|
wrapperCol={{ span: 24 }}
|
||||||
|
width="500px"
|
||||||
|
trigger={<MyButtons.Create title={`添加${props.title}`} />}
|
||||||
|
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 },
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
51
src/pages/moments/classification/modals/Update.tsx
Normal file
51
src/pages/moments/classification/modals/Update.tsx
Normal file
@ -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 (
|
||||||
|
<BetaSchemaForm<ApiTypes.Customer.CustomerMomentCategories.Update>
|
||||||
|
{...MyModalFormProps.props}
|
||||||
|
title={`编辑${props.title}`}
|
||||||
|
trigger={<MyButtons.Edit />}
|
||||||
|
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 },
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
69
src/pages/moments/list/index.tsx
Normal file
69
src/pages/moments/list/index.tsx
Normal file
@ -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 (
|
||||||
|
<MyPageContainer
|
||||||
|
title={title}
|
||||||
|
enableTabs={true}
|
||||||
|
tabKey="moments-list"
|
||||||
|
tabLabel={title}
|
||||||
|
>
|
||||||
|
<ProTable
|
||||||
|
{...MyProTableProps.props}
|
||||||
|
expandable={{
|
||||||
|
defaultExpandAllRows: true,
|
||||||
|
}}
|
||||||
|
request={async (params, sort) =>
|
||||||
|
MyProTableProps.request(
|
||||||
|
params,
|
||||||
|
sort,
|
||||||
|
Apis.Customer.CustomerMoments.List,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
toolBarRender={(action) => [
|
||||||
|
<Create key="Create" reload={action?.reload} title={title} />,
|
||||||
|
]}
|
||||||
|
columns={[
|
||||||
|
MyColumns.ID(),
|
||||||
|
{
|
||||||
|
title: '名称',
|
||||||
|
dataIndex: 'name',
|
||||||
|
},
|
||||||
|
MyColumns.UpdatedAt(),
|
||||||
|
MyColumns.CreatedAt(),
|
||||||
|
MyColumns.Option({
|
||||||
|
render: (_, item: any, index, action) => (
|
||||||
|
<Space key={index}>
|
||||||
|
<Update item={item} reload={action?.reload} title={title} />
|
||||||
|
<MyButtons.Delete
|
||||||
|
onConfirm={() =>
|
||||||
|
Apis.Customer.CustomerMomentCategories.Delete({
|
||||||
|
id: item.id,
|
||||||
|
}).then(() => action?.reload())
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</MyPageContainer>
|
||||||
|
);
|
||||||
|
}
|
||||||
305
src/pages/moments/list/modals/Create.tsx
Normal file
305
src/pages/moments/list/modals/Create.tsx
Normal file
@ -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<any>({});
|
||||||
|
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: () => <MyTransferProject />,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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 (
|
||||||
|
<MyModal
|
||||||
|
title={`创建${props.title}`}
|
||||||
|
type="primary"
|
||||||
|
size={'middle'}
|
||||||
|
width="800px"
|
||||||
|
node={
|
||||||
|
<Space direction="vertical">
|
||||||
|
<Steps current={current} items={steps} />
|
||||||
|
<BetaSchemaForm<ApiTypes.Customer.CustomerMomentCategories.Store>
|
||||||
|
{...MyModalFormProps.props}
|
||||||
|
title={`添加${props.title}`}
|
||||||
|
wrapperCol={{ span: 24 }}
|
||||||
|
width="800px"
|
||||||
|
layoutType="Form"
|
||||||
|
trigger={<MyButtons.Create title={`添加${props.title}`} />}
|
||||||
|
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 (
|
||||||
|
<Space
|
||||||
|
style={{ display: 'flex', justifyContent: 'flex-end' }}
|
||||||
|
>
|
||||||
|
{current > 0 && (
|
||||||
|
<Button onClick={handlePrev}>上一步</Button>
|
||||||
|
)}
|
||||||
|
{current < steps.length - 1 ? (
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={() => props.form?.submit?.()}
|
||||||
|
>
|
||||||
|
下一步
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={() => props.form?.submit?.()}
|
||||||
|
>
|
||||||
|
提交
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</Space>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
51
src/pages/moments/list/modals/Update.tsx
Normal file
51
src/pages/moments/list/modals/Update.tsx
Normal file
@ -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 (
|
||||||
|
<BetaSchemaForm<ApiTypes.Customer.CustomerMomentCategories.Update>
|
||||||
|
{...MyModalFormProps.props}
|
||||||
|
title={`编辑${props.title}`}
|
||||||
|
trigger={<MyButtons.Edit />}
|
||||||
|
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 },
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user