Commit 0ef160a1 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 暂存商品保存草稿的修改

parent 055dc11b
module.exports = [
{ name: 'LogisticsV2', token: '732fb8e33970ff5dee830423a630e8e85c3ef3293abba7581b16749dfce8608b', categoryIds: [0], }, // 物流能力v2
{ name: 'ProductV2', token: 'df37f2a0e3829c4288708ae211920bdbdee55e5e2f48b1e8cf7d1925ac618d9a', categoryIds: [0], }, // 商品服务V2
{ name: 'TemplateV2', token: '7bb5578bc50e4e7935cbc146a2192e978053d5380cc96fcfdc0a754cfe885ec5', categoryIds: [0], }, // 页面模板服务V2
{ name: 'PayV2', token: '4b5f2f2d42f0774b61074d69d5d756c725ba067d9dafe2c3785f592ae85d1696', categoryIds: [0], }, // 支付服务
{ name: 'SearchV2', token: 'f3e6ec26764f54d06ba33f487ff42d7debeaef397e51dc395040447737eb2e66', categoryIds: [0], }, // 搜索服务V2
{ name: 'PurchaseV2', token: '84c81ef877863ad4e2c0ebb2c3b3e80f9539420f2fc0828ef33f5159e8423b2c', categoryIds: [0] }, // 采购服务V2
{ name: 'SettleV2', token: 'fed8d45aa92e7f0e382a3dcc5e0ef63f13f0badeabab76d6a6e2db49aa403346', categoryIds: [0] },
{ name: 'TransactionV2', token: '3ad04435494d01c359b9f07948338e019133a3e6c0fccdbe1bc3adc19cf1e0b1', categoryIds: [0] }, // 交易服务V2
{ name: 'ContractV2', token: 'bbf1f327cfe7c59d1e7fd9c5d25119829dd79d238b1f1c79ed97331e220721a4', categoryIds: [0] }, // 合同能力V2
{ name: 'OrderNewV2', token: '89202a7986a86e7306925203d7eea0d999af8bb98d70a210d217a470d44b2dba', categoryIds: [0], }, //订单服务V2 New
{ name: 'MemberV2', token: 'be87c2732cb1253f82fe6c27d6cca9982c7dca9b384e46cc2e797b5835846834', categoryIds: [0]}, //会员服务 V2
{ name: 'ReportV2', token: 'dab50c384c27f1c981a03f2c44ad76d1e7e1f60b4520bd279cea67f5cf146cee', categoryIds: [0]}, // 报表服务v2 首页
{ name: 'EnhanceV2', token: '71b97616a81866ade2731437ca121e288b1dd8331dce4b5c1ccaacb176c16580', categoryIds: [0], }, // 加工服务v2
{ name: 'MessageV2', token: '69a667ec9861e8bdc25b89238d0b908a2123d9fce26e72fec3cdf6cd0b1f2681', categoryIds: [0], }, // 消息中心v2
{ name: 'MarketingV2', token: 'f6d5cee2383ca203dfa2882b84dfa02a1d79de3c3ad892b42f030437fdc5ea21', categoryIds: [0], }, // 营销能力
{ name: 'AfterServiceV2', token: '58748fc89dcdb33ec5cac520c00293ba92abca362a8ddb979df589effd0db9bd', categoryIds: [0], }, // 售后能力V2
{ name: 'ManageV2', token: '9ee3a1cb5a73ca02935e70debeda5bde0464f2fe1eb32c25855fd8acff9f68f2', categoryIds: [0] }, // 平台后台v2
{ name: 'LogisticsV2', token: 'd41aad1407040953cd8b3bf5c168fd5844efc11bbad276ef9d0fa11f18fe020e', categoryIds: [0], }, // 物流能力v2
{ name: 'ProductV2', token: 'c5ae8a687961fa2d4774be448f2bdfafcdf1d3711606c503b5a464b48ec9b284', categoryIds: [0], }, // 商品服务V2
{ name: 'TemplateV2', token: 'd2195d8b07f8b92cb093b46c5134ed2e8a388aeba4a50dcf5ab2291648c51fc6', categoryIds: [0], }, // 页面模板服务V2
{ name: 'PayV2', token: 'be269e58d88c3a39893fa240e0cdd6bb33c3024a4eb540b73a89acd06e046a9d', categoryIds: [0], }, // 支付服务
{ name: 'SearchV2', token: '07f6ffdc8839fd490a4d91368bfeb3e64aa0e482a2ec6f140dedbb05132e4b46', categoryIds: [0], }, // 搜索服务V2
{ name: 'PurchaseV2', token: 'ad23a5656edba68778283171dab7db72996e255c0f641078b9a306e311a69a7b', categoryIds: [0] }, // 采购服务V2
{ name: 'SettleV2', token: '3a5020a0b7193d25324a269f857140ae605627fbb60d0cdc1758c49cbf924e9d', categoryIds: [0] }, // 结算服务
{ name: 'TransactionV2', token: '44534d9d7fcced951ee37007326d320a5d7a126a935764489ef7830ce6023b1a', categoryIds: [0] }, // 交易服务V2
{ name: 'ContractV2', token: '63a046f33fe25262505d046e591fcf7b0bbd5dbd0463b633aaecc2d7e1b8e2c8', categoryIds: [0] }, // 合同能力V2
{ name: 'OrderNewV2', token: '8f0b8e35c954254f204f61626be668cbb2f8986f35fc10722d53b1363e7097da', categoryIds: [0], }, //订单服务V2
{ name: 'MemberV2', token: '596ac70489e083241edce79cc1da8a0a181ac3cb1cb9bb71cf0618ef11b70adf', categoryIds: [0]}, //会员服务 V2
{ name: 'ReportV2', token: '2436ccbe5c04c685adbb91742e79077128eb5874c023eeb39af8439931b940da', categoryIds: [0]}, // 报表服务v2 首页
{ name: 'EnhanceV2', token: '0b11ea89018df65b84a08aa077248d8b38506ccbb8c93c3cff4d8dc0d9caa6b7', categoryIds: [0], }, // 加工服务v2
{ name: 'MessageV2', token: 'fc0791ae75c9de60813e69b581d7ec70f302237e1a7d9bb1937a98eec403c69c', categoryIds: [0], }, // 消息中心v2
{ name: 'MarketingV2', token: '4d2a4cc5b8cb2d028dc707667a5f25297e63083376aa8d565f03e25d7f9eaf09', categoryIds: [0], }, // 营销能力
{ name: 'AfterServiceV2', token: 'eaea8b931eb1ba4bdccc3edb2e6853ac3ea41c1c2d3003dfce23a9dc9d21dc71', categoryIds: [0], }, // 售后能力V2
{ name: 'ManageV2', token: 'edc3141ad4ce4ff3e1fc084214cf6547986263d8d4415e57d6f3b866015ac87a', categoryIds: [0] }, // 平台后台v2
]
......@@ -18,8 +18,8 @@ import ProductDescFormYang from './addProductsItem/productDescFormYang'
import { useLocalStore, observer } from 'mobx-react'
import { store } from '@/store'
import { CommodityType } from './constant';
import { getProductCommodityGetCommodity, getProductCustomerGetCustomerCategoryById, postProductCommodityApplyCheckCommodity, postProductCommoditySaveOrUpdateCommodity } from '@/services/ProductV2Api';
import { CommodityType, filterUsefulData, filterUsefulDraftData } from './constant';
import { getProductCommodityGetCommodity, getProductCommodityGetCommodityDraftById, getProductCustomerGetCustomerCategoryById, postProductCommodityApplyCheckCommodity, postProductCommoditySaveOrUpdateCommodity, postProductCommoditySaveOrUpdateCommodityDraft } from '@/services/ProductV2Api';
import { getTemplateWebPageTemplateWebFindGoodsDescribeTemplate } from '@/services/TemplateV2Api';
const { TabPane } = Tabs
......@@ -34,6 +34,7 @@ const AddProducts: React.FC<{}> = (props) => {
const [clickTabIndex, setClickTabIndex] = useState<string[]>(['1'])
const [clickCurrentIndex, setClickCurrentIndex] = useState<string>('1')
const [isDisableSaveBtn, setIsDisableSaveBtn] = useState<boolean>(false)
const [isDisableSaveDraft, setIsDisableSaveDrate] = useState<boolean>(false)
const [currentTemplateName, setCurrentTemplateName] = useState<string>()
// let [formRefs, setFormRefs] = useState([]) //子form的ref数组
const childFormRefs = useRef([]) // 子form的ref数组
......@@ -62,45 +63,12 @@ const AddProducts: React.FC<{}> = (props) => {
useEffect(() => {
productDescriptionTemplate()
// 新增商品数据的编辑
const { id } = history.location.query
if (id) {
const makeRequest = async () => {
const productRes = await getProductCommodityGetCommodity({ id: id })
const { data } = productRes
/** 仅保存需要的数据 */
setProductInfoByEdit({
name: data.name,
brand: data.brand,
customerCategory: data.customerCategory,
slogan: data.slogan,
sellingPoint: data.sellingPoint || [],
commodityAreaList: data.commodityAreaList,
isUpdateAttribute: data.isUpdateAttribute,
unitId: data.unitId,
unitName: data.unitName,
subUnitId: data.subUnitId,
subUnitName: data.subUnitName,
minOrder: data.minOrder,
isMemberPrice: data.isMemberPrice,
priceType: data.priceType,
commodityAttributeList: data.commodityAttributeList,
unitPriceAndPicList: data.unitPriceAndPicList,
isAllAttributePic: data.isAllAttributePic,
commodityRemark: data.commodityRemark,
logistics: data.logistics,
isInvoice: data.isInvoice,
marks: data.marks,
packing: data.packing,
afterService: data.afterService,
isTax: true,
taxRate: data.taxRate,
title: data.title,
keywords: data.keywords,
description: data.description,
type: data.type,
createTime: data.createTime,
})
const { data } = await getProductCommodityGetCommodity({ id: id })
setProductInfoByEdit(filterUsefulData(data))
setProductName(data?.name)
setProductPriceType(data?.priceType)
const attributeRes = await getProductCustomerGetCustomerCategoryById({ id: data?.customerCategory?.id + '' })
......@@ -116,6 +84,32 @@ const AddProducts: React.FC<{}> = (props) => {
makeRequest()
}
// 草稿数据的编辑
const { draftId } = history.location.query
if (draftId) {
const makeDraftRequest = async () => {
const { data: _data }: any = await getProductCommodityGetCommodityDraftById({ commodityDraftId: draftId })
const { draft: data } = _data
// @todo 草稿数据复制表单
setProductInfoByEdit(filterUsefulDraftData(data))
setProductName(data?.name)
setProductPriceType(data?.priceType)
if(data.customerCategory?.length) {
const attributeRes = await getProductCustomerGetCustomerCategoryById({ id: data.customerCategory[data.customerCategory.length-1] })
setAttributeLists(attributeRes.data?.customerAttributeList)
}
if(data?.unitPriceAndPicList?.length) {
let unitPicList = data.unitPriceAndPicList.map(item => item.goods)
let selectGoods = unitPicList.indexOf(null) === -1 ? Object.values(unitPicList.reduce((item, next) => {
item[next?.id] = next;
return item
}, {})) : []
setSelectedGoods(selectGoods)
}
}
makeDraftRequest()
}
return () => {
clearData([])
}
......@@ -376,6 +370,165 @@ const AddProducts: React.FC<{}> = (props) => {
}
}
// 保存草稿
const onSaveDraft = () => {
setIsDisableSaveDrate(true)
const { draftId } = history.location.query
if (childFormRefs.current.length > 0) {
try {
let data = childFormRefs.current.map(async __ => {
return (
await __.current.getFieldsValue(true)
)
})
Promise.all(data).then((values) => {
console.log(values, 'draft')
productSelectAttribute.length > 0 && productSelectAttribute.map(_itme => {
_itme.customerAttribute = { id: _itme.customerAttributeId }
delete _itme.attributeName
delete _itme.isPrice
})
let _bacsicForm = { ...values[0], draft: true, isUpdateAttribute: true }
if (values.length > 0) {
for (let i = 0; i < values.length; i++) {
if (values[i].deliveryType) {
_bacsicForm = { ..._bacsicForm, logistics: { ...values[i] } }
} else {
_bacsicForm = { ..._bacsicForm, ...values[i] }
}
}
}
let _productDescription = { ...productDescription }
for (let i in _productDescription) {
if (_productDescription[i]?.length === 0) {
delete _productDescription[i]
}
}
let _params = {
..._bacsicForm,
commodityAttributeList: productSelectAttribute,
commodityRemark: _productDescription,
isAllAttributePic: isAllAttributePic,
isUpdateAttribute: true,
}
let _commodityAreaList: any = []
_params.commodityAreaList.length > 0 && areaOption.length > 0 && _params.commodityAreaList.map(_itme => {
if (_itme && _itme.length > 0) {
let _temp: any = {}
let pobj = areaOption.filter(_ => _.code === _itme[0])[0]
let cobj = pobj.areaResponses.filter(__ => __.code === _itme[1])[0]
_temp.provinceCode = pobj?.code || null
_temp.provinceName = pobj?.name || null
_temp.cityCode = cobj?.code || null
_temp.cityName = cobj?.name || null
cobj?.code ? _temp.isAllCity = false : _temp.isAllCity = true
_commodityAreaList.push(_temp)
}
})
if (_commodityAreaList.length > 0) {
_params.isAllArea = false
_params.commodityAreaList = _commodityAreaList
} else {
_params.isAllArea = true
delete _params.commodityAreaList
}
if (clickTabIndex.indexOf("5") !== -1) {
let _productAttributeAndImageParams = [...productAttributeAndImageParams]
if (_productAttributeAndImageParams.length > 0) {
_productAttributeAndImageParams.map(_item => {
_item.goods = { id: _item.goodsId } // id为0表示无货品
delete _item.goodsId
if (_item.commodityPic.length > 0) {
_item.commodityPic = _item.commodityPic.map(__item => __item?.response?.data || __item?.url || __item)
if (_item.commodityPic.filter(Boolean).length === 0) {
throw new Error(intl.formatMessage({ id: 'commodity.products.addProducts.onSave.error.1' }))
}
if (isAllAttributePic) {
_item.commodityPic = _productAttributeAndImageParams[0].commodityPic
}
} else {
if (isAllAttributePic && _productAttributeAndImageParams[0].commodityPic.length > 0 && _productAttributeAndImageParams[0].commodityPic.filter(Boolean).length > 0) { //处理所有属性共用
_item.commodityPic = _productAttributeAndImageParams[0].commodityPic
}
}
})
}
_params.unitPriceAndPicList = _productAttributeAndImageParams
} else {
if (productInfoByEdit) {
_params.unitPriceAndPicList = productInfoByEdit.unitPriceAndPicList
_params.isAllAttributePic = productInfoByEdit.isAllAttributePic
if (clickTabIndex.indexOf("4") !== -1) {
_params.unitPriceAndPicList = priceAttributeParams.map((item, index) => {
const pic = productInfoByEdit.unitPriceAndPicList[index]?.commodityPic
return {
id: item.id,
goods: { id: item.goodsId },
attributeAndValueList: item.attributeAndValueList,
unitPrice: item.unitPrice,
priceRate: item.priceRate,
commodityPic: pic
}
})
}
}
}
if (productInfoByEdit) {
if (clickTabIndex.indexOf("3") === -1) // 商品属性
_params.commodityAttributeList = productInfoByEdit.commodityAttributeList
if (clickTabIndex.indexOf("4") === -1) { // 价格属性
_params.unitId = productInfoByEdit.unitId
_params.unitName = productInfoByEdit.unitName
_params.minOrder = productInfoByEdit.minOrder
_params.priceType = productInfoByEdit.priceType
_params.isMemberPrice = productInfoByEdit.isMemberPrice
_params.taxRate = productInfoByEdit.taxRate
}
if (clickTabIndex.indexOf("6") === -1) // 商品描述
_params.commodityRemark = productInfoByEdit.commodityRemark
if (clickTabIndex.indexOf("7") === -1) // 物流
_params.logistics = productInfoByEdit.logistics
if (clickTabIndex.indexOf("8") === -1) { // 其他
_params.isInvoice = productInfoByEdit.isInvoice
_params.marks = productInfoByEdit.marks
_params.packing = productInfoByEdit.packing
_params.afterService = productInfoByEdit.afterService
}
_params.isUpdateAttribute = productInfoByEdit.isUpdateAttribute
} else {
_params.isInvoice = true
}
let numberKeys = Object.keys(_params).map(_ => Number(_)).filter(Boolean)
if (numberKeys.length > 0) {
numberKeys.map(item => delete _params[item])
}
console.log(_params, 'params')
postProductCommoditySaveOrUpdateCommodityDraft(draftId ? {id: draftId, draft: _params} : {draft: _params}).then(({code}) => {
if(code === 1000) {
setIsDisableSaveDrate(false)
}
setIsDisableSaveDrate(false)
})
})
} catch (error) {
console.log(error)
setIsDisableSaveDrate(false)
}
}
}
const handleApplyCheck = () => {
postProductCommodityApplyCheckCommodity({ id: responseId }).then(res => {
if (res.code === 1000)
......@@ -394,10 +547,17 @@ const AddProducts: React.FC<{}> = (props) => {
backIcon={<ReutrnEle description={intl.formatMessage({ id: 'commodity.products.addProducts.back' })} />}
title={history.location.query.id ? intl.formatMessage({ id: 'commodity.products.addProducts.title.1' }): intl.formatMessage({ id: 'commodity.products.addProducts.title.2' })}
extra={[
<Button key="2" disabled={isEnableCheck} onClick={handleApplyCheck}>{intl.formatMessage({ id: 'commodity.products.addProducts.extra.button.1' })}</Button>,
<Button key="2" disabled={isEnableCheck} onClick={handleApplyCheck}>
{
intl.formatMessage({ id: 'commodity.products.addProducts.extra.button.1' })
}
</Button>,
<Button key="1" type="primary" icon={<SaveOutlined />} onClick={onSave} disabled={isDisableSaveBtn}>
{intl.formatMessage({ id: 'commodity.products.addProducts.extra.button.2' })}
</Button>,
<Button key="3" onClick={onSaveDraft} disabled={isDisableSaveDraft}>
保存草稿
</Button>,
]}
>
<Card>
......
......@@ -101,8 +101,8 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
}, [])
useEffect(() => {
const { id } = history.location.query
if (id && getBasicFormParamsByEdit?.name) {
const { id, draftId } = history.location.query
if ((id || draftId) && getBasicFormParamsByEdit?.name) {
handleBrandSearch(getBasicFormParamsByEdit.brandName)
onCustomerCategoryChange(getBasicFormParamsByEdit.customerCategoryId)
// 赋[]初值 显示一行区域选择
......
......@@ -66,7 +66,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
productName,
selectedGoods,
productSelectAttribute,
setProductSelectAttribute,
tableDataSource,
setTableDataSource,
clearData,
......@@ -74,8 +73,6 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
productInfoByEdit,
getPriceAttributeFormParamsByEdit,
selectCategoryId,
productAttributeAndImageParams,
tabClickItem,
setProductPriceType,
isRecombination
} = ProductStore
......@@ -316,7 +313,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
:
_tempObj[_attributeNameArr[i] || _attributeNameArr[0]] = _rowArr // 当一项变动的时候 找_attributeNameArr可能会找不到 找不到的情况下置为索引0的那项
if (history.location.query?.id) {
if (history.location.query?.id || history.location.query?.draftId) {
// 编辑的时候,先指定数据中的货品id,如果是重新组合的不存在id就使用选择的货品中的第一个,如果没有置为0;同理,不存在单价就置为{}
if (isRecombination) {
_tempObj[intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.goodsName' })] = selectedGoods.length > 0 ? selectedGoods[0].id : 0
......
......@@ -317,3 +317,78 @@ export const upperCommoditySchema: ISchema = {
}
}
}
export const filterUsefulData = (data) => {
// 仅获取表单所需要的字段数据
return {
name: data.name,
brand: data.brand,
customerCategory: data.customerCategory,
slogan: data.slogan,
sellingPoint: data.sellingPoint || [],
commodityAreaList: data.commodityAreaList,
isUpdateAttribute: data.isUpdateAttribute,
unitId: data.unitId,
unitName: data.unitName,
subUnitId: data.subUnitId,
subUnitName: data.subUnitName,
minOrder: data.minOrder,
isMemberPrice: data.isMemberPrice,
priceType: data.priceType,
commodityAttributeList: data.commodityAttributeList,
unitPriceAndPicList: data.unitPriceAndPicList,
isAllAttributePic: data.isAllAttributePic,
commodityRemark: data.commodityRemark,
logistics: data.logistics,
isInvoice: data.isInvoice,
marks: data.marks,
packing: data.packing,
afterService: data.afterService,
isTax: true,
taxRate: data.taxRate,
title: data.title,
keywords: data.keywords,
description: data.description,
type: data.type,
createTime: data.createTime,
}
}
export const filterUsefulDraftData = (data) => {
console.log(data, 'data')
return {
name: data.name,
brandId: data.brandId,
customerCategoryId: data.customerCategoryId,
slogan: data.slogan,
sellingPoint: data.sellingPoint || [],
commodityAreaList: data.commodityAreaList || [],
isUpdateAttribute: data.isUpdateAttribute,
unitId: data.unitId,
unitName: data.unitName,
subUnitId: data.subUnitId,
subUnitName: data.subUnitName,
minOrder: data.minOrder,
isMemberPrice: data.isMemberPrice,
priceType: data.priceType,
commodityAttributeList: data.commodityAttributeList || [],
unitPriceAndPicList: data.unitPriceAndPicList || [],
isAllAttributePic: data.isAllAttributePic,
commodityRemark: data.commodityRemark,
logistics: data.logistics,
isInvoice: data.isInvoice,
marks: data.marks,
packing: data.packing,
afterService: data.afterService,
isTax: true,
taxRate: data.taxRate,
title: data.title,
keywords: data.keywords,
description: data.description,
type: data.type,
createTime: data.createTime,
// 是否草稿
draft: data.draft,
}
}
import React, { useState, useEffect, useRef, useMemo } from 'react'
import { history, useIntl } from 'umi'
import { Button, Form, Card, Modal, Result, Progress, Select, Tooltip, Checkbox, Row, Col, Dropdown, Menu, Space, message, Badge } from 'antd'
import { Button, Form, Card, Modal, Result, Progress, Select, Tooltip, Checkbox, Row, Col, Dropdown, Menu, Space, message, Badge, Tabs, Tag } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
PlusOutlined,
......@@ -35,6 +35,7 @@ import { getTemplateWebMemberShopWebFindCurrMemberShop } from '@/services/Templa
import PutawayGuide, { GuideMenu } from './components/putawayGuide'
import { useRowSelectionTable, useRowSelectionTableCtl } from '@/hooks/useRowSelectionTable'
import { postOrderCommonProductProcessFind } from '@/services/OrderNewV2Api'
import { getProductCommodityGetCommodityDraftList, postProductCommodityDeleteCommodityDraftBatch } from '@/services/ProductV2Api'
const { confirm } = Modal;
......@@ -45,6 +46,7 @@ const formActions = createFormActions();
const Products: React.FC<{}> = () => {
const intl = useIntl();
const ref = useRef<any>({})
const refDraft = useRef<any>({})
const judgeShopRef = useRef<boolean>(true)
const [upForm] = Form.useForm()
const [importModal, setImportModal] = useState(false)
......@@ -91,6 +93,7 @@ const Products: React.FC<{}> = () => {
return value
}, [formatInitialValue])
// 商品列表列
const columns: ColumnType<any>[] = [
{
title: 'ID',
......@@ -185,6 +188,128 @@ const Products: React.FC<{}> = () => {
}
];
// 草稿列
const draftColumns: ColumnType<any>[] = [
{
title: 'ID',
dataIndex: 'id',
key: 'id',
width: 60
},
{
title: intl.formatMessage({ id: 'commodity.products.columns.name' }),
dataIndex: ['draft', 'name'],
key: 'name',
className: 'commonPickColor',
width: 240,
ellipsis: true,
render: (text: any, record: any) => <EyePreview url={`/memberCenter/commodityAbility/commodity/products/detail?id=${record.id}`}>
{text}
</EyePreview>
},
{
title: intl.formatMessage({ id: 'commodity.products.columns.customerCategory' }),
dataIndex: ['draft', 'customerCategory', 'name'],
key: 'customerCategory.name',
},
{
title: intl.formatMessage({ id: 'commodity.products.columns.brand' }),
dataIndex: ['draft', 'brand', 'name'],
key: 'brand.name',
},
{
title: intl.formatMessage({ id: 'commodity.products.columns.unitName' }),
dataIndex: ['draft', 'unitName'],
key: 'unitName',
},
{
title: intl.formatMessage({ id: 'commodity.products.columns.priceType' }),
dataIndex: ['draft', 'priceType'],
key: 'priceType',
render: text => priceTypeLabel[text]
},
{
title: intl.formatMessage({ id: 'commodity.products.columns.type' }),
dataIndex: ['draft', 'type'],
key: 'type',
render: t => {
if(t === 1) {
return intl.formatMessage({ id: 'commodity.products.columns.type.1' })
} else if(t === 2) {
return intl.formatMessage({ id: 'commodity.products.columns.type.2' })
} else if(t === 3) {
return intl.formatMessage({ id: 'commodity.products.columns.type.3' })
}
}
},
{
title: intl.formatMessage({ id: 'commodity.products.columns.min' }),
dataIndex: ['draft', 'min'],
key: 'min',
render: (text, reocrd) => {
if (reocrd.priceType === 1) {
if (reocrd.max === reocrd.min)
return <>{intl.formatMessage({ id: 'commodity.products.columns.currency' })}{reocrd.min}</>
else
return <>{intl.formatMessage({ id: 'commodity.products.columns.currency' })}{reocrd.min} ~ {intl.formatMessage({ id: 'commodity.products.columns.currency' })}{reocrd.max}</>
}
if (reocrd.priceType === 3) {
if (reocrd.max === reocrd.min)
return <>{reocrd.min}</>
else
return <>{reocrd.min} ~ {reocrd.max}</>
}
if (reocrd.priceType === 2)
return null
}
},
{
title: intl.formatMessage({ id: 'commodity.products.columns.applyTime' }),
dataIndex: ['draft', 'applyTime'],
key: 'applyTime',
render: text => text && moment(text).format('YYYY-MM-DD HH:mm:ss')
},
{
title: intl.formatMessage({ id: 'commodity.products.columns.status' }),
dataIndex: ['draft', 'status'],
key: 'status',
render: () => <Tag>草稿</Tag>
},
{
title: intl.formatMessage({ id: 'commodity.products.columns.option' }),
dataIndex: 'option',
width: 160,
render: (text, record) => (<>
<Button type='link' onClick={()=>clickDraftModify(record)}>修改</Button>
<Button type='link' onClick={()=>clickDraftDelete(record)}>删除</Button>
</>)
}
];
const clickDraftModify = (record) => {
history.push(`/memberCenter/commodityAbility/commodity/products/add?draftId=${record["id"]}`)
}
const clickDraftDelete = (record) => {
confirm({
title: intl.formatMessage({ id: 'commodity.products.confirmDelete.title' }),
icon: <ExclamationCircleOutlined />,
okText: intl.formatMessage({ id: 'commodity.products.confirmDelete.okText' }),
okType: 'danger',
cancelText: intl.formatMessage({ id: 'commodity.products.confirmDelete.cancelText' }),
onOk() {
postProductCommodityDeleteCommodityDraftBatch({idList: [record['id']]}).then(({code}) => {
if(code === 1000) {
refDraft.current.reload()
}
})
},
onCancel() {
console.log('Cancel');
}
})
}
const previewUpper = (upId) => {
history.push(`/memberCenter/commodityAbility/commodity/products/detail?id=${upId}`)
}
......@@ -233,7 +358,7 @@ const Products: React.FC<{}> = () => {
)
}
const fetchData = (params: any) => {
const fetchData = (params) => {
const searchParams = {
...searchData,
...params,
......@@ -250,6 +375,16 @@ const Products: React.FC<{}> = () => {
})
}
const fetchDraftData = (params) => {
return new Promise((resolve) => {
getProductCommodityGetCommodityDraftList(params).then(res => {
const { data } = res
console.log(data, 'draft')
resolve(data)
})
})
}
const clickModify = (id: number) => {
history.push(`/memberCenter/commodityAbility/commodity/products/edit?id=${id}`)
}
......@@ -748,46 +883,66 @@ const Products: React.FC<{}> = () => {
</Space>
);
const changeTabs = (key) => {
console.log(key, 'key')
}
return (
<PageHeaderWrapper>
<Card>
<StandardTable
columns={columns}
currentRef={ref}
rowSelection={rowSelection}
tableProps={{
rowKey: 'id',
}}
fetchTableData={(params: any) => fetchData(params)}
controlRender={
<NiceForm
actions={formActions}
onSubmit={values => ref.current.reload(values)}
expressionScope={{
controllerBtns,
}}
effects={($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'name',
FORM_FILTER_PATH,
)
FormEffectHooks.onFieldChange$('brandId').subscribe(() => {
searchBrandOptionEffect(actions, 'brandId')
})
FormEffectHooks.onFieldChange$('customerCategoryId').subscribe(() => {
searchCustomerCategoryOptionEffect(actions, 'customerCategoryId')
})
<Tabs defaultActiveKey="1" onChange={changeTabs}>
<Tabs.TabPane tab="全部" key="1">
<StandardTable
columns={columns}
currentRef={ref}
rowSelection={rowSelection}
tableProps={{
rowKey: 'id',
}}
schema={productSchema}
{...formatedFormValue}
onReset={() => {
clear()
fetchTableData={(params) => fetchData(params)}
controlRender={
<NiceForm
actions={formActions}
onSubmit={values => ref.current.reload(values)}
expressionScope={{
controllerBtns,
}}
effects={($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'name',
FORM_FILTER_PATH,
)
FormEffectHooks.onFieldChange$('brandId').subscribe(() => {
searchBrandOptionEffect(actions, 'brandId')
})
FormEffectHooks.onFieldChange$('customerCategoryId').subscribe(() => {
searchCustomerCategoryOptionEffect(actions, 'customerCategoryId')
})
}}
schema={productSchema}
{...formatedFormValue}
onReset={() => {
clear()
}}
/>
}
/>
</Tabs.TabPane>
<Tabs.TabPane tab="草稿" key="2">
<StandardTable
columns={draftColumns}
currentRef={refDraft}
rowSelection={rowSelection}
tableProps={{
rowKey: 'id',
}}
fetchTableData={(params) => fetchDraftData(params)}
/>
}
/>
</Tabs.TabPane>
</Tabs>
</Card>
<Modal
title={modalTitle}
......
......@@ -38,14 +38,15 @@ class ProductStore implements IProductModule {
@computed
public get getBasicFormParamsByEdit(): IBasicFormParam {
return {
brandId: this.productInfoByEdit?.brand?.id,
brandId: this.productInfoByEdit?.brandId,
brandName: this.productInfoByEdit?.brand?.name,
name: this.productInfoByEdit?.name,
slogan: this.productInfoByEdit?.slogan,
sellingPoint: this.productInfoByEdit?.sellingPoint,
commodityAreaList: this.productInfoByEdit?.commodityAreaList.map(item => [item.provinceCode, item.cityCode]),
customerCategoryId: this.productInfoByEdit?.customerCategory.fullId.split('.').map(item => Number(item) + ''),
customerCategoryName: this.productInfoByEdit?.customerCategory.fullName
// 兼容草稿
customerCategoryId: this.productInfoByEdit?.draft ? this.productInfoByEdit?.customerCategoryId : this.productInfoByEdit?.customerCategory.fullId.split('.').map(item => Number(item) + ''),
customerCategoryName: this.productInfoByEdit?.customerCategory?.fullName
}
}
......@@ -162,6 +163,7 @@ class ProductStore implements IProductModule {
this.selectBrandId = null;
this.productPriceType = null;
this.isRecombination = false;
this.sendCycle = null;
}
// 编辑时 品类变更 清空部分数据
......
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