From 3b8eefa933dded1428d4673d5923d935cab0facf Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 6 Mar 2025 17:22:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E8=A1=8C=E8=B6=8B=E5=8A=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.ts | 7 + .../FashionTrend/components/UpdateForm.tsx | 210 ++++++++++++++++ src/pages/FashionTrend/index.tsx | 226 ++++++++++++++++++ src/services/pop-b2b2c/errorController.ts | 30 +-- src/services/pop-b2b2c/index.ts | 2 + .../pop-b2b2c/pbcFashionTrendController.ts | 2 +- .../pbcPurchaseAgentInfoController.ts | 101 ++++++++ src/services/pop-b2b2c/typings.d.ts | 84 +++++++ 8 files changed, 646 insertions(+), 16 deletions(-) create mode 100644 src/pages/FashionTrend/components/UpdateForm.tsx create mode 100644 src/pages/FashionTrend/index.tsx create mode 100644 src/services/pop-b2b2c/pbcPurchaseAgentInfoController.ts diff --git a/config/routes.ts b/config/routes.ts index 6a53aa7..906f106 100644 --- a/config/routes.ts +++ b/config/routes.ts @@ -266,6 +266,13 @@ export default [ access: 'operateInstructionQuery', component: './OperatingInstructions', }, + { + name: '流行趋势', + path: '/fashion-trend', + icon: 'message', + access: 'fashionTrendQuery', + component: './FashionTrend', + }, { name: '广告设置', path: '/ad', diff --git a/src/pages/FashionTrend/components/UpdateForm.tsx b/src/pages/FashionTrend/components/UpdateForm.tsx new file mode 100644 index 0000000..8f02a20 --- /dev/null +++ b/src/pages/FashionTrend/components/UpdateForm.tsx @@ -0,0 +1,210 @@ +import React, { useRef, useState } from 'react'; +import { DrawerForm, ProFormInstance, ProFormText, ProFormUploadButton, ProFormRadio, ProFormTextArea } from '@ant-design/pro-components'; +import { message } from 'antd'; +import Upload, { RcFile } from 'antd/es/upload'; + +export type FormValueType = { + target?: string; + template?: string; + type?: string; + time?: string; + frequency?: string; +} & Partial; + +export type UpdateFormProps = { + onCancel: (flag?: boolean, formVals?: FormValueType) => void; + onSubmit: (values: FormValueType) => Promise; + updateModalVisible: boolean; + values: Partial; +}; + +const UpdateForm: React.FC = (props) => { + const formRef = useRef(); + const [pbcType, setPbcType] = useState(props.values.pbcType || 1) + + return ( + { + let pbcPicAddress = "" + if (value.pbcType === 1 && value.pbcImage.length > 0) { + pbcPicAddress = value.pbcImage.map((e: any) => { + return e.url || e.response.data; + }).join(','); + } else if (value.pbcType === 2 && value.pbcVideo.length > 0) { + pbcPicAddress = value.pbcVideo[0].url || value.pbcVideo[0].response.data; + } + return props.onSubmit({ ...value, pbcPicAddress, pbcId: props.values.pbcId }) + }} + drawerProps={{ + destroyOnClose: true, + }} + initialValues={{ + pbcTitle: props.values.pbcTitle, + pbcType: props.values.pbcType || 1, + pbcImage: props.values.pbcType === 1 && props.values.pbcPicAddress ? props.values.pbcPicAddress.split(',').map((e, index) => { + return { + uid: '-' + index, + name: e.substring(e.lastIndexOf('/') + 1), + status: 'done', + url: e, + } + }) : [], + pbcVideo: props.values.pbcType === 2 && props.values.pbcPicAddress ? [{ + uid: '-1', + name: props.values.pbcPicAddress.substring(props.values.pbcPicAddress.lastIndexOf('/') + 1), + status: 'done', + url: props.values.pbcPicAddress, + }] : [], + pbcContent: props.values.pbcContent + }} + onOpenChange={(visible) => { + formRef.current?.resetFields(); + if (!visible) { + props.onCancel(); + } + }} + > + + { + setPbcType(e.target.value) + formRef.current?.setFieldValue('pbcImage', []); + formRef.current?.setFieldValue('pbcVideo', []); + }, + }} + /> + {pbcType === 1 ? { + switch (info.file.status) { + case 'done': + if (info.file.response.retcode === 0) { + message.error(info.file.response.retmsg); + formRef.current?.setFieldValue('pbcContent', []) + } + break; + default: + break; + } + }, + action: process.env.BASE_URL + '/oss/imgUpload', + beforeUpload(file: RcFile) { + const isLt10M = file.size / 1024 / 1024 < 10; + if (!isLt10M) { + message.error('图片大小不能超过10MB!'); + } + return isLt10M || Upload.LIST_IGNORE; + }, + onPreview: async (file) => { + if (file.uid.includes('-')) { + window.open(file.url); + } + if (file.response && file.response.retcode) { + window.open(file.response.data); + } + }, + listType: 'picture-card', + }} + rules={[ + { required: true, message: '请上传图片' }, + ]} + /> : + { + switch (info.file.status) { + case 'done': + if (info.file.response.retcode === 0) { + message.error(info.file.response.retmsg); + formRef.current?.setFieldValue('pbcVideo', []) + } + break; + default: + break; + } + }, + action: process.env.BASE_URL + '/oss/imgUpload', + beforeUpload(file: RcFile) { + const isLt30M = file.size / 1024 / 1024 < 30; + if (!isLt30M) { + message.error('视频大小不能超过30MB!'); + } + return isLt30M || Upload.LIST_IGNORE; + }, + onPreview: async (file) => { + if (file.uid === '-1') { + window.open(file.url); + } + if (file.response && file.response.retcode) { + window.open(file.response.data); + } + }, + listType: 'picture-card', + }} + rules={[ + { required: true, message: '请上传视频' }, + ]} + />} + + + ); +}; + +export default UpdateForm; \ No newline at end of file diff --git a/src/pages/FashionTrend/index.tsx b/src/pages/FashionTrend/index.tsx new file mode 100644 index 0000000..02e7cf7 --- /dev/null +++ b/src/pages/FashionTrend/index.tsx @@ -0,0 +1,226 @@ +import { PlusOutlined } from '@ant-design/icons'; +import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; +import { PageContainer } from '@ant-design/pro-layout'; +import { Button, message, Popconfirm, Switch } from 'antd'; +import React, { useRef, useState } from 'react'; +import { Access, useAccess } from 'umi'; +import { getFashionTrendPageUsingPost, removeFashionTrendUsingGet, addOrUpdateFashionTrendUsingPost, changeFashionTrendStateUsingGet } from '@/services/pop-b2b2c/pbcFashionTrendController'; +import UpdateForm from './components/UpdateForm'; + +/** + * 查询表格 + * @param param0 + */ +const fetchData = async (params: API.PbcFashionTrend_) => { + const msg = await getFashionTrendPageUsingPost(params); + return { + data: msg.data?.records || [], + total: msg.data?.total, + success: msg.retcode, + } as any; +}; + +const handleUpdateState = async (id: number, state: number) => { + const hide = message.loading('正在保存'); + if (!id) return false; + try { + const msg = await changeFashionTrendStateUsingGet({ pbcId: id, pbcState: state }); + hide(); + if (msg.retcode) { + message.success(!id ? '新增成功!' : '保存成功!'); + return true; + } + message.error(msg.retmsg); + return false; + } catch (error) { + hide(); + message.error(!id ? '新增失败,请重试!' : '保存失败,请重试!'); + return false; + } +}; + +/** + * 删除节点 + * @param id + */ +const handleRemove = async (fields: API.PbcFashionTrend_) => { + const hide = message.loading('正在删除'); + if (!fields.pbcId) return false; + + try { + const msg = await removeFashionTrendUsingGet({ pbcId: fields.pbcId }); + hide(); + if (msg.retcode) { + message.success('删除成功,即将刷新'); + } else { + message.error(msg.retmsg ?? '删除失败,请重试'); + } + return true; + } catch (error) { + hide(); + message.error('删除失败,请重试'); + return false; + } +}; + +const TableList: React.FC = () => { + const access: any = useAccess(); + const actionRef = useRef(); + const [updateModalVisible, handleUpdateModalVisible] = useState(false); + const [stepFormValues, setStepFormValues] = useState({}); + + const handleAdd = async (fields: API.PbcFashionTrend_) => { + const hide = message.loading('正在提交'); + try { + const msg = await addOrUpdateFashionTrendUsingPost(fields); + hide(); + if (msg.retcode) { + message.success(!fields.pbcId ? '添加成功' : '更新成功'); + handleUpdateModalVisible(false); + actionRef.current?.reload(); + } else { + message.error(msg.retmsg ?? '操作失败,请重试'); + } + } catch (error) { + hide(); + message.error('操作失败,请重试'); + } + }; + + const columns: ProColumns[] = [ + { + title: '标题', + dataIndex: 'pbcTitle', + }, + { + title: '类型', + dataIndex: 'pbcType', + valueEnum: { + 1: '图片', + 2: '视频', + }, + }, + { + title: '创建时间', + dataIndex: 'pbcCreateAt', + valueType: 'date', + search: false, + }, + { + title: '操作', + valueType: 'option', + width: 180, + render: (text, record) => ( + + + { + const success = await handleUpdateState(record.pbcId || 0, value ? 1 : 2); + if (success) { + if (actionRef.current) { + actionRef.current.reload(); + } + } + }} + /> + + + + + + { + const success = await handleRemove(record); + if (success) actionRef.current?.reload(); + }} + > + + + + + ), + }, + ]; + return ( + + + columns={columns} + actionRef={actionRef} + request={fetchData} + rowKey="pbcId" + size="small" + bordered + search={{ + labelWidth: 'auto', + span: 6, + optionRender: ({ searchText }, { form }) => { + return [ + , + + + , + ]; + }, + }} + pagination={{ + defaultPageSize: 20, + showSizeChanger: true, + }} + scroll={{ + y: 'calc(100vh - 320px)', + }} + dateFormatter="string" + options={false} + toolBarRender={() => []} + /> + { + handleUpdateModalVisible(false); + setStepFormValues({}); + }} + updateModalVisible={updateModalVisible} + values={stepFormValues} + /> + + ); +}; + +export default TableList; diff --git a/src/services/pop-b2b2c/errorController.ts b/src/services/pop-b2b2c/errorController.ts index f29cc7f..5f0967b 100644 --- a/src/services/pop-b2b2c/errorController.ts +++ b/src/services/pop-b2b2c/errorController.ts @@ -2,41 +2,41 @@ /* eslint-disable */ import request from '@/utils/request'; -/** error GET /error */ -export async function errorUsingGet(options?: { [key: string]: any }) { - return request>('/error', { +/** errorHtml GET /error */ +export async function errorHtmlUsingGet(options?: { [key: string]: any }) { + return request('/error', { method: 'GET', ...(options || {}), }); } -/** error PUT /error */ -export async function errorUsingPut(options?: { [key: string]: any }) { - return request>('/error', { +/** errorHtml PUT /error */ +export async function errorHtmlUsingPut(options?: { [key: string]: any }) { + return request('/error', { method: 'PUT', ...(options || {}), }); } -/** error POST /error */ -export async function errorUsingPost(options?: { [key: string]: any }) { - return request>('/error', { +/** errorHtml POST /error */ +export async function errorHtmlUsingPost(options?: { [key: string]: any }) { + return request('/error', { method: 'POST', ...(options || {}), }); } -/** error DELETE /error */ -export async function errorUsingDelete(options?: { [key: string]: any }) { - return request>('/error', { +/** errorHtml DELETE /error */ +export async function errorHtmlUsingDelete(options?: { [key: string]: any }) { + return request('/error', { method: 'DELETE', ...(options || {}), }); } -/** error PATCH /error */ -export async function errorUsingPatch(options?: { [key: string]: any }) { - return request>('/error', { +/** errorHtml PATCH /error */ +export async function errorHtmlUsingPatch(options?: { [key: string]: any }) { + return request('/error', { method: 'PATCH', ...(options || {}), }); diff --git a/src/services/pop-b2b2c/index.ts b/src/services/pop-b2b2c/index.ts index ff21ab3..b8f9a0e 100644 --- a/src/services/pop-b2b2c/index.ts +++ b/src/services/pop-b2b2c/index.ts @@ -27,6 +27,7 @@ import * as pbcProductLabelConfigController from './pbcProductLabelConfigControl import * as pbcProductLabelConfigTypeController from './pbcProductLabelConfigTypeController'; import * as pbcProductLabelHotController from './pbcProductLabelHotController'; import * as pbcProductShopCartController from './pbcProductShopCartController'; +import * as pbcPurchaseAgentInfoController from './pbcPurchaseAgentInfoController'; import * as pbcQrController from './pbcQrController'; import * as pbcRecommendBusinessController from './pbcRecommendBusinessController'; import * as pbcRequirementController from './pbcRequirementController'; @@ -65,6 +66,7 @@ export default { pbcProductLabelConfigTypeController, pbcProductLabelHotController, pbcProductShopCartController, + pbcPurchaseAgentInfoController, pbcRecommendBusinessController, pbcRequirementController, pbcRequirementReplyController, diff --git a/src/services/pop-b2b2c/pbcFashionTrendController.ts b/src/services/pop-b2b2c/pbcFashionTrendController.ts index 687a9fe..8f87cea 100644 --- a/src/services/pop-b2b2c/pbcFashionTrendController.ts +++ b/src/services/pop-b2b2c/pbcFashionTrendController.ts @@ -91,7 +91,7 @@ export async function getFashionTrendPageUsingPost( ); } -/** h后台根据id删除单个趋势详情 GET /b2b2c/pbcFashionTrend/removeFashionTrend */ +/** 后台根据id删除单个趋势详情 GET /b2b2c/pbcFashionTrend/removeFashionTrend */ export async function removeFashionTrendUsingGet( // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) params: API.removeFashionTrendUsingGETParams, diff --git a/src/services/pop-b2b2c/pbcPurchaseAgentInfoController.ts b/src/services/pop-b2b2c/pbcPurchaseAgentInfoController.ts new file mode 100644 index 0000000..775fe89 --- /dev/null +++ b/src/services/pop-b2b2c/pbcPurchaseAgentInfoController.ts @@ -0,0 +1,101 @@ +// @ts-ignore +/* eslint-disable */ +import request from '@/utils/request'; + +/** 申请采购员,或者申请失败后编辑会重新审核,或者申请成功后编辑采购员资料 POST /b2b2c/pbcPurchaseAgentInfo/addOrUpdatePurchaseAgentInfo */ +export async function addOrUpdatePurchaseAgentInfoUsingPost( + body: API.PbcPurchaseAgentInfo_, + options?: { [key: string]: any }, +) { + return request( + '/b2b2c/pbcPurchaseAgentInfo/addOrUpdatePurchaseAgentInfo', + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }, + ); +} + +/** 后台获取申请采购员分页 分页 POST /b2b2c/pbcPurchaseAgentInfo/admin/getPurchaseAgentPage */ +export async function getPurchaseAgentPageForAdminUsingPost( + body: API.PbcPurchaseAgentInfo_, + options?: { [key: string]: any }, +) { + return request( + '/b2b2c/pbcPurchaseAgentInfo/admin/getPurchaseAgentPage', + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }, + ); +} + +/** 后台同意或者拒绝采购员申请 GET /b2b2c/pbcPurchaseAgentInfo/admin/judgePurchaseAgent */ +export async function judgePurchaseAgentForAdminUsingGet( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.judgePurchaseAgentForAdminUsingGETParams, + options?: { [key: string]: any }, +) { + return request('/b2b2c/pbcPurchaseAgentInfo/admin/judgePurchaseAgent', { + method: 'GET', + params: { + ...params, + }, + ...(options || {}), + }); +} + +/** 后台根据id获取采购员申请详情 后台 GET /b2b2c/pbcPurchaseAgentInfo/admin/purchaseAgentDetail */ +export async function purchaseAgentDetailForAdminUsingGet( + // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) + params: API.purchaseAgentDetailForAdminUsingGETParams, + options?: { [key: string]: any }, +) { + return request( + '/b2b2c/pbcPurchaseAgentInfo/admin/purchaseAgentDetail', + { + method: 'GET', + params: { + ...params, + }, + ...(options || {}), + }, + ); +} + +/** 买家获取申请采购员分页 分页 POST /b2b2c/pbcPurchaseAgentInfo/front/getPurchaseAgentPage */ +export async function getPurchaseAgentPageUsingPost( + body: API.PbcPurchaseAgentInfo_, + options?: { [key: string]: any }, +) { + return request( + '/b2b2c/pbcPurchaseAgentInfo/front/getPurchaseAgentPage', + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + ...(options || {}), + }, + ); +} + +/** 前端获取采购员申请详情 后台 GET /b2b2c/pbcPurchaseAgentInfo/purchaseAgentDetail */ +export async function purchaseAgentDetailUsingGet(options?: { [key: string]: any }) { + return request( + '/b2b2c/pbcPurchaseAgentInfo/purchaseAgentDetail', + { + method: 'GET', + ...(options || {}), + }, + ); +} diff --git a/src/services/pop-b2b2c/typings.d.ts b/src/services/pop-b2b2c/typings.d.ts index 08e548e..bb314e9 100644 --- a/src/services/pop-b2b2c/typings.d.ts +++ b/src/services/pop-b2b2c/typings.d.ts @@ -147,6 +147,12 @@ declare namespace API { retmsg?: string; }; + type AjaxResultIPagePbcPurchaseAgentInfo_ = { + data?: IPagePbcPurchaseAgentInfo_; + retcode?: number; + retmsg?: string; + }; + type AjaxResultIPagePbcRequirement_ = { data?: IPagePbcRequirement_; retcode?: number; @@ -489,6 +495,12 @@ declare namespace API { retmsg?: string; }; + type AjaxResultPbcPurchaseAgentInfo_ = { + data?: PbcPurchaseAgentInfo_; + retcode?: number; + retmsg?: string; + }; + type AjaxResultPbcRequirement_ = { data?: PbcRequirement_; retcode?: number; @@ -1075,6 +1087,14 @@ declare namespace API { total?: number; }; + type IPagePbcPurchaseAgentInfo_ = { + current?: number; + pages?: number; + records?: PbcPurchaseAgentInfo_[]; + size?: number; + total?: number; + }; + type IPagePbcRequirement_ = { current?: number; pages?: number; @@ -1165,6 +1185,13 @@ declare namespace API { type JSONObject = true; + type judgePurchaseAgentForAdminUsingGETParams = { + /** pbcId */ + pbcId: number; + /** pbcReviewStatus */ + pbcReviewStatus: number; + }; + type labelDetailForAdminUsingGETParams = { /** pbcId */ pbcId: number; @@ -2154,6 +2181,8 @@ declare namespace API { pbcScanCnt?: number; /** 状态,0是删除,1是正常,2是作废 */ pbcState?: number; + /** 缩略图 */ + pbcThumbNail?: string; /** 标题 */ pbcTitle?: string; /** 类型,1是图片,2是视频 */ @@ -3032,6 +3061,45 @@ declare namespace API { productCommonDataList?: PbcProductCommonData[]; }; + type PbcPurchaseAgentInfo_ = { + /** 创建时间 */ + pbcCreateAt?: string; + /** 创建人 */ + pbcCreateBy?: number; + /** 创建人 */ + pbcCreateByUserName?: string; + /** 主键 */ + pbcId?: number; + /** 年龄 */ + pbcPurchaseAgentAge?: number; + /** 擅长面料用途 */ + pbcPurchaseAgentFabricUse?: string; + /** 头像 */ + pbcPurchaseAgentImage?: string; + /** 联系电话 */ + pbcPurchaseAgentMobile?: string; + /** 采购员姓名 */ + pbcPurchaseAgentName?: string; + /** 常驻区域 */ + pbcPurchaseAgentResidentArea?: string; + /** 从业年数 */ + pbcPurchaseAgentWorkingAge?: number; + /** 审核状态,0是待审核,1是审核通过,2是审核被拒绝 */ + pbcReviewStatus?: number; + /** 状态,0是删除,1是正常,2是作废 */ + pbcState?: number; + /** 更新时间 */ + pbcUpdateAt?: string; + /** 更新人 */ + pbcUpdateBy?: number; + /** 更新人 */ + pbcUpdateByUserName?: string; + /** 申请人的userId,不需要传 */ + pbcUserId?: number; + /** 手机验证码 */ + pbcValidCode?: string; + }; + type PbcRecommendBusiness_ = { pbcBusiness?: PbcBusiness; /** 商户id */ @@ -3064,8 +3132,14 @@ declare namespace API { type PbcRequirement_ = { /** 当前页 */ current?: number; + /** 是否是指定小哥,0不是,1是 */ + isPrivate?: number; /** 条数 */ pageSize?: number; + /** 接纳的留言的id */ + pbcAdoptionRequirementReplyId?: number; + /** 接纳的用户id */ + pbcAdoptionUserId?: number; /** 审核状态,0表示审核中,1表示审核通过,2表示审核未通过 */ pbcApprovalStatus?: number; /** 需求预算,可以填入文字描述 */ @@ -3084,6 +3158,10 @@ declare namespace API { pbcId?: number; /** 需求图片 */ pbcImages?: string; + /** 采纳的采购员id,如果采纳的留言是采购员的话 */ + pbcPurchaseAgentId?: number; + /** 当类型是指定小哥时,必传 */ + pbcPurchaseAgentInfoList?: PbcPurchaseAgentInfo_[]; /** 状态,0是删除,1是正常,2是作废 */ pbcState?: number; /** 需求标题 */ @@ -3099,6 +3177,7 @@ declare namespace API { publishEndTime?: string; /** 后端使用,创建开始时间 */ publishStartTime?: string; + /** 不用传,返回的时候这个参数存放留言信息 */ replyList?: PbcRequirementReply_[]; }; @@ -3957,6 +4036,11 @@ declare namespace API { productId: number; }; + type purchaseAgentDetailForAdminUsingGETParams = { + /** pbcId */ + pbcId: number; + }; + type queryAuthorityUsingPOSTParams = { /** roleId */ roleId: number;