@fle-ui/plus-goods-detail-drawer
Version:
@fle-ui/plus-goods-detail-drawer
96 lines • 4.05 kB
JavaScript
import "antd/es/descriptions/style";
import _Descriptions from "antd/es/descriptions";
import "antd/es/typography/style";
import _Typography from "antd/es/typography";
import React from 'react';
import { formatDescriptionsItem, formatValueToBoolean } from '../DescriptionsItem';
import GoodsSectionTable from '../SectionTable';
var Text = _Typography.Text;
var LogisticsInfoSection = function LogisticsInfoSection(_ref) {
var hideFields = _ref.hideFields,
freightInfo = _ref.freightInfo,
changeContent = _ref.changeContent,
beforeContent = _ref.beforeContent,
isAudit = _ref.isAudit;
if (!freightInfo) return null;
var FreightTypes = [{
type: 'onceFreightInfo',
title: '一件代发快递运费'
}, {
type: 'purchaseFreightInfo',
title: '集采批发快递运费'
}, {
type: 'sampleFreightInfo',
title: '样品运费信息'
}];
var getFreightContent = function getFreightContent(freightData) {
if (!freightData) return '-';
if (freightData.freightType === 1) {
return freightData.rules && freightData.rules.length > 0 ? /*#__PURE__*/React.createElement(GoodsSectionTable, {
showPreview: false,
data: freightData.rules,
thead: [{
name: '配送地区',
key: 'regionNames'
}, {
name: '运费规则',
key: 'rateText'
}],
header: /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Text, {
style: {
color: '#999'
}
}, "\u8FD0\u8D39\u6A21\u677F\u540D\u79F0\uFF1A"), /*#__PURE__*/React.createElement(Text, null, freightData.freightName), freightData.chargeMode && /*#__PURE__*/React.createElement(Text, null, "\uFF08".concat(freightData.chargeMode, "\uFF09"))),
footer: freightData.noDeliveryRegionNames ? /*#__PURE__*/React.createElement("div", {
style: {
color: '#999'
}
}, "\u4E0D\u53D1\u8D27\u5730\u533A\uFF1A", freightData.noDeliveryRegionNames) : null
}) : '-';
}
if (freightData.freightType === 2) {
return /*#__PURE__*/React.createElement("div", {
className: "freight-description-wrap"
}, freightData.freightDescription || '-');
}
return '-';
};
return /*#__PURE__*/React.createElement("div", {
id: "logistics-info",
className: "goods-detail-drawer-section"
}, /*#__PURE__*/React.createElement("div", {
className: "goods-detail-drawer-section-title"
}, "\u7269\u6D41\u4FE1\u606F"), FreightTypes.map(function (_ref2) {
var _changeRecordData$rul;
var type = _ref2.type,
title = _ref2.title;
var freightData = freightInfo[type];
var changeRecordData = changeContent === null || changeContent === void 0 ? void 0 : changeContent[type];
var beforeContentData = beforeContent === null || beforeContent === void 0 ? void 0 : beforeContent[type];
return /*#__PURE__*/React.createElement(_Descriptions, {
key: type,
size: "small",
colon: false,
layout: "vertical",
column: (freightData === null || freightData === void 0 ? void 0 : freightData.freightType) === 2 ? 1 : undefined,
style: {
marginTop: 20
},
items: [formatDescriptionsItem({
hideFields: hideFields,
key: "freightInfo.".concat(type),
label: title,
dynamicWidth: (changeRecordData === null || changeRecordData === void 0 ? void 0 : changeRecordData.rules) && (changeRecordData === null || changeRecordData === void 0 ? void 0 : (_changeRecordData$rul = changeRecordData.rules) === null || _changeRecordData$rul === void 0 ? void 0 : _changeRecordData$rul.length) > 0,
labelStyle: {
fontWeight: 500,
color: '#1d2531',
width: '100px'
},
isChangeRecord: isAudit && formatValueToBoolean(changeRecordData),
beforeContent: getFreightContent(beforeContentData),
children: getFreightContent(freightData)
})].filter(Boolean)
});
}));
};
export default LogisticsInfoSection;