| 1 |
- function _newArrowCheck(e,t){if(e!==t)throw new TypeError("Cannot instantiate an arrow function")}exports.__esModule=!0,exports.clearCustomer=clearCustomer,exports.createRequestId=createRequestId,exports.didMount=didMount,exports.didUnmount=didUnmount,exports.forceUpdate=forceUpdate,exports.formatAmount=formatAmount,exports.formatDate=formatDate,exports.formatTime=formatTime,exports.getCustomState=getCustomState,exports.queryCustomerInfo=queryCustomerInfo,exports.renderBalance=renderBalance,exports.renderBalanceSummary=renderBalanceSummary,exports.renderJsx=renderJsx,exports.renderOrders=renderOrders,exports.searchCustomers=searchCustomers,exports.selectCustomer=selectCustomer,exports.setCustomState=setCustomState,exports.setQueryType=setQueryType,exports.updateKeyword=updateKeyword;var _customState={},APP_TYPE="APP_N9NPHVTQLPBPO8MR6WFG",CUSTOMER_FORM_UUID="FORM-NO966791YOK2XKW9DMSEGD5L1IN73UHW3ME6LR1",STORAGE_KEY="tyson.customer-info-query.selected-customer",requestSequence=0,FIELDS={customerNumber:"textField_l6em70k2",customerName:"textField_l6em70k4"};function didMount(){var t=null;try{t=JSON.parse(window.localStorage.getItem(STORAGE_KEY)||"null")}catch(e){t=null}this.setCustomState({keyword:t&&t.customerNumber?t.customerNumber+" - "+(t.customerName||""):"",searching:!1,customers:[],selectedCustomer:t&&t.customerNumber?t:null,queryType:"balance",querying:!1,result:null,error:"",searchVisible:!1})}function didUnmount(){this._customerSearchTimer&&clearTimeout(this._customerSearchTimer)}function setQueryType(e){this.setCustomState({queryType:e,result:null,error:""}),this.forceUpdate()}function updateKeyword(e){var t=this,r=e||"";t.setCustomState({keyword:r,searchVisible:!0,error:""}),t.forceUpdate(),t._customerSearchTimer&&clearTimeout(t._customerSearchTimer),r.trim().length<2?(t.setCustomState({customers:[],searching:!1}),t.forceUpdate()):t._customerSearchTimer=setTimeout(function(){t.searchCustomers(r.trim())},300)}function searchCustomers(e){var t=this,r=this,a={formUuid:CUSTOMER_FORM_UUID,appType:APP_TYPE,currentPage:1,pageSize:20},o=[{key:FIELDS.customerNumber,value:e,type:"TEXT",operator:"contains",componentName:"TextField"}],e=[{key:FIELDS.customerName,value:e,type:"TEXT",operator:"contains",componentName:"TextField"}],n=(r.setCustomState({searching:!0}),r.forceUpdate(),{}),s={};return Object.keys(a).forEach(function(e){_newArrowCheck(this,t),n[e]=a[e],s[e]=a[e]}.bind(this)),n.searchFieldJson=JSON.stringify(o),s.searchFieldJson=JSON.stringify(e),Promise.all([r.utils.yida.searchFormDatas(n),r.utils.yida.searchFormDatas(s)]).then(function(e){var t=this,a={},o=[];e.forEach(function(e){var r=this;_newArrowCheck(this,t),(e&&e.data||e&&e.content&&e.content.data||[]).forEach(function(e){_newArrowCheck(this,r);var e=e.formData||{},t=e[FIELDS.customerNumber];t&&!a[t]&&(a[t]=!0,o.push({customerNumber:t,customerName:e[FIELDS.customerName]||""}))}.bind(this))}.bind(this)),r.setCustomState({customers:o,searching:!1}),r.forceUpdate()}).catch(function(e){r.setCustomState({searching:!1,customers:[]}),r.utils.toast({title:e&&e.message?e.message:"客户查询失败",type:"error"}),r.forceUpdate()})}function selectCustomer(e){try{window.localStorage.setItem(STORAGE_KEY,JSON.stringify(e))}catch(e){}this.setCustomState({selectedCustomer:e,keyword:e.customerNumber+" - "+e.customerName,searchVisible:!1,customers:[],result:null,error:""}),this.forceUpdate()}function clearCustomer(){try{window.localStorage.removeItem(STORAGE_KEY)}catch(e){}this.setCustomState({keyword:"",selectedCustomer:null,customers:[],result:null,error:""}),this.forceUpdate()}function queryCustomerInfo(){var t=this,e=t.getCustomState(),r=e.selectedCustomer;if(r){var e="balance"===e.queryType?"customerBalance":"customerUnlockOrders",a=t.dataSourceMap&&t.dataSourceMap[e];if(a&&a.load){t.setCustomState({querying:!0,error:"",result:null}),t.forceUpdate();r={inputs:JSON.stringify({Headers:{"Content-Type":"application/json"},Query:{},Body:{requestID:t.createRequestId(),CUSTOMER_NUMBER:r.customerNumber,CUSTOMER_NAME:r.customerName}})};try{return Promise.resolve(a.load(r)).then(function(e){e=e&&void 0!==e.Response?e.Response:e;if("string"==typeof(e=(e=e&&void 0!==e.content?e.content:e)&&void 0!==e.serviceReturnValue?e.serviceReturnValue:e))try{e=JSON.parse(e)}catch(e){}t.setCustomState({querying:!1,result:e||{}}),t.forceUpdate()}).catch(function(e){t.setCustomState({querying:!1,result:null,error:e&&e.message?e.message:"SAP查询失败"}),t.utils.toast({title:e&&e.message?e.message:"SAP查询失败",type:"error"}),t.forceUpdate()})}catch(e){t.setCustomState({querying:!1,result:null,error:e&&e.message?e.message:"SAP查询初始化失败"}),t.utils.toast({title:e&&e.message?e.message:"SAP查询初始化失败",type:"error"}),t.forceUpdate()}}else a="查询数据源不可用:"+e+";当前数据源:"+(t.dataSourceMap?Object.keys(t.dataSourceMap).join(", "):"未初始化"),t.setCustomState({error:a,result:null}),t.utils.toast({title:a,type:"error"}),t.forceUpdate()}else t.utils.toast({title:"请先选择客户",type:"warning"})}function createRequestId(){var e;return requestSequence+=1,window.crypto&&window.crypto.randomUUID?window.crypto.randomUUID():window.crypto&&window.crypto.getRandomValues?(e=new Uint32Array(4),window.crypto.getRandomValues(e),e[0].toString(16)+"-"+e[1].toString(16)+"-"+e[2].toString(16)+"-"+e[3].toString(16)):Date.now().toString(36)+"-"+requestSequence.toString(36)+"-"+Math.random().toString(36).slice(2)}function formatAmount(e){var t=Number(e||0);return isNaN(t)?e||"-":t.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})}function formatDate(e){var t;return e?8===(e=String(e)).length?e.slice(0,4)+"-"+e.slice(4,6)+"-"+e.slice(6,8):(t=e.match(/^(\d{4}-\d{2}-\d{2})/))?t[1]:e:"-"}function formatTime(e){var t;return e?(t=String(e).match(/T(\d{2}:\d{2}:\d{2})/))?t[1]:String(e):"-"}function renderBalanceSummary(e){return React.createElement("div",{style:styles.balanceSummary},React.createElement("div",null,React.createElement("span",{style:styles.summaryLabel},"客户组"),React.createElement("strong",null,e.CUSTOMER_GROUP||"-")),React.createElement("div",null,React.createElement("span",{style:styles.summaryLabel},"客户组描述"),React.createElement("strong",null,e.CUSTOMER_GROUP_DESC||"-")),React.createElement("div",null,React.createElement("span",{style:styles.summaryLabel},"总风险金额"),React.createElement("strong",{style:styles.summaryAmount},this.formatAmount(e.TOTAL_RISK_AMT))))}function renderBalance(e,t){var r=this,e=e.result||{},a=e.ITEM||[];return a.length?React.createElement("div",null,this.renderBalanceSummary(e),React.createElement("div",{style:styles.tableWrap},React.createElement("table",{className:"customer-query-table",style:styles.table},React.createElement("thead",null,React.createElement("tr",null,React.createElement("th",null,"公司代码"),React.createElement("th",null,"币种"),React.createElement("th",null,"未结金额"))),React.createElement("tbody",null,a.map(function(e,t){return _newArrowCheck(this,r),React.createElement("tr",{key:t},React.createElement("td",null,e.COMPANY_CODE||"-"),React.createElement("td",null,e.CURRENCY||"-"),React.createElement("td",{style:styles.amountHighlight},this.formatAmount(e.OUTSTAND_AMT)))}.bind(this)))))):React.createElement("div",{style:styles.empty},"未查询到余额数据")}function renderOrders(e,t){var r=this,e=e.result&&e.result.ITEM||[];return e.length?React.createElement("div",{style:styles.tableWrap},React.createElement("table",{className:"customer-query-table",style:styles.table},React.createElement("thead",null,React.createElement("tr",null,React.createElement("th",null,"客户编码"),React.createElement("th",null,"客户名称"),React.createElement("th",null,"公司代码"),React.createElement("th",null,"销售订单号"),React.createElement("th",null,"销售组织"),React.createElement("th",null,"订单金额"),React.createElement("th",null,"币种"),React.createElement("th",null,"释放日期"),React.createElement("th",null,"释放时间"),React.createElement("th",null,"状态"))),React.createElement("tbody",null,e.map(function(e,t){return _newArrowCheck(this,r),React.createElement("tr",{key:t},React.createElement("td",null,e.CUSTOMER_NUMBER||"-"),React.createElement("td",{style:styles.nameCell},e.CUSTOMER_NAME||"-"),React.createElement("td",null,e.COMPANY_CODE||"-"),React.createElement("td",{style:styles.orderCell},e.SALES_ORDER||"-"),React.createElement("td",null,e.SALES_ORG||"-"),React.createElement("td",{style:styles.amountCell},this.formatAmount(e.SALES_AMOUNT)),React.createElement("td",null,e.CURRENCY||"-"),React.createElement("td",null,this.formatDate(e.RELEASE_DATE)),React.createElement("td",null,this.formatTime(e.RELEASE_TIME)),React.createElement("td",null,React.createElement("span",{style:"S"===e.RELEASE_STATUS?styles.statusSuccess:styles.statusError},"S"===e.RELEASE_STATUS?"成功":"失败")))}.bind(this))))):React.createElement("div",{style:styles.empty},"未查询到收款解锁订单")}function renderJsx(){var a=this,o=this,e=o.getCustomState(),t=o.utils.isMobile(),r=e.selectedCustomer,n=e.result;return React.createElement("div",{style:styles.page},React.createElement("style",null,".customer-query-table th{background:#EEF4F0;color:#405149;font-weight:700;white-space:nowrap;padding:10px 12px;border-bottom:1px solid #D7E1DB}.customer-query-table td{padding:9px 12px;border-bottom:1px solid #E7ECE9;white-space:nowrap}.customer-query-table tbody tr:last-child td{border-bottom:0}.customer-query-table tbody tr:nth-child(even){background:#FAFCFB}.customer-query-table tbody tr:hover{background:#F1F6F3}"),React.createElement("div",{style:styles.shell},React.createElement("div",{style:styles.header},React.createElement("div",null,React.createElement("div",{style:styles.eyebrow},"CUSTOMER SERVICE"),React.createElement("h1",{style:styles.title},"客户信息查询"),React.createElement("p",{style:styles.subtitle},"查询客户余额与收款解锁订单"))),React.createElement("section",{style:styles.panel},React.createElement("div",{style:t?styles.queryStack:styles.queryRow},React.createElement("div",{style:styles.customerField},React.createElement("div",{style:styles.fieldLabel},"选择客户"),React.createElement("div",{style:styles.searchWrap},React.createElement("input",{key:r?r.customerNumber:"empty",defaultValue:e.keyword||"",placeholder:"输入客户编码或名称,至少 2 个字符",onChange:function(e){_newArrowCheck(this,a),o.updateKeyword(e.target.value)}.bind(this),onFocus:function(e){_newArrowCheck(this,a),o.setCustomState({searchVisible:!0}),o.forceUpdate()}.bind(this),style:styles.input}),r&&React.createElement("button",{type:"button",onClick:function(e){_newArrowCheck(this,a),o.clearCustomer()}.bind(this),style:styles.clearButton},"清除"),e.searchVisible&&(e.searching||e.customers&&0<e.customers.length)&&React.createElement("div",{style:styles.searchMenu},e.searching&&React.createElement("div",{style:styles.searchHint},"正在搜索客户..."),!e.searching&&e.customers.map(function(t){var r=this;return _newArrowCheck(this,a),React.createElement("button",{type:"button",key:t.customerNumber,onClick:function(e){_newArrowCheck(this,r),o.selectCustomer(t)}.bind(this),style:styles.customerOption},React.createElement("b",null,t.customerNumber),React.createElement("span",null,t.customerName||"未维护名称"))}.bind(this))))),React.createElement("div",{style:styles.queryTypeField},React.createElement("div",{style:styles.fieldLabel},"查询内容"),React.createElement("div",{style:styles.typeRow},React.createElement("button",{type:"button",onClick:function(e){_newArrowCheck(this,a),o.setQueryType("balance")}.bind(this),style:"balance"===e.queryType?styles.typeActive:styles.typeButton},"客户余额"),React.createElement("button",{type:"button",onClick:function(e){_newArrowCheck(this,a),o.setQueryType("unlockOrders")}.bind(this),style:"unlockOrders"===e.queryType?styles.typeActive:styles.typeButton},"收款解锁订单"))),React.createElement("div",{style:styles.queryActionField},React.createElement("div",{style:styles.fieldLabel},"操作"),React.createElement("button",{type:"button",disabled:e.querying,onClick:function(e){_newArrowCheck(this,a),r?o.queryCustomerInfo():(o.setCustomState({error:"请先选择客户后再查询",result:null}),o.forceUpdate())}.bind(this),style:e.querying||!r?styles.queryDisabled:styles.queryButton},e.querying?"查询中...":"查询"))),!r&&React.createElement("div",{style:styles.validationHint},"请选择客户后再查询")),e.error&&React.createElement("div",{style:styles.error},e.error),n&&React.createElement("section",{style:styles.resultPanel},React.createElement("div",{style:styles.resultHeader},React.createElement("div",null,React.createElement("div",{style:styles.eyebrow},"balance"===e.queryType?"BALANCE":"UNLOCKED ORDERS"),React.createElement("h2",{style:styles.resultTitle},"balance"===e.queryType?"客户余额":"收款解锁订单")),React.createElement("div",{style:styles.customerSummary},(n.CUSTOMER_NUMBER||r&&r.customerNumber||"-")+" "+(n.CUSTOMER_NAME||r&&r.customerName||""))),"balance"===e.queryType?o.renderBalance(e,t):o.renderOrders(e,t)),!n&&!e.error&&React.createElement("div",{style:styles.empty},"选择客户和查询内容后,可查看对应的 SAP 信息。")),React.createElement("div",{style:{display:"none"}},this.state&&this.state.timestamp))}var styles={page:{minHeight:"100vh",background:"#F4F6F5",color:"#17211E",fontFamily:"Microsoft YaHei, Arial, sans-serif",padding:"20px 16px 40px"},shell:{maxWidth:1120,margin:"0 auto"},header:{padding:"12px 0 22px",borderBottom:"1px solid #DCE3DF",marginBottom:20,textAlign:"center"},eyebrow:{color:"#3B6C55",fontSize:11,fontWeight:700,letterSpacing:1.2,marginBottom:6},title:{margin:0,fontSize:28,lineHeight:1.2,letterSpacing:"-0.5px"},subtitle:{margin:"8px 0 0",color:"#66746E",fontSize:14},panel:{background:"#FFFFFF",border:"1px solid #DCE3DF",padding:20,boxShadow:"0 10px 28px rgba(25,48,38,.06)"},fieldLabel:{color:"#405149",fontSize:13,fontWeight:700,margin:"0 0 8px"},queryRow:{display:"flex",alignItems:"flex-end",gap:14},queryStack:{display:"flex",flexDirection:"column",gap:14},customerField:{flex:1,minWidth:260},queryTypeField:{width:300},queryActionField:{width:110},searchWrap:{position:"relative"},input:{width:"100%",boxSizing:"border-box",minHeight:46,border:"1px solid #B7C5BD",borderRadius:4,padding:"0 72px 0 13px",fontSize:15,outline:"none",background:"#fff"},clearButton:{position:"absolute",right:8,top:8,border:0,background:"#EEF3F0",color:"#466253",minHeight:30,borderRadius:3,padding:"0 10px",cursor:"pointer"},searchMenu:{position:"absolute",zIndex:20,top:49,left:0,right:0,maxHeight:280,overflowY:"auto",background:"#fff",border:"1px solid #B7C5BD",boxShadow:"0 12px 24px rgba(22,43,34,.14)"},searchHint:{padding:14,color:"#66746E",fontSize:13},customerOption:{display:"flex",width:"100%",minHeight:48,padding:"10px 13px",gap:12,alignItems:"center",border:0,borderBottom:"1px solid #EDF1EE",background:"#fff",textAlign:"left",cursor:"pointer",color:"#17211E"},typeRow:{display:"flex",gap:8},typeStack:{display:"flex",flexDirection:"column",gap:10},typeButton:{flex:1,minHeight:44,border:"1px solid #B7C5BD",borderRadius:4,background:"#fff",color:"#405149",fontSize:14,cursor:"pointer"},typeActive:{flex:1,minHeight:44,border:"1px solid #24563E",borderRadius:4,background:"#24563E",color:"#fff",fontSize:14,fontWeight:700,cursor:"pointer"},queryButton:{width:"100%",minHeight:46,border:0,borderRadius:4,background:"#D76F2B",color:"#fff",fontSize:15,fontWeight:700,cursor:"pointer"},queryDisabled:{width:"100%",minHeight:46,border:0,borderRadius:4,background:"#C8D0CB",color:"#FFFFFF",fontSize:15,fontWeight:700,cursor:"not-allowed"},validationHint:{marginTop:8,color:"#9B3D15",fontSize:12},resultPanel:{background:"#FFFFFF",border:"1px solid #DCE3DF",margin:"20px auto 0",padding:24,maxWidth:1120,boxSizing:"border-box"},resultHeader:{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",gap:8,borderBottom:"1px solid #E7ECE9",paddingBottom:16,marginBottom:18,textAlign:"center"},resultTitle:{margin:0,fontSize:22},customerSummary:{color:"#5D6B64",fontSize:13,textAlign:"center"},balanceSummary:{display:"flex",justifyContent:"center",gap:40,marginBottom:18,padding:"14px 18px",background:"#F6F9F7",border:"1px solid #DDE6E0",color:"#405149",textAlign:"center"},summaryLabel:{display:"block",marginBottom:5,color:"#718078",fontSize:12,fontWeight:400},summaryAmount:{color:"#1D6141",fontVariantNumeric:"tabular-nums"},empty:{padding:"36px 18px",marginTop:20,textAlign:"center",color:"#7A8881",background:"#FFFFFF",border:"1px dashed #C9D5CE",fontSize:14},error:{marginTop:20,padding:"12px 14px",background:"#FFF1EB",border:"1px solid #F1B895",color:"#9B3D15",fontSize:14},tableWrap:{overflowX:"auto",border:"1px solid #DDE6E0",borderRadius:4,background:"#FFFFFF"},table:{width:"100%",borderCollapse:"collapse",fontSize:13,minWidth:620,textAlign:"center",lineHeight:1.35},amountCell:{textAlign:"right",fontVariantNumeric:"tabular-nums"},amountHighlight:{textAlign:"right",color:"#1D6141",fontWeight:700,fontVariantNumeric:"tabular-nums"},nameCell:{textAlign:"left",minWidth:150},orderCell:{fontFamily:"Consolas, monospace",fontWeight:700},mobileCard:{border:"1px solid #DFE7E2",padding:15,marginBottom:10,background:"#FBFCFB"},cardTop:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:14},currency:{color:"#5F6E66",fontSize:12},metric:{display:"flex",justifyContent:"space-between",gap:12,padding:"8px 0",borderTop:"1px solid #E7ECE9",color:"#64726B",fontSize:13},highlight:{color:"#1D6141",fontWeight:700},detailGrid:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px 12px",fontSize:13,color:"#64726B"},statusSuccess:{display:"inline-block",padding:"3px 8px",borderRadius:12,color:"#1D6141",background:"#E4F1E8",fontSize:12,fontWeight:700},statusError:{display:"inline-block",padding:"3px 8px",borderRadius:12,color:"#A83B27",background:"#FCE9E4",fontSize:12,fontWeight:700}};function getCustomState(e){return void 0===_customState?e?void 0:{}:e?_customState[e]:Object.assign({},_customState)}function setCustomState(t){void 0!==_customState&&(Object.keys(t||{}).forEach(function(e){_customState[e]=t[e]}),this.forceUpdate())}function forceUpdate(){this.setState({timestamp:(new Date).getTime()})}
|