前端转vue
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TradeAPIsHelper.ts 47KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325
  1. import SystemFunction from '../../Library.Ext/Function/SystemFunction'
  2. // 定义一些类型,由于不清楚具体类型,这里先做简单定义,实际使用中需要根据情况完善
  3. type PageBase = any;
  4. type Message = {
  5. Fd16?: string;
  6. Fd30?: string;
  7. Fd31?: string;
  8. Fd100_1?: string;
  9. Fd34?: string;
  10. Fd12?: string;
  11. Fd125?: string;
  12. CustomizeTransitEntry?: (x: any) => boolean;
  13. CustomizeTransit?: any;
  14. };
  15. type Result = {
  16. Code?: string;
  17. Desc?: string;
  18. };
  19. type Selector = any;
  20. type ComboBox = any;
  21. type DataBox = any;
  22. type DataTable = any;
  23. type FrameworkElement = any;
  24. type UIElement = any;
  25. type NotifyMessage = any;
  26. type PrintTypes = any;
  27. type PrintContainer = any;
  28. type AuthConditionElement = {
  29. OperationType?: string;
  30. Txcode?: string;
  31. CTSigns?: string;
  32. SinAmt?: string;
  33. DeAccountType?: string;
  34. CrAccountType?: string;
  35. DeAccountPro?: string;
  36. CrAccountPro?: string;
  37. DeIsOwn?: string;
  38. CrIsOwn?: string;
  39. DCIsSameCus?: string;
  40. DeCaAddAmt?: string;
  41. DeTrAddAmt?: string;
  42. SumAddAmt?: string;
  43. LossMarked?: string;
  44. DocumentType?: string;
  45. DeductMarked?: string;
  46. LongOrShort?: string;
  47. LegalPerson?: string;
  48. CrTrAddAmt?: string;
  49. };
  50. type CheckConditionElements = {
  51. Account?: any;
  52. Money?: any;
  53. OperationType?: string;
  54. Txcode?: string;
  55. CTSigns?: string;
  56. SinAmt?: string;
  57. DeAccountType?: string;
  58. CrAccountType?: string;
  59. DeAccountPro?: string;
  60. CrAccountPro?: string;
  61. DeIsOwn?: string;
  62. CrIsOwn?: string;
  63. DCIsSameCus?: string;
  64. DeCaAddAmt?: string;
  65. DeTrAddAmt?: string;
  66. SumAddAmt?: string;
  67. LossMarked?: string;
  68. DocumentType?: string;
  69. DeductMarked?: string;
  70. LongOrShort?: string;
  71. LegalPerson?: string;
  72. CrTrAddAmt?: string;
  73. };
  74. type TransitType = any;
  75. type PrintTemplate = any;
  76. type PrintAttributes = any;
  77. type TradeBusData = {
  78. [key: string]: string;
  79. };
  80. type IPage = any;
  81. type WorkFlowHandle = {
  82. deleteProcessInsById: (processId: string, reason: string) => void;
  83. CompleteTaskById: (workItemId: string) => void;
  84. };
  85. type AuthDataHelper = {
  86. ProcessId: string;
  87. ClearAuthData: () => void;
  88. };
  89. type CheckDataHelper = {
  90. ProcessId: string;
  91. ClearCheckData: () => void;
  92. };
  93. type AsksuperResultType = 'Success' | 'Failed';
  94. type CheckManager = {
  95. GetCheckManager: (obj: any) => any;
  96. Result: (t: AsksuperResultType, busData: TradeBusData) => void;
  97. SetAuthCheckTitle: (element: any, str: string) => void;
  98. };
  99. type AuthManager = {
  100. GetAuthManager: (obj: any) => any;
  101. Result: (t: AsksuperResultType, busData: TradeBusData) => void;
  102. };
  103. type LoginAuthentication = {
  104. Instance: {
  105. GroupKinbrNo: string;
  106. };
  107. };
  108. type LoginUserInfo = {
  109. TellerNo: string;
  110. GetUserInfo: (key: string) => string;
  111. };
  112. type TradePowerManager = {
  113. Instance: {
  114. IsPowerCheckByUser: boolean;
  115. GetTradePowerByCode: (tradeCode: string) => any[];
  116. };
  117. };
  118. type TradeManagerHandle = {
  119. TT_SYSCONFIG_GetConfigValueByConfigID: (configId: string) => string;
  120. };
  121. type Feild8583 = {
  122. SetAuthFd125: (fd125: string) => any;
  123. GetStrBytes: (fd125: string, start: number, length: number) => string;
  124. };
  125. type TransitErrorCodeMap = {
  126. GetInstance: () => {
  127. GetErrorMessage: (notify: string, type: string) => string;
  128. };
  129. };
  130. type SelectionManager = {
  131. Instance: {
  132. PullSelection: (code: string, arguments?: any, mainCode?: string) => any;
  133. };
  134. };
  135. type UserFunction = {
  136. GetSelectedValue: (combo: ComboBox) => string;
  137. SetSelectedValue: (combo: ComboBox, val: any) => void;
  138. SetSelectedKey: (combo: ComboBox, key: string) => void;
  139. ToDecimal: (src: string) => number;
  140. ToDateTime: (src: string) => Date;
  141. };
  142. type TradeHandle = {
  143. ExcuteShell: (cmd: string) => boolean;
  144. };
  145. type TemplateBase = {
  146. PrintType: PrintTypes;
  147. DrawingSpecialMark: (left: number, top: number, markText: string) => void;
  148. DrawingSpecialMarkWithElement: (left: number, top: number, element: UIElement) => void;
  149. };
  150. type ReportEntity = {
  151. new(reportURI: string): ReportEntity;
  152. Analyze: (data: string) => void;
  153. Print: () => void;
  154. };
  155. type PrintContainerExt = {
  156. GetPrintElement: (page: PageBase) => PrintAttributes;
  157. SetPrintElement: (obj: any, pa: PrintAttributes) => void;
  158. };
  159. class TradeAPIsHelper {
  160. // ctor & Property
  161. public Page: PageBase;
  162. constructor(page: PageBase) {
  163. this.Page = page;
  164. }
  165. // 封装交易API函数
  166. // Message操作
  167. public InitFd(message: Message): void {
  168. SystemFunction.InitFd(this.Page, message);
  169. }
  170. public CommSend(message: Message): void {
  171. SystemFunction.CommSend(this.Page, message);
  172. }
  173. public CommSend96(message: Message): void {
  174. SystemFunction.CommSend96(this.Page, message);
  175. }
  176. public CallServer(message: Message): boolean {
  177. return this.Page.CallServer(message);
  178. }
  179. public CallAgn(message: Message): boolean {
  180. return this.Page.CallAgn(message);
  181. }
  182. public CallAgnTips(message: Message): boolean {
  183. return this.Page.CallAgnTips(message);
  184. }
  185. public CallAgnRun(message: Message): boolean {
  186. return this.Page.CallAgnRun(message);
  187. }
  188. public CallMobileBanking(message: Message): boolean {
  189. return this.Page.DoTransit(message, TransitType.CallMobileBanking);
  190. }
  191. public CallAgnCIS(message: Message): boolean {
  192. return this.Page.DoTransit(message, TransitType.CallAgnCIS);
  193. }
  194. public CallAgnCard(message: Message): boolean {
  195. return this.Page.DoTransit(message, TransitType.CallAgnCard);
  196. }
  197. public CallAgnHeat01(message: Message): boolean {
  198. return this.Page.DoTransit(message, TransitType.CallAgnHeat01);
  199. }
  200. public CallAgnHeat02(message: Message): boolean {
  201. return this.Page.DoTransit(message, TransitType.CallAgnHeat02);
  202. }
  203. public CallAgnHeat03(message: Message): boolean {
  204. return this.Page.DoTransit(message, TransitType.CallAgnHeat03);
  205. }
  206. public CallAgnIDC(message: Message): boolean {
  207. return this.Page.DoTransit(message, TransitType.CallAgnIDC);
  208. }
  209. public CallAgnIBPS(message: Message): boolean {
  210. return this.Page.DoTransit(message, TransitType.CallAgnIBPS);
  211. }
  212. public CallAgnSHCZ(message: Message): boolean {
  213. return this.Page.DoTransit(message, TransitType.CallAgnSHCZ);
  214. }
  215. public CallAgnIBDW(message: Message): boolean {
  216. return this.Page.DoTransit(message, TransitType.CallAgnIBDW);
  217. }
  218. public CallAgnNew(message: Message): boolean {
  219. return this.Page.DoTransit(message, TransitType.CallAgnNew);
  220. }
  221. public CallAgnCardEx(message: Message): boolean {
  222. return this.Page.DoTransit(message, TransitType.CallAgnCardEx);
  223. }
  224. public CallAgnCartoon(message: Message): boolean {
  225. return this.Page.DoTransit(message, TransitType.CallAgnCartoon);
  226. }
  227. public CallAgnHPF(message: Message): boolean {
  228. return this.Page.DoTransit(message, TransitType.CallAgnHPF);
  229. }
  230. public CallAgnTV(message: Message): boolean {
  231. return this.Page.DoTransit(message, TransitType.CallAgnTV);
  232. }
  233. public CallAgnFSSR(message: Message): boolean {
  234. return this.Page.DoTransit(message, TransitType.CallAgnFSSR);
  235. }
  236. public CallAgnCLFJG(message: Message): boolean {
  237. return this.Page.DoTransit(message, TransitType.CallAgnCLFJG);
  238. }
  239. public CallAgnHontax(message: Message): boolean {
  240. return this.Page.DoTransit(message, TransitType.CallAgnHontax);
  241. }
  242. public CallAgnOrder(message: Message): boolean {
  243. return this.Page.DoTransit(message, TransitType.CallAgnOrder);
  244. }
  245. public CallAgnMIS(message: Message): boolean {
  246. return this.Page.DoTransit(message, TransitType.CallAgnMIS);
  247. }
  248. public CallAgnWXJJ_LP(message: Message): boolean {
  249. return this.Page.DoTransit(message, TransitType.CallAgnWXJJ_LP);
  250. }
  251. public CallAgnWXJJ_CDX(message: Message): boolean {
  252. return this.Page.DoTransit(message, TransitType.CallAgnWXJJ_CDX);
  253. }
  254. public CallAgnNetBank(message: Message): boolean {
  255. return this.Page.DoTransit(message, TransitType.CallAgnNetBank);
  256. }
  257. public CallAgnMF01(message: Message): boolean {
  258. return this.Page.DoTransit(message, TransitType.CallAgnMF01);
  259. }
  260. public CallAgnMF02(message: Message): boolean {
  261. return this.Page.DoTransit(message, TransitType.CallAgnMF02);
  262. }
  263. public CallAgnWater(message: Message): boolean {
  264. return this.Page.DoTransit(message, TransitType.CallAgnWater);
  265. }
  266. public CallAgnCnaps2(message: Message): boolean {
  267. return this.Page.DoTransit(message, TransitType.CallAgnCnaps2);
  268. }
  269. public CallAgn_CZYYSW(message: Message): boolean {
  270. return this.Page.DoTransit(message, TransitType.CallAgn_CZYYSW);
  271. }
  272. public CallAgn_EasyPay(message: Message): boolean {
  273. return this.Page.DoTransit(message, TransitType.CallAgn_EasyPay);
  274. }
  275. public CallAgn_Ebill(message: Message): boolean {
  276. return this.Page.DoTransit(message, TransitType.CallAgn_Ebill);
  277. }
  278. public CallAgn_SDYCT(message: Message): boolean {
  279. return this.Page.DoTransit(message, TransitType.CallAgn_SDYCT);
  280. }
  281. public CallAgn_GasFee(message: Message): boolean {
  282. return this.Page.DoTransit(message, TransitType.CallAgn_GasFee);
  283. }
  284. public CallAgn_NJT(message: Message): boolean {
  285. return this.Page.DoTransit(message, TransitType.CallAgn_NJT);
  286. }
  287. public CallNoFileSys(message: Message): boolean {
  288. return this.Page.DoTransit(message, TransitType.CallNoFileSys);
  289. }
  290. public CallAgn_FGJWQ(message: Message): boolean {
  291. return this.Page.DoTransit(message, TransitType.CallAgn_FGJWQ);
  292. }
  293. public CallAgnNew_WL(message: Message): boolean {
  294. return this.Page.DoTransit(message, TransitType.CallAgnNew_WL);
  295. }
  296. public CallAgn_GGJ(message: Message): boolean {
  297. return this.Page.DoTransit(message, TransitType.CallAgn_GGJ);
  298. }
  299. public CallAgn_FGJWQ_HH(message: Message): boolean {
  300. return this.Page.DoTransit(message, TransitType.CallAgn_FGJWQ_HH);
  301. }
  302. public CallAgn_DF(message: Message): boolean {
  303. return this.Page.DoTransit(message, TransitType.CallAgn_DF);
  304. }
  305. public CallAgn_CW(message: Message): boolean {
  306. return this.Page.DoTransit(message, TransitType.CallAgn_CW);
  307. }
  308. public CallAgn_ZJJG(message: Message): boolean {
  309. return this.Page.DoTransit(message, TransitType.CallAgn_ZJJG);
  310. }
  311. public CallAgn_CKXT(message: Message): boolean {
  312. return this.Page.DoTransit(message, TransitType.CallAgn_CKXT);
  313. }
  314. public CustomizeTransit(msg: Message, func: (x: any) => boolean | null): void {
  315. // 取消自定义处理
  316. if (func === null) {
  317. msg.CustomizeTransitEntry = null;
  318. return;
  319. }
  320. msg.CustomizeTransitEntry = (x: any) => {
  321. try {
  322. return func(x);
  323. } catch (ex) {
  324. console.error('TradeAPIsHelper.CustomizeTransit:执行异常!', ex);
  325. x.Error = (ex as Error).message;
  326. return false;
  327. }
  328. };
  329. }
  330. // 控件辅助操作
  331. public AddItemOfSelecteAll(element: ComboBox, value: string = ''): boolean {
  332. return SystemFunction.AddItemOfSelecteAll(this.Page, element, value);
  333. }
  334. public RemoveItemOfSelecteAll(element: ComboBox): boolean {
  335. return SystemFunction.RemoveItemOfSelecteAll(this.Page, element);
  336. }
  337. public GetError(msg: Message): string {
  338. return SystemFunction.GetError(this.Page, msg);
  339. }
  340. public GetNotifyMessage(notify: string | NotifyMessage): string {
  341. if (typeof notify === 'string') {
  342. return TransitErrorCodeMap.GetInstance().GetErrorMessage(notify, 'notify');
  343. } else {
  344. return this.GetNotifyMessage(notify.toString());
  345. }
  346. }
  347. public CallComboBoxData(comboBox: ComboBox, message: Message, formatString: string, defalutCombox: string = "Null"): Result {
  348. return SystemFunction.CallComboBoxData(this.Page, comboBox, message, formatString, defalutCombox);
  349. }
  350. public CallComboBoxDataSelector(selector: Selector, code: string, arguments?: { [key: string]: string }): boolean {
  351. if (selector === null) return false;
  352. selector.Items.clear();
  353. let dict: any;
  354. if (this.Page.TradeInfo.MainCode === undefined || this.Page.TradeInfo.MainCode === '') {
  355. dict = SelectionManager.Instance.PullSelection(code, arguments);
  356. } else {
  357. dict = SelectionManager.Instance.PullSelection(code, arguments, this.Page.TradeInfo.MainCode);
  358. }
  359. if (dict === null) return false;
  360. selector.SetItems(dict);
  361. return true;
  362. }
  363. public SetAssertNotEmpty(element: FrameworkElement, flag: boolean): void {
  364. SystemFunction.SetAssertNotEmpty(this.Page, element, flag);
  365. }
  366. public GetSelectedValue(combo: ComboBox): string {
  367. return UserFunction.GetSelectedValue(combo);
  368. }
  369. public SetSelectedValue(combo: ComboBox, val: any): void {
  370. UserFunction.SetSelectedValue(combo, val);
  371. }
  372. public SetSelectedKey(combo: ComboBox, key: string): void {
  373. UserFunction.SetSelectedKey(combo, key);
  374. }
  375. public ToDecimal(src: string): number {
  376. return UserFunction.ToDecimal(src);
  377. }
  378. public ToDateTime(src: string): Date {
  379. return UserFunction.ToDateTime(src);
  380. }
  381. public DateToBig(date: string): string[] {
  382. return this.Page.DateToBig(date);
  383. }
  384. // 字符串数字处理类
  385. // 转换字符串为数字 atoi(string)
  386. public Atoi(number: string): number {
  387. return SystemFunction.Atoi(this.Page, number);
  388. }
  389. // 转换数字为字符串 itoa(number,string)
  390. public Itoa(number: number, format: string): string {
  391. return SystemFunction.Itoa(this.Page, number, format);
  392. }
  393. // 截取一个子串 substr(string,number,number)
  394. public SubStr(sourceData: string, start: number, length: number): string {
  395. return SystemFunction.SubStr(this.Page, sourceData, start, length);
  396. }
  397. // 得到字符串的长度 len(string)
  398. public Len(sourceData: string): number {
  399. return SystemFunction.Len(this.Page, sourceData);
  400. }
  401. // 把指定的ascii码值转换为字符串 chr(number)
  402. public Chr(number: number): string {
  403. return SystemFunction.Chr(this.Page, number);
  404. }
  405. // 求两个整数的余 mod(number1,number)
  406. public Mod(number1: number, number2: number): number {
  407. return SystemFunction.Mod(this.Page, number1, number2);
  408. }
  409. // 把一个数字型字符串转换为','分割的形式 comma(string,[number])
  410. public Comma(sourceData: string, length: number): string {
  411. return SystemFunction.Comma(this.Page, sourceData, length);
  412. }
  413. // 得到数字字符串对应的数值 val(string,[number])
  414. public Val(sourceData: string, weight: number): number {
  415. return SystemFunction.Val(this.Page, sourceData, weight);
  416. }
  417. // 去掉尾部空格 rtrim(string)
  418. public RTrim(sourceData: string): string {
  419. return SystemFunction.RTrim(this.Page, sourceData);
  420. }
  421. // 去掉左边空格 ltrim(string)
  422. public LTrim(sourceData: string): string {
  423. return SystemFunction.LTrim(this.Page, sourceData);
  424. }
  425. // 去掉所有空格,包括字符串中间的空格 delspace(string)
  426. public Delspace(sourceData: string): string {
  427. return SystemFunction.Delspace(this.Page, sourceData);
  428. }
  429. // 左补齐参数字符 PadLeft(string,int,char)
  430. public PadLeft(sourcedata: string, length: number, varChar: string = ' '): string {
  431. return SystemFunction.PadLeft(this.Page, sourcedata, length, varChar);
  432. }
  433. // 右补齐参数字符 PadRight(string,length,var)
  434. public PadRight(sourcedata: string, length: number, varChar: string = ' '): string {
  435. return SystemFunction.PadRight(this.Page, sourcedata, length, varChar);
  436. }
  437. // 以某个字符构建某长度的字符串 Space(lenth,char)
  438. public Space(lenght: number, c: string = ' '): string {
  439. return SystemFunction.Space(this.Page, lenght, c);
  440. }
  441. // 计算两个日期直接的绝对差值(天数)
  442. public Func(fDate: string, sDate: string): number {
  443. const startDate = new Date(
  444. parseInt(fDate.substring(0, 4)),
  445. parseInt(fDate.substring(4, 6)) - 1,
  446. parseInt(fDate.substring(6))
  447. );
  448. const endDate = new Date(
  449. parseInt(sDate.substring(0, 4)),
  450. parseInt(sDate.substring(4, 6)) - 1,
  451. parseInt(sDate.substring(6))
  452. );
  453. const timeSpan = endDate.getTime() - startDate.getTime();
  454. return Math.floor(timeSpan / (1000 * 60 * 60 * 24));
  455. }
  456. // 将数字类型转换成大写金额字符串 ChangeToCNY(decimal)
  457. public ChangeToCNY(num: number): string {
  458. return SystemFunction.ChangeToCNY(this.Page, num);
  459. }
  460. // 按格式解析返回字串,给combox添加项
  461. public SetSel(comboBox: ComboBox, fileData: string, formatString: string): boolean {
  462. return SystemFunction.SetSel(this.Page, comboBox, fileData, formatString);
  463. }
  464. // 非法汉字字符检查
  465. public CheckHalf(str: string): boolean {
  466. return true;
  467. }
  468. // 格式化金额数值:千分位、去空格(左对齐)
  469. public FormatAMT(amtVal: number): string {
  470. return this.Delspace(this.Comma(amtVal.toString(), 17));
  471. }
  472. // 将数字转换成中文
  473. private static unit: string[] = ["", "十", "百", "千", "万", "十万", "百万", "千万", "亿", "十亿", "百亿", "千亿", "万亿"];
  474. private static unit_T: string[] = ["", "拾", "佰", "仟", "萬", "拾萬", "佰萬", "仟萬", "亿", "拾亿", "佰亿", "仟亿", "萬亿"];
  475. public ChangeToCI(value: number, isSimple: boolean = true, hasUnit: boolean = false): string {
  476. let ret = '';
  477. const data = Math.abs(value).toString();
  478. for (let i = 0; i < data.length; i++) {
  479. const item = data[i];
  480. let c = '';
  481. switch (item) {
  482. case '0':
  483. c = isSimple ? "零" : "零";
  484. break;
  485. case '1':
  486. c = isSimple ? "一" : "壹";
  487. break;
  488. case '2':
  489. c = isSimple ? "二" : "贰";
  490. break;
  491. case '3':
  492. c = isSimple ? "三" : "叁";
  493. break;
  494. case '4':
  495. c = isSimple ? "四" : "肆";
  496. break;
  497. case '5':
  498. c = isSimple ? "五" : "伍";
  499. break;
  500. case '6':
  501. c = isSimple ? "六" : "陆";
  502. break;
  503. case '7':
  504. c = isSimple ? "七" : "柒";
  505. break;
  506. case '8':
  507. c = isSimple ? "八" : "捌";
  508. break;
  509. case '9':
  510. c = isSimple ? "九" : "玖";
  511. break;
  512. default:
  513. throw new Error("ChangeToCI:参数异常!");
  514. }
  515. ret += c;
  516. if (hasUnit) {
  517. // 加载单位
  518. ret += isSimple ? TradeAPIsHelper.unit[data.length - i - 1] : TradeAPIsHelper.unit_T[data.length - i - 1];
  519. }
  520. }
  521. return ret;
  522. }
  523. // 将汉字(零,一 ……十二转换为阿拉伯数字1至12)
  524. public ChangeToNum(value: string): number {
  525. let c = -1;
  526. switch (value) {
  527. case "零":
  528. c = 0;
  529. break;
  530. case "一":
  531. c = 1;
  532. break;
  533. case "二":
  534. c = 2;
  535. break;
  536. case "三":
  537. c = 3;
  538. break;
  539. case "四":
  540. c = 4;
  541. break;
  542. case "五":
  543. c = 5;
  544. break;
  545. case "六":
  546. c = 6;
  547. break;
  548. case "七":
  549. c = 7;
  550. break;
  551. case "八":
  552. c = 8;
  553. break;
  554. case "九":
  555. c = 9;
  556. break;
  557. case "十":
  558. c = 10;
  559. break;
  560. case "十一":
  561. c = 11;
  562. break;
  563. case "十二":
  564. c = 12;
  565. break;
  566. default:
  567. break;
  568. }
  569. return c;
  570. }
  571. // 转换证件类型
  572. private static _LicKindList_: { [key: string]: string } | null = null;
  573. public ChgLicKind(kind: string): string {
  574. if (TradeAPIsHelper._LicKindList_ === null) {
  575. TradeAPIsHelper._LicKindList_ = SelectionManager.Instance.PullSelection("C004", null);
  576. const c003Data = SelectionManager.Instance.PullSelection("C003", null);
  577. Object.entries(c003Data).forEach(([key, value]) => {
  578. TradeAPIsHelper._LicKindList_[key] = value;
  579. });
  580. }
  581. if (TradeAPIsHelper._LicKindList_.hasOwnProperty(kind)) {
  582. return TradeAPIsHelper._LicKindList_[kind];
  583. }
  584. const item = Object.entries(TradeAPIsHelper._LicKindList_).find(([_, value]) => value === kind);
  585. return item ? item[0] : kind;
  586. }
  587. // 解析文本文件、excel文件、DataTable文件
  588. public AnalyzeTxtData(txt_RowSplit: string[], txt_ColumnSlit: string, txt_EnCode: string, isColumnHeader: boolean = true): DataTable {
  589. return SystemFunction.AnalyzeTxtData(txt_RowSplit, txt_ColumnSlit, txt_EnCode, isColumnHeader);
  590. }
  591. public AnalyseExcelData(RowCount: number = 0, columnCount: number = 0): DataTable {
  592. return SystemFunction.AnalyseExcelData(RowCount, columnCount);
  593. }
  594. public AnalyseDataTable(data: DataTable, txt_RowSplit: string, txt_ColumnSlit: string): string {
  595. return this.AnalyseDataTable(data, txt_RowSplit, txt_ColumnSlit);
  596. }
  597. // 文件操作相关
  598. public Shell(cmd: string): boolean {
  599. return TradeHandle.ExcuteShell(cmd);
  600. }
  601. public Getfiletxt(fileName: string): string {
  602. return SystemFunction.Getfiletxt(fileName);
  603. }
  604. public Savefiletxt(fileName: string, fileContent: string, append: boolean): boolean {
  605. return SystemFunction.Savefiletxt(fileName, fileContent, append);
  606. }
  607. // MessageBox-弹出消息框
  608. // 消息提示默认值
  609. private static readonly IsCoverAll = true;
  610. private static readonly IsReverse = true;
  611. private static readonly Direction = 3;
  612. private static readonly AnimationEnable = false;
  613. // 输入信息提示
  614. public ShowTip(message: string): boolean {
  615. const current: FrameworkElement = this.Page;
  616. const flag = this.Page.GetEnableFocusControl();
  617. let fm: any;
  618. if (flag) {
  619. fm = this.Page.GetManagerInstance();
  620. if (fm !== null) {
  621. current = fm.CurrentFocusedElement;
  622. }
  623. }
  624. return this.ShowTipElement(current, message);
  625. }
  626. public ShowTipElement(target: UIElement, message: string): boolean {
  627. return target.ShowTip(message);
  628. }
  629. public ShowTipPlacement(target: UIElement, message: string, placement: any = 'Bottom'): boolean {
  630. return target.ShowTip(placement, message);
  631. }
  632. // 功能选择消息提示
  633. public ShowComfirmBox(message: string, comfirm: string[], defaultfocus: string | null = null): string {
  634. let def = 1;
  635. if (comfirm.includes(defaultfocus as string)) {
  636. def = comfirm.indexOf(defaultfocus as string) + 1;
  637. }
  638. const ret = this.Page.ShowComfirmBox(message, comfirm, def);
  639. return comfirm[ret];
  640. }
  641. @Obsolete
  642. public ShowComfirmBoxKey(message: string, comfirm: { [key: string]: string }, defaultfocus: string = 'None'): string {
  643. return this.Page.ShowPageMessageBoxExt(message, comfirm, defaultfocus);
  644. }
  645. public ShowComfirmBoxParams(message: string, ...comfirm: string[]): number {
  646. return this.Page.ShowComfirmBox(message, comfirm);
  647. }
  648. // 推送消息提示
  649. public ShowPopueMessageBox(content: any, caption: string = "提示信息"): void {
  650. // 原函数体为空
  651. }
  652. // 默认选择提示
  653. public ShowQuestionMessageBox(content: any, caption: string = "询问信息", focuResult: string = "Yes", results: string[] = ["Yes", "No"]): string {
  654. const result = this.Page.ShowPageMessageBoxMetro(
  655. content,
  656. caption,
  657. null,
  658. this.ConvertMessageBoxResultToStr(focuResult),
  659. TradeAPIsHelper.Direction,
  660. TradeAPIsHelper.IsReverse,
  661. TradeAPIsHelper.IsCoverAll,
  662. TradeAPIsHelper.AnimationEnable,
  663. this.ConvertMessageBoxButton(results)
  664. );
  665. return this.ConvertStrToMessageBoxResult(result);
  666. }
  667. public ShowQuestionMessageBoxCustom(content: any, results: string[], defaultIndex: number, caption: string = "询问信息"): string {
  668. const defaultValue = results.length > defaultIndex ? results[defaultIndex] : results[0];
  669. return this.Page.ShowPageMessageBoxMetro(
  670. content,
  671. caption,
  672. null,
  673. defaultValue,
  674. TradeAPIsHelper.Direction,
  675. TradeAPIsHelper.IsReverse,
  676. TradeAPIsHelper.IsCoverAll,
  677. TradeAPIsHelper.AnimationEnable,
  678. results
  679. );
  680. }
  681. // 场景信息提醒提示
  682. public ShowSuccessMessageBox(content: any | null = null, caption: string = "业务办理成功"): string {
  683. const image = this.Page.GetResource("MessageBoxMetroSuccess");
  684. const result = this.Page.ShowPageMessageBoxMetro(
  685. content,
  686. caption,
  687. image,
  688. this.ConvertMessageBoxResultToStr("OK"),
  689. TradeAPIsHelper.Direction,
  690. TradeAPIsHelper.IsReverse,
  691. TradeAPIsHelper.IsCoverAll,
  692. TradeAPIsHelper.AnimationEnable,
  693. this.ConvertMessageBoxButton(["OK"])
  694. );
  695. return this.ConvertStrToMessageBoxResult(result);
  696. }
  697. public ShowInfoMessageBox(content: any | null = null, caption: string = "提示信息"): string {
  698. const image = this.Page.GetResource("MessageBoxMetroInfo");
  699. const result = this.Page.ShowPageMessageBoxMetro(
  700. content,
  701. caption,
  702. image,
  703. this.ConvertMessageBoxResultToStr("OK"),
  704. TradeAPIsHelper.Direction,
  705. TradeAPIsHelper.IsReverse,
  706. TradeAPIsHelper.IsCoverAll,
  707. TradeAPIsHelper.AnimationEnable,
  708. this.ConvertMessageBoxButton(["OK"])
  709. );
  710. return this.ConvertStrToMessageBoxResult(result);
  711. }
  712. public ShowErrorMessageBox(content: any | null = null, caption: string = "错误信息"): string {
  713. const image = this.Page.GetResource("MessageBoxMetroError");
  714. const result = this.Page.ShowPageMessageBoxMetro(
  715. content,
  716. caption,
  717. image,
  718. this.ConvertMessageBoxResultToStr("OK"),
  719. TradeAPIsHelper.Direction,
  720. TradeAPIsHelper.IsReverse,
  721. TradeAPIsHelper.IsCoverAll,
  722. TradeAPIsHelper.AnimationEnable,
  723. this.ConvertMessageBoxButton(["OK"])
  724. );
  725. return this.ConvertStrToMessageBoxResult(result);
  726. }
  727. public ShowWarnMessageBox(content: any | null = null, caption: string = "警告信息"): string {
  728. const image = this.Page.GetResource("MessageBoxMetroWarn");
  729. const result = this.Page.ShowPageMessageBoxMetro(
  730. content,
  731. caption,
  732. image,
  733. this.ConvertMessageBoxResultToStr("OK"),
  734. TradeAPIsHelper.Direction,
  735. TradeAPIsHelper.IsReverse,
  736. TradeAPIsHelper.IsCoverAll,
  737. TradeAPIsHelper.AnimationEnable,
  738. this.ConvertMessageBoxButton(["OK"])
  739. );
  740. return this.ConvertStrToMessageBoxResult(result);
  741. }
  742. // 转换方法
  743. private ConvertStrToMessageBoxResult(str: string | null): string {
  744. str = str || '';
  745. switch (str.trim()) {
  746. case "取消":
  747. return "Cancel";
  748. case "否":
  749. return "No";
  750. case "确定":
  751. return "OK";
  752. case "是":
  753. return "Yes";
  754. default:
  755. return "None";
  756. }
  757. }
  758. private ConvertMessageBoxResultToStr(result: string): string {
  759. switch (result) {
  760. case "Cancel":
  761. return "取消";
  762. case "No":
  763. return "否";
  764. case "OK":
  765. return "确定";
  766. case "Yes":
  767. return "是";
  768. default:
  769. return "未知";
  770. }
  771. }
  772. private ConvertMessageBoxButton(msg: string[]): string[] {
  773. return msg;
  774. }
  775. // DataBox相关函数
  776. public InitDataBox(databox: DataBox): void {
  777. databox.InitDataBox();
  778. }
  779. public GetDataForDataTable(databox: DataBox): DataTable {
  780. return databox.GetDataForDataTable();
  781. }
  782. public GetDataForString(databox: DataBox): string {
  783. return databox.GetDataForString();
  784. }
  785. public BindDataTable(databox: DataBox, dtSource: DataTable): void {
  786. databox.BindDataTable(dtSource);
  787. }
  788. public DataBinding(databox: DataBox, fileData: string, ...columnName: string[]): void {
  789. databox.DataBinding(fileData, columnName);
  790. }
  791. public DataBindingXML(databox: DataBox, fileData: string, nodeName: string, ...columnName: string[]): void {
  792. const str = databox.AnalyzeXMLtoStr(fileData, nodeName);
  793. databox.DataBinding(str || fileData, columnName);
  794. }
  795. public DataBindingLevel(databox: DataBox, fileData: string, level: any, ...columnNames: string[]): void {
  796. databox.DataBinding(fileData, level, columnNames);
  797. }
  798. public SetColumnsHeader(databox: DataBox, columnIndex: number, header: string): void {
  799. databox.SetColumnsHeader(columnIndex, header);
  800. }
  801. public SetColumnsWidth(databox: DataBox, columnIndex: number, width: number): void {
  802. databox.SetColumnsWidth(columnIndex, width);
  803. }
  804. public SetColumnsVisible(databox: DataBox, columnIndex: number, visible: boolean): void {
  805. databox.SetColumnsVisible(columnIndex, visible);
  806. }
  807. public SetColumnsFormat(databox: DataBox, columnIndex: number, format: string): void {
  808. databox.SetColumnsFormat(columnIndex, format);
  809. }
  810. public SetColumnsAlign(databox: DataBox, columnIndex: number, align: string): void {
  811. databox.SetColumnsAlign(columnIndex, align);
  812. }
  813. public GetSelectMultiRows(databox: DataBox): any[] {
  814. return databox.GetSelectMultiRows();
  815. }
  816. public GetSelectSingleRow(databox: DataBox): any {
  817. return databox.GetSelectSingleRow();
  818. }
  819. public GetSelectRowValue(databox: DataBox, hasRowIndex: boolean = true): string[] {
  820. let ret = databox.GetSelectRowValue();
  821. if (!hasRowIndex && ret && ret.length > 1) {
  822. ret = ret.slice(1);
  823. }
  824. return ret;
  825. }
  826. public SetSelDataBox(databox: DataBox, colName: string, dic: { [key: string]: string }): void {
  827. databox.SetSel(colName, dic);
  828. }
  829. public AddColumn(databox: DataBox, column: any): void {
  830. databox.AddColumn(column);
  831. }
  832. public AddHyperlinkColumn(databox: DataBox, colName: string, click: (event: any) => void, hotkey: string = 'None'): void {
  833. databox.AddHyperlinkColumn(colName, click, hotkey);
  834. }
  835. public AddRowDataBox(databox: DataBox, newRow: any): boolean {
  836. return databox.AddRow(newRow);
  837. }
  838. public AddRowValues(databox: DataBox, ...values: any[]): boolean {
  839. return databox.AddRow(values);
  840. }
  841. public UpdateRow(databox: DataBox, ...values: any[]): boolean {
  842. return databox.UpdateRow(values);
  843. }
  844. public DeleteSelectRows(databox: DataBox): boolean {
  845. return databox.DeleteSelectRows();
  846. }
  847. // Combobox控件相关
  848. public AddItems(target: any, items: any[]): void {
  849. target.AddItems(items);
  850. }
  851. public SetItems(target: any, items: any[]): void {
  852. target.SetItems(items);
  853. }
  854. public GetSelectedKey(target: any): string {
  855. return target.GetSelectedKey();
  856. }
  857. // 设置焦点相关
  858. public SetFocus(element: FrameworkElement | null = null): void {
  859. this.Page.SetFocus(element);
  860. }
  861. // 检查账号是否是卡
  862. public CheckCardBin(acno: string): boolean {
  863. return this.Page.CheckCardBin(acno);
  864. }
  865. // 打印相关
  866. public CreateSpecialMarkPrint(pt: PrintTypes, left: number, top: number, markText: string): PrintContainer {
  867. const tb = new TemplateBase();
  868. tb.PrintType = pt;
  869. tb.DrawingSpecialMark(left, top, markText);
  870. return tb;
  871. }
  872. public CreateSpecialMarkPrintElement(pt: PrintTypes, left: number, top: number, element: UIElement): PrintContainer {
  873. const tb = new TemplateBase();
  874. tb.PrintType = pt;
  875. tb.DrawingSpecialMarkWithElement(left, top, element);
  876. return tb;
  877. }
  878. public PrintCertificate(authForms: PrintContainer[]): void {
  879. this.Page.PrintCertificate(authForms);
  880. // add by chuhai 清空前端流水,避免交易不关闭导致流水重复。
  881. this.Page.ClearSerialNumber();
  882. }
  883. public PrintAcdtl_1(message: Message): string {
  884. return '';
  885. }
  886. public PrintAcdtl_hst(message: Message): string {
  887. return '';
  888. }
  889. public PrintAcdtl_h(message: Message): string {
  890. return '';
  891. }
  892. public Print_Sq(message: Message): string {
  893. return '';
  894. }
  895. public PrintReport(formatMessage: string, reportURI: string, paraDic: { [key: string]: string } | null): void {
  896. let sb = formatMessage;
  897. if (paraDic) {
  898. sb += '\n[parameters]\n';
  899. for (const [key, value] of Object.entries(paraDic)) {
  900. sb += `${key}=${value}\n`;
  901. }
  902. sb += ';';
  903. }
  904. const re = new ReportEntity(reportURI);
  905. // 补偿PrintAttributes给ReportEntity
  906. let pa = PrintContainerExt.GetPrintElement(this.Page);
  907. if (!pa) pa = this.Page.GetPrintAttributes();
  908. PrintContainerExt.SetPrintElement(re, pa);
  909. re.Analyze(sb);
  910. re.Print();
  911. }
  912. // 查找上层Ipage
  913. private FindAncestor<T>(element: any): T | null {
  914. let obj: any = null;
  915. for (obj = this.Page.VisualTreeHelper.GetParent(element); !(obj instanceof T); obj = this.Page.VisualTreeHelper.GetParent(obj)) {
  916. if (obj === null) break;
  917. }
  918. return obj as T;
  919. }
  920. // 授权/复核
  921. public RestoreTradePage(serialid: string, busData: TradeBusData): void {
  922. this.Page.ShowTradeTab(serialid, (page: IPage) => {
  923. this.Page.Dispatcher.BeginInvoke(() => {
  924. const resultKey = busData.hasOwnProperty('SuperFlag') ? 'SuperFlag' : 'AuthFlag';
  925. let resultflag = false;
  926. if (busData[resultKey]) {
  927. resultflag = busData[resultKey] === 'true';
  928. }
  929. // 没有找到page,说明已经关闭过前端软件
  930. if (page === null) {
  931. // target.ShowErrorMessageBox("此任务的交易已丢失!");
  932. // 如果target是消息推送过来的,用target.ShowErrorMessageBox会报错,暂时用这个代替
  933. this.ShowInfoMessageBox("此任务的交易已丢失,请重新做该交易");
  934. // MessageBox.Show("此任务的交易已丢失,请重新做该交易", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
  935. let deletereason = '';
  936. if (resultKey === 'SuperFlag') {
  937. deletereason = 'SuperFaild';
  938. } else if (resultKey === 'AuthFlag') {
  939. deletereason = 'AuthFaild';
  940. } else {
  941. deletereason = 'TellerDelete';
  942. }
  943. // 如果失败,不管是找没找到能还原的界面,因为工作流配置为不非环形流程,都需要删除流程,tradepage的流水号serialid也不用更新,
  944. // 如果还原了界面,客户还可以使用原来的流水号再提交申请,这个由服务端做了处理。
  945. WorkFlowHandle.deleteProcessInsById(busData['ProcessId'], deletereason); // TellerDelete只是做为删除流程实例原因的描述
  946. } else {
  947. // TabItem item = page.GetCurrentTabItem();
  948. page.GetTradeInfoData().SetTradeBus(busData); // .SetTradeData(data);
  949. // CheckManager c = item as CheckManager;
  950. // AuthManager a = item as AuthManager;
  951. let t: AsksuperResultType = 'Failed';
  952. if (resultflag) {
  953. if (busData.hasOwnProperty('WorkItemId')) {
  954. WorkFlowHandle.CompleteTaskById(busData['WorkItemId']); // 提交任务
  955. }
  956. t = 'Success';
  957. } else {
  958. let deletereason = '';
  959. let processid = '';
  960. if (resultKey === 'SuperFlag') {
  961. const checkdata = new CheckDataHelper(page);
  962. deletereason = 'SuperFaild';
  963. processid = checkdata.ProcessId;
  964. checkdata.ClearCheckData();
  965. } else if (resultKey === 'AuthFlag') {
  966. const authdata = new AuthDataHelper(page);
  967. deletereason = 'AuthFaild';
  968. processid = authdata.ProcessId;
  969. authdata.ClearAuthData();
  970. }
  971. /* 如果失败,不管是找没找到能还原的界面,因为工作流配置为不非环形流程,都需要删除流程,tradepage的流水号serialid也不用更新,
  972. 如果还原了界面,客户还可以使用原来的流水号再提交申请,这个由服务端做了处理。
  973. TellerDelete只是做为删除流程实例原因的描述 */
  974. WorkFlowHandle.deleteProcessInsById(processid, deletereason);
  975. t = 'Failed';
  976. }
  977. // if (c != null)
  978. // c.Result(t, busData);
  979. // else
  980. const c = CheckManager.GetCheckManager(page);
  981. const a = AuthManager.GetAuthManager(page);
  982. if (c && resultKey === 'SuperFlag') {
  983. c.Result(t, busData);
  984. } else if (a && resultKey === 'AuthFlag') {
  985. a.Result(t, busData);
  986. }
  987. }
  988. }, 'Loaded');
  989. });
  990. }
  991. public GetAuthElement(out oepnBranch: string, DeAccount: string = '', CrAccount: string = '', SinAmt: string = '', CTSigns: string = '', OperationType: string = '', DeAccountSeqn: string = ''): AuthConditionElement | null {
  992. oepnBranch = '';
  993. let result: AuthConditionElement | null = null;
  994. const message: Message = {};
  995. this.InitFd(message);
  996. this.CommSend(message);
  997. message.Fd16 = '8980';
  998. message.Fd30 = DeAccount;
  999. message.Fd31 = CrAccount;
  1000. message.Fd100_1 = SinAmt;
  1001. message.Fd34 = DeAccountSeqn;
  1002. if (!this.CallServer(message)) {
  1003. this.ShowErrorMessageBox(this.GetError(message));
  1004. return null;
  1005. }
  1006. if (message.Fd12 !== '0000') {
  1007. this.ShowErrorMessageBox(this.GetError(message));
  1008. return null;
  1009. } else {
  1010. result = {
  1011. OperationType: OperationType ? OperationType.trim() : '',
  1012. Txcode: this.Page.TradeInfoData.GetTradeInfo(this.Page).TradeCode,
  1013. CTSigns: CTSigns ? CTSigns.trim() : '',
  1014. SinAmt: SinAmt ? SinAmt.trim() : '',
  1015. } as AuthConditionElement;
  1016. const fd125 = Feild8583.SetAuthFd125(message.Fd125);
  1017. fd125.CTSigns = CTSigns;
  1018. fd125.SinAmt = SinAmt;
  1019. oepnBranch = DeAccount ? Feild8583.GetStrBytes(message.Fd125, 176, 5) : Feild8583.GetStrBytes(message.Fd125, 181, 5);
  1020. result.DeAccountType = fd125.DeAccountType.trim();
  1021. result.CrAccountType = fd125.CrAccountType.trim();
  1022. result.DeAccountPro = fd125.DeAccountPro.trim();
  1023. result.CrAccountPro = fd125.CrAccountPro.trim();
  1024. result.DeIsOwn = fd125.DeIsOwn === 'Y' ? 'true' : 'false';
  1025. result.CrIsOwn = fd125.CrIsOwn === 'Y' ? 'true' : 'false';
  1026. result.DCIsSameCus = fd125.DCIsSameCus === 'Y' ? 'true' : 'false';
  1027. result.DeCaAddAmt = fd125.DeCaAddAmt.trim();
  1028. if (!SinAmt.trim()) SinAmt = '0.0';
  1029. result.DeCaAddAmt = (parseFloat(fd125.DeCaAddAmt.trim()) + parseFloat(SinAmt)).toString();
  1030. result.CrTrAddAmt = (parseFloat(fd125.CrTrAddAmt.trim()) + parseFloat(SinAmt)).toString();
  1031. result.DeTrAddAmt = (parseFloat(fd125.DeTrAddAmt.trim()) + parseFloat(SinAmt)).toString();
  1032. result.SumAddAmt = (parseFloat(fd125.DeTrAddAmt.trim()) + parseFloat(SinAmt) + parseFloat(fd125.DeCaAddAmt.trim())).toString();
  1033. result.LossMarked = fd125.LossMarked === 'Y' ? 'true' : fd125.LossMarked === 'N' ? 'false' : '';
  1034. result.DocumentType = fd125.DocumentType.trim();
  1035. result.DeductMarked = fd125.DeductMarked.trim();
  1036. result.LongOrShort = fd125.LongOrShort === 'Y' ? 'true' : fd125.LongOrShort === 'N' ? 'false' : '';
  1037. result.LegalPerson = LoginAuthentication.Instance.GroupKinbrNo;
  1038. }
  1039. return result;
  1040. }
  1041. public GetCheckElement(args: any): CheckConditionElements | null {
  1042. const SinAmt = args.SinAmt.toString();
  1043. let result: CheckConditionElements | null = null;
  1044. const message: Message = {};
  1045. this.InitFd(message);
  1046. this.CommSend(message);
  1047. message.Fd16 = '8980';
  1048. message.Fd30 = args.DeAccount;
  1049. message.Fd31 = args.CrAccount;
  1050. message.Fd100_1 = SinAmt;
  1051. message.Fd34 = args.DeAccountSeqn;
  1052. if (!this.CallServer(message)) {
  1053. this.ShowErrorMessageBox(this.GetError(message));
  1054. return null;
  1055. }
  1056. if (message.Fd12 !== '0000') {
  1057. this.ShowErrorMessageBox(this.GetError(message));
  1058. return null;
  1059. } else {
  1060. result = {
  1061. Account: args.Account,
  1062. Money: args.Amt,
  1063. OperationType: args.OperationType ? args.OperationType.trim() : '',
  1064. Txcode: this.Page.TradeInfoData.GetTradeInfo(this.Page).TradeCode,
  1065. CTSigns: args.CTSigns ? args.CTSigns.trim() : '',
  1066. SinAmt: args.Amt.toString() && args.Amt !== 0 ? args.Amt.toString() : SinAmt,
  1067. } as CheckConditionElements;
  1068. const fd125 = Feild8583.SetAuthFd125(message.Fd125);
  1069. fd125.CTSigns = args.CTSigns;
  1070. fd125.SinAmt = SinAmt;
  1071. result.DeAccountType = fd125.DeAccountType.trim();
  1072. result.CrAccountType = fd125.CrAccountType.trim();
  1073. result.DeAccountPro = fd125.DeAccountPro.trim();
  1074. result.CrAccountPro = fd125.CrAccountPro.trim();
  1075. result.DeIsOwn = fd125.DeIsOwn === 'Y' ? 'true' : 'false';
  1076. result.CrIsOwn = fd125.CrIsOwn === 'Y' ? 'true' : 'false';
  1077. result.DCIsSameCus = fd125.DCIsSameCus === 'Y' ? 'true' : 'false';
  1078. result.DeCaAddAmt = fd125.DeCaAddAmt.trim();
  1079. if (!SinAmt.trim()) SinAmt = '0.0';
  1080. result.DeCaAddAmt = (parseFloat(fd125.DeCaAddAmt.trim()) + parseFloat(SinAmt)).toString();
  1081. result.CrTrAddAmt = (parseFloat(fd125.CrTrAddAmt.trim()) + parseFloat(SinAmt)).toString();
  1082. result.DeTrAddAmt = (parseFloat(fd125.DeTrAddAmt.trim()) + parseFloat(SinAmt)).toString();
  1083. result.SumAddAmt = (parseFloat(fd125.DeTrAddAmt.trim()) + parseFloat(SinAmt) + parseFloat(fd125.DeCaAddAmt.trim())).toString();
  1084. result.LossMarked = fd125.LossMarked === 'Y' ? 'true' : fd125.LossMarked === 'N' ? 'false' : '';
  1085. result.DocumentType = fd125.DocumentType.trim();
  1086. result.DeductMarked = fd125.DeductMarked.trim();
  1087. result.LongOrShort = fd125.LongOrShort === 'Y' ? 'true' : fd125.LongOrShort === 'N' ? 'false' : '';
  1088. result.LegalPerson = LoginAuthentication.Instance.GroupKinbrNo;
  1089. }
  1090. return result;
  1091. }
  1092. public SetAuthCheckTitle(element: FrameworkElement, str: string): void {
  1093. CheckManager.SetAuthCheckTitle(element, str);
  1094. }
  1095. // 获取菜单属性
  1096. public GetTradeMetadata(name: string): string {
  1097. const model = this.Page.TradeModel;
  1098. if (!model || !model.Metadata.hasOwnProperty(name)) return '';
  1099. return model.Metadata[name];
  1100. }
  1101. public CheckTradePower(powerCode: string): boolean {
  1102. if (!TradePowerManager.Instance.IsPowerCheckByUser) return true;
  1103. const list = TradePowerManager.Instance.GetTradePowerByCode(this.Page.TradeInfo.TradeCode);
  1104. if (!list || list.length === 0) return false;
  1105. return list.some((x: any) => x.RuleNo === powerCode);
  1106. }
  1107. private static _SignInStateList_: string[] = [
  1108. "TellerTransfer",
  1109. "TellerChecking",
  1110. "TellerChecked",
  1111. "TellerSignOut",
  1112. ];
  1113. public CheckWorkState(defV: boolean | null = null): boolean {
  1114. const FLAG = TradeManagerHandle.TT_SYSCONFIG_GetConfigValueByConfigID("2ea3a7e6cfa04f89a335bf1e363295de");
  1115. if (FLAG === "V24") {
  1116. // 若给定了默认值,则需要检查当前交易菜单配置
  1117. if (defV !== null) {
  1118. let flag = false;
  1119. if (!Boolean(this.GetTradeMetadata("isCheckWorkState"))) {
  1120. flag = defV;
  1121. }
  1122. if (!flag) return true;
  1123. }
  1124. const TSGY = TradeManagerHandle.TT_SYSCONFIG_GetConfigValueByConfigID("TSGY");
  1125. if (TSGY.includes(LoginUserInfo.TellerNo)) {
  1126. return true;
  1127. }
  1128. const status = LoginUserInfo.GetUserInfo("WorkState");
  1129. if (TradeAPIsHelper._SignInStateList_.includes(status)) return true;
  1130. this.ShowWarnMessageBox("当前柜员非签到状态,请先签到...");
  1131. return false;
  1132. } else {
  1133. return true;
  1134. }
  1135. }
  1136. public CheckDFState(defV: boolean | null = null): boolean {
  1137. const FLAG = TradeManagerHandle.TT_SYSCONFIG_GetConfigValueByConfigID("2ea3a7e6cfa04f89a335bf1e363295de");
  1138. if (FLAG === "V0" && TradeManagerHandle.TT_SYSCONFIG_GetConfigValueByConfigID("TGJC") !== "true") {
  1139. // 若给定了默认值,则需要检查当前交易菜单配置
  1140. if (defV !== null) {
  1141. let flag = false;
  1142. if (!Boolean(this.GetTradeMetadata("isCheckDFState"))) {
  1143. flag = defV;
  1144. }
  1145. if (!flag) return true;
  1146. }
  1147. const msg: Message = {};
  1148. this.InitFd(msg);
  1149. this.CommSend(msg);
  1150. msg.Fd16 = "K119";
  1151. msg.Fd92 = LoginUserInfo.TellerNo;
  1152. if (!this.CallServer(msg)) {
  1153. // 处理调用失败情况
  1154. }
  1155. // 后续逻辑需要根据实际业务补充
  1156. return true;
  1157. } else {
  1158. return true;
  1159. }
  1160. }
  1161. }
  1162. export default TradeAPIsHelper;