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

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

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