"use strict";(wx.webpackJsonp=wx.webpackJsonp||[]).push([[5905],{3309:function(e,n,t){var i=t(2180),a=t(1413),l=t(4165),o=t(3433),c=t(5861),r=t(9439),d=t(1515),s=t(2954),u=t.n(s),_=t(7294),m="index-module__backIcon___FTPvT",h="index-module__layoutBlock___iTKzU",p="index-module__main___psfpk",x="index-module__context___vPnoF",f="index-module__addButton___Vbspa",v="index-module__customerTop___VVqjP",g="index-module__customerBottom___ekw5L",j="index-module__colorCardTop___Jnl1v",C="index-module__colorCardBottom___lQOyT",S="index-module__leftCont___5tYjq",Z="index-module__rightCont___sCETr",N="index-module__rightCont__top___ZmrOT",k="index-module__rightCont__bottom___IeLdy",y="index-module__rightCont__left___muVzH",b="index-module__rightCont__right___dnxwW",I="index-module__paymentMethod___eKk13",G="index-module__remarkTop___P7e8j",w="index-module__remarkTitle___tAE2G",T="index-module__remarkTag___EGjaw",P="index-module__remarkBottom___IMmi1",O="index-module__remarkContent___EgVxL",z="index-module__bottomBar___EQ_0b",D="index-module__bottomTotal___wjjfT",B="index-module__bottomBar__button___SxFzf",E=t(8260),J=t(9742),L=t(2128),M=t(6028),V=t(3407),A=t(7018),q=t(1115),F=t(1251),K=t(5273),W=t(5989),$=t(2019),Q=t(4812),U=t(146),H=t(6107),Y=t(2185),R=t(7227),X=t(5893),ee=function AddColorCard(){var e=u().getCurrentPages(),n=e[e.length-1],t=(0,_.useState)({}),i=(0,r.Z)(t,2),ee=i[0],ne=i[1],te=(0,_.useState)([]),ie=(0,r.Z)(te,2),ae=ie[0],le=ie[1],oe=(0,F.dl)().fetchData,ce=(0,_.useState)([]),re=(0,r.Z)(ce,2),de=re[0],se=re[1];(0,s.useDidShow)((function(){var e=u().getStorageSync("sampleCuttingCache");e&&(console.log("sampleCuttingCache",JSON.parse(e)),se(JSON.parse(e)))}));var ue=(0,_.useState)({clientId:-1,clientName:"",clientPhone:""}),_e=(0,r.Z)(ue,2),me=_e[0],he=_e[1],pe=function(){var e=(0,c.Z)((0,l.Z)().mark((function _callee(){var e,t,i,a,c,r,d,s;return(0,l.Z)().wrap((function _callee$(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,oe({page:1,size:10});case 2:if((a=l.sent).success){l.next=5;break}return l.abrupt("return",q.Z9.error(a.msg));case 5:n.data.clientId=a.data.list.length>0?null===(e=a.data.list[0])||void 0===e?void 0:e.id:-1,n.data.clientName=a.data.list.length>0?null===(t=a.data.list[0])||void 0===t?void 0:t.name:"",n.data.clientPhone=a.data.list.length>0?null===(i=a.data.list[0])||void 0===i?void 0:i.phone:"",c=n.data,r=c.clientId,d=c.clientName,s=c.clientPhone,he({clientId:r,clientName:d,clientPhone:s}),le((0,o.Z)(a.data.list));case 11:case"end":return l.stop()}}),_callee)})));return function getClient(){return e.apply(this,arguments)}}();(0,_.useEffect)((function(){pe()}),[]),(0,s.useUnload)((function(){u().removeStorageSync("sampleCuttingCache")}));var xe=(0,U.oO)(),fe=xe.fetchData,ve=xe.state,ge=(0,R.Ds)((0,c.Z)((0,l.Z)().mark((function _callee2(){var e,n;return(0,l.Z)().wrap((function _callee2$(t){for(;;)switch(t.prev=t.next){case 0:if(ee.address_id){t.next=2;break}return t.abrupt("return",q.Z9.none("请选择地址"));case 2:if(me.clientId){t.next=4;break}return t.abrupt("return",q.Z9.none("请选择客户"));case 4:return e=[],de.forEach((function(n){n.multipleSelection.forEach((function(n){e.push({product_color_id:n.product_color_id,color_num:n.count})}))})),t.next=8,fe({address_id:ee.address_id,cut_sample_order_product_color_list:e,purchaser_id:me.clientId,remark:Ge,shipment_mode:2});case 8:(n=t.sent).success&&(u().showToast({title:"提交成功",icon:"success",duration:2e3}),u().removeStorageSync("sampleCuttingCache"),(0,q.jD)("/pages/sampleCutting/sampleCuttingDetail/index",{id:n.data.id},"redirectTo"));case 10:case"end":return t.stop()}}),_callee2)}))),300),je=(0,_.useCallback)((function(e){return{lab:null==e?void 0:e.lab,rgb:null==e?void 0:e.rgb,texture_url:null==e?void 0:e.texture_url}}),[]),Ce=function handleCountChange(e,n,t){console.log("value",e,de);var i=de.findIndex((function(e){return e.product_id===n}));if(1===de.length&&1===de[i].multipleSelection.length&&0===e)return q.Z9.none("最后一个剪样不能删除");0!==e?se((function(i){var a=i.map((function(i){return i.product_id===n&&(i.multipleSelection=i.multipleSelection.map((function(n){return n.product_color_id===t&&(n.count=e),n}))),i}));return u().setStorageSync("sampleCuttingCache",JSON.stringify(a)),a})):u().showModal({content:"确认删除所选剪样?",confirmText:"删除",confirmColor:"#337fff",success:function success(e){e.confirm&&function deleteColorCard(e,n){se((function(t){var i=[],a=t.findIndex((function(n){return n.product_id===e}));return console.log("multipleSelection",t),1===t[a].multipleSelection.length?(t.splice(a,1),i=(0,o.Z)(t)):i=t.map((function(t){return t.product_id===e&&(t.multipleSelection=t.multipleSelection.filter((function(e){return e.product_color_id!==n}))),t})),u().setStorageSync("sampleCuttingCache",JSON.stringify(i)),i}))}(n,t)}})};(0,s.useDidShow)((function(){var e,t,i,a,l,o,c,r,d;null!==(e=n.data)&&void 0!==e&&e.clientId&&""!==(null===(t=n.data)||void 0===t?void 0:t.clientId)&&(he({clientId:null===(a=n.data)||void 0===a?void 0:a.clientId,clientName:null===(l=n.data)||void 0===l?void 0:l.clientName,clientPhone:null===(o=n.data)||void 0===o?void 0:o.clientPhone}),me.clientId!==(null===(c=n.data)||void 0===c?void 0:c.clientId)&&De(null===(r=n.data)||void 0===r?void 0:r.clientId));null==(null===(i=n.data)||void 0===i?void 0:i.clientId)&&(he((function(){var e,n,t;return{clientId:ae.length>0?null===(e=ae[0])||void 0===e?void 0:e.id:-1,clientName:ae.length>0?null===(n=ae[0])||void 0===n?void 0:n.name:"",clientPhone:ae.length>0?null===(t=ae[0])||void 0===t?void 0:t.phone:""}})),ae.length>0&&De(null===(d=ae[0])||void 0===d?void 0:d.id))}));var Se=function initAddressInfo(){ne((function(e){return(0,a.Z)((0,a.Z)({},e),{},{province_name:"",address_id:"",city_name:"",address_detail:"",district_name:"",target_user_name:"",purchaser_phone:""})}))};(0,s.useDidShow)((function(){var e,t,i,l,o,c,r,d,s;if(console.log("addressObj",null===(e=n.data)||void 0===e?void 0:e.addressObj,me.clientId,null===(t=n.data)||void 0===t?void 0:t.clientId),null===(i=n.data)||void 0===i||!i.addressObj)return Se();var u=null===(l=n.data)||void 0===l?void 0:l.addressObj,_=u.purchaser_id,m=u.province_name,h=u.id,p=u.city_name,x=u.address_detail,f=u.district_name,v=u.name,g=u.phone;_===(null===(o=n.data)||void 0===o?void 0:o.clientId)?ne((function(e){return(0,a.Z)((0,a.Z)({},e),{},{province_name:m||"",address_id:h||"",city_name:p||"",address_detail:x||"",district_name:f||"",target_user_name:v||"",purchaser_phone:g||""})})):Se();var j=h,C=null==n||null===(c=n.data)||void 0===c||null===(r=c.ids)||void 0===r?void 0:r.filter((function(e){return e==j}));console.log("ids",null==n||null===(d=n.data)||void 0===d?void 0:d.ids),null!=n&&null!==(s=n.data)&&void 0!==s&&s.ids&&0===C.length&&Se()}));var Ze=(0,_.useState)(!1),Ne=(0,r.Z)(Ze,2),ke=Ne[0],ye=Ne[1],be=(0,_.useState)(""),Ie=(0,r.Z)(be,2),Ge=Ie[0],we=Ie[1],Te=(0,_.useCallback)((function(e){ye(!1),console.log("remark",e),we(e)}),[]),Pe=(0,_.useMemo)((function(){return de.reduce((function(e,n){return e+n.multipleSelection.length}),0)}),[de]),Oe=(0,_.useMemo)((function(){return de.reduce((function(e,n){return e+n.multipleSelection.reduce((function(e,n){return e+n.count}),0)}),0)}),[de]),ze=(0,Y.gV)().fetchData,De=function(){var e=(0,c.Z)((0,l.Z)().mark((function _callee3(e){var t,i,o;return(0,l.Z)().wrap((function _callee3$(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,ze({purchaser_id:e});case 2:(t=l.sent).success&&(i=t.data.list,(o=null==i?void 0:i.find((function(e){return e.is_default})))||(o=null==i?void 0:i[0]),ne((function(e){return(0,a.Z)((0,a.Z)({},e),{},{province_name:o.province_name||"",address_id:o.id||"",city_name:o.city_name||"",address_detail:o.address_detail||"",district_name:o.district_name||"",target_user_name:o.name||"",purchaser_phone:o.phone||""})})),n.data.addressObj=o);case 4:case"end":return l.stop()}}),_callee3)})));return function getDefaultAddressList(n){return e.apply(this,arguments)}}();return(0,X.jsxs)(d.G7,{className:p,children:[(0,X.jsx)(H.Z,{hasLeft:!0,leftSlot:(0,X.jsx)(d.G7,{onClick:function onClickBack(){u().showModal({content:"返回后页面数据将不回保留,确认返回?",confirmColor:"#4a8dff",success:function success(e){e.confirm&&u().navigateBack({delta:1})}})},children:(0,X.jsx)(M.Z,{customClassName:m,name:"icon-chakanquanbukehu",size:48,color:"#191919"})}),title:"领取剪样"}),(0,X.jsxs)(d.G7,{className:x,children:[(0,X.jsxs)(E.Z,{circle:!0,onClick:function handleSelectCustomer(){(0,q.jD)("/pages/customerPage/index?clientId=".concat(null==me?void 0:me.clientId))},customStyle:{marginTop:"12px"},customClassName:h,children:[(0,X.jsx)(d.G7,{className:v,children:(0,X.jsx)(d.G7,{children:"客户信息"})}),(0,X.jsx)(L.Z,{direction:"horizontal",customStyles:{margin:"12px 0"}}),(0,X.jsxs)(d.G7,{className:g,children:[-1!==me.clientId?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(d.xv,{style:{color:"#333333"},children:me.clientName}),(0,X.jsx)(d.xv,{style:{color:"#333333"},children:me.clientPhone})]}):(0,X.jsx)(d.G7,{children:"选择领取客户"}),(0,X.jsx)(M.Z,{name:"icon-chakanquanbukehu",color:"#444444",size:32})]})]}),-1!==me.clientId&&(0,X.jsx)(K.Z,{showBtn:!1,showWhatFont:"物流",navSelect:function handSelect(){(0,q.jD)("/pages/addressManager/index?purchaser_id=".concat(me.clientId))},obj:ee,receivingStatus:2,icon:(0,X.jsx)(M.Z,{name:"icon-dizhi1",size:60})}),(0,X.jsx)(J.Z,{customClassName:f,circle:!0,onClick:function handleAddColorCard(){u().setStorageSync("sampleCuttingCache",JSON.stringify(de)),(0,q.jD)("/pages/sampleCutting/sampleCuttingList/index",{isGoBack:!0,isAddSampleCutIdList:de.map((function(e){return e.product_id}))})},plain:!0,size:"normal",type:"primary",children:"添加剪样"}),de.map((function(e,n){return(0,X.jsxs)(E.Z,{customStyle:{marginTop:"12px"},circle:!0,customClassName:h,children:[(0,X.jsx)(d.G7,{className:j,children:e.product_code_and_name}),(0,X.jsx)(L.Z,{direction:"horizontal",customStyles:{margin:"12px 0"}}),e.multipleSelection.map((function(n){return(0,X.jsxs)(d.G7,{className:C,children:[(0,X.jsx)(d.G7,{style:{minWidth:"24%"},children:(0,X.jsx)(d.G7,{className:S,children:(0,X.jsx)(V.Z,{value:je(n)})})}),(0,X.jsxs)(d.G7,{className:Z,children:[(0,X.jsx)(d.G7,{className:N,children:"#".concat((0,Q.ZK)(n.product_color_code)," ").concat(n.product_color_name)}),(0,X.jsxs)(d.G7,{className:k,children:[(0,X.jsx)(d.G7,{className:y}),(0,X.jsx)(d.G7,{className:b,children:(0,X.jsx)(A.Z,{defaultNum:(null==n?void 0:n.count)||1,onChange:function onChange(t){return Ce(t,e.product_id,n.product_color_id)},unit:"份",minNum:0,maxNum:999})})]}),(0,X.jsx)(L.Z,{direction:"horizontal",customStyles:{margin:"12px 0 0 "}})]})]},n.product_color_id)})),(0,X.jsx)(d.G7,{className:I,children:"快递到付"})]},n)})),(0,X.jsxs)(E.Z,{circle:!0,customClassName:h,onClick:function handleShowDesc(){ye(!0)},children:[(0,X.jsxs)(d.G7,{className:G,children:[(0,X.jsx)(d.G7,{className:w,children:"备注信息"}),(0,X.jsxs)(d.G7,{className:T,children:[(0,X.jsx)(d.xv,{children:"填写/修改备注"}),(0,X.jsx)(M.Z,{name:"icon-chakanquanbukehu",color:"#444444",size:32})]})]}),(0,X.jsx)(L.Z,{direction:"horizontal",customStyles:{margin:"12px 0"}}),(0,X.jsx)(d.G7,{className:P,children:(0,X.jsx)(d.G7,{className:O,children:Ge||"尚未备注信息"})})]})]}),(0,X.jsxs)(d.G7,{className:z,children:[(0,X.jsxs)(d.G7,{className:D,children:["当前共 ",de.length," 种面料, ",Pe||0," 种色号,共 ",Oe||0," 份"]}),(0,X.jsx)(J.Z,{customClassName:B,type:"primary",disabled:ve.loading||ve.success,round:!0,loading:ve.loading,onClick:ge,children:"提交订单"})]}),(0,X.jsx)(W.Z,{show:ke,showTitle:!1,onClose:function onClose(){return ye(!1)},children:ke&&(0,X.jsx)($.Z,{onSave:Te,defaultValue:Ge})})]})};Page((0,i.createPageConfig)(ee,"pages/sampleCutting/addSampleCutting/index",{root:{cn:[]}},{navigationBarTitleText:"领取剪样",disableSwipeBack:!0,navigationStyle:"custom"}||{}))}},function(e){e.O(0,[2107,1216,8592],(function(){return n=3309,e(e.s=n);var n}));e.O()}]);