Commit 59c041ef authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

feat: 对接商品列表导出

parent d02f486c
......@@ -159,6 +159,7 @@ export default {
'commodity.products.handleBatchDelete.okText':'OK',
'commodity.products.handleBatchDelete.cancelText':'Cancel',
'commodity.products.handleBatchDelete.error':'Please select the product that needs to be operated',
'commodity.products.handleExport.querendaochu': 'Are you sure to export the selected item?',
'commodity.products.confirmDelete.title':'Are you sure you want to perform the delete operation?',
'commodity.products.confirmDelete.okText':'OK',
'commodity.products.confirmDelete.cancelText':'Cancel',
......@@ -946,6 +947,7 @@ export default {
'commodity.products.schema.fastSchema.daochuchenggong' : 'Export success',
'commodity.products.schema.fastSchema.zuiduodaochuyiqiange' : 'Export a maximum of 1000 QR codes',
'commodity.products.menuMore.5' : 'Export product QR code',
'commodity.products.menuMore.6' : 'Export',
'commodity.products.liebiaogouxuan' : 'List check:',
'commodity.products.geshangpin' : 'A commodity',
'commodity.products.shuoming' : 'xplain:',
......
......@@ -31,6 +31,7 @@
'common.tip.select.required':'Please select a record',
'common.tip.designpage.leave.confirm':'Are you sure to leave the template decoration page? ',
'common.tip.save.success':'Save successfully',
'common.tip.save.tip': 'Notice',
/** tabel */
'common.table.action':'Operation',
......
......@@ -160,6 +160,7 @@ export default {
'commodity.products.handleBatchDelete.okText' : '확정하다',
'commodity.products.handleBatchDelete.cancelText' : '취소',
'commodity.products.handleBatchDelete.error' : '필요한 품목을 선택하십시오.',
'commodity.products.handleExport.querendaochu': '선택한 상품을 내보내시겠습니까?',
'commodity.products.confirmDelete.title' : '삭제 작업을 수행하시겠습니까?',
'commodity.products.confirmDelete.okText' : '확정하다',
'commodity.products.confirmDelete.cancelText' : '취소',
......@@ -946,6 +947,7 @@ export default {
'commodity.products.schema.fastSchema.daochuchenggong' : '성공적으로 내보내기',
'commodity.products.schema.fastSchema.zuiduodaochuyiqiange' : '최대 1000개의 상품 qr 코드를 내보낸다',
'commodity.products.menuMore.5' : '상품의 qr 코드를 내보내다',
'commodity.products.menuMore.6' : '이끌어 내다',
'commodity.products.liebiaogouxuan' : '목록 체크:',
'commodity.products.geshangpin' : '몇 가지 상품',
'commodity.products.shuoming' : '해설',
......
......@@ -31,6 +31,7 @@ export default {
'common.tip.select.required': '레코드를 선택하십시오.',
'common.tip.designpage.leave.confirm': '템플릿 인테리어 페이지를 떠나시겠습니까?',
'common.tip.save.success': '저장 성공',
'common.tip.save.tip': '제시하다',
/** tabel */
'common.table.action': '조작하다',
......
......@@ -160,6 +160,7 @@ export default {
'commodity.products.handleBatchDelete.okText' : '确定',
'commodity.products.handleBatchDelete.cancelText' : '取消',
'commodity.products.handleBatchDelete.error' : '请选择需要操作的商品',
'commodity.products.handleExport.querendaochu': '确认导出所选商品?',
'commodity.products.confirmDelete.title' : '确定要执行删除操作?',
'commodity.products.confirmDelete.okText' : '确定',
'commodity.products.confirmDelete.cancelText' : '取消',
......@@ -947,6 +948,7 @@ export default {
'commodity.products.schema.fastSchema.daochuchenggong' : '导出成功',
'commodity.products.schema.fastSchema.zuiduodaochuyiqiange' : '最多导出1000个商品二维码',
'commodity.products.menuMore.5' : '导出商品二维码',
'commodity.products.menuMore.6' : '导出',
'commodity.products.liebiaogouxuan' : '列表勾选:',
'commodity.products.geshangpin' : '个商品',
'commodity.products.shuoming' : '说明:',
......
......@@ -31,6 +31,8 @@ export default {
'common.tip.select.required': '请选择一条记录',
'common.tip.designpage.leave.confirm': '是否确认离开模板装修页面?',
'common.tip.save.success': '保存成功',
'common.tip.modal.tip': '提示',
/** tabel */
'common.table.action': '操作',
......
......@@ -30,7 +30,7 @@ import useSetSearchValueInTable from '@/hooks/useSetSearchValueInTable'
import { priceTypeLabel, productStatusColor, productStatusLabel } from './constant'
import EyePreview from '@/components/EyePreview'
import UpperProductModalTable from './components/upperProductModalTable'
import { getProductCommodityGetCommodityList, getProductCommodityGetShop, GetProductCommodityGetShopResponse, postProductCommodityApplyCheckCommodity, postProductCommodityCopyCommodity, postProductCommodityDeleteBatchCommodity, postProductCommodityExportCommodityQrCode, postProductCommodityGetCommodityIsExistStock, postProductCommodityGetCommoditySkuIdList, postProductCommodityGetShopBatch, postProductCommodityOffPublishCommodity, postProductCommodityOffPublishCommodityBatch, postProductCommodityPublishCommodity, postProductCommodityPublishCommodityBatch } from '@/services/ProductV2Api'
import { getProductCommodityGetCommodityList, getProductCommodityGetShop, GetProductCommodityGetShopResponse, postProductCommodityApplyCheckCommodity, postProductCommodityCopyCommodity, postProductCommodityDeleteBatchCommodity, postProductCommodityExportCommodityQrCode, postProductCommodityExportCommoditySkuByCommodityIdList, postProductCommodityGetCommodityIsExistStock, postProductCommodityGetCommoditySkuIdList, postProductCommodityGetShopBatch, postProductCommodityOffPublishCommodity, postProductCommodityOffPublishCommodityBatch, postProductCommodityPublishCommodity, postProductCommodityPublishCommodityBatch } from '@/services/ProductV2Api'
import { getTemplateWebMemberShopWebFindCurrMemberShop } from '@/services/TemplateV2Api'
import PutawayGuide, { GuideMenu } from './components/putawayGuide'
import { useRowSelectionTable, useRowSelectionTableCtl } from '@/hooks/useRowSelectionTable'
......@@ -59,6 +59,7 @@ const Products: React.FC<{}> = () => {
const [currentOptionId, setCurrentOptionId] = useState<number>()
const [isDisabledOKbtn, setIsDisabledOKbtn] = useState<boolean>(false)
const [exportQrcodeModal, setExportQrcodeModal] = useState<boolean>(false)
const [exportVisible, setExportVisible] = useState<boolean>(false)
const [exportLoading, setExportLoading] = useState<boolean>(false)
const currentRefRow = useRef<any>([])
const currentCtrlRef = useRef<useRowSelectionTableCtl>()
......@@ -610,7 +611,7 @@ const Products: React.FC<{}> = () => {
const handleMenuClick = (e) => {
const selectedRowKeys = currentRefRow.current.map(item => item.id)
// 1 批量删除;2 删除导入批次 0 导入上游;3 批量上架;4 批量下架 5导出商品二维码
// 1 批量删除;2 删除导入批次 0 导入上游;3 批量上架;4 批量下架 5导出商品二维码 6导出
if (e.key === '1') {
handleBatchDelete(selectedRowKeys, true)
} else if (e.key === '2') {
......@@ -627,9 +628,38 @@ const Products: React.FC<{}> = () => {
return message.error(intl.formatMessage({ id: 'commodity.products.schema.fastSchema.qingxuanzeshangjiashangpin' }))
}
selectedRowKeys.length ? setExportQrcodeModal(true) : message.error(intl.formatMessage({ id: 'commodity.products.handleBatchDelete.error' }))
} else if(e.key === '6') {
selectedRowKeys.length ? setExportVisible(true) : message.error(intl.formatMessage({ id: 'commodity.products.handleBatchDelete.error' }))
}
}
const handleExport = () => {
const selectedRowKeys = currentRefRow.current.map(item => item.id)
let a: any = document.createElement("a")
document.body.appendChild(a)
a.style = "display: none"
setExportLoading(true)
if (selectedRowKeys.length > 1000) {
return message.error(intl.formatMessage({ id: 'commodity.products.schema.fastSchema.zuiduodaochuyiqiange' }))
}
postProductCommodityExportCommoditySkuByCommodityIdList({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/vnd.ms-excel" })
const url = window.URL.createObjectURL(blob);
a.href = url;
a.download = filename;
a.click();
window.URL.revokeObjectURL(url);
}).finally(() => {
message.success(intl.formatMessage({ id: 'commodity.products.schema.fastSchema.daochuchenggong' }))
setExportVisible(false)
setExportLoading(false)
currentCtrlRef.current.setSelectedRowKeys([])
currentCtrlRef.current.setSelectRow([])
})
}
const handleExportQrcode = () => {
let a: any = document.createElement("a")
document.body.appendChild(a)
......@@ -652,6 +682,8 @@ const Products: React.FC<{}> = () => {
setExportLoading(false)
message.success(intl.formatMessage({ id: 'commodity.products.schema.fastSchema.daochuchenggong' }))
setExportQrcodeModal(false)
currentCtrlRef.current.setSelectedRowKeys([])
currentCtrlRef.current.setSelectRow([])
})
}
......@@ -725,6 +757,9 @@ const Products: React.FC<{}> = () => {
<Menu.Item key="5" icon={<ExportOutlined />}>
{intl.formatMessage({ id: 'commodity.products.menuMore.5' })}
</Menu.Item>
<Menu.Item key="6" icon={<ExportOutlined />}>
{intl.formatMessage({ id: 'commodity.products.menuMore.6' })}
</Menu.Item>
</Menu>
)
......@@ -913,6 +948,16 @@ const Products: React.FC<{}> = () => {
data={inconformityProductIds}
onCancel={handleGuideCancel}
/>
{/* 导出SKU级商品 */}
<Modal
title={intl.formatMessage({ id: 'common.tip.modal.tip' })}
visible={exportVisible}
onOk={handleExport}
onCancel={()=>setExportVisible(false)}
confirmLoading={exportLoading}
>
<h2>{intl.formatMessage({ id: 'commodity.products.handleExport.querendaochu' })}</h2>
</Modal>
</PageHeaderWrapper>
)
}
......
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