Commit 02f6a574 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 处理货品商品列表跨页选择异常,处理角色切换翻译报错

parent acd05d0d
...@@ -3,6 +3,7 @@ import { Dropdown, Space, Menu, message } from 'antd'; ...@@ -3,6 +3,7 @@ import { Dropdown, Space, Menu, message } from 'antd';
import { CaretDownOutlined } from '@ant-design/icons'; import { CaretDownOutlined } from '@ant-design/icons';
import { getAuth, setAuth, setRouters } from '@/utils/auth'; import { getAuth, setAuth, setRouters } from '@/utils/auth';
import { postMemberLoginSwitchrole } from '@/services/MemberV2Api'; import { postMemberLoginSwitchrole } from '@/services/MemberV2Api';
import { useIntl } from 'umi'
interface MemberRole { interface MemberRole {
memberRoleId: number; memberRoleId: number;
...@@ -11,6 +12,7 @@ interface MemberRole { ...@@ -11,6 +12,7 @@ interface MemberRole {
}; };
const Roles: React.FC = () => { const Roles: React.FC = () => {
const intl = useIntl()
const [curRole, setCurRole] = useState<MemberRole>(null); const [curRole, setCurRole] = useState<MemberRole>(null);
const [roles, setRoles] = useState<MemberRole[]>([]); const [roles, setRoles] = useState<MemberRole[]>([]);
......
...@@ -41,6 +41,7 @@ const AddAtttribute: React.FC<{}> = () => { ...@@ -41,6 +41,7 @@ const AddAtttribute: React.FC<{}> = () => {
const [isSee, setIsSee] = useState(false) // 判断查看依据 const [isSee, setIsSee] = useState(false) // 判断查看依据
const [isSpecial, setIsSpecial] = useState(false) //特殊属性禁用展示方式 const [isSpecial, setIsSpecial] = useState(false) //特殊属性禁用展示方式
const [submitLoading, setSubmitLoading] = useState<boolean>(false) const [submitLoading, setSubmitLoading] = useState<boolean>(false)
const [isDisabledEmpty, setIsDisabledEmpty] = useState<boolean>(false) // 禁用必填
useEffect(() => { useEffect(() => {
const { location } = history const { location } = history
...@@ -162,8 +163,10 @@ const AddAtttribute: React.FC<{}> = () => { ...@@ -162,8 +163,10 @@ const AddAtttribute: React.FC<{}> = () => {
const priceAttributeChange = (e) => { const priceAttributeChange = (e) => {
if(e.target.checked) { if(e.target.checked) {
setIsDisabledEmpty(true)
menuForm.setFieldsValue({"isEmpty": true}) menuForm.setFieldsValue({"isEmpty": true})
} else { } else {
setIsDisabledEmpty(false)
menuForm.setFieldsValue({"isEmpty": false}) menuForm.setFieldsValue({"isEmpty": false})
} }
} }
...@@ -253,7 +256,9 @@ const AddAtttribute: React.FC<{}> = () => { ...@@ -253,7 +256,9 @@ const AddAtttribute: React.FC<{}> = () => {
> >
<Row> <Row>
<Col span={24}> <Col span={24}>
<Form.Item name="isEmpty" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled={isSee}>{intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.form.isEmpty' })}</Checkbox></Form.Item> <Form.Item name="isEmpty" valuePropName="checked" initialValue={false} noStyle>
<Checkbox disabled={isSee || isDisabledEmpty}>{intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.form.isEmpty' })}</Checkbox>
</Form.Item>
</Col> </Col>
{/* <Col span={24}> {/* <Col span={24}>
<Form.Item name="isImage" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled={isSee}>上传图片</Checkbox></Form.Item> <Form.Item name="isImage" valuePropName="checked" initialValue={false} noStyle><Checkbox disabled={isSee}>上传图片</Checkbox></Form.Item>
...@@ -269,7 +274,12 @@ const AddAtttribute: React.FC<{}> = () => { ...@@ -269,7 +274,12 @@ const AddAtttribute: React.FC<{}> = () => {
</Col> */} </Col> */}
<Col span={24}> <Col span={24}>
{/* 规格属性 -> 原价格属性 */} {/* 规格属性 -> 原价格属性 */}
<Form.Item name="isPrice" valuePropName="checked" initialValue={false} noStyle><Checkbox onChange={priceAttributeChange} disabled={isSee}>{intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.form.isPrice' })}</Checkbox></Form.Item> <Form.Item name="isPrice" valuePropName="checked" initialValue={false} noStyle>
<Checkbox
onChange={priceAttributeChange}
disabled={isSee}>{intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.form.isPrice' })}
</Checkbox>
</Form.Item>
<Tooltip title={intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.form.isPrice.tooltip' })}> <Tooltip title={intl.formatMessage({ id: 'classAndProperty.attribute.addAttribute.form.isPrice.tooltip' })}>
<InfoCircleOutlined /> <InfoCircleOutlined />
</Tooltip> </Tooltip>
......
...@@ -26,17 +26,6 @@ import { getProductGoodsGetGoodsList, postProductGoodsDeleteBatchGoods } from '@ ...@@ -26,17 +26,6 @@ import { getProductGoodsGetGoodsList, postProductGoodsDeleteBatchGoods } from '@
const { Option } = Select; const { Option } = Select;
const { confirm } = Modal const { confirm } = Modal
// 定义选择的行数据的类型
interface Item {
key: string;
role: string;
specification: string;
type: string;
brand: string;
unit: string;
unitPrice: string;
batch: string;
}
let timeChange: any; let timeChange: any;
...@@ -45,15 +34,17 @@ const formActions = createFormActions(); ...@@ -45,15 +34,17 @@ const formActions = createFormActions();
const Goods: React.FC<{}> = () => { const Goods: React.FC<{}> = () => {
const intl = useIntl(); const intl = useIntl();
const ref = useRef<any>({}) const ref = useRef<any>({})
const [selectRow, setSelectRow] = useState<Item[]>([]) // 模态框选择的行数据 const currentRefRow = useRef<any>([])
const [selectedRowKeys, setSelectedRowKeys] = useState<Array<number>>([])
const [importModal, setImportModal] = useState(false) const [importModal, setImportModal] = useState(false)
const [deleteBatchModal, setDeleteBatchModal] = useState(false) const [deleteBatchModal, setDeleteBatchModal] = useState(false)
const [modalTitle, setModalTitle] = useState(intl.formatMessage({ id: 'commodity.goods.modalTitle.1' })) const [modalTitle, setModalTitle] = useState(intl.formatMessage({ id: 'commodity.goods.modalTitle.1' }))
const [modalStep, setModalStep] = useState(0) const [modalStep, setModalStep] = useState(0)
const [batchDeleteKeys, setBatchDeleteKeys] = useState<any>([])
const [goodsRowSelection, goodsRowCtl] = useRowSelectionTable() const [goodsRowSelection, goodsRowCtl] = useRowSelectionTable()
useEffect(() => {
currentRefRow.current = goodsRowCtl.selectRow
}, [goodsRowCtl])
const columns: ColumnType<any>[] = [ const columns: ColumnType<any>[] = [
{ {
title: intl.formatMessage({ id: 'commodity.goods.columns.code' }), title: intl.formatMessage({ id: 'commodity.goods.columns.code' }),
...@@ -148,16 +139,6 @@ const Goods: React.FC<{}> = () => { ...@@ -148,16 +139,6 @@ const Goods: React.FC<{}> = () => {
setImportModal(false) setImportModal(false)
} }
const rowSelection = {
selectedRowKeys: selectedRowKeys,
onChange: (selectedRowKeys: any, selectedRows: any) => {
setSelectRow(selectedRows);
setSelectedRowKeys(selectedRowKeys);
setBatchDeleteKeys([...batchDeleteKeys, ...selectedRowKeys]);
console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
}
}
const modalLoadTemplate = () => { const modalLoadTemplate = () => {
console.log('模板下载!') console.log('模板下载!')
} }
...@@ -286,8 +267,8 @@ const Goods: React.FC<{}> = () => { ...@@ -286,8 +267,8 @@ const Goods: React.FC<{}> = () => {
title: intl.formatMessage({ id: 'commodity.goods.handleMenuClick.title' }), title: intl.formatMessage({ id: 'commodity.goods.handleMenuClick.title' }),
icon: <ExclamationCircleOutlined />, icon: <ExclamationCircleOutlined />,
onOk() { onOk() {
if (!goodsRowCtl.selectedRowKeys.length) { return message.error(intl.formatMessage({ id: 'commodity.goods.handleMenuClick.error' })) } if (!currentRefRow.current.length) { return message.error(intl.formatMessage({ id: 'commodity.goods.handleMenuClick.error' })) }
postProductGoodsDeleteBatchGoods({ idList: goodsRowCtl.selectedRowKeys }).then(res => { postProductGoodsDeleteBatchGoods({ idList: currentRefRow.current.map(item => item.id) }).then(res => {
ref.current.reload() ref.current.reload()
}) })
}, },
......
import React, { useState, useRef } from 'react' import React, { useState, useRef, useEffect } from 'react'
import { history, useIntl } from 'umi' import { history, useIntl } from 'umi'
import { Button, Form, Card, Modal, Row, Col, Dropdown, Tooltip, Menu, Space, message, Checkbox, Badge } from 'antd' import { Button, Form, Card, Modal, Row, Col, Dropdown, Tooltip, Menu, Space, message, Checkbox, Badge } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout' import { PageHeaderWrapper } from '@ant-design/pro-layout'
...@@ -25,19 +25,7 @@ import moment from 'moment' ...@@ -25,19 +25,7 @@ import moment from 'moment'
import { productStatusColor, productStatusLabel } from './constant' import { productStatusColor, productStatusLabel } from './constant'
import { getProductChannelCommodityGetChannelCommodityList, getProductChannelCommodityGetShop, getProductChannelCommodityGetShopBatch, GetProductChannelCommodityGetShopResponse, postProductChannelCommodityBatchOffPublishCommodity, postProductChannelCommodityBatchPublishCommodity, postProductChannelCommodityDeleteBatchChannelCommodity, postProductChannelCommodityPublishCommodity } from '@/services/ProductV2Api' import { getProductChannelCommodityGetChannelCommodityList, getProductChannelCommodityGetShop, getProductChannelCommodityGetShopBatch, GetProductChannelCommodityGetShopResponse, postProductChannelCommodityBatchOffPublishCommodity, postProductChannelCommodityBatchPublishCommodity, postProductChannelCommodityDeleteBatchChannelCommodity, postProductChannelCommodityPublishCommodity } from '@/services/ProductV2Api'
import { getTemplateWebMemberChannelWebFindCurrMemberChannel } from '@/services/TemplateV2Api' import { getTemplateWebMemberChannelWebFindCurrMemberChannel } from '@/services/TemplateV2Api'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
// 定义选择的行数据的类型
interface Item {
id: string;
role: string;
specification: string;
type: string;
brand: string;
unit: string;
price: string;
batch: string;
status: string;
}
const { confirm } = Modal; const { confirm } = Modal;
const formActions = createFormActions(); const formActions = createFormActions();
...@@ -45,8 +33,7 @@ const formActions = createFormActions(); ...@@ -45,8 +33,7 @@ const formActions = createFormActions();
const DirectChannel: React.FC<{}> = () => { const DirectChannel: React.FC<{}> = () => {
const intl = useIntl(); const intl = useIntl();
const ref = useRef<any>({}) const ref = useRef<any>({})
const [selectRow, setSelectRow] = useState<Item[]>([]) // 模态框选择的行数据 const currentRefRow = useRef<any>([])
const [selectedRowKeys, setSelectedRowKeys] = useState<number[]>([])
const [isUp, setIsUp] = useState(1) // 1上0下架状态 const [isUp, setIsUp] = useState(1) // 1上0下架状态
const [upDownModal, setUpDownModal] = useState(false) const [upDownModal, setUpDownModal] = useState(false)
const [shopsOption, setShopsOption] = useState<GetProductChannelCommodityGetShopResponse>([]) const [shopsOption, setShopsOption] = useState<GetProductChannelCommodityGetShopResponse>([])
...@@ -56,8 +43,11 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -56,8 +43,11 @@ const DirectChannel: React.FC<{}> = () => {
const [currentOptionId, setCurrentOptionId] = useState<number>() const [currentOptionId, setCurrentOptionId] = useState<number>()
const [isDisabledOKbtn, setIsDisabledOKbtn] = useState<boolean>(false) const [isDisabledOKbtn, setIsDisabledOKbtn] = useState<boolean>(false)
const [isBatchOption, setIsBatchOption] = useState<boolean>(false) // 是否是批量上下架操作 const [isBatchOption, setIsBatchOption] = useState<boolean>(false) // 是否是批量上下架操作
const currentRef = useRef<any>([]) const [rowSelection, rowCtl] = useRowSelectionTable()
const currentRowRef = useRef<any>([])
useEffect(() => {
currentRefRow.current = rowCtl.selectRow
}, [rowCtl])
const columns: ColumnType<any>[] = [ const columns: ColumnType<any>[] = [
{ {
...@@ -187,7 +177,8 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -187,7 +177,8 @@ const DirectChannel: React.FC<{}> = () => {
// paramId ? 单个删除 : 批量删除 // paramId ? 单个删除 : 批量删除
const clickDelete = (paramId?: number) => { const clickDelete = (paramId?: number) => {
if (currentRef.current.length || paramId) const ids = currentRefRow.current.map(item => item.id)
if (ids.length || paramId)
confirm({ confirm({
title: intl.formatMessage({ id: 'commodity.products.directChannel.clickDelete.title' }), title: intl.formatMessage({ id: 'commodity.products.directChannel.clickDelete.title' }),
icon: <ExclamationCircleOutlined />, icon: <ExclamationCircleOutlined />,
...@@ -195,8 +186,7 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -195,8 +186,7 @@ const DirectChannel: React.FC<{}> = () => {
okType: 'danger', okType: 'danger',
cancelText: intl.formatMessage({ id: 'commodity.products.directChannel.clickDelete.cancelText' }), cancelText: intl.formatMessage({ id: 'commodity.products.directChannel.clickDelete.cancelText' }),
onOk() { onOk() {
console.log(currentRef.current) postProductChannelCommodityDeleteBatchChannelCommodity({ idList: paramId ? [paramId] : ids }).then(res => {
postProductChannelCommodityDeleteBatchChannelCommodity({ idList: paramId ? [paramId] : currentRef.current }).then(res => {
if (res.code === 1000) if (res.code === 1000)
ref.current.reload() ref.current.reload()
}) })
...@@ -218,24 +208,12 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -218,24 +208,12 @@ const DirectChannel: React.FC<{}> = () => {
}) })
} }
const rowSelection = {
selectedRowKeys: selectedRowKeys,
onChange: (selectedRowKeys: any, selectedRows: any) => {
setSelectRow(selectedRows);
setSelectedRowKeys(selectedRowKeys);
currentRef.current = selectedRowKeys
currentRowRef.current = selectedRows
}
}
// 判断所选商品 priceType, ?source, status一致 // 判断所选商品 priceType, ?source, status一致
const judgeType = () => { const judgeType = () => {
// let sourceArr = Array.from(new Set(selectRow.map((item:any) => item.channelCommodity.source))) let priceTypeArr = Array.from(new Set(currentRefRow.current.map((item: any) => item.channelCommodity.commodity.priceType)))
let priceTypeArr = Array.from(new Set(currentRowRef.current.map((item: any) => item.channelCommodity.commodity.priceType))) let statusArr = Array.from(new Set(currentRefRow.current.map((item: any) => item.status)))
let statusArr = Array.from(new Set(currentRowRef.current.map((item: any) => item.status)))
return { return {
isPassJudge: priceTypeArr.length === 1 && statusArr.length === 1, isPassJudge: priceTypeArr.length === 1 && statusArr.length === 1,
// source: sourceArr,
priceType: priceTypeArr priceType: priceTypeArr
} }
} }
...@@ -243,7 +221,7 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -243,7 +221,7 @@ const DirectChannel: React.FC<{}> = () => {
const handleBatchClick = (param: string) => { const handleBatchClick = (param: string) => {
setIsBatchOption(true) setIsBatchOption(true)
setShopsOption([]) setShopsOption([])
if (currentRef.current.length) { if (currentRefRow.current.length) {
let _judge = judgeType() let _judge = judgeType()
if (_judge.isPassJudge) { if (_judge.isPassJudge) {
setUpDownModal(true) setUpDownModal(true)
...@@ -296,7 +274,7 @@ const DirectChannel: React.FC<{}> = () => { ...@@ -296,7 +274,7 @@ const DirectChannel: React.FC<{}> = () => {
let params: any = {} let params: any = {}
if (isBatchOption) { if (isBatchOption) {
params = { params = {
idList: currentRowRef.current.map(item => item.id), idList: currentRefRow.current.map(item => item.id),
shopList: checkedValues shopList: checkedValues
} }
} else { } else {
......
...@@ -30,25 +30,13 @@ import useSetSearchValueInTable from '@/hooks/useSetSearchValueInTable' ...@@ -30,25 +30,13 @@ import useSetSearchValueInTable from '@/hooks/useSetSearchValueInTable'
import { priceTypeLabel, productStatusColor, productStatusLabel } from './constant' import { priceTypeLabel, productStatusColor, productStatusLabel } from './constant'
import EyePreview from '@/components/EyePreview' import EyePreview from '@/components/EyePreview'
import UpperProductModalTable from './components/upperProductModalTable' import UpperProductModalTable from './components/upperProductModalTable'
import { Item } from '@/components/ButtonTabs'
import { getProductCommodityGetCommodityList, getProductCommodityGetShop, GetProductCommodityGetShopResponse, postProductCommodityApplyCheckCommodity, postProductCommodityCopyCommodity, postProductCommodityDeleteBatchCommodity, postProductCommodityExportCommodityQrCode, postProductCommodityGetShopBatch, postProductCommodityOffPublishCommodity, postProductCommodityOffPublishCommodityBatch, postProductCommodityPublishCommodity, postProductCommodityPublishCommodityBatch } from '@/services/ProductV2Api' import { getProductCommodityGetCommodityList, getProductCommodityGetShop, GetProductCommodityGetShopResponse, postProductCommodityApplyCheckCommodity, postProductCommodityCopyCommodity, postProductCommodityDeleteBatchCommodity, postProductCommodityExportCommodityQrCode, postProductCommodityGetShopBatch, postProductCommodityOffPublishCommodity, postProductCommodityOffPublishCommodityBatch, postProductCommodityPublishCommodity, postProductCommodityPublishCommodityBatch } from '@/services/ProductV2Api'
import { getTemplateWebMemberShopWebFindCurrMemberShop } from '@/services/TemplateV2Api' import { getTemplateWebMemberShopWebFindCurrMemberShop } from '@/services/TemplateV2Api'
import PutawayGuide from './components/putawayGuide' import PutawayGuide from './components/putawayGuide'
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
const { confirm } = Modal; const { confirm } = Modal;
// 定义选择的行数据的类型
interface Item {
key: string;
productName: string;
type: string;
brand: string;
unit: string;
price: string;
time: string;
status: string;
}
let timeChange: any; let timeChange: any;
const formActions = createFormActions(); const formActions = createFormActions();
...@@ -58,7 +46,6 @@ const Products: React.FC<{}> = () => { ...@@ -58,7 +46,6 @@ const Products: React.FC<{}> = () => {
const ref = useRef<any>({}) const ref = useRef<any>({})
const judgeShopRef = useRef<boolean>(true) const judgeShopRef = useRef<boolean>(true)
const [upForm] = Form.useForm() const [upForm] = Form.useForm()
const [selectedRowKeys, setSelectedRowKeys] = useState<Array<string>>([])
const [importModal, setImportModal] = useState(false) const [importModal, setImportModal] = useState(false)
const [deleteBatchModal, setDeleteBatchModal] = useState(false) const [deleteBatchModal, setDeleteBatchModal] = useState(false)
const [modalTitle, setModalTitle] = useState(intl.formatMessage({ id: 'commodity.products.modalTitle.1' })) const [modalTitle, setModalTitle] = useState(intl.formatMessage({ id: 'commodity.products.modalTitle.1' }))
...@@ -72,18 +59,18 @@ const Products: React.FC<{}> = () => { ...@@ -72,18 +59,18 @@ const Products: React.FC<{}> = () => {
const [isDisabledOKbtn, setIsDisabledOKbtn] = useState<boolean>(false) const [isDisabledOKbtn, setIsDisabledOKbtn] = useState<boolean>(false)
const [exportQrcodeModal, setExportQrcodeModal] = useState<boolean>(false) const [exportQrcodeModal, setExportQrcodeModal] = useState<boolean>(false)
const [exportLoading, setExportLoading] = useState<boolean>(false) const [exportLoading, setExportLoading] = useState<boolean>(false)
const currentRef = useRef<any>([])
const currentRefRow = useRef<any>([]) const currentRefRow = useRef<any>([])
const [rowSelection, RowCtl] = useRowSelectionTable({ customKey: 'id' });
const upperRef = useRef<any>({}) const upperRef = useRef<any>({})
const [giudeVisible, setGiudeVisible] = useState<boolean>(false) const [giudeVisible, setGiudeVisible] = useState<boolean>(false)
const [shopId, setShopId] = useState<any>() const [shopId, setShopId] = useState<any>()
/** 带参数查询,给表单带默认值 */ /** 带参数查询,给表单带默认值 */
const { searchData, formatInitialValue, clear } = useSetSearchValueInTable(); const { searchData, formatInitialValue, clear } = useSetSearchValueInTable()
useEffect(() => { useEffect(() => {
console.log(upDownModal, 'upDownModal') currentRefRow.current = RowCtl.selectRow
}, [upDownModal]) }, [RowCtl])
const formatedFormValue = useMemo(() => { const formatedFormValue = useMemo(() => {
const value = formatInitialValue?.value || {}; const value = formatInitialValue?.value || {};
...@@ -244,15 +231,6 @@ const Products: React.FC<{}> = () => { ...@@ -244,15 +231,6 @@ const Products: React.FC<{}> = () => {
setImportModal(false) setImportModal(false)
} }
const rowSelection = {
selectedRowKeys: selectedRowKeys,
onChange: (selectedRowKeys: any, selectedRows: any) => {
setSelectedRowKeys(selectedRowKeys);
currentRef.current = selectedRowKeys
currentRefRow.current = selectedRows
}
}
const modalLoadTemplate = () => { const modalLoadTemplate = () => {
console.log('模板下载!') console.log('模板下载!')
} }
...@@ -403,8 +381,7 @@ const Products: React.FC<{}> = () => { ...@@ -403,8 +381,7 @@ const Products: React.FC<{}> = () => {
const clickUp = (param: number, id: number) => { // param: 0 下架 1上架 id为null批量上架 const clickUp = (param: number, id: number) => { // param: 0 下架 1上架 id为null批量上架
setCurrentOptionId(id) setCurrentOptionId(id)
const fn = id ? getProductCommodityGetShop : postProductCommodityGetShopBatch const fn = id ? getProductCommodityGetShop : postProductCommodityGetShopBatch
// @ts-ignore fn(id ? { id } : { idList: RowCtl.selectedRowKeys }, { ctlType: 'none' }).then(res => {
fn(id ? { id } : { idList: currentRef.current }, { ctlType: 'none' }).then(res => {
setShopsOption(res.data) setShopsOption(res.data)
setCheckedValues(res.data.filter(_ => _.isCheck)) setCheckedValues(res.data.filter(_ => _.isCheck))
}) })
...@@ -421,8 +398,7 @@ const Products: React.FC<{}> = () => { ...@@ -421,8 +398,7 @@ const Products: React.FC<{}> = () => {
if (isUp) { if (isUp) {
if (checkedValues.length > 0) { if (checkedValues.length > 0) {
const fn = isBatch ? postProductCommodityPublishCommodityBatch : postProductCommodityPublishCommodity const fn = isBatch ? postProductCommodityPublishCommodityBatch : postProductCommodityPublishCommodity
// @ts-ignore fn(isBatch ? { storeId: shopId['id'], storeName: shopId['name'], storeLogo: shopId['logo'], shopList: checkedValues, idList: RowCtl.selectedRowKeys } : { storeId: shopId?.id || null, storeName: shopId?.name || null, storeLogo: shopId?.logo || null, ...params }).then(() => {
fn(isBatch ? { storeId: shopId['id'], storeName: shopId['name'], storeLogo: shopId['logo'], shopList: checkedValues, idList: currentRef.current } : { storeId: shopId?.id || null, storeName: shopId?.name || null, storeLogo: shopId?.logo || null, ...params }).then(() => {
setUpDownModal(false) setUpDownModal(false)
ref.current.reload() ref.current.reload()
setIsDisabledOKbtn(false) setIsDisabledOKbtn(false)
...@@ -469,7 +445,6 @@ const Products: React.FC<{}> = () => { ...@@ -469,7 +445,6 @@ const Products: React.FC<{}> = () => {
} }
const clickSubmitCheck = (record) => { const clickSubmitCheck = (record) => {
console.log('提交审核')
const { id } = record; const { id } = record;
if (id) if (id)
postProductCommodityApplyCheckCommodity({ id: id }).then(res => { postProductCommodityApplyCheckCommodity({ id: id }).then(res => {
...@@ -481,6 +456,7 @@ const Products: React.FC<{}> = () => { ...@@ -481,6 +456,7 @@ const Products: React.FC<{}> = () => {
const handleBatch = (type: string) => { const handleBatch = (type: string) => {
// 判断 批量操作的商品类型相同、并且满足可上(审核通过,下架)下架()的状态 // 判断 批量操作的商品类型相同、并且满足可上(审核通过,下架)下架()的状态
const rows = [...currentRefRow.current] const rows = [...currentRefRow.current]
const selectedRowKeys = rows.map(item => item.id)
const canUp = rows.every(item => item.status === 4 || item.status === 6) const canUp = rows.every(item => item.status === 4 || item.status === 6)
const canDown = !rows.some(item => item.status !== 5) const canDown = !rows.some(item => item.status !== 5)
const isSamilar = rows.every(item => item.priceType === rows[0]['priceType']) const isSamilar = rows.every(item => item.priceType === rows[0]['priceType'])
...@@ -499,9 +475,9 @@ const Products: React.FC<{}> = () => { ...@@ -499,9 +475,9 @@ const Products: React.FC<{}> = () => {
if (type === '3') { if (type === '3') {
clickUp(1, null) clickUp(1, null)
} else { } else {
postProductCommodityOffPublishCommodityBatch({ idList: currentRef.current }).then(res => { postProductCommodityOffPublishCommodityBatch({ idList: selectedRowKeys }).then(res => {
ref.current.reload() ref.current.reload()
setSelectedRowKeys([]) RowCtl.setSelectedRowKeys([])
}) })
} }
}, },
...@@ -519,9 +495,10 @@ const Products: React.FC<{}> = () => { ...@@ -519,9 +495,10 @@ const Products: React.FC<{}> = () => {
} }
const handleMenuClick = (e) => { const handleMenuClick = (e) => {
const selectedRowKeys = currentRefRow.current.map(item => item.id)
// 1 批量删除;2 删除导入批次 0 导入上游;3 批量上架;4 批量下架 5导出商品二维码 // 1 批量删除;2 删除导入批次 0 导入上游;3 批量上架;4 批量下架 5导出商品二维码
if(e.key === '1'){ if(e.key === '1'){
handleBatchDelete(currentRef.current, true) handleBatchDelete(selectedRowKeys, true)
} else if (e.key === '2') { } else if (e.key === '2') {
console.log('删除导入批次') console.log('删除导入批次')
setDeleteBatchModal(true) setDeleteBatchModal(true)
...@@ -530,11 +507,10 @@ const Products: React.FC<{}> = () => { ...@@ -530,11 +507,10 @@ const Products: React.FC<{}> = () => {
} else if (e.key === '3' || e.key === '4') { } else if (e.key === '3' || e.key === '4') {
handleBatch(e.key) handleBatch(e.key)
} else if(e.key === '5') { } else if(e.key === '5') {
console.log(currentRefRow.current)
if(!currentRefRow.current.every(item => item.status === 5)) { if(!currentRefRow.current.every(item => item.status === 5)) {
return message.error(intl.formatMessage({ id: 'commodity.products.schema.fastSchema.qingxuanzeshangjiashangpin' })) return message.error(intl.formatMessage({ id: 'commodity.products.schema.fastSchema.qingxuanzeshangjiashangpin' }))
} }
currentRef.current.length ? setExportQrcodeModal(true) : message.error(intl.formatMessage({ id: 'commodity.products.handleBatchDelete.error' })) selectedRowKeys.length ? setExportQrcodeModal(true) : message.error(intl.formatMessage({ id: 'commodity.products.handleBatchDelete.error' }))
} }
} }
...@@ -543,7 +519,8 @@ const Products: React.FC<{}> = () => { ...@@ -543,7 +519,8 @@ const Products: React.FC<{}> = () => {
document.body.appendChild(a) document.body.appendChild(a)
a.style = "display: none" a.style = "display: none"
setExportLoading(true) setExportLoading(true)
postProductCommodityExportCommodityQrCode({idList: currentRef.current}, { responseType: 'blob', getResponse: true }).then((res:any) => { const selectedRowKeys = currentRefRow.current.map(item => item.id)
postProductCommodityExportCommodityQrCode({idList: selectedRowKeys}, { responseType: 'blob', getResponse: true }).then((res:any) => {
const { data, response } = res const { data, response } = res
const filename = response.headers.get('content-disposition').split('=')[1] const filename = response.headers.get('content-disposition').split('=')[1]
let blob = new Blob([data], {type: "application/x-zip-compressed"}) let blob = new Blob([data], {type: "application/x-zip-compressed"})
...@@ -554,7 +531,7 @@ const Products: React.FC<{}> = () => { ...@@ -554,7 +531,7 @@ const Products: React.FC<{}> = () => {
window.URL.revokeObjectURL(url); window.URL.revokeObjectURL(url);
}).finally(() => { }).finally(() => {
setExportLoading(false) setExportLoading(false)
message.success(intl.formatMessage({ id: 'commodity.products.handleBatch.daochuchenggong' })) message.success(intl.formatMessage({ id: 'commodity.products.schema.fastSchema.daochuchenggong' }))
setExportQrcodeModal(false) setExportQrcodeModal(false)
}) })
} }
...@@ -674,10 +651,10 @@ const Products: React.FC<{}> = () => { ...@@ -674,10 +651,10 @@ const Products: React.FC<{}> = () => {
'name', 'name',
FORM_FILTER_PATH, FORM_FILTER_PATH,
) )
FormEffectHooks.onFieldChange$('brandId').subscribe(state => { FormEffectHooks.onFieldChange$('brandId').subscribe(() => {
searchBrandOptionEffect(actions, 'brandId') searchBrandOptionEffect(actions, 'brandId')
}) })
FormEffectHooks.onFieldChange$('customerCategoryId').subscribe(state => { FormEffectHooks.onFieldChange$('customerCategoryId').subscribe(() => {
searchCustomerCategoryOptionEffect(actions, 'customerCategoryId') searchCustomerCategoryOptionEffect(actions, 'customerCategoryId')
}) })
}} }}
...@@ -798,7 +775,7 @@ const Products: React.FC<{}> = () => { ...@@ -798,7 +775,7 @@ const Products: React.FC<{}> = () => {
onCancel={() => setExportQrcodeModal(false)} onCancel={() => setExportQrcodeModal(false)}
confirmLoading={exportLoading} confirmLoading={exportLoading}
> >
<h1>{intl.formatMessage({ id: 'commodity.products.liebiaogouxuan' })}{currentRef.current.length || 0}{intl.formatMessage({ id: 'commodity.products.geshangpin' })}</h1> <h1>{intl.formatMessage({ id: 'commodity.products.liebiaogouxuan' })}{RowCtl.selectedRowKeys.length || 0}{intl.formatMessage({ id: 'commodity.products.geshangpin' })}</h1>
<h2>{intl.formatMessage({ id: 'commodity.products.shuoming' })}</h2> <h2>{intl.formatMessage({ id: 'commodity.products.shuoming' })}</h2>
<p>{intl.formatMessage({ id: 'commodity.products.textone' })}</p> <p>{intl.formatMessage({ id: 'commodity.products.textone' })}</p>
<p>{intl.formatMessage({ id: 'commodity.products.texttwo' })}</p> <p>{intl.formatMessage({ id: 'commodity.products.texttwo' })}</p>
......
import React from 'react' import React, { useState } from 'react'
import { history, useIntl } from 'umi' import { history, useIntl } from 'umi'
import { Button, Card, message } from 'antd' import { Button, Card, message } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout' import { PageHeaderWrapper } from '@ant-design/pro-layout'
...@@ -31,10 +31,12 @@ const AddRepository: React.FC<{}> = (props) => { ...@@ -31,10 +31,12 @@ const AddRepository: React.FC<{}> = (props) => {
pageStatus pageStatus
} = usePageStatus() } = usePageStatus()
const [loading, setLoading] = useState<boolean>(false)
// 整体表单提交 // 整体表单提交
const formSubmit = async (values) => { const formSubmit = async (values) => {
setLoading(true)
const params = omit(values, ['NO_SUBMIT3']) const params = omit(values, ['NO_SUBMIT3'])
console.log(params, 'params')
if (params['applyMember']) { if (params['applyMember']) {
params['applyMember'] = params['applyMember'] params['applyMember'] = params['applyMember']
} }
...@@ -52,10 +54,11 @@ const AddRepository: React.FC<{}> = (props) => { ...@@ -52,10 +54,11 @@ const AddRepository: React.FC<{}> = (props) => {
let res = await postProductFreightSpaceAdd(params) let res = await postProductFreightSpaceAdd(params)
if (res.code === 1000) { if (res.code === 1000) {
setTimeout(() => { setTimeout(() => {
history.goBack(-1) history.goBack()
}, 1000) }, 1000)
} }
} }
setLoading(false)
} }
return ( return (
...@@ -67,7 +70,7 @@ const AddRepository: React.FC<{}> = (props) => { ...@@ -67,7 +70,7 @@ const AddRepository: React.FC<{}> = (props) => {
extra={( extra={(
pageStatus !== PageStatus.PREVIEW pageStatus !== PageStatus.PREVIEW
? ( ? (
<Button key="1" onClick={() => addSchemaAction.submit()} type="primary" icon={<SaveOutlined />}> <Button key="1" loading={loading} onClick={() => addSchemaAction.submit()} type="primary" icon={<SaveOutlined />}>
{intl.formatMessage({ id: 'repositories.addRepository.extra' })} {intl.formatMessage({ id: 'repositories.addRepository.extra' })}
</Button> </Button>
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment