import { useState, useEffect } from 'react' import nothingImg from '../../static/appimgs/nothing.png' import { useLocation, useNavigate } from 'react-router-dom'; import { trademarkList, getFileTypeByIds, supplementTrademarkData } from '../../request/api' import { showImage, uploadFileUrl } from '../../request/request' import { UploadOutlined } from '@ant-design/icons'; import { Modal } from 'antd'; import type { TableProps, } from 'antd'; import { message, Spin, Pagination, Table, Image, Input, Form, Upload, Button } from 'antd'; const { TextArea } = Input; import { buySupplementList, supplementDetail } from '../../request/api' export default function TrademarkMall() { // 获取上传过的文件类型 const getUpFileTypeByIdsArray = async (ids: string) => { try { const res: any = await getFileTypeByIds({ ids: ids }) console.log(res); const newUpFile = res.map((item: any) => { return { uid: item.fileId, name: item.fileName, status: 'done', url: showImage(item.fileId, false) } }) // console.log(newUpFile, 'newUpFile'); setUpFileArray(newUpFile) } catch (error: any) { if (error.response) { const data = error.response.data; messageApi.open({ type: 'error', content: data.msg ? data.msg : `${data.path}(${data.status})`, }); } else { console.error(error) } } } const [trademarkId, setTrademarkId] = useState('') const getBuySupplementList = async (page: number, id: string) => { try { const res: any = await buySupplementList({ orderId: id, page: page, rows: 10 }) // setPage(res.page) // setTotal(res.total) // // console.log(res); // setData(res.rows) setCommunicationData(res.rows) setCommunicationTotal(res.total) setCommunicationPage(res.page) } catch (error: any) { if (error.response) { const data = error.response.data; messageApi.open({ type: 'error', content: data.msg ? data.msg : `${data.path}(${data.status})`, }); } else { console.error(error) } } } const token = sessionStorage.getItem('token') const [upFileArray, setUpFileArray] = useState([]) // 上传的文件数组 const [form] = Form.useForm(); const [modal, setModal] = useState(false) // 自定义验证函数 const validateContentOrFile = (_rule: any, _value: any, callback: (error?: string) => void, form: any) => { const { upCorrectionRemark, upFile } = form.getFieldsValue(); if (upCorrectionRemark || (upFile && Array.isArray(upFile.fileList) && upFile.fileList.length > 0)) { callback(); } else { callback('内容和附件至少需要填写或上传一项'); } }; // 点击上传资料确定 const [correctionId, setCorrectionId] = useState('') // 点击查看内容选中的id // 是否需要回复信息 const [correctionReply, setCorrectionReply] = useState('') //0为仅通知 , 1为需要回复 const [orderId, setOrderId] = useState('') const submitData = async (params: any) => { if (correctionReply == '0') { try { await supplementTrademarkData({ correctionParentId: correctionId, // correctionType: CorrectionType, orderId: orderId, correctionFiles: '', correctionRemark: '已读', }) getBuySupplementList(communicationPage, trademarkId) getTrademarkList(page) // if (props.user == 'sell') { // getSellSupplementList() // } else if (props.user == 'buy') { // getBuySupplementList() // } // props.upData() // messageApi.open({ // type: 'success', // content: '已提交', // }) setIsModalVisible(false) // form.resetFields(); // console.log(res); } catch (error: any) { if (error.response) { const data = error.response.data; messageApi.open({ type: 'error', content: data.msg ? data.msg : `${data.path}(${data.status})`, }); } else { console.error(error) } } } else { try { await supplementTrademarkData({ correctionParentId: correctionId, // correctionType: CorrectionType, orderId: orderId, correctionFiles: params.correctionFiles, correctionRemark: params.correctionRemark, }) // if (props.user == 'sell') { // getSellSupplementList() // } else if (props.user == 'buy') { // getBuySupplementList() // } // props.upData() messageApi.open({ type: 'success', content: '已提交', }) getTrademarkList(page) getBuySupplementList(communicationPage, trademarkId) setIsModalVisible(false) // form.resetFields(); // console.log(res); } catch (error: any) { if (error.response) { const data = error.response.data; messageApi.open({ type: 'error', content: data.msg ? data.msg : `${data.path}(${data.status})`, }); } else { console.error(error) } } } } // 补充资料详情 const [detailData, setDetailData] = useState({}) // 补充资料弹窗 const [isModalVisible, setIsModalVisible] = useState(false) // 沟通弹窗 const [visible, setVisible] = useState(false); const [fileList, setFileList] = useState([]) // 上传文件列表 // 获取文件类型 const getFileTypeByIdsArray = async (ids: string) => { try { const res: any = await getFileTypeByIds({ ids: ids }) setFileList(res) } catch (error: any) { if (error.response) { const data = error.response.data; messageApi.open({ type: 'error', content: data.msg ? data.msg : `${data.path}(${data.status})`, }); } else { console.error(error) } } } // const [orderId, setOrderId] = useState('') const [checkRemark, setCheckRemark] = useState('') //失败原因 const [messageApi, contextHolder] = message.useMessage(); const { state } = useLocation() const nav = useNavigate(); const height = window.innerHeight - 180; const columns: TableProps['columns'] = [ { title: '序号', dataIndex: 'index', key: 'index', align: 'center', fixed: 'left', width: 90, render: (_text, _record, index) => (page - 1) * 10 + index + 1, // 显示序号,从1开始 }, { title: '服务类型', dataIndex: 'trademarkModeName', fixed: 'left', align: 'center', key: 'trademarkModeName', width: 150, ellipsis: { showTitle: true, }, }, { title: '类型/名称', fixed: 'left', dataIndex: 'trademarkName', key: 'trademarkName', align: 'center', ellipsis: { showTitle: true, }, width: 200, render: (_text, record) => ( {record.trademarkType == 'text' ? '文字' : record.trademarkType == 'image' ? '图形' : record.trademarkType == 'text-image' ? '图文' : ''} / {record.trademarkName} {/* {record} */} ) }, { title: '涉及类别', dataIndex: 'trademarkTypeDTOS', align: 'center', key: 'trademarkTypeDTOS', width: 150, ellipsis: { showTitle: true, }, render: (trademarkTypeDTOS) => ( // trademarkTypeDTOS.map( //
//
// ) trademarkTypeDTOS.length > 0 ? ( trademarkTypeDTOS.map((item: any) => { return (
第{item.code}类 : {item.name}
) }) ) : '暂无' ) }, { title: '商标图样', dataIndex: 'trademarkPhoto', align: 'center', key: 'trademarkPhoto', width: 200, render: (text) => ( text ? ( ) : '暂无' ) }, { title: '状态', dataIndex: 'trademarkStatus', align: 'center', key: 'trademarkStatus', width: 110, render: (text, record) => (
{text == '-1' ?
{ setCheckRemark(record.checkRemark) setModal(true) // console.log(record.checkRemark); }} >
审核未通过
已退款
(点击查看原因)
: text == '0' ? 待付款 : text == '1' ? 已付款 : text == '2' ? 审核中 : text == '3' ? 提交至商标局 : text == '4' ? 不予受理 : text == '5' ? 已受理 : text == '6' ? 已发初审公告 : text == '7' ? 部分驳回 : text == '8' ? 全部驳回 : text == '9' ? 下证 : '未知' }
) }, // { // title: '申请人', // // 使用数组形式访问嵌套对象属性 // dataIndex: ['trademarkUserDTO', 'name'], // align: 'center', // // 修改 key 保证唯一性 // key: 'trademarkUserDTOName', // width: 150, // render: (text) => ( // // {text || '-'} // // ) // }, // // { // // title: '申请人证件号', // // dataIndex: ['trademarkUserDTO', 'name'], // // align: 'center', // // key: 'appOrderId', // // width: 150, // // render: (text) => ( // // // // {text ? text : '未完善'} // // // // ) // // }, // { // title: '联系人', // // 使用数组形式访问嵌套对象属性 // dataIndex: ['trademarkUserDTO', 'contactName'], // align: 'center', // // 修改 key 保证唯一性 // key: 'trademarkUserDTOContactName', // width: 150, // render: (text) => ( // // {text || '-'} // // ) // }, { title: '操作', // dataIndex: 'contractManagementId', align: 'center', // key: 'appOrderId', width: 150, // bordeLeft: true, fixed: 'right', render: (record) => (
{ nav(`/trademark-ai-edit/${record.trademarkId}`, { // state: { // trademarkMode: record.trademarkMode, //申请类型id // trademarkModeName: record.trademarkModeName, //申请类型名称 // trademarkId: record.trademarkId, //商标id // } }) // console.log(record.checkStatus); }}>{ record.trademarkStatus == '2' || record.trademarkStatus == '3' ? '查看' : '编辑' } 0 ? 'unset' : 'none', display: Number(record.trademarkStatus) >= 4 ? 'unset' : 'none', marginLeft: 10, }} onClick={async () => { setTrademarkId(record.trademarkId) setVisible(true) getBuySupplementList(1, record.trademarkId) }} >进度沟通
0 ? 'unset' : 'none', }}>
{record.waitCorrectionCount}
) }, ] const [disabled, setDisabled] = useState(false) const getSupplementDetail = async (id: string) => { try { const res: any = await supplementDetail(id) console.log(res); setDetailData(res) if (res.correctionFiles) { await getFileTypeByIdsArray(res.correctionFiles) } if (res.buyId) { setDisabled(true) const newData: any = await supplementDetail(res.buyId) form.setFieldsValue({ upCorrectionRemark: newData.correctionRemark, // 内容 }) if (newData.correctionFiles) { getUpFileTypeByIdsArray(newData.correctionFiles) } } else { setDisabled(false) } } catch (error: any) { if (error.response) { const data = error.response.data; messageApi.open({ type: 'error', content: data.msg ? data.msg : `${data.path}(${data.status})`, }); } else { console.error(error) } } } const [data, setData] = useState([]) // 沟通数组 const [communicationData, setCommunicationData] = useState([]) // 沟通分页 const [communicationPage, setCommunicationPage] = useState(1) // 沟通分页条数 const [communicationTotal, setCommunicationTotal] = useState(0) const communicationColums: TableProps['columns'] = [ { title: '序号', dataIndex: 'index', key: 'index', align: 'center', width: 90, render: (_text, _record, index) => (communicationPage - 1) * 10 + index + 1, // 显示序号,从1开始 }, { title: '资料主题', dataIndex: 'correctionTitle', align: 'center', width: 200, render: (text) => (
{text}
) }, { title: '资料内容', dataIndex: 'correctionRemark', align: 'center', width: 300, render: (text) => (
{text}
) }, { title: '发起时间', dataIndex: 'createTime', align: 'center', width: 200, }, { title: '当前进度', dataIndex: 'correctionStatus', align: 'center', width: 100, render: (text) => ( <> {text == '4' ? '不予受理' : text == '5' ? '已受理' : text == '6' ? '已发初审公告' : text == '7' ? '部分驳回' : text == '8' ? '全部驳回' : text == '9' ? '商标注册完成' : "未知"} ) }, { title: '状态', dataIndex: 'buyId', align: 'center', width: 100, render: (text) => ( <> 待补充 已补充 {/* {text == '4' ? '不予受理' : text == '5' ? '已受理' : text == '6' ? '已发初审公告' : text == '7' ? '部分驳回' : text == '8' ? '全部驳回' : text == '9' ? '商标注册完成' : "未知"} */} ) }, { title: '操作', align: 'center', width: 100, render: (record: any) => ( { console.log(record); setCorrectionReply(record.correctionReply) // console.log(record.correctionId); setCorrectionId(record.correctionId) getSupplementDetail(record.correctionId) setIsModalVisible(true) setOrderId(record.orderId) form.resetFields(); }}>查看内容 ) }, ] const [loading, setLoading] = useState(false) const [page, setPage] = useState(1) const [total, setTotal] = useState(0) const getTrademarkList = async (page: any) => { try { setLoading(true) setData([]) const res: any = await trademarkList({ keywords: state && state.keywords ? state.keywords : '', rows: 10, page: page }) console.log('结果', res); setData(res.rows) setTotal(res.total) setLoading(false) } catch (error: any) { setLoading(false) if (error.response) { const data = error.response.data; messageApi.open({ type: 'error', content: data.msg ? data.msg : `${data.path}(${data.status})`, }); } else { console.error(error) } } finally { setLoading(false) } } // useEffect(() => { // // console.log(state.keywords); // getTrademarkList(1) // // console.log(1); // }, []) useEffect(() => { // console.log(state.keywords); getTrademarkList(1) }, [state]) return (
{contextHolder} {data.length <= 0 ? (
暂无数据
) : (
{ setPage(page) getTrademarkList(page) }} />
)}
{ setModal(false) }} > 失败原因:{checkRemark} { setVisible(false) }} width={1300} > { setCommunicationPage(currentPage); getBuySupplementList(currentPage, trademarkId) }, showSizeChanger: false, current: communicationPage } } style={{ textAlign: 'center' }} // 设置表格内容居中显示 rowKey="trademarkId" // 指定数据项的唯一标识符 locale={{ emptyText: '暂无数据' }} >
{ setIsModalVisible(false); // 清空表单 form.resetFields(); }} centered >
{/* {correctionId} {CorrectionType} */}
平台需要您补充的内容说明
主题
内容
附件
{fileList.length > 0 ? ( //
材料列表
{ fileList.map((item: any) => { return (
{ window.open(showImage(item.fileId, false)) }} > {item.fileName}
) }) }
) : (
)}
在下面填写您补充的内容
{ const uids = upFileArray.map((file: any) => file.response.data.fileId).join(','); // console.log('提取的 uid 字符串:', uids); submitData({ correctionFiles: uids, correctionRemark: value.upCorrectionRemark, }) }} onFinishFailed={() => { messageApi.open({ type: 'error', content: '内容和附件至少需要填写或上传一项', }) }} autoComplete="off" >
内容
validateContentOrFile(rule, value, callback, form), // }, // ]} rules={correctionReply == '0' ? [] : [ { validator: (rule, value, callback) => validateContentOrFile(rule, value, callback, form), }, ]} >
附件
validateContentOrFile(rule, value, callback, form), // }, // ]} rules={correctionReply === '0' ? [] : [ { validator: (rule, value, callback) => validateContentOrFile(rule, value, callback, form), }, ]} > { setUpFileArray(info.fileList) // console.log(info.fileList); }} headers={{ 'Auth': `Bearer ${token}` }} disabled={correctionReply == '0'} >
) }