1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017 |
- import React, { PureComponent } from "react";
- import { connect } from "dva";
- import { routerRedux } from "dva/router";
- import {
- Icon,
- Checkbox,
- Select,
- Input,
- DatePicker,
- Popover,
- Button,
- notification,
- message,
- Layout,
- Row,
- Col,
- Affix,
- Popconfirm,
- Spin,
- Tag,
- Modal
- } from "antd";
- import moment from "moment";
- import styles from "./index.less";
- import OrderGoodsList from "@/components/OrderGoodsList/index.js";
- import TreeListModal from "@/components/SelectDialog/TreeList/index";
- import InvoiceDialog from "@/components/InvoiceDialog/index";
- import { getCustomer, getDefaultCurrency } from "@/utils/request.js";
- import FormPayforDialog from "@/components/PayforDialog/index";
- import {
- setItemsDefaultData,
- getMaxOccupyMny,
- matchCustomerCast,
- ifSupplierIsOrg,
- translateItemBomFromItem
- } from "./orderTools";
- import { getGoodAndPalettePriceConAPI,saveGoodsOptsResultAPI, getOptByIdAPI } from "../../../services/api";
- const { Header, Content } = Layout;
- // 获取默认币种
- const currency = {
- id: getDefaultCurrency().id || "",
- currencySign: getDefaultCurrency().currencySign || "¥",
- currencyPriceScale: getDefaultCurrency().currencyPriceScale || 2,
- currencyAmountScale: getDefaultCurrency().currencyAmountScale || 2
- };
- const ifOptional = true;
- const ifStrucManage = true;
- class OrderEidt extends PureComponent {
- constructor(props) {
- super(props);
- this.customerId = getCustomer().id;
- this.customerRankCode = getCustomer().customerRankCode;
- this.ifPromotion = false; // 是否重新询促销
- this.ifOccupy = false; // 是否重新询费用
- this.ifCredit = false; // 是否重新询信用
- this.ifFillBom = false; // 是否重新补充BOM信息
- // this.promotionStyle = ""; // 促销维度
- this.giftItems = [];
- this.state = {
- ref: {},
- addressData: [], // 收货地址
- invoiceInfoData: [], // 发票
- btnTxt: "展开地址",
- iconType: "down",
- isShow: false, // 控制地址收起展开
- totalWeight: 0, // 总质量
- totalVolume: 0, // 总体积
- totalNum: 0, // 总数量
- totalDealAmount: 0, // 订单成交金额
- totalAmount: 0, // 商品总金额(订单原金额)
- promAmount: 0, // 促销金额
- supplierId: "", // 供应商
- transportModeId: "", // 运输方式
- settleModeId: "", // 结算方式
- underPaymentModeId: "", // 支付方式
- underPaymentModeCode: "",
- underPaymentModeName: "", // 支付方式name
- remark: "", // 订单备注
- deliveryDate: Date.now(), // 期望收货日期
- offsetAmount: 0, // 费用冲抵金额
- haveChecked: false, // 购物车下单,暂存订单编辑用到该参数
- supplierDisabled: false, // 供应商不可编辑,默认false
- srcOrderId: "", // 来源单据(原单主键)
- srcOrderCode: "", // 来源单据编号
- castTypeId: "", // 客户费用单类型主键(货补兑付)
- saleModel: "01", // 销售模式
- // 根据供货方是否组织,判断是否一级经销商,默认为一级经销商
- ifCashOrder: false, // 是否 货补兑付订单(一级渠道商才能使用货补)
- ifOneSupplier: true, // 是否一级渠道商
- ifEditOrder: false, // 是否是订单编辑
- loading: false, // 提交、暂存
- goodsLoading: false, // 商品行
- occupyMnyTopLimit: {},
- payNeedData: {},
- modalResultVisible: false,
- ifSubmit: false,
- isSubBut: false,
- actionType: "",
- isDisabled: false,
- optValShow: false,
- optSearchVal: "",
- optValSelectId: "",
- optVal: {
- baseGoodsOptValue: "",
- baseGoodsOptId: "",
- ext05: "",
- ext04: "",
- price: ""
- } ,
- currRow: -1,
- goodsAttrVals: []
- };
- }
- componentWillMount() {
- const { dispatch, location } = this.props;
- // 获取购物车商品(购物车下单)
- const cartData = location["cartData"];
- // 获取订单主键(订单编辑)
- const orderId = location[`orderId`];
- // 复制
- const query = location[`query`];
- // 货补兑付
- const cashOrderData = location[`cashOrderData`];
- dispatch({
- type: "orderEdit/getSupplierData",
- payload: null
- })
- .finally(() => {
- const { supplierData } = this.props;
- const { supplierId, saleModel } = this.state;
- if (supplierId) {
- // // 匹配账期
- // dispatch({
- // type: "orderEdit/getAccountPeriodInfo",
- // payload: {
- // saleOrg: supplierId, // 销售组织
- // customer: this.customerId, // 客户
- // saleModel: saleModel
- // }
- // });
- // 判断供应商是否为组织
- const isOrg = ifSupplierIsOrg(supplierId, supplierData);
- // 供应商是组织时,只设置ifOneSupplier为true,适配货补
- if (isOrg) {
- this.setState({
- ifOneSupplier: true
- });
- } else {
- this.setState({
- ifOneSupplier: false
- });
- }
- }
- });
- dispatch({
- type: "orderEdit/getAddressData",
- payload: null
- })
- .finally(() => {
- const { addressData, orderEditData } = this.props;
- // console.log("===");
- // console.log(orderEditData);
- // console.log(addressData);
- if (orderEditData && orderEditData.reqOrderReceiveAddress && orderEditData.reqOrderReceiveAddress.receiveAddressId && addressData) {
- addressData.forEach(item => {
- item.isSelected = "0";
- });
- (addressData.find(item => item.id == orderEditData.reqOrderReceiveAddress.receiveAddressId) || {}).isSelected = "1";
- this.setState({
- addressData: addressData
- });
- }
- });
- dispatch({
- type: "orderEdit/getLogisticsData",
- payload: null
- });
- dispatch({
- type: "orderEdit/getSettlementData",
- payload: null
- });
- dispatch({
- type: "orderEdit/getPayforMainData",
- payload: null
- });
- // 获取项目
- dispatch({
- type: "orderEdit/getProjectData",
- payload: {
- search_EQ_isEnable: 1
- }
- });
- dispatch({
- type: "orderEdit/getInvoiceInfoData",
- payload: null
- })
- .finally(() => {
- const { invoiceInfoData, orderEditData } = this.props;
- if (orderEditData && orderEditData.reqOrderInvoice &&
- orderEditData.reqOrderInvoice.invoiceId && invoiceInfoData
- ) {
- invoiceInfoData.forEach(item => {
- item.isDefault = "0";
- });
- (
- invoiceInfoData.find(
- item => item.id == orderEditData.reqOrderInvoice.invoiceId
- ) || {}
- ).isDefault =
- "1";
- this.setState({
- invoiceInfoData: invoiceInfoData
- });
- }
- });
- // 防止有历史数据,先清空订单商品,促销等相关信息
- dispatch({
- type: "orderEdit/orderEditData",
- orderEditData: null
- });
- dispatch({
- type: "orderEdit/orderCartData",
- orderCartData: []
- });
- dispatch({
- type: "orderEdit/occupyMnyTopLimits",
- occupyMnyTopLimits: null
- });
- dispatch({
- type: "orderEdit/orderCredit",
- orderCredit: {}
- });
- dispatch({
- type: "orderEdit/promotionInfoData",
- promotionInfoData: null
- });
- // 复制订单
- if (query && query.orderId) {
- dispatch({
- type: "orderEdit/getOrderEditDataForCopy",
- payload: {
- id: query.orderId
- }
- });
- this.setState({
- srcOrderId: query.orderId,
- srcOrderCode: query.orderCode,
- haveChecked: true
- });
- }
- // 订单编辑 (例如:订单暂存编辑、驳回编辑)
- if (orderId) {
- dispatch({
- type: "orderEdit/getOrderEditData",
- payload: {
- id: orderId
- }
- });
- this.setState({
- ifEditOrder: true,
- haveChecked: true
- });
- }
- // 购物车下单
- if (cartData) {
- dispatch({
- type: "orderEdit/orderCartData",
- orderCartData: setItemsDefaultData(cartData.cartlist, false)
- });
- this.setState({
- supplierId: cartData.saleOrgId || cartData.supplierId,
- ifOneSupplier: cartData.isPrimaryChannel == 1 ? true : false,
- supplierDisabled: true,
- goodsLoading: cartData.isPrimaryChannel == 1 ? true : false,
- haveChecked: true
- });
- }
- // 货补兑付下单 todo...
- if (cashOrderData) {
- dispatch({
- type: "orderEdit/orderCartData",
- orderCartData: setItemsDefaultData(cashOrderData.reqOrderItems, true)
- });
- this.setState({
- castTypeId: cashOrderData.castTypeId,
- supplierId: cashOrderData.saleOrgId,
- ifOneSupplier: true, // 一级经销商才能使用货补
- saleModel: "03",
- supplierDisabled: true,
- haveChecked: false,
- ifCashOrder: true
- });
- }
- }
- componentWillReceiveProps(nextProps) {
- const { dispatch, orderCartData, occupyMnyTopLimits } = nextProps;
- const { ifCashOrder, ifOneSupplier } = this.state;
- // 非货补订单重新询促销,先清空费用冲抵、促销、赠品信息
- if (this.ifPromotion && !ifCashOrder) {
- // 清空促销,赠品信息
- dispatch({
- type: "orderEdit/promotionInfoData",
- promotionInfoData: null
- });
- this.giftItems = [];
- this.setState({
- goodsLoading: true
- });
- // 如为一级经销商,则需重新匹配费用
- if (ifOneSupplier) {
- // 重新询促销,代表商品行信息发生改变,此时,重新匹配费用
- const occupyMnyTopLimit = matchCustomerCast(orderCartData, occupyMnyTopLimits);
- this.setState({
- offsetAmount: 0,
- occupyMnyTopLimit: occupyMnyTopLimit || {}
- });
- }
- }
- if ("promotionInfoData" in nextProps) {
- const promotionInfoData = nextProps.promotionInfoData;
- if (promotionInfoData && promotionInfoData.reqOrderItems) {
- dispatch({
- type: "orderEdit/orderCartData",
- orderCartData: promotionInfoData.reqOrderItems
- });
- }
- }
- if ("addressData" in nextProps) {
- const addressData = nextProps.addressData;
- this.setState({
- addressData: addressData
- });
- }
- if ("invoiceInfoData" in nextProps) {
- const invoiceInfoData = nextProps.invoiceInfoData;
- this.setState({
- invoiceInfoData: invoiceInfoData
- });
- }
- if ("orderCartData" in nextProps) {
- const orderCartData = nextProps.orderCartData;
- if (orderCartData && orderCartData.length > 0) {
- if (this.state.haveChecked) {
- // 查询促销信息
- this.ifPromotion = true;
- // 重新补充Bom信息
- this.ifFillBom = true;
- // 非货补下单且为一级渠道商下单,重新询费用
- if (!this.state.ifCashOrder && this.state.ifOneSupplier) {
- // 查询费用
- this.ifOccupy = true;
- }
- this.setState({
- haveChecked: false
- });
- }
- }
- }
- if ("orderEditData" in nextProps) {
- const orderEditData = nextProps.orderEditData;
- if (orderEditData && orderEditData.id) {
- if (this.state.haveChecked) {
- // todo...
- this.setState({
- supplierDisabled: (orderEditData.saleOrgId || orderEditData.supplierId) ? true : false,
- supplierId: orderEditData.saleOrgId || orderEditData.supplierId, // 供应商(一级渠道商为组织、非一级渠道商为上级客户)
- ifOneSupplier: orderEditData.saleOrgId ? true : false,
- transportModeId: orderEditData.transportModeId, // 运输方式
- settleModeId: orderEditData.settleModeId, // 结算方式
- underPaymentModeId: orderEditData.underPaymentModeId, // 支付方式
- underPaymentModeCode: orderEditData.underPaymentModeCode, // 支付方式
- underPaymentModeName: orderEditData.underPaymentModeName,
- remark: orderEditData.remark, // 订单备注
- deliveryDate: Date.now() // 期望收货日期
- });
- // todo...
- if (orderEditData.reqOrderItems.length > 0) {
- dispatch({
- type: "orderEdit/orderCartData",
- orderCartData: orderEditData.reqOrderItems
- });
- const { addressData, invoiceInfoData } = nextProps;
- if (
- orderEditData.reqOrderReceiveAddress &&
- orderEditData.reqOrderReceiveAddress.receiveAddressId
- ) {
- addressData.forEach(item => {
- item.isSelected = "0";
- });
- (
- addressData.find(
- item =>
- item.id ==
- orderEditData.reqOrderReceiveAddress.receiveAddressId
- ) || {}
- ).isSelected =
- "1";
- }
- if (
- orderEditData.reqOrderInvoice &&
- orderEditData.reqOrderInvoice.invoiceId
- ) {
- invoiceInfoData.forEach(item => {
- item.isDefault = "0";
- });
- (
- invoiceInfoData.find(
- item => item.id == orderEditData.reqOrderInvoice.invoiceId
- ) || {}
- ).isDefault =
- "1";
- }
- }
- }
- }
- }
- // 订单暂存、提交返回结果 todo...
- if ("resultOrder" in nextProps) {
- const resultOrder = nextProps.resultOrder;
- if (!resultOrder) return null;
- if (resultOrder.id) {
- let msg = "订单提交成功";
- if (resultOrder.orderStatusCode == "01") {
- msg = "订单暂存成功";
- if (this.state.underPaymentModeName == "在线支付" && this.state.isSubBut) {
- const currencyName = JSON.parse(localStorage["_A_P_currency"]).name;
- const payBillDatalist = {
- id: resultOrder.id
- };
- this.state.payNeedData = {
- total_amount: resultOrder.totalDealAmount,
- out_trade_no: resultOrder.orderCode,
- paymentModeName: resultOrder.paymentModeName,
- currencyName: currencyName,
- payBillData: payBillDatalist
- };
- dispatch({
- type: "paymentNotice/orderPayBillSet",
- orderPayBillSet: this.state.payNeedData
- });
- this.props.dispatch({
- type: "global/orderListVisible",
- payload: true
- });
- } else {
- setTimeout(() => {
- dispatch(routerRedux.push("/buyer/orderList"));
- }, 2000);
- }
- } else {
- // 删除购物车相关商品
- this.removeShopCart();
- }
- notification.success({
- message: msg,
- description: `订单号为${resultOrder.orderCode},2秒后跳转到订单列表页`,
- duration: 2
- });
- if (resultOrder.orderStatusCode == "01" && this.state.underPaymentModeName == "在线支付") {
- console.log("去支付");
- } else {
- setTimeout(() => {
- dispatch(routerRedux.push("/buyer/orderList"));
- }, 2000);
- }
- dispatch({
- type: "orderEdit/resultOrder",
- resultOrder: null
- });
- } else {
- const { ifSubmit } = this.state;
- if (!ifSubmit) return;
- let msg = "订单提交失败";
- if (resultOrder.orderStatusCode == "01") {
- msg = "订单暂存失败";
- }
- if (resultOrder.message) {
- msg = `${msg}:${resultOrder.message}`;
- }
- notification.error({
- message: msg,
- duration: 3
- });
- dispatch({
- type: "orderEdit/resultOrder",
- resultOrder: null
- });
- }
- }
- }
- componentDidUpdate() {
- const { orderCartData, dispatch, occupyMnyTopLimits } = this.props;
- const { supplierId, ifCashOrder, saleModel, ifOneSupplier } = this.state;
- // orderCartData.forEach(item => {
- // console.log(`=================================${item.dealAmount}`);
- // return item;
- // });
- // 非货补订单询促销
- if (!ifCashOrder && this.ifPromotion) {
- // 匹配促销信息
- dispatch({
- type: "orderEdit/getPromotionInfo",
- payload: {
- saleOrgId: supplierId, // 销售组织
- customerId: this.customerId, // 客户
- // isPrimaryChannel: ifOneSupplier ? 1 : 0, // 是否一级渠道商
- orderType: "reqOrder",
- reqOrderItems: orderCartData // 商品行信息
- }
- })
- .finally(() => {
- this.setState({
- goodsLoading: false
- });
- // 非货补下单且为一级渠道商下单,检测信用
- if (!this.state.ifCashOrder && this.state.ifOneSupplier) {
- this.checkCreditHandle();
- }
- // 重新补充BOM信息
- if (this.ifFillBom) {
- this.LinkGoodsBomInfo();
- }
- // this.LinkGoodsBomInfo();
- });
- this.giftItems = [];
- this.ifPromotion = false;
- }
- // 非货补下单且为一级渠道商下单,匹配费用,检测信用
- if (!ifCashOrder && ifOneSupplier) {
- if (this.ifOccupy) {
- // 匹配费用
- dispatch({
- type: "orderEdit/getOccupyMnyTopLimit",
- payload: {
- saleOrgId: supplierId, // 销售组织
- customerId: this.customerId // 客户
- }
- })
- .finally(() => {
- const occupyMnyTopLimit = matchCustomerCast(orderCartData, this.props.occupyMnyTopLimits);
- this.setState({
- occupyMnyTopLimit: occupyMnyTopLimit || {}
- });
- });
- this.ifOccupy = false;
- }
- if (this.ifCredit) {
- this.checkCreditHandle();
- this.ifCredit = false;
- }
- }
- }
- // 设为默认地址
- setDefaultHandle(index) {
- let { addressData } = this.state;
- addressData = Array.isArray(addressData)
- ? addressData
- : Object.values(addressData);
- // 设置默认收获地址
- this.props.dispatch({
- type: "orderEdit/setDefaultAddress",
- payload: {
- customer: this.customerId, // 客户id
- id: addressData[index].id // 收获地址id
- }
- })
- .finally((res) => {
- res.forEach(item => {
- if (!!item.isDefault) item.isSelected = "1";
- else item.isSelected = "0";
- });
- /*
- if (res) {
- addressData.forEach(item => {
- item.isDefault = "0";
- item.isSelected = "0";
- });
- addressData[index].isDefault = "1";
- addressData[index].isSelected = "1";
- }
- */
- this.setState({
- addressData: Object.assign({}, res)
- });
- });
- /*
- addressData.forEach(item => {
- item.isDefault = "0";
- item.isSelected = "0";
- });
- addressData[index].isDefault = "1";
- addressData[index].isSelected = "1";
- this.setState({
- addressData: Object.assign({}, addressData)
- });
- */
- }
- // 结算方式改变
- settlementChange(value) {
- this.setState({
- settleModeId: value
- });
- }
- // 支付方式
- payforMainChange(value) {
- const { payforMainData } = this.props;
- let payModl = "", code = "";
- for (var i = 0; i < payforMainData.length; i++) {
- if (payforMainData[i].id == value) {
- payModl = payforMainData[i].name;
- code = payforMainData[i].code;
- }
- }
- this.setState({
- underPaymentModeId: value,
- underPaymentModeCode: code,
- underPaymentModeName: payModl
- });
- }
- checkCreditHandle() {
- // const { orderCartData, dispatch } = this.props;
- // const { supplierId, saleModel } = this.state;
- // if (supplierId && orderCartData && Array.isArray(orderCartData)) {
- // // 信用检测
- // dispatch({
- // type: "orderEdit/orderCreditChecker",
- // payload: {
- // saleOrgId: supplierId, // 销售组织
- // customerId: this.customerId, // 客户
- // saleModel: saleModel,
- // reqOrderItems: orderCartData // 商品行信息
- // }
- // });
- // }
- }
- // 联查BOM信息
- LinkGoodsBomInfo() {
- const { dispatch, orderCartData } = this.props;
- dispatch({
- type: "orderEdit/getItemBomInfo",
- payload: {
- reqOrderItems: orderCartData // 商品行信息
- }
- });
- this.ifFillBom = false;
- }
- // 删除购物车商品
- removeShopCart() {
- const { orderCartData, cartListData, dispatch } = this.props;
- if (!cartListData || !Array.isArray(cartListData)) return;
- if (!orderCartData || !Array.isArray(orderCartData)) return;
- const { supplierId } = this.state;
- const cartIds = [];
- for (let i = 0; i < cartListData.length; i++) {
- const saleOrgId = cartListData[i].saleOrgId || cartListData[i].supplierId;
- if (saleOrgId == supplierId) {
- const newCartlistData = cartListData[i].cartlist;
- if (newCartlistData && newCartlistData.length > 0) {
- orderCartData.forEach(orderItem => {
- const cart = newCartlistData.find(item => item.goodsId == orderItem.goodsId);
- if (cart && cart.id) {
- cartIds.push(cart.id);
- }
- });
- }
- }
- }
- if (cartIds && cartIds.length > 0) {
- const cartId = cartIds.join(",");
- dispatch({
- type: "cartList/deleteCartListData",
- payload: { id: cartId }
- });
- }
- }
- selectAddressHandle(index) {
- let { addressData } = this.state;
- addressData = Array.isArray(addressData)
- ? addressData
- : Object.values(addressData);
- addressData.forEach(item => {
- item.isSelected = "0";
- });
- addressData[index].isSelected = "1";
- this.setState({
- addressData: Object.assign({}, addressData)
- });
- }
- promotionChangeHandle(style) {
- const { orderCartData, dispatch, promotionInfoData } = this.props;
- const mutualRelationShip = promotionInfoData.mutualRelationShip;
- const { supplierId, ifCashOrder, ifOneSupplier } = this.state;
- if (!ifCashOrder) {
- dispatch({
- type: "orderEdit/getPromotionInfo",
- payload: {
- saleOrgId: supplierId, // 销售组织
- customerId: this.customerId, // 客户
- isPrimaryChannel: ifOneSupplier ? 1 : 0, // 是否一级渠道商
- promotionStyle: style,
- reqOrderItems: orderCartData // 商品行信息
- }
- })
- .finally(() => {
- const { dispatch, promotionInfoData } = this.props;
- const newPromotionInfoData = Object.assign({}, promotionInfoData);
- newPromotionInfoData.giftProms = promotionInfoData.giftProms;
- newPromotionInfoData.orderPriceProm = promotionInfoData.orderPriceProm;
- newPromotionInfoData.reqOrderItems = promotionInfoData.reqOrderItems;
- newPromotionInfoData.mutualRelationShip = mutualRelationShip;
- dispatch({
- type: "orderEdit/promotionInfoData",
- promotionInfoData: newPromotionInfoData
- });
- });
- this.giftItems = [];
- }
- }
- async onOptClick(goods, index) {
- const attrs = await getOptByIdAPI({id: goods.goodsId, groupId: "", colourCode:""});
- this.setState({
- currRow: index,
- optValShow: true,
- goodsAttrVals: attrs[0].goodsAttrVals
- })
- }
- selectColor(optValSelectId) {
- this.setState({
- optValSelectId
- });
- }
- async confirmColor(color) {
- const { dispatch, orderCartData, supplierData } = this.props;
- let goodsDetail = {...orderCartData[this.state.currRow]}
- let existRow = orderCartData.findIndex((item,index) => item.ext05 == color.attrValId && item.goodsId == color.goodsId && index != this.state.currRow)
- if (existRow >= 0) {
- message.info("所选颜色商品已存在,请重新选择!");
- return
- }
- const params = {
- organizationId: supplierData[0].id,
- customerId: getCustomer().id,
- goodsId: goodsDetail.goodsId,
- orderTypeId: '01',
- paletteId: color.attrValId,
- shopId: ''
- }
- const result = await getGoodAndPalettePriceConAPI(params)
- if (result.length) {
- const optParams = [{
- goodsOptDtos: [{
- goodsId: goodsDetail.goodsId,
- goodsOptVals: [color],
- optResult: color.custDocGroupName+ ":" + color.attrValName,
- uniqueKey: goodsDetail.goodsId
- }]
- }]
- const opt = await saveGoodsOptsResultAPI(optParams);
- const price = result[0].price
- const priceAndMny = {
- promPrice : price,
- basePrice : price,
- dealPrice : price,
- salePrice : price,
- ext09 : price,
- ext10 : price * goodsDetail.orderNum,
- amount : price * goodsDetail.orderNum,
- dealAmount : goodsDetail.amount,
- baseGoodsOptId : opt[0].goodsOptDtos[0].id,
- baseGoodsOptValue : color.custDocGroupName+ ":" + color.attrValName,
- ext05 : color.attrValCode
- }
- let newItem = Object.assign({},goodsDetail,priceAndMny)
- orderCartData.splice(this.state.currRow,1,newItem)
- dispatch({
- type: "orderEdit/orderCartData",
- orderCartData: [...orderCartData]
- })
- }
- }
- // 备注改变
- remarkChange(e) {
- this.setState({
- remark: e.target.value
- });
- }
- // 收货日期改变
- dateChange(date, datestring) {
- this.setState({
- deliveryDate: datestring
- });
- }
- // 物流方式改变
- logisticsChange(value) {
- this.setState({
- transportModeId: value
- });
- }
- // 供应商改变
- supplierChange(value) {
- const { dispatch, supplierData } = this.props;
- const { supplierId, saleModel } = this.state;
- // 匹配账期
- // dispatch({
- // type: "orderEdit/getAccountPeriodInfo",
- // payload: {
- // saleOrg: value, // 销售组织
- // customer: this.customerId, // 客户
- // saleModel: saleModel
- // }
- // });
- // 判断供应上是否为组织
- const isOrg = ifSupplierIsOrg(value, supplierData);
- // 供应商是组织时,只设置ifOneSupplier为true,适配货补
- if (isOrg) {
- this.setState({
- supplierId: value,
- ifOneSupplier: true
- });
- this.ifOccupy = true;
- } else {
- this.setState({
- supplierId: value,
- ifOneSupplier: false
- });
- }
- dispatch({
- type: "orderEdit/orderCartData",
- orderCartData: []
- });
- // 促销
- dispatch({
- type: "orderEdit/promotionInfoData",
- promotionInfoData: null
- });
- this.giftItems = [];
- // 信用检测
- dispatch({
- type: "orderEdit/orderCredit",
- orderCredit: {}
- });
- // 清空促销
- dispatch({
- type: "orderEdit/occupyMnyTopLimits",
- occupyMnyTopLimits: null
- });
- }
- // 票扣改变时
- custfeeChange(e) {
- e.preventDefault();
- const value = e.target.value;
- const reg = /^-?(0|[1-9][0-9]*)(\.[0-9]*)?$/;
- if (value.length == 0) {
- this.setState({
- offsetAmount: value
- });
- } else {
- if (value.length > 1 && value.indexOf("0") == 0 && value.indexOf(".") != 1) {
- this.setState({
- offsetAmount: parseFloat(value)
- });
- } else {
- if (value && reg.test(value)) {
- this.setState({
- offsetAmount: value
- });
- } else {
- message.info("请输入有效金额!");
- }
- }
- }
- }
- // 票扣输入框失去焦点时
- custfeeBlur() {
- const { totalAmount, promAmount, offsetAmount, occupyMnyTopLimit } = this.state;
- const max = getMaxOccupyMny(
- occupyMnyTopLimit,
- totalAmount,
- totalAmount - promAmount
- );
- let value = +offsetAmount;
- if (value > max) {
- value = max;
- message.info("您录入的费用冲抵金额不能超出本次最高可冲抵金额!");
- }
- if (value < 0) {
- value = 0;
- }
- value = +(value.toFixed(currency.currencyAmountScale));
- this.setState({
- offsetAmount: value,
- totalDealAmount: totalAmount - promAmount - value
- });
- this.ifCredit = true;
- }
- // 获取商品信息
- goodsInfoChange(value) {
- const { totalDealAmount, promAmount, occupyMnyTopLimit } = this.state;
- const offsetAmount = +this.state.offsetAmount;
- /**
- * 促销金额 = 商品总金额-商品促销后总金额
- * 订单金额 = 商品促销后总金额 - 冲抵金额
- */
- this.setState({
- totalAmount: value.newTotalAmount,
- promAmount: value.newTotalAmount - value.newTotalDealAmount,
- totalDealAmount: value.newTotalDealAmount - offsetAmount,
- totalWeight: value.newAllWeight,
- totalVolume: value.newAllVolume,
- totalNum: value.newTotalNum
- });
- }
- // 展开收起地址
- showAddressClick() {
- this.setState({
- btnTxt: this.state.btnTxt == "展开地址" ? "收起地址" : "展开地址",
- iconType: this.state.iconType == "down" ? "up" : "down",
- isShow: !this.state.isShow
- });
- }
- // 取消
- cancelHandle() {
- const { dispatch } = this.props;
- const { ifCashOrder, ifOneSupplier } = this.state;
- // 如果是货补兑付订单,则点击取消返回货补兑付列表页
- if (ifCashOrder && ifOneSupplier) {
- dispatch(routerRedux.push("/buyer/goodsSupplyList"));
- } else {
- dispatch(routerRedux.push("/buyer/orderList"));
- }
- }
- // 暂存
- saveTempHandle(isSubmit) {
- const { dispatch } = this.props;
- const postData = this.packageOrderData();
- const warnInfo = this.validOrderData(postData);
- if (warnInfo) {
- message.warning(warnInfo);
- return false;
- }
- this.setState({
- loading: true,
- ifSubmit: true,
- isSubBut: false
- });
- dispatch({
- type: "orderEdit/saveTempOrder",
- payload: postData
- })
- .finally(() => {
- this.setState({
- loading: false,
- isDisabled: true
- });
- });
- }
- // 提交
- okHandle() {
- const { dispatch, orderCredit, payforMainData, accountPeriodInfo } = this.props;
- const { ifCashOrder, castTypeId, ifOneSupplier, underPaymentModeId } = this.state;
- let postData = this.packageOrderData();
- // 提交订单时,如有买赠或整单降价,则补充相应信息
- postData = this.fillOrderPriceCutAndGiftRows(postData);
- // 补充BOM信息
- postData = this.fillGoodsBomInfo(postData);
- let warnInfo = this.validOrderData(postData);
- // 货补兑付时,补充客户费用单主键 todo...
- if (ifCashOrder && ifOneSupplier) {
- if (!castTypeId) {
- warnInfo += "未获取到客户费用单主键,请重新下单! ";
- }
- postData.saleModel = "03"; // 货补下单时,销售模式为03
- postData.offsetAmount = postData.totalDealAmount;
- postData.totalAmount = 0;
- postData.totalDealAmount = 0;
- postData.costTypeId = castTypeId;
- postData.reqOrderItems.forEach(item => {
- if (item.isGift != 1) {
- item.offsetAmount = item.dealAmount;
- }
- });
- }
- if (warnInfo) {
- message.warning(warnInfo);
- return false;
- }
- this.setState({
- loading: true,
- ifSubmit: true
- });
- if (this.state.underPaymentModeName == "在线支付") {
- // this.saveTempHandle(true);
- this.setState({ isSubBut: true });
- dispatch({
- type: "orderEdit/saveTempOrder",
- payload: postData
- })
- .finally(() => {
- this.setState({
- loading: false
- });
- });
- return;
- }
- if (orderCredit && orderCredit.validMessage) {
- message.info(orderCredit.validMessage);
- }
- // totalDealAmount: 0, // 订单成交金额
- // totalAmount: 0, // 商品总金额(订单原金额)
- // if (parseFloat(orderCredit) + parseFloat(postData.totalDealAmount) < parseFloat(postData.totalAmount)) {
- // message.info("信用不足!");
- // }
- // if (!accountPeriodInfo || !accountPeriodInfo.name) {
- // message.info("未匹配到账期");
- // }
- dispatch({
- type: "orderEdit/submitOrder",
- payload: postData
- }).finally((data) => {
- this.setState({
- loading: false
- });
- });
- }
- // 补充整单降价、赠品行信息
- fillOrderPriceCutAndGiftRows(postData) {
- const giftItems = this.giftItems;
- const { promotionInfoData } = this.props;
- // 如有整单降价,则在表头上补充整单降价促销信息
- if (promotionInfoData && promotionInfoData.orderPriceProm) {
- const orderPriceProm = promotionInfoData.orderPriceProm;
- postData.reqOrderPromRels = [
- {
- activityId: orderPriceProm.activityId,
- ruleId: orderPriceProm.ruleId,
- description: orderPriceProm.description,
- promWay: 2, // 1 买赠 2 降价
- isWhole: 1 // 1 整单
- }
- ];
- }
- if (giftItems && giftItems.length > 0) {
- const giftRows = [];
- giftItems.forEach(giftProm => {
- const giftDtos = giftProm.giftDtos;
- if (giftDtos && giftDtos.length > 0) {
- giftDtos.forEach(gift => {
- // 封装赠品行信息
- const translate = {
- id: null,
- isGift: 1,
- basePrice: 0,
- salePrice: 0,
- promPrice: 0,
- dealPrice: 0,
- ext09:0,
- ext10:0,
- amount: 0, // 金额
- promAmount: 0, // 均摊到行上的整单降价促销金额
- dealAmount: 0, // 成交金额
- offsetAmount: 0, // 均摊到行上的费用冲抵金额
- reqOrderPromRels: [
- {
- ruleId: giftProm.ruleId,
- ruleCode: giftProm.ruleCode,
- ruleName: giftProm.ruleName,
- activityId: giftProm.activityId,
- activityCode: giftProm.activityCode,
- activityName: giftProm.activityName,
- giftId: gift.giftId,
- description: giftProm.description,
- combineType: giftProm.combineType, // 组合类型 1 固定组合
- goodCombineNum: giftProm.goodCombineNum, // 固定组合类商品基准数量
- promWay: 1, // 1 买赠 2 降价
- isWhole: 0
- }
- ]
- };
- const newGift = Object.assign({}, gift, translate);
- giftRows.push(newGift);
- });
- }
- });
- // 如果赠品行不为空,则补充到订单表体行
- if (giftRows.length > 0) {
- const reqOrderItems = postData.reqOrderItems;
- const newReqOrderItems = reqOrderItems.concat(giftRows);
- postData.reqOrderItems = newReqOrderItems;
- }
- }
- return postData;
- }
- // 补充BOM信息
- fillGoodsBomInfo(postData) {
- const reqOrderItems = postData.reqOrderItems;
- const reqOrderItemBoms = translateItemBomFromItem(reqOrderItems);
- postData.reqOrderItems = reqOrderItems;
- postData.reqOrderItemBoms = reqOrderItemBoms;
- return postData;
- }
- // 校验订单数据
- validOrderData(postData) {
- if (!postData) return "订单信息有误,请重新下单!";
- let msg = "";
- if (!this.state.supplierId) {
- msg += "供应商不能为空!";
- }
- if (!this.state.underPaymentModeId) {
- msg += "请输入支付方式!";
- }
- // if (!postData.transportModeId) {
- // msg += "运输方式不能为空!";
- // }
- // if (!postData.settleModeId) {
- // msg += "结算方式不能为空!";
- // }
- if (!postData.deliveryDate) {
- msg += "期望到货日期不能为空!";
- }
- if (
- !postData.reqOrderReceiveAddress ||
- !postData.reqOrderReceiveAddress.receiveAddressId
- ) {
- msg += "收货地址信息不能为空!";
- }
- if (!postData.reqOrderInvoice || !postData.reqOrderInvoice.invoiceId) {
- msg += "发票信息不能为空!";
- }
- if (!postData.reqOrderItems || postData.reqOrderItems.length < 1) {
- msg += "商品信息不能为空!";
- }
- // postData.reqOrderItems.forEach((item, index) => {
- // if (!item.salePrice || !item.stock || parseFloat(item.salePrice) <= 0 || parseFloat(item.stock) <= 0) {
- // msg += `第${index + 1}行商品【${item.goodsDisplayName}】无价格或无库存,不可下单,请修改!`;
- // }
- // });
- return msg;
- }
- // 封装订单信息
- packageOrderData() {
- const { orderCartData, location, orderEditData } = this.props;
- const {
- id,
- supplierId,
- transportModeId,
- settleModeId,
- underPaymentModeId,
- underPaymentModeCode,
- remark,
- deliveryDate,
- invoiceInfoData,
- totalAmount,
- totalDealAmount,
- offsetAmount,
- totalWeight,
- totalVolume,
- srcOrderId,
- srcOrderCode,
- totalNum,
- ifEditOrder,
- saleModel,
- ifOneSupplier
- } = this.state;
- // 默认地址
- let addressData = this.state.addressData;
- addressData = Array.isArray(addressData)
- ? addressData
- : Object.values(addressData);
- const addressDefault = addressData.find(item => item.isSelected == "1") || {};
- // 默认发票
- const invoiceInfoDefault = invoiceInfoData.find(
- item => item.isDefault == "1"
- ) || {};
- // todo...
- orderCartData.forEach(item => {
- item.reqOrderId = null;
- item.id = null;
- if (item.reqOrderPromRels) {
- item.reqOrderPromRels.forEach(promRel => {
- promRel.isWhole = 0;
- });
- }
- });
- const postData = {
- // todo...
- id: ifEditOrder ? orderEditData.id : "",
- orderCode: ifEditOrder ? orderEditData.orderCode : "",
- customerId: this.customerId,
- saleOrgId: ifOneSupplier ? supplierId : "", // 销售组织 (一级经销商)
- supplierId: ifOneSupplier ? "" : supplierId, // 供应商(非一级经销商)
- saleModel: "01", // 销售模式(正向时默认01:正向销售)
- transportModeId: transportModeId, // 运输方式
- settleModeId: settleModeId, // 结算方式
- underPaymentModeId: underPaymentModeCode, // 支付方式
- deliveryDate: deliveryDate, // 期望收货日期
- totalNum: "", // 总数量
- currency: currency.id, // 币种
- currencySign: currency.currencySign, // 币符
- currencyPriceScale: currency.currencyPriceScale, // 币种单价精度
- currencyAmountScale: currency.currencyAmountScale, // 币种金额精度
- totalAmount: totalAmount, // 原金额
- totalDealAmount: totalDealAmount, // 成交金额
- totalWeight: totalWeight, // 总重量
- totoalVolume: totalVolume, // 总体积
- totalNum: totalNum, // 总数量
- reqOrderSource: "01", // 门户
- srcOrderId: srcOrderId,
- srcOrderCode: srcOrderCode,
- remark: remark, // 订单备注
- offsetAmount: offsetAmount, // 费用冲抵金额
- reqOrderReceiveAddress: {
- reqOrderId: id,
- receiveAddressId: addressDefault.id, // 收货地址id
- receiver: addressDefault.receiver, // 收货人
- receiverTel: addressDefault.receiverTel, // 电话
- receiverPhone: addressDefault.receiverPhone, // 手机
- countryId: addressDefault.countryId,
- receiverProvince: addressDefault.receiverProvince, // 省
- receiverProvinceId: addressDefault.receiveAddressId,
- receiverCity: addressDefault.receiverCity, // 市
- receiverCityId: addressDefault.receiverCityId,
- receiverCounty: addressDefault.receiverCounty, // 县
- receiverCountyId: addressDefault.receiverCountyId,
- receiverTown: addressDefault.receiverTown, // 镇
- receiverTownId: addressDefault.receiverTownId,
- receiverAddress: addressDefault.receiverAddress, // 详细地址
- receiverZipcode: addressDefault.receiverZipcode, // 邮编
- isDefault: addressDefault.isDefault // 是否默认地址
- },
- reqOrderInvoice: {
- reqOrderId: id,
- invoiceId: invoiceInfoDefault.id, // 发票id
- invoiceType: invoiceInfoDefault.invoiceType, // 发票类型
- invoiceContent: invoiceInfoDefault.invoiceContent, // 开票项目
- invoiceTitle: invoiceInfoDefault.invoiceTitle, // 发票抬头
- invoiceTaxId: invoiceInfoDefault.invoiceTaxId, // 纳税人识别码
- invoiceBank: invoiceInfoDefault.invoiceBank, // 开户银行
- invoiceAccount: invoiceInfoDefault.invoiceAccount, // 开户账户
- invoiceSubBank: invoiceInfoDefault.invoiceSubBank // 支行
- },
- reqOrderItems: orderCartData
- };
- return Object.assign({}, postData);
- }
- // showCustfeeDialog() {
- // this.props.dispatch({
- // type: "global/custfeeVisible",
- // payload: true
- // });
- // }
- showInvoiceDialog() {
- this.props.dispatch({
- type: "global/invoiceVisible",
- payload: true
- });
- }
- showModal() {
- const { supplierId } = this.state;
- if (!supplierId) {
- message.info("请先选择供应商!");
- return false;
- }
- this.props.dispatch({
- type: "global/treeListVisible",
- payload: true
- });
- }
- addGoodsInfo(treeListSelectedRows) {
- const { orderCartData, dispatch } = this.props;
- let newOrderCartData = [];
- if (typeof orderCartData == "object") {
- newOrderCartData = orderCartData.concat([]);
- }
- // 判断添加的商品是否重复 todo...
- treeListSelectedRows.forEach(addRow => {
- let repeat = false;
- const conversionRate = parseFloat(addRow.conversionRate || "1");
- newOrderCartData.forEach(item => {
- // 重复,则累加订货数量、主数量
- if (item.goodsId == addRow.id && item.ext05 == addRow.ext05) {
- item.orderNum += 1;
- item.mainNum += conversionRate;
- repeat = true;
- }
- });
- if (!repeat) {
- const newAddRow = Object.assign({}, addRow);
- newAddRow.orderNum = 1;
- newAddRow.mainNum = conversionRate;
- const newAddRows = setItemsDefaultData([newAddRow], true);
- newOrderCartData = newOrderCartData.concat(newAddRows);
- }
- });
- dispatch({
- type: "orderEdit/orderCartData",
- orderCartData: newOrderCartData
- });
- // 匹配促销信息
- this.ifPromotion = true;
- // 重新补充BOM信息
- this.ifFillBom = true;
- }
- // setModalResultVisible = (modalResultVisible) => {
- // this.setState({ modalResultVisible });
- // }
- render() {
- const {
- btnTxt,
- iconType,
- isShow,
- totalAmount,
- totalDealAmount,
- promAmount,
- totalWeight,
- totalVolume,
- invoiceInfoData,
- supplierId,
- transportModeId,
- settleModeId,
- underPaymentModeId,
- underPaymentModeCode,
- underPaymentModeName,
- supplierDisabled,
- ifCashOrder,
- occupyMnyTopLimit,
- ifOneSupplier,
- modalResultVisible,
- actionType
- } = this.state;
- const {
- logisticsData,
- settlementData,
- payforMainData,
- orderCartData,
- orderCredit,
- supplierData,
- promotionInfoData,
- accountPeriodInfo
- } = this.props;
- if (payforMainData && payforMainData.length && this.state.underPaymentModeId == "") {
- for (var i = 0; i < payforMainData.length; i++) {
- if (payforMainData[i].code == "GoodsFirst") {
- this.setState({ underPaymentModeId: payforMainData[i].id });
- }
- }
- }
- const currOrderMaxOccMny = getMaxOccupyMny(
- occupyMnyTopLimit,
- totalAmount,
- totalAmount - promAmount
- );
- let addressData = this.state.addressData;
- addressData = Array.isArray(addressData)
- ? addressData
- : Object.values(addressData);
- // 收货地址
- const addressHtml = () => {
- if (!addressData) return null;
- const htmlArr = [];
- let defaultHtml;
- for (let i = 0; i < addressData.length; i++) {
- const index = i;
- if (!addressData[i].receiverPhone) addressData[i].receiverPhone = "";
- if (addressData[i].isSelected == 1) {
- defaultHtml = (
- <li className={styles.addressItem} key={addressData[i].id}>
- <span
- className={styles.name}
- style={{ border: "2px solid #E14C46" }}
- >
- {addressData[i].receiver}
- </span>
- <div className={styles.infoBox}>
- <span className={styles.addressTxt}>
- {addressData[i].receiverProvince}{" "}
- {addressData[i].receiverCity}{" "}
- {addressData[i].receiverCounty}{" "}
- {addressData[i].receiverTown} {addressData[i].receiverAddress}
- </span>
- <span className={styles.phoneNumber}>
- {addressData[i].receiverPhone ? addressData[i].receiverPhone.substr(0, 3) + "****" + addressData[i].receiverPhone.substring(7, 11) : ""}
- </span>
- <span
- style={{
- display:
- addressData[i].isDefault == 1 ? "inline-block" : "none"
- }}
- className={styles.defaultBtn}
- >
- 默认地址
- </span>
- <span
- className={
- addressData[i].isDefault == 1
- ? styles.defaultAdr
- : styles.setDefault
- }
- onClick={this.setDefaultHandle.bind(this, index)}
- >
- 设为默认
- </span>
- </div>
- </li>
- );
- } else {
- const html = (
- <li
- className={styles.addressItem}
- key={addressData[i].id}
- style={{ display: isShow ? "block" : "none" }}
- >
- <span
- className={styles.name}
- onClick={this.selectAddressHandle.bind(this, index)}
- >
- {addressData[i].receiver}
- </span>
- <div className={styles.infoBox}>
- <span className={styles.addressTxt}>
- {addressData[i].receiverProvince}{" "}
- {addressData[i].receiverCity}{" "}
- {addressData[i].receiverCounty}{" "}
- {addressData[i].receiverTown} {addressData[i].receiverAddress}
- </span>
- <span className={styles.phoneNumber}>
- {addressData[i].receiverPhone ? addressData[i].receiverPhone.substr(0, 3) + "****" + addressData[i].receiverPhone.substring(7, 11) : ""}
- </span>
- <span
- style={{
- display:
- addressData[i].isDefault == 1 ? "inline-block" : "none"
- }}
- className={styles.defaultBtn}
- >
- 默认地址
- </span>
- <span
- className={
- addressData[i].isDefault == 1
- ? styles.defaultAdr
- : styles.setDefault
- }
- onClick={this.setDefaultHandle.bind(this, index)}
- >
- 设为默认
- </span>
- </div>
- </li>
- );
- htmlArr.push(html);
- }
- }
- htmlArr.unshift(defaultHtml);
- return htmlArr;
- };
- // 拼接下拉框选项
- const selectOptionHtml = listData => {
- if (!listData || listData.length < 1) return null;
- const optionHtmls = listData.map(item => (
- <Select.Option key={item.id} value={item.id}>
- {item.name}
- </Select.Option>
- ));
- return optionHtmls;
- };
- // 发票信息
- const invoiceInfoHtml = () => {
- if (!invoiceInfoData) return null;
- const invoiceInfo = invoiceInfoData.find(item => item.isDefault == 1);
- let html;
- if (!invoiceInfo) {
- html = (
- <Row className={styles.invoiceInfo}>
- <Col span={2}/>
- <Col span={4}/>
- <Col span={2} className={styles.taxpayersNum}>
- 纳税人识别号:
- </Col>
- <Col span={4}/>
- <Col span={2} className={styles.bank}>
- 开户行:
- </Col>
- <Col span={4}/>
- <Col span={1} className={styles.account}>
- 账号:
- </Col>
- <Col span={4}/>
- <Col span={1}>
- <span
- className={styles.selectBtn}
- onClick={this.showInvoiceDialog.bind(this)}
- >
- 选择
- </span>
- </Col>
- </Row>
- );
- } else {
- html = (
- <Row className={styles.invoiceInfo}>
- <Col span={2}>{invoiceInfo.invoiceType}</Col>
- <Col span={4} title={invoiceInfo.invoiceTitle}>
- {invoiceInfo.invoiceTitle}
- </Col>
- <Col span={2} className={styles.taxpayersNum}>
- 纳税人识别号:
- </Col>
- <Col span={4} title={invoiceInfo.invoiceTaxId}>
- <em>{invoiceInfo.invoiceTaxId}</em>
- </Col>
- <Col span={2} className={styles.bank}>
- 开户行:
- </Col>
- <Col span={4} title={invoiceInfo.invoiceBank}>
- <em>{invoiceInfo.invoiceBank}</em>
- </Col>
- <Col span={1} className={styles.account}>
- 账号:
- </Col>
- <Col span={4} title={invoiceInfo.invoiceAccount}>
- <em>{invoiceInfo.invoiceAccount}</em>
- </Col>
- <Col span={1}>
- <span
- className={styles.selectBtn}
- onClick={this.showInvoiceDialog.bind(this)}
- >
- 选择
- </span>
- </Col>
- </Row>
- );
- }
- return html;
- };
- // 信用查询
- const content = () => {
- if (!orderCredit) return null;
- const creditData = orderCredit.creditData;
- if (!creditData || creditData.length < 1) {
- return (
- <div className={styles.infoSearchCon}>
- 未匹配到信用
- </div>
- );
- }
- return (
- <div className={styles.infoSearchCon}>
- <Layout>
- <Header>本单信用满足情况</Header>
- <Content>
- {creditData.map(item => {
- return (
- <Row key={item.id}>
- <Col span={4}>{item.productLineName}</Col>
- <Col span={6}>信用余额:</Col>
- <Col span={4}>
- {parseFloat(item.creditBalance || 0).toFixed(currency.currencyAmountScale)}
- </Col>
- <Col span={6}>本单产品线金额:</Col>
- <Col span={4}>{parseFloat(item.thisProdLineAmount || 0)
- .toFixed(currency.currencyAmountScale)}
- </Col>
- </Row>
- );
- })}
- </Content>
- </Layout>
- </div>
- );
- };
- const disabledDate = current => {
- return current && current.valueOf() <= Date.now() - 86400000;
- };
- return (
- <div className={styles.orderEidtBox}>
- {/* <BreadcrumbPackage additems={BreadcrumbPaths} /> */}
- <Spin spinning={this.state.loading}>
- <div className={styles.supplierBox}>
- <span className={styles.name}>
- {supplierDisabled ? "供应商" : "请选择供应商"}
- </span>
- <Select
- className={styles.supplierSelect}
- value={supplierId}
- disabled={supplierDisabled}
- onChange={this.supplierChange.bind(this)}
- >
- {selectOptionHtml(supplierData)}
- </Select>
- </div>
- {/* 订单信息 */}
- <div className={styles.orderInfoBox}>
- {/* 收货地址 */}
- <div className={styles.consigneeInfo}>
- <p className={styles.consigneeInfoTxt}>收货人信息</p>
- <div className={styles.addressListBox}>
- <div className={styles.scrollbar}>
- <ul className={styles.addressList}>{addressHtml()}</ul>
- </div>
- </div>
- <span
- className={styles.showBtn}
- onClick={this.showAddressClick.bind(this)}
- >
- {btnTxt}
- <Icon type={`${iconType}`} className={styles.icon}/>
- </span>
- </div>
- {/* 收货地址-- 结束 */}
- {/* 物流结算方式 */}
- <div className={styles.logisticsSettlement}>
- <p className={styles.logisticsSettlementTxt}>物流结算</p>
- <div className={styles.logistics}>
- <div className={styles.logisticsItem}>
- <span className={styles.name}>运输方式</span>
- <Select
- className={styles.selectBox}
- value={transportModeId}
- onChange={this.logisticsChange.bind(this)}
- >
- {selectOptionHtml(logisticsData)}
- </Select>
- </div>
- {/* <div className={styles.logisticsItem}>
- <span className={styles.name}>结算方式</span>
- <Select
- className={styles.selectBox}
- value={settleModeId}
- onChange={this.settlementChange.bind(this)}
- >
- {selectOptionHtml(settlementData)}
- </Select>
- </div>
- <div className={styles.logisticsItem}>
- <span className={styles.name}>支付方式</span>
- <Select
- className={styles.selectBox}
- value={underPaymentModeId}
- onChange={this.payforMainChange.bind(this)}
- >
- {selectOptionHtml(payforMainData)}
- </Select>
- </div>
- <div className={styles.logisticsItem}>
- <span className={styles.name}>账期</span>
- <span className={styles.accountCheck}>
- {accountPeriodInfo ? accountPeriodInfo.name : ""}
- </span>
- </div> */}
- </div>
- </div>
- {/* 物流结算方式 */}
- {/* 发票信息 */}
- <div className={styles.logisticsSettlement}>
- <p className={styles.logisticsSettlementTxt}>发票信息</p>
- <div className={styles.logistics}>{invoiceInfoHtml()}</div>
- </div>
- {/* 发票信息--end */}
- {/* 期望到货日期 */}
- <div className={styles.logisticsSettlement}>
- <p className={styles.logisticsSettlementTxt}>
- 备注
- </p>
- <div className={styles.arrival}>
- {/* <DatePicker
- className={styles.datePickerBox}
- value={moment(this.state.deliveryDate)}
- disabledDate={disabledDate}
- onChange={this.dateChange.bind(this)}
- /> */}
- <Input
- className={styles.iptBox}
- placeholder="备注说明内容"
- value={this.state.remark}
- onChange={this.remarkChange.bind(this)}
- />
- </div>
- </div>
- {/* 期望到货日期--end */}
- </div>
- {/* 订单信息--结束 */}
- <Button
- style={{ display: ifCashOrder && ifOneSupplier ? "none" : "inline-block" }}
- className={styles.addGoodsBtn}
- onClick={this.showModal.bind(this)}
- >
- <Icon type="plus" className={styles.icon}/>增加商品
- </Button>
- {/* 商品 */}
- <Spin spinning={this.state.goodsLoading}>
- <OrderGoodsList
- promotionInfoData={promotionInfoData}
- orderCartData={orderCartData}
- projectData={this.props.projectData}
- ifEditable={!(ifCashOrder && ifOneSupplier)}
- onChange={this.goodsInfoChange.bind(this)}
- offsetAmount={this.state.offsetAmount}
- promotionChange={this.promotionChangeHandle.bind(this)}
- optClick={this.onOptClick.bind(this)}
- ifOptional={ifOptional}
- ifPromotion={value => {
- this.ifPromotion = value;
- }}
- setGiftItems={items => {
- this.giftItems = items;
- }}
- {...this.props}
- ref={c => {
- this.orderGoodsList = c;
- }}
- />
- </Spin>
- {/* 商品--end */}
- {/* 订单底部信息 */}
- <Affix className={styles.orderGoodsFooter} offsetBottom={0}>
- <div className={styles.orderGoodsTotal}>
- <Row className={styles.row}>
- <Col span={5}>
- <span className={styles.name}>总重量:</span>
- <span className={styles.valueBox}>
- <em>{totalWeight.toFixed(2)}千克</em>
- </span>
- </Col>
- <Col span={5}>
- <div style={{ display: ifCashOrder || !ifOneSupplier ? "none" : "block" }}>
- <span className={styles.name}>商品金额:</span>
- <span className={`${styles.valueBox} ${styles.red}`}>
- ¥{totalAmount.toFixed(2)}
- </span>
- </div>
- <div style={{ display: ifCashOrder || !ifOneSupplier ? "block" : "none" }}>
- <span className={styles.name}>总体积:</span>
- <span className={styles.valueBox}>
- <em>{totalVolume.toFixed(2)}</em>
- </span>
- </div>
- </Col>
- <Col span={9}>
- {/* <div
- className={styles.item}
- style={{ display: ifCashOrder || !ifOneSupplier ? "none" : "block" }}
- >
- <span className={styles.name}>费用冲抵:</span>
- <span className={styles.valueBox}>
- <Input
- className={styles.ipt}
- onChange={this.custfeeChange.bind(this)}
- onBlur={this.custfeeBlur.bind(this)}
- value={this.state.offsetAmount}
- />
- </span>
- <span className={styles.txt}>
- (本次最高冲抵:
- <span style={{ color: "#E14C46" }}>
- ¥{parseFloat(currOrderMaxOccMny || "0")
- .toFixed(currency.currencyAmountScale)}
- </span>
- </span>
- <span className={styles.txt}>
- 费用总余额:
- <span style={{ color: "#E14C46" }}>
- ¥{parseFloat((occupyMnyTopLimit || {}).supplyMaxOccupyMny || "0")
- .toFixed(currency.currencyAmountScale)}
- </span>
- )
- </span>
- </div> */}
- <div
- className={styles.item}
- style={{ display: (!ifCashOrder && !ifOneSupplier) ? "block" : "none" }}
- >
- <span className={styles.name}>促销金额:</span>
- <span className={`${styles.valueBox} ${styles.red}`}>
- ¥{promAmount.toFixed(2)}
- </span>
- </div>
- <div
- className={styles.item}
- style={{ display: ifCashOrder || !ifOneSupplier ? "none" : "block" }}
- >
- <span className={styles.name}>促销金额:</span>
- <span className={`${styles.valueBox} ${styles.red}`}>
- ¥{promAmount.toFixed(2)}
- </span>
- </div>
- <div style={{ display: ifCashOrder || !ifOneSupplier ? "block" : "none" }}>
- <span className={styles.name}>商品金额:</span>
- <span className={`${styles.valueBox} ${styles.red}`}>
- ¥{totalAmount.toFixed(2)}
- </span>
- </div>
- </Col>
- <Col span={5} className={styles.lastCol}>
- <span className={styles.name}>订单总金额:</span>
- <span
- className={styles.valueBox}
- style={{
- fontSize: 24,
- color: "#D81719"
- }}
- >
- ¥{ifCashOrder && ifOneSupplier ? "0.00" : totalDealAmount.toFixed(2)}
- </span>
- </Col>
- </Row>
- <Row className={styles.row}>
- <Col span={4}>
- {/* <div
- className={styles.item}
- style={{ display: (!ifCashOrder && !ifOneSupplier) ? "block" : "none" }}
- >
- <span className={styles.name}>促销金额:</span>
- <span className={`${styles.valueBox} ${styles.red}`}>
- ¥{promAmount.toFixed(currency.currencyAmountScale)}
- </span>
- </div> */}
- {/* <div style={{ display: ifCashOrder || !ifOneSupplier ? "none" : "block" }}>
- <span className={styles.name}>总体积:</span>
- <span className={styles.valueBox}>
- <em>{totalVolume.toFixed(4)}</em>
- </span>
- </div> */}
- </Col>
- <Col span={4}>
- {/* <div
- className={styles.item}
- style={{ display: ifCashOrder || !ifOneSupplier ? "none" : "block" }}
- >
- <span className={styles.name}>促销金额:</span>
- <span className={`${styles.valueBox} ${styles.red}`}>
- ¥{promAmount.toFixed(currency.currencyAmountScale)}
- </span>
- </div> */}
- </Col>
- <Col span={6}>
- {/* <span
- className={styles.infoSearch}
- style={{ display: ifCashOrder || !ifOneSupplier ? "none" : "inline-block" }}
- >
- 信用查询
- <Popover
- content={content()}
- title={null}
- trigger="hover"
- style={{ width: 500 }}
- >
- <Icon type="question-circle" className={styles.icon}/>
- </Popover>
- </span> */}
- </Col>
- <Col span={10} className={styles.lastCol}>
- <div className={styles.btnBox}>
- <div className={styles.cancelBtn}>
- <Popconfirm
- title="是否确定取消?"
- onConfirm={this.cancelHandle.bind(this)}
- >
- <Button className={styles.btn}>取消</Button>
- </Popconfirm>
- <Button
- style={{
- display: ifCashOrder && ifOneSupplier ? "none" : "inline-block"
- }}
- className={styles.btn}
- onClick={this.saveTempHandle.bind(this)}
- disabled={this.state.isDisabled}
- >
- 暂存
- </Button>
- <Button
- className={styles.btn}
- onClick={this.okHandle.bind(this)}
- >
- 提交
- </Button>
- </div>
- </div>
- </Col>
- </Row>
- </div>
- </Affix>
- {/* 订单底部信息--end */}
- <TreeListModal
- ref={ref => (this.state.ref.treeListModal = ref)}
- title="请选择商品"
- supplierId={this.state.supplierId}
- treeUrl="/buyer/goods-category/tree"
- listUrl="/b2b/goods/find-by-customer"
- saleModel="01"
- onConfirm={this.addGoodsInfo.bind(this)}
- />
- <InvoiceDialog invoiceInfoData={invoiceInfoData}/>
- </Spin>
- <FormPayforDialog
- payNeedData={this.state.payNeedData}
- orderPayBillSet={this.props.orderPayBillSet}
- backToWho="orderList"
- />
- <Modal title="颜色选择" visible={this.state.optValShow}
- onCancel={() => {
- this.setState({optValShow: false})
- }}
- onOk={async () => {
- if (this.state.optValSelectId) {
- const colorSelc = this.state.goodsAttrVals ? this.state.goodsAttrVals.find(item => item.attrValId == this.state.optValSelectId) : null
- const optVal = Object.assign({},this.state.optVal,colorSelc,{baseGoodsOptValue: `${colorSelc.custDocGroupName}->${colorSelc.attrValName}`})
- this.setState({
- optVal ,
- optValShow: false,
- goodsAttrVals: []
- })
- this.confirmColor(optVal)
- } else {
- message.warning("请选择颜色")
- }
- }}
- width="1000px" maskClosable={false}
- >
- <div>
- <Input.Search placeholder="请输入颜色编码"
- // defaultValue={this.state.optSearchVal}
- onBlur={(e) => {
- this.setState({optSearchVal: e.target.value})
- }}
- onSearch={(e) => {
- this.setState({optSearchVal: e})
- }}
- onPressEnter={(e) => {
- this.setState({optSearchVal: e.target.value})
- }}
- />
- </div>
- <div style={{height: "500px",width: "950px",overflow: "auto", marginTop: "10px"}}>
- {
- this.state.goodsAttrVals ? this.state.goodsAttrVals.filter(item => !this.state.optSearchVal || item.attrValName.indexOf(this.state.optSearchVal) >= 0).map((item,index) => {
- // return <Tag color={this.state.optValSelectId == item.attrValName ? "red" : ""} className={styles.colorItem} onClick={this.selectColor.bind(this)}>{item.attrValName}</Tag>
- return <Tag key={item.attrValId} color={this.state.optValSelectId == item.attrValId ? "red" : ""} className={styles.colorItem} onClick={() => {this.selectColor(item.attrValId)}}>{item.attrValName}</Tag>
- }) : ""
- }
- </div>
- </Modal>
- </div>
- );
- }
- }
- export default connect(state => ({
- supplierData: state.orderEdit.supplierData,
- addressData: state.orderEdit.addressData,
- logisticsData: state.orderEdit.logisticsData,
- settlementData: state.orderEdit.settlementData,
- payforMainData: state.orderEdit.payforMainData,
- invoiceInfoData: state.orderEdit.invoiceInfoData,
- orderCartData: state.orderEdit.orderCartData,
- resultOrder: state.orderEdit.resultOrder,
- // orderCustfeeData: state.orderEdit.orderCustfeeData,
- promotionInfoData: state.orderEdit.promotionInfoData,
- occupyMnyTopLimits: state.orderEdit.occupyMnyTopLimits,
- orderCredit: state.orderEdit.orderCredit,
- orderEditData: state.orderEdit.orderEditData,
- cartListData: state.cartList.cartListData,
- projectData: state.orderEdit.projectData,
- orderPayBillSet: state.paymentNotice.orderPayBillSet,
- accountPeriodInfo: state.orderEdit.accountPeriodInfo
- // treeListSelectedRows: state.global.selectedRows
- }))(OrderEidt);
|