CLodopfuncs.js 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969
  1. /* eslint-disable */
  2. // #ifdef APP-VUE
  3. // import Api from '@/common/vmeitime-http/index.js';
  4. window = {
  5. location: {
  6. // href: 'http://192.168.1.41:8000'
  7. href: 'http://127.0.0.1/print'
  8. }
  9. };
  10. // #endif
  11. (function(win) {
  12. let printListDev = [];
  13. let printListOnline = [];
  14. var CLODOP = {
  15. strWebPageID: "3DFAAAC",
  16. strTaskID: "",
  17. // strHostURI: "http://192.168.0.105:8000",
  18. // wsHostURI: "ws://192.168.0.105:8000/c_webskt/",
  19. strHostURI: "http://192.168.1.41:8000",
  20. wsHostURI: "ws://192.168.1.41:8000/c_webskt/",
  21. VERSION: "6.2.2.6",
  22. IVERSION: "6226",
  23. CVERSION: "3.0.9.3",
  24. HTTPS_STATUS: 2,
  25. VERSION_EXT: true,
  26. iBaseTask: 0,
  27. timeThreshold: 5,
  28. Priority: 0,
  29. blIslocal: true,
  30. Iframes: [],
  31. ItemDatas: {},
  32. PageData: {},
  33. defStyleJson: {},
  34. PageDataEx: {},
  35. ItemCNameStyles: {},
  36. blWorking: false,
  37. blNormalItemAdded: false,
  38. blTmpSelectedIndex: null,
  39. Caption: null,
  40. Color: null,
  41. CompanyName: null,
  42. strBroadcastMS: null,
  43. Border: null,
  44. Inbrowse: null,
  45. webskt: null,
  46. SocketEnable: false,
  47. SocketOpened: false,
  48. NoClearAfterPrint: false,
  49. On_Return_Remain: false,
  50. On_Broadcast_Remain: false,
  51. On_Return: null,
  52. Result: null,
  53. iTrySendTimes: 0,
  54. OBO_Mode: 1,
  55. blOneByone: false,
  56. DelimChar: "\f\f",
  57. Printers: {
  58. "default": "1",
  59. "list": []
  60. },
  61. altMessageWebSocketInvalid: "WebSocket没准备好,点确定继续...",
  62. altMessageNoReadWriteFile: "不能远程读写文件!",
  63. altMessageNoReadFile: "不能远程读文件!",
  64. altMessageNoWriteFile: "不能远程写文件!",
  65. altMessageNoPrintDesign: "不能远程打印设计!",
  66. altMessageNoPrintSetup: "不能远程打印维护!",
  67. altMessageSomeWindowExist: "有窗口已打开,先关闭它(持续如此时请刷新页面)!",
  68. altMessageBusy: "上一个请求正忙,请稍后再试!",
  69. Browser: (function() {
  70. // #ifdef APP-VUE
  71. navigator = {
  72. userAgent: `Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Mobile Safari/537.36`
  73. };
  74. // #endif
  75. var ua = navigator.userAgent;
  76. var isOpera = Object.prototype.toString.call(window.opera) == "[object Opera]";
  77. return {
  78. IE: !!window.attachEvent && !isOpera,
  79. Opera: isOpera,
  80. WebKit: ua.indexOf("AppleWebKit/") > -1,
  81. Gecko: ua.indexOf("Gecko") > -1 && ua.indexOf("KHTML") === -1,
  82. MobileSafari: /Apple.*Mobile/.test(ua)
  83. }
  84. })(),
  85. GetTaskID: function() {
  86. if (!this.strTaskID || this.strTaskID == "") {
  87. var dt = new Date();
  88. this.iBaseTask++;
  89. this.strTaskID = "" + dt.getHours() + dt.getMinutes() + dt.getSeconds() + "_" + this
  90. .iBaseTask;
  91. }
  92. return this.strWebPageID + this.strTaskID;
  93. },
  94. DoInit: function() {
  95. if (process.env.NODE_ENV === 'development') {
  96. //开发环境
  97. CLODOP.Printers.list = printListDev
  98. } else {
  99. //生产环境
  100. CLODOP.Printers.list = printListOnline
  101. }
  102. this.strTaskID = "";
  103. if (this.NoClearAfterPrint) return;
  104. this.ItemDatas = {
  105. "count": 0
  106. };
  107. this.PageData = {};
  108. this.ItemCNameStyles = {};
  109. this.defStyleJson = {
  110. "beginpage": 0,
  111. "beginpagea": 0
  112. };
  113. this.blNormalItemAdded = false;
  114. win.CLODOP.OpenWebSocket();
  115. },
  116. OpenWebSocket: function() {
  117. // #ifdef APP-VUE
  118. if (window.On_CLodop_Opened) {
  119. if (CLODOP.Priority == window.CLODOP_OK_Priority) setTimeout(
  120. "window.On_CLodop_Opened(CLODOP)", 1);
  121. }
  122. // #endif
  123. // #ifndef APP-VUE
  124. // #endif
  125. if (!window.WebSocket && !window.MozWebSocket) {
  126. if (window.On_CLodop_Opened) {
  127. if (CLODOP.Priority == window.CLODOP_OK_Priority) setTimeout(
  128. "window.On_CLodop_Opened(CLODOP)", 1);
  129. }
  130. return;
  131. }
  132. this.SocketEnable = true;
  133. try {
  134. if (!this.webskt || this.webskt.readyState == 3) {
  135. if (!window.WebSocket && window.MozWebSocket) window.WebSocket = window.MozWebSocket;
  136. this.webskt = uni.connectSocket({
  137. url: CLODOP.wsHostURI,
  138. success: res => {
  139. console.info(res);
  140. },
  141. fail: res => {
  142. console.info(res);
  143. }
  144. });
  145. this.webskt.onOpen(function(e) {
  146. CLODOP.SocketOpened = true;
  147. if (window.On_CLodop_Opened) {
  148. if (CLODOP.Priority == window.CLODOP_OK_Priority) setTimeout(window
  149. .On_CLodop_Opened(
  150. CLODOP), 10000);
  151. }
  152. });
  153. this.webskt.onMessage(function(e) {
  154. console.log(e);
  155. CLODOP.resultHandle(e.data);
  156. });
  157. this.webskt.onClose(function(e) {
  158. if (!CLODOP.SocketOpened) {
  159. CLODOP.SocketEnable = false;
  160. return;
  161. }
  162. // setTimeout(CLODOP.OpenWebSocket(), 2000);
  163. });
  164. this.webskt.onError(function(e) {
  165. console.info(e);
  166. });
  167. }
  168. } catch (err) {
  169. this.webskt = null;
  170. if (err.message.indexOf("SecurityError") > -1)
  171. this.SocketEnable = false;
  172. else
  173. setTimeout(CLODOP.OpenWebSocket(), 2000);
  174. }
  175. },
  176. resultHandle: function(data) {
  177. CLODOP.blOneByone = false;
  178. var strResult = data;
  179. CLODOP.Result = strResult;
  180. try {
  181. var strFTaskID = null;
  182. var iPos = strResult.indexOf("=");
  183. if (iPos >= 0 && iPos < 30) {
  184. strFTaskID = strResult.slice(0, iPos);
  185. strResult = strResult.slice(iPos + 1);
  186. }
  187. if (strFTaskID.indexOf("ErrorMS") > -1) {
  188. console.info(strResult);
  189. return;
  190. }
  191. if (strFTaskID.indexOf("BroadcastMS") > -1) {
  192. CLODOP.strBroadcastMS = strResult;
  193. if (CLODOP.On_Broadcast) {
  194. var selfFunc = CLODOP.On_Broadcast;
  195. CLODOP.On_Broadcast(strResult);
  196. if (!CLODOP.On_Broadcast_Remain && selfFunc === CLODOP.On_Broadcast)
  197. CLODOP.On_Broadcast = null;
  198. }
  199. return;
  200. }
  201. if (CLODOP.On_Return) {
  202. var selfFunc = CLODOP.On_Return;
  203. if ((strResult.toLowerCase() == "true") || (strResult.toLowerCase() == "false"))
  204. CLODOP.On_Return(strFTaskID, strResult.toLowerCase() == "true");
  205. else
  206. CLODOP.On_Return(strFTaskID, strResult);
  207. if (!CLODOP.On_Return_Remain && selfFunc === CLODOP.On_Return) CLODOP.On_Return = null;
  208. }
  209. } catch (err) {
  210. console.log(err);
  211. };
  212. },
  213. wsSend: function(strData) {
  214. console.info(strData);
  215. // #ifdef APP-VUE
  216. return CLODOP.postSend(strData);
  217. // #endif
  218. if (!this.SocketEnable) return;
  219. if (this.webskt && this.webskt.readyState == 1) {
  220. this.Result = null;
  221. this.iTrySendTimes = 0;
  222. // #ifndef APP-VUE
  223. this.webskt.send({
  224. data: strData,
  225. success: res => {
  226. console.info(res);
  227. },
  228. fail: res => {
  229. console.info(res);
  230. }
  231. });
  232. // #endif
  233. return true;
  234. } else {
  235. console.info(this.altMessageWebSocketInvalid);
  236. this.iTrySendTimes++;
  237. if (this.iTrySendTimes <= 1) {
  238. setTimeout(CLODOP.wsSend(strData), 500);
  239. } else {
  240. this.OpenWebSocket();
  241. }
  242. }
  243. },
  244. postSend: function(data) {
  245. // Api.flPostPrint(data).then(res => {
  246. // console.log(res);
  247. // CLODOP.resultHandle(res.data);
  248. // })
  249. },
  250. FORMAT: function(oType, oValue) {
  251. if (this.blWorking) {
  252. console.info(this.altMessageBusy);
  253. return null;
  254. }
  255. var tResult = null;
  256. if (oType !== undefined && oValue !== undefined) {
  257. if (oType.replace(/^\s+|\s+$/g, "").toLowerCase().indexOf("time:") == 0) {
  258. oType = oType.replace(/^\s+|\s+$/g, "").slice(5);
  259. if (oValue.toLowerCase().indexOf("now") > -1) oValue = (new Date()).toString();
  260. if (oValue.toLowerCase().indexOf("date") > -1) oValue = (new Date()).toString();
  261. if (oValue.toLowerCase().indexOf("time") > -1) oValue = (new Date()).toString();
  262. var TypeYMD = "ymd";
  263. if (oValue.toLowerCase().indexOf("ymd") > -1) {
  264. TypeYMD = "ymd";
  265. oValue = oValue.slice(3);
  266. }
  267. if (oValue.toLowerCase().indexOf("dmy") > -1) {
  268. TypeYMD = "dmy";
  269. oValue = oValue.slice(3);
  270. }
  271. if (oValue.toLowerCase().indexOf("mdy") > -1) {
  272. TypeYMD = "mdy";
  273. oValue = oValue.slice(3);
  274. }
  275. oValue = oValue.replace(/ [^ ]*\+[^ ]* /g, " ");
  276. oValue = oValue.replace(/\(.*\)/g, " ");
  277. oValue = oValue.replace(/星期日|星期一|星期二|星期三|星期四|星期五|星期六/g, " ");
  278. oValue = oValue.replace(/[A-Za-z]+day|Mon|Tue|Wed|Thu|Fri|Sat|Sun/g, " ");
  279. var aMonth = 0;
  280. var exp = new RegExp("Oct[A-Za-z]*|十月|10月", "i");
  281. if (oValue.match(exp) !== null) {
  282. aMonth = 10;
  283. oValue = oValue.replace(exp, "");
  284. }
  285. exp = new RegExp("Nov[A-Za-z]*|十一月|11月", "i");
  286. if (oValue.match(exp) !== null) {
  287. aMonth = 11;
  288. oValue = oValue.replace(exp, "");
  289. }
  290. exp = new RegExp("Dec[A-Za-z]*|十二月|12月", "i");
  291. if (oValue.match(exp) !== null) {
  292. aMonth = 12;
  293. oValue = oValue.replace(exp, "");
  294. }
  295. exp = new RegExp("Jan[A-Za-z]*|一月|01月|1月", "i");
  296. if (oValue.match(exp) !== null) {
  297. aMonth = 1;
  298. oValue = oValue.replace(exp, "");
  299. }
  300. exp = new RegExp("Feb[A-Za-z]*|二月|02月|2月", "i");
  301. if (oValue.match(exp) !== null) {
  302. aMonth = 2;
  303. oValue = oValue.replace(exp, "");
  304. }
  305. exp = new RegExp("Mar[A-Za-z]*|三月|03月|3月", "i");
  306. if (oValue.match(exp) !== null) {
  307. aMonth = 3;
  308. oValue = oValue.replace(exp, "");
  309. }
  310. exp = new RegExp("Apr[A-Za-z]*|四月|04月|4月", "i");
  311. if (oValue.match(exp) !== null) {
  312. aMonth = 4;
  313. oValue = oValue.replace(exp, "");
  314. }
  315. exp = new RegExp("May[A-Za-z]*|五月|05月|5月", "i");
  316. if (oValue.match(exp) !== null) {
  317. aMonth = 5;
  318. oValue = oValue.replace(exp, "");
  319. }
  320. exp = new RegExp("Jun[A-Za-z]*|六月|06月|6月", "i");
  321. if (oValue.match(exp) !== null) {
  322. aMonth = 6;
  323. oValue = oValue.replace(exp, "");
  324. }
  325. exp = new RegExp("Jul[A-Za-z]*|七月|07月|7月", "i");
  326. if (oValue.match(exp) !== null) {
  327. aMonth = 7;
  328. oValue = oValue.replace(exp, "");
  329. }
  330. exp = new RegExp("Aug[A-Za-z]*|八月|08月|8月", "i");
  331. if (oValue.match(exp) !== null) {
  332. aMonth = 8;
  333. oValue = oValue.replace(exp, "");
  334. }
  335. exp = new RegExp("Sep[A-Za-z]*|九月|09月|9月", "i");
  336. if (oValue.match(exp) !== null) {
  337. aMonth = 9;
  338. oValue = oValue.replace(exp, "");
  339. }
  340. oValue = oValue.replace(/日|秒/g, " ");
  341. oValue = oValue.replace(/时|分/g, ":");
  342. var subTime = oValue.match(/ \d+:\d+:\d+/);
  343. if (subTime == null) subTime = "";
  344. oValue = oValue.replace(/ \d+:\d+:\d+/, "") + subTime;
  345. var dValue = new Date();
  346. var iYear = 0;
  347. var iMonth = 0;
  348. var iDate = 0;
  349. var iHour = 0;
  350. var iMinutes = 0;
  351. var iSecond = 0;
  352. var tmpValue = oValue;
  353. var sValue = "";
  354. var MC1 = 0;
  355. MC2 = 0;
  356. MC3 = 0;
  357. sValue = tmpValue.match(/\d+/);
  358. if (sValue !== null) {
  359. MC1 = parseInt(sValue[0]);
  360. tmpValue = tmpValue.replace(/\d+/, "");
  361. }
  362. sValue = tmpValue.match(/\d+/);
  363. if (sValue !== null) {
  364. MC2 = parseInt(sValue[0]);
  365. tmpValue = tmpValue.replace(/\d+/, "");
  366. }
  367. if (aMonth <= 0) {
  368. sValue = tmpValue.match(/\d+/);
  369. if (sValue !== null) {
  370. MC3 = parseInt(sValue[0]);
  371. tmpValue = tmpValue.replace(/\d+/, "");
  372. }
  373. }
  374. if (aMonth > 0) {
  375. iMonth = aMonth;
  376. if (MC2 <= 31) {
  377. iYear = MC1;
  378. iDate = MC2;
  379. } else {
  380. iYear = MC2;
  381. iDate = MC1;
  382. }
  383. } else
  384. if (TypeYMD == "dmy") {
  385. iDate = MC1;
  386. iMonth = MC2;
  387. iYear = MC3;
  388. } else
  389. if (TypeYMD == "mdy") {
  390. iMonth = MC1;
  391. iDate = MC2;
  392. iYear = MC3;
  393. } else {
  394. iYear = MC1;
  395. iMonth = MC2;
  396. iDate = MC3;
  397. if (MC3 > 31) {
  398. iYear = MC3;
  399. iMonth = MC1;
  400. iDate = MC2;
  401. if (MC1 > 12) {
  402. iDate = MC1;
  403. iMonth = MC2
  404. };
  405. } else {
  406. if (MC2 > 12) {
  407. iYear = MC2;
  408. iMonth = MC1;
  409. }
  410. }
  411. }
  412. var sValue = tmpValue.match(/\d+/);
  413. if (sValue !== null) {
  414. iHour = parseInt(sValue[0]);
  415. tmpValue = tmpValue.replace(/\d+/, "");
  416. }
  417. var sValue = tmpValue.match(/\d+/);
  418. if (sValue !== null) {
  419. iMinutes = parseInt(sValue[0]);
  420. tmpValue = tmpValue.replace(/\d+/, "");
  421. }
  422. var sValue = tmpValue.match(/\d+/);
  423. if (sValue !== null) {
  424. iSecond = parseInt(sValue[0]);
  425. tmpValue = tmpValue.replace(/\d+/, "");
  426. }
  427. if (oType.toLowerCase() == "isvalidformat")
  428. oValue = (iYear > 0 && iMonth > 0 && iMonth <= 12 && iDate > 0 && iDate <= 31);
  429. else {
  430. if (("" + iYear).length < 4) iYear = iYear + 2000;
  431. dValue.setFullYear(iYear, iMonth - 1, iDate);
  432. dValue.setHours(iHour);
  433. dValue.setMinutes(iMinutes);
  434. dValue.setSeconds(iSecond);
  435. var iDay = dValue.getDay();
  436. if (oType.toLowerCase() == "weekindex")
  437. oValue = iDay;
  438. else
  439. if (oType.toLowerCase() == "floatvalue")
  440. oValue = dValue.getTime();
  441. else {
  442. var sWeek = "";
  443. switch (iDay) {
  444. case 0:
  445. sWeek = "日";
  446. break;
  447. case 1:
  448. sWeek = "一";
  449. break;
  450. case 2:
  451. sWeek = "二";
  452. break;
  453. case 3:
  454. sWeek = "三";
  455. break;
  456. case 4:
  457. sWeek = "四";
  458. break;
  459. case 5:
  460. sWeek = "五";
  461. break;
  462. case 6:
  463. sWeek = "六";
  464. break;
  465. }
  466. oValue = oType.replace(/dddd/ig, "星期" + sWeek);
  467. if (/(y+)/i.test(oValue)) oValue = oValue.replace(RegExp.$1, (iYear + "")
  468. .substr(
  469. 4 - RegExp.$1.length));
  470. if (/(m+:)/i.test(oValue)) oValue = oValue.replace(RegExp.$1, ("00" + iMinutes +
  471. ":").substr(("00" + iMinutes +
  472. ":").length - RegExp.$1.length));
  473. if (/(M+)/i.test(oValue)) {
  474. var dsWidth = ("" + iMonth).length > RegExp.$1.length ? ("" + iMonth)
  475. .length :
  476. RegExp.$1.length;
  477. oValue = oValue.replace(RegExp.$1, ("00" + iMonth).substr(("00" + iMonth)
  478. .length -
  479. dsWidth));
  480. }
  481. if (/(d+)/i.test(oValue)) {
  482. var dsWidth = ("" + iDate).length > RegExp.$1.length ? ("" + iDate).length :
  483. RegExp.$1.length;
  484. oValue = oValue.replace(RegExp.$1, ("00" + iDate).substr(("00" + iDate)
  485. .length -
  486. dsWidth));
  487. }
  488. if (/(H+)/i.test(oValue)) oValue = oValue.replace(RegExp.$1, ("00" + iHour)
  489. .substr(
  490. ("00" + iHour).length -
  491. RegExp.$1.length));
  492. if (/(n+)/i.test(oValue)) oValue = oValue.replace(RegExp.$1, ("00" + iMinutes)
  493. .substr(
  494. ("00" + iMinutes).length -
  495. RegExp.$1.length));
  496. if (/(s+)/i.test(oValue)) oValue = oValue.replace(RegExp.$1, ("00" + iSecond)
  497. .substr(
  498. ("00" + iSecond).length -
  499. RegExp.$1.length));
  500. }
  501. }
  502. if (CLODOP.On_Return) {
  503. var selfFunc = CLODOP.On_Return;
  504. CLODOP.On_Return(0, oValue);
  505. if (!CLODOP.On_Return_Remain && selfFunc === CLODOP.On_Return) CLODOP.On_Return =
  506. null;
  507. }
  508. return oValue;
  509. } else
  510. if (this.blIslocal || oType.indexOf("FILE:") < 0) {
  511. this.PageData["format_type"] = oType;
  512. this.PageData["format_value"] = oValue;
  513. if (this.DoPostDatas("format") == true) {
  514. this.GetLastResult(false);
  515. tResult = this.GetTaskID();
  516. }
  517. } else console.info(this.altMessageNoReadWriteFile)
  518. }
  519. this.DoInit();
  520. this.blWorking = false;
  521. return tResult;
  522. },
  523. SET_PRINT_PAPER: function(Top, Left, Width, Height, strPrintTask) {
  524. return this.PRINT_INITA(Top, Left, Width, Height, strPrintTask);
  525. },
  526. PRINT_INIT: function(strPrintTask) {
  527. return this.PRINT_INITA(null, null, null, null, strPrintTask);
  528. },
  529. PRINT_INITA: function(Top, Left, Width, Height, strPrintTask) {
  530. if (Top === undefined || Top === null) Top = "";
  531. if (Left === undefined || Left === null) Left = "";
  532. if (Width === undefined || Width === null) Width = "";
  533. if (Height === undefined || Height === null) Height = "";
  534. if (strPrintTask === undefined || strPrintTask === null) strPrintTask = "";
  535. this.NoClearAfterPrint = false;
  536. this.DoInit();
  537. this.PageData["top"] = Top;
  538. this.PageData["left"] = Left;
  539. this.PageData["width"] = Width;
  540. this.PageData["height"] = Height;
  541. this.PageData["printtask"] = strPrintTask;
  542. return true;
  543. },
  544. SET_PRINT_MODE: function(strModeType, ModeValue) {
  545. if (strModeType === undefined || strModeType === null) strModeType = "";
  546. if (ModeValue === undefined || ModeValue === null) ModeValue = "";
  547. if (strModeType === "") return false;
  548. strModeType = strModeType.toLowerCase();
  549. this.PageData[strModeType] = ModeValue;
  550. if (strModeType == "noclear_after_print") this.NoClearAfterPrint = ModeValue;
  551. if (strModeType.indexOf("window_def") > -1 || strModeType.indexOf("control_printer") > -1) {
  552. var tResult = null;
  553. if (this.DoPostDatas("onlysetprint") == true) {
  554. this.GetLastResult(false);
  555. tResult = this.GetTaskID();
  556. }
  557. this.DoInit();
  558. this.blWorking = false;
  559. return tResult;
  560. }
  561. },
  562. ADD_PRINT_TEXT: function(top, left, width, height, strText) {
  563. return this.AddItemArray(2, top, left, width, height, strText);
  564. },
  565. ADD_PRINT_TEXTA: function(itemName, top, left, width, height, strText) {
  566. return this.AddItemArray(2, top, left, width, height, strText, itemName);
  567. },
  568. ADD_PRINT_HTM: function(top, left, width, height, strHTML) {
  569. return this.AddItemArray(4, top, left, width, height, strHTML);
  570. },
  571. ADD_PRINT_HTML: function(top, left, width, height, strHTML) {
  572. return this.AddItemArray(1, top, left, width, height, strHTML);
  573. },
  574. ADD_PRINT_HTMLA: function(itemName, top, left, width, height, strHTML) {
  575. return this.AddItemArray(1, top, left, width, height, strHTML, itemName);
  576. },
  577. ADD_PRINT_BARCODE: function(top, left, width, height, BarType, BarValue) {
  578. return this.AddItemArray(9, top, left, width, height, BarValue, null, null, null, null, null,
  579. null, BarType);
  580. },
  581. ADD_PRINT_BARCODEA: function(ItemName, top, left, width, height, BarType, BarValue) {
  582. return this.AddItemArray(9, top, left, width, height, BarValue, ItemName, null, null, null,
  583. null, null, BarType);
  584. },
  585. ADD_PRINT_RECTA: function(top, left, width, height, intPenStyle, intPenWidth, intColor) {
  586. return this.AddItemArray(3, top, left, width, height, null, null, 2, intPenStyle, intPenWidth,
  587. intColor, null);
  588. },
  589. ADD_PRINT_RECT: function(top, left, width, height, intPenStyle, intPenWidth) {
  590. return this.AddItemArray(3, top, left, width, height, null, null, 2, intPenStyle, intPenWidth,
  591. null, null);
  592. },
  593. ADD_PRINT_ELLIPSEA: function(top, left, width, height, intPenStyle, intPenWidth, intColor) {
  594. return this.AddItemArray(3, top, left, width, height, null, null, 3, intPenStyle, intPenWidth,
  595. intColor, null);
  596. },
  597. ADD_PRINT_ELLIPSE: function(top, left, width, height, intPenStyle, intPenWidth) {
  598. return this.AddItemArray(3, top, left, width, height, null, null, 3, intPenStyle, intPenWidth,
  599. null, null);
  600. },
  601. ADD_PRINT_SHAPE: function(ShapeType, top, left, width, height, intPenStyle, intPenWidth, intColor) {
  602. return this.AddItemArray(3, top, left, width, height, null, null, ShapeType, intPenStyle,
  603. intPenWidth, intColor,
  604. null);
  605. },
  606. ADD_PRINT_LINE: function(top1, left1, top2, left2, intPenStyle, intPenWidth) {
  607. return this.AddItemArray(3, top1, left1, top2, left2, null, null, 0, intPenStyle, intPenWidth,
  608. null, "1");
  609. },
  610. ADD_PRINT_DNLINE: function(Top, Left, Width, Height, intPenStyle, intPenWidth) {
  611. return this.AddItemArray(3, Top, Left, Width, Height, null, null, 1, intPenStyle, intPenWidth,
  612. null, null);
  613. },
  614. ADD_PRINT_DNLINEA: function(Top, Left, Width, Height, intPenStyle, intPenWidth, intColor) {
  615. return this.AddItemArray(3, Top, Left, Width, Height, null, null, 1, intPenStyle, intPenWidth,
  616. intColor, null);
  617. },
  618. ADD_PRINT_UPLINE: function(Top, Left, Width, Height, intPenStyle, intPenWidth) {
  619. return this.AddItemArray(3, Top, Left, Width, Height, null, null, 0, intPenStyle, intPenWidth,
  620. null, null);
  621. },
  622. ADD_PRINT_UPLINEA: function(Top, Left, Width, Height, intPenStyle, intPenWidth, intColor) {
  623. return this.AddItemArray(3, Top, Left, Width, Height, null, null, 0, intPenStyle, intPenWidth,
  624. intColor, null);
  625. },
  626. ADD_PRINT_TABLE: function(top, left, width, height, strHTML) {
  627. return this.AddItemArray(6, top, left, width, height, strHTML);
  628. },
  629. ADD_PRINT_TBURL: function(top, left, width, height, strURL) {
  630. return this.AddItemArray(7, top, left, width, height, strURL);
  631. },
  632. ADD_PRINT_URL: function(top, left, width, height, strURL) {
  633. return this.AddItemArray(5, top, left, width, height, strURL);
  634. },
  635. ADD_PRINT_IMAGE: function(top, left, width, height, strHTML) {
  636. return this.AddItemArray(8, top, left, width, height, strHTML);
  637. },
  638. ADD_PRINT_CHART: function(top, left, width, height, strChartTypess, strHTML) {
  639. return this.AddItemArray(10, top, left, width, height, strHTML, null, null, null, null, null,
  640. null, null,
  641. strChartTypess);
  642. },
  643. SET_PRINT_PROPERTY: function(ItemNO, intPageType, intHorzOrient, intVertOrient) {
  644. this.SET_PRINT_STYLEA(ItemNO, "ItemType", intPageType);
  645. this.SET_PRINT_STYLEA(ItemNO, "HOrient", intHorzOrient);
  646. this.SET_PRINT_STYLEA(ItemNO, "VOrient", intVertOrient);
  647. },
  648. SET_PRINT_PROPERTYA: function(ItemName, intPageType, intHorzOrient, intVertOrient) {
  649. this.SET_PRINT_PROPERTY(ItemName, intPageType, intHorzOrient, intVertOrient);
  650. },
  651. SET_PRINT_STYLE: function(strStyleName, StyleValue) {
  652. if (strStyleName === undefined || strStyleName === null) strStyleName = "";
  653. if (StyleValue === undefined || StyleValue === null) StyleValue = "";
  654. if (strStyleName === "") return false;
  655. strStyleName = strStyleName.toLowerCase();
  656. this.defStyleJson[strStyleName] = StyleValue;
  657. },
  658. SET_PRINT_STYLEA: function(ItemNo, strKey, Value) {
  659. if (ItemNo === undefined || ItemNo === null) ItemNo = "";
  660. if (strKey === undefined || strKey === null) strKey = "";
  661. if (Value === undefined || Value === null) Value = "";
  662. if (ItemNo === "" || strKey === "") return false;
  663. if (this.ItemDatas["count"] <= 0) {
  664. if (this.PageData["add_print_program_data"] !== undefined) {
  665. this.ItemCNameStyles[strKey.toLowerCase() + "-" + ItemNo] = Value;
  666. return true;
  667. } else {
  668. return false;
  669. }
  670. }
  671. strKey = strKey.toLowerCase();
  672. if (strKey == "type") return false;
  673. var blResult = false;
  674. if (ItemNo == 0) {
  675. ItemNo = this.ItemDatas["count"];
  676. }
  677. for (var vItemNO in this.ItemDatas) {
  678. var ItemName = this.ItemDatas[vItemNO]["itemname"];
  679. if ((ItemNo == vItemNO) || (ItemNo == ItemName) || ((typeof ItemNo === "string") && (
  680. typeof ItemName ===
  681. "string") && (ItemNo.toUpperCase() == ItemName.toUpperCase()))) {
  682. this.ItemDatas[vItemNO][strKey] = Value;
  683. blResult = true;
  684. }
  685. }
  686. if (blResult) return true;
  687. return false;
  688. },
  689. SET_PRINT_TEXT_STYLE: function(ItemNO, strFontName, intSize, intBold, intItalic, intUnderline,
  690. intAlignment) {
  691. this.SET_PRINT_STYLEA(ItemNO, "fontname", strFontName);
  692. this.SET_PRINT_STYLEA(ItemNO, "fontsize", intSize);
  693. this.SET_PRINT_STYLEA(ItemNO, "bold", intBold);
  694. this.SET_PRINT_STYLEA(ItemNO, "italic", intItalic);
  695. this.SET_PRINT_STYLEA(ItemNO, "underline", intUnderline);
  696. this.SET_PRINT_STYLEA(ItemNO, "alignment", intAlignment);
  697. },
  698. SET_PRINT_TEXT_STYLEA: function(ItemNO, strFontName, intSize, intBold, intItalic, intUnderline,
  699. intAlignment, Color) {
  700. this.SET_PRINT_TEXT_STYLE(ItemNO, strFontName, intSize, intBold, intItalic, intUnderline,
  701. intAlignment);
  702. this.SET_PRINT_STYLEA(ItemNO, "fontcolor", Color);
  703. },
  704. SET_PRINT_TEXT_STYLEB: function(ItemNO, strFontName, intSize, intBold, intItalic, intUnderline,
  705. intAlignment, Color) {
  706. this.SET_PRINT_TEXT_STYLEA(ItemNO, strFontName, intSize, intBold, intItalic, intUnderline,
  707. intAlignment, Color);
  708. },
  709. NEWPAGE: function() {
  710. this.NewPage();
  711. },
  712. NewPage: function() {
  713. var blSomeNormal = false;
  714. var noItemType;
  715. for (var vItemNO in this.ItemDatas) {
  716. if (vItemNO == "count") noItemType = false;
  717. else noItemType = true;
  718. for (var vItemxx in this.ItemDatas[vItemNO]) {
  719. if (vItemxx == "itemtype") {
  720. noItemType = false;
  721. if ((this.ItemDatas[vItemNO][vItemxx] == 0) || (this.ItemDatas[vItemNO][vItemxx] ==
  722. 4)) {
  723. blSomeNormal = true;
  724. break;
  725. }
  726. }
  727. }
  728. if (noItemType) blSomeNormal = true;
  729. if (blSomeNormal) break;
  730. }
  731. if (blSomeNormal) this.defStyleJson["beginpage"] = this.defStyleJson["beginpage"] + 1;
  732. },
  733. NEWPAGEA: function() {
  734. this.NewPageA();
  735. },
  736. NewPageA: function() {
  737. var blSomeNormal = false;
  738. var noItemType;
  739. for (var vItemNO in this.ItemDatas) {
  740. if (vItemNO == "count") noItemType = false;
  741. else noItemType = true;
  742. for (var vItemxx in this.ItemDatas[vItemNO]) {
  743. if (vItemxx == "itemtype") {
  744. noItemType = false;
  745. if ((this.ItemDatas[vItemNO][vItemxx] == 0) || (this.ItemDatas[vItemNO][vItemxx] ==
  746. 4)) {
  747. blSomeNormal = true;
  748. break;
  749. }
  750. }
  751. }
  752. if (noItemType) blSomeNormal = true;
  753. if (blSomeNormal) break;
  754. }
  755. if (blSomeNormal) this.defStyleJson["beginpagea"] = this.defStyleJson["beginpagea"] + 1;
  756. },
  757. PREVIEW: function(sView, iW, iH) {
  758. if (this.blWorking) {
  759. console.info(this.altMessageBusy);
  760. return null;
  761. }
  762. var tResult = null;
  763. if ((!sView) && (this.blIslocal)) {
  764. if (this.DoPostDatas("preview") == true) {
  765. this.Result = null;
  766. this.GetLastResult(true);
  767. tResult = this.GetTaskID();
  768. }
  769. } else {
  770. if (this.DoPostDatas("cpreview") == true) {
  771. this.DoCPreview(sView, iW, iH);
  772. tResult = this.GetTaskID();
  773. }
  774. }
  775. this.DoInit();
  776. this.blWorking = false;
  777. return tResult;
  778. },
  779. PRINT: function(sView, iW, iH) {
  780. if (this.blWorking) {
  781. console.info(this.altMessageBusy);
  782. return null;
  783. }
  784. var tResult = null;
  785. if (this.DoPostDatas("print") == true)
  786. tResult = this.GetTaskID();
  787. this.DoInit();
  788. this.blWorking = false;
  789. return tResult;
  790. },
  791. GET_PRINTER_COUNT: function() {
  792. if (this.Printers === undefined) return 0;
  793. else {
  794. return this.Printers["list"].length;
  795. }
  796. },
  797. GET_PRINTER_NAME: function(intNO) {
  798. if (this.Printers === undefined) return "";
  799. else {
  800. if (typeof intNO == "string" && intNO.indexOf(":") > -1) {
  801. var strPPname = intNO.slice(intNO.indexOf(":") + 1);
  802. intNO = intNO.slice(0, intNO.indexOf(":"));
  803. if (intNO == -1)
  804. return this.Printers["list"][this.Printers["default"]][strPPname];
  805. else
  806. return this.Printers["list"][intNO][strPPname];
  807. } else {
  808. if (intNO == -1)
  809. return this.Printers["list"][this.Printers["default"]].name;
  810. else
  811. if (intNO >= 0 && intNO < this.Printers["list"].length)
  812. return this.Printers["list"][intNO].name;
  813. else return "Printer NO. overflow";
  814. }
  815. }
  816. },
  817. GET_PAGESIZES_LIST: function(PNameIndx, Split, ListName, NameOrID) {
  818. if (!ListName) ListName = "pagelist";
  819. if (!NameOrID) NameOrID = "name";
  820. if (this.Printers === undefined) return "";
  821. else {
  822. if (PNameIndx == -1) PNameIndx = this.Printers["list"][this.Printers["default"]].name;
  823. for (var intNO in this.Printers["list"]) {
  824. if (PNameIndx == intNO || PNameIndx == this.Printers["list"][intNO].name) {
  825. var strList = "";
  826. for (var iPNO in this.Printers["list"][intNO][ListName]) {
  827. if ((NameOrID == "id") && this.Printers["list"][intNO][ListName][iPNO].id) {
  828. if (strList === "") strList = this.Printers["list"][intNO][ListName][iPNO]
  829. .id;
  830. else
  831. strList = strList + Split + this.Printers["list"][intNO][ListName][iPNO]
  832. .id;
  833. } else {
  834. if (strList === "") strList = this.Printers["list"][intNO][ListName][iPNO]
  835. .name;
  836. else
  837. strList = strList + Split + this.Printers["list"][intNO][ListName][iPNO]
  838. .name;
  839. }
  840. }
  841. return strList;
  842. }
  843. }
  844. return "";
  845. }
  846. },
  847. SET_PRINTER_INDEX: function(strName, strKeyModeName) {
  848. let printIndex = uni.getStorageSync('printIndex');
  849. if (printIndex === false) {
  850. this.PageData.printerindex = 1
  851. } else {
  852. this.PageData.printerindex = printIndex
  853. }
  854. return true;
  855. if (this.Printers === undefined) return false;
  856. else {
  857. if (!strKeyModeName) strKeyModeName = "printerindex";
  858. strName = strName + "";
  859. strName = strName.replace(/^\s+|\s+$/g, "");
  860. var iPos = strName.indexOf(",");
  861. var strNameOrNO = strName;
  862. if (iPos > -1) strNameOrNO = strName.slice(0, iPos);
  863. if (strNameOrNO == "-1") {
  864. this.PageData[strKeyModeName] = this.Printers["default"];
  865. if (iPos > -1) this.PageData["printersubid"] = strName.slice(iPos + 1);
  866. return true;
  867. } else {
  868. for (var vNO in this.Printers["list"]) {
  869. var strPrinterName = this.Printers["list"][vNO].name;
  870. if (!strPrinterName) continue;
  871. if ((strPrinterName.replace(/\\/g, "") == strNameOrNO.replace(/\\/g, "")) || (vNO ==
  872. strNameOrNO)) {
  873. this.PageData[strKeyModeName] = vNO;
  874. if (iPos > -1) this.PageData["printersubid"] = strName.slice(iPos + 1);
  875. return true;
  876. }
  877. }
  878. return false;
  879. }
  880. }
  881. },
  882. SET_PRINTER_INDEXA: function(strName) {
  883. return this.SET_PRINTER_INDEX(strName, "printerindexa");
  884. },
  885. PRINT_DESIGN: function() {
  886. if (this.blWorking) {
  887. console.info(this.altMessageBusy);
  888. return null;
  889. }
  890. var tResult = null;
  891. if (this.blIslocal) {
  892. if (this.DoPostDatas("print_design") == true) {
  893. this.Result = null;
  894. this.GetLastResult(true);
  895. tResult = this.GetTaskID();
  896. }
  897. } else console.info(this.altMessageNoPrintDesign);
  898. this.DoInit();
  899. this.blWorking = false;
  900. return tResult;
  901. },
  902. PRINT_SETUP: function() {
  903. if (this.blWorking) {
  904. console.info(this.altMessageBusy);
  905. return null;
  906. }
  907. var tResult = null;
  908. if (this.blIslocal) {
  909. if (this.DoPostDatas("print_setup") == true) {
  910. this.Result = null;
  911. this.GetLastResult(true);
  912. tResult = this.GetTaskID();
  913. }
  914. } else console.info(this.altMessageNoPrintSetup);
  915. this.DoInit();
  916. this.blWorking = false;
  917. return tResult;
  918. },
  919. SET_PRINT_PAGESIZE: function(intOrient, PageWidth, PageHeight, strPageName) {
  920. if (intOrient !== undefined && intOrient !== null) this.PageData["orient"] = intOrient;
  921. if (PageWidth !== undefined && PageWidth !== null) this.PageData["pagewidth"] = PageWidth;
  922. if (PageHeight !== undefined && PageHeight !== null) this.PageData["pageheight"] = PageHeight;
  923. if (strPageName !== undefined && strPageName !== null) this.PageData["pagename"] = strPageName;
  924. },
  925. SET_PRINT_COPIES: function(intCopies) {
  926. if (intCopies !== undefined && intCopies !== null) {
  927. this.PageData["printcopies"] = intCopies;
  928. return true;
  929. }
  930. },
  931. SELECT_PRINTER: function(blPrint) {
  932. this.SelectBox.create(388, 240, !blPrint);
  933. return true;
  934. },
  935. PRINTA: function(blPrintB, sView) {
  936. if (this.blWorking) {
  937. console.info(this.altMessageBusy);
  938. return null;
  939. }
  940. var tResult = null;
  941. if (!sView && this.blIslocal) {
  942. this.Result = null;
  943. if (blPrintB) {
  944. if (this.DoPostDatas("printb") == true) {
  945. this.GetLastResult(false);
  946. tResult = this.GetTaskID();
  947. }
  948. } else {
  949. if (this.DoPostDatas("printa") == true) {
  950. this.GetLastResult(true);
  951. tResult = this.GetTaskID();
  952. }
  953. }
  954. this.DoInit();
  955. this.blWorking = false;
  956. } else {
  957. this.SELECT_PRINTER(true);
  958. }
  959. return tResult;
  960. },
  961. PRINTAOK: function(iPrintIndex, iPrintCopies, iStartNO, iEndNO, onlySelect) {
  962. this.SET_PRINTER_INDEX(iPrintIndex);
  963. this.SET_PRINT_COPIES(iPrintCopies);
  964. if (iStartNO !== undefined && iStartNO !== 0) this.SET_PRINT_MODE("PRINT_START_PAGE", iStartNO);
  965. if (iEndNO !== undefined && iEndNO !== 0) this.SET_PRINT_MODE("PRINT_END_PAGE", iEndNO);
  966. if (!onlySelect) this.PRINT();
  967. else {
  968. this.blTmpSelectedIndex = iPrintIndex;
  969. if (CLODOP.On_Return) {
  970. var selfFunc = CLODOP.On_Return;
  971. CLODOP.On_Return(0, iPrintIndex);
  972. if (!CLODOP.On_Return_Remain && selfFunc === CLODOP.On_Return) CLODOP.On_Return = null;
  973. }
  974. }
  975. },
  976. SET_LICENSES: function(strCompanyName, strLicense, strLicenseA, strLicenseB) {
  977. if ((strCompanyName == 'THIRD LICENSE') && (strLicense == "")) {
  978. if (strLicenseA && strLicenseA !== "") this.PageDataEx["licensec"] = strLicenseA;
  979. if (strLicenseB && strLicenseB !== "") this.PageDataEx["licensed"] = strLicenseB;
  980. } else if ((strCompanyName == 'LICENSE TETCODE') && (strLicense == "") && (strLicenseB == "")) {
  981. if (strLicenseA && strLicenseA !== "") this.PageDataEx["Licensetetcode"] = strLicenseA;
  982. } else {
  983. if (strCompanyName && strCompanyName !== "") this.PageDataEx["companyname"] =
  984. strCompanyName;
  985. if (strLicense && strLicense !== "") this.PageDataEx["license"] = strLicense;
  986. if (strLicenseA && strLicenseA !== "") this.PageDataEx["licensea"] = strLicenseA;
  987. if (strLicenseB && strLicenseB !== "") this.PageDataEx["licenseb"] = strLicenseB;
  988. }
  989. },
  990. PRINTB: function() {
  991. return this.PRINTA(true);
  992. },
  993. PREVIEWA: function() {
  994. return this.PREVIEW();
  995. },
  996. PREVIEWB: function() {
  997. return this.PREVIEW();
  998. },
  999. ADD_PRINT_SETUP_BKIMG: function(strContent) {
  1000. if (strContent !== undefined && strContent !== null) {
  1001. this.PageData["setup_bkimg"] = strContent;
  1002. return true;
  1003. }
  1004. },
  1005. SET_PREVIEW_WINDOW: function(intDispMode, intToolMode, blDirectPrint, oWidth, oHeight,
  1006. strPButtonCaptoin) {
  1007. if (intDispMode !== undefined && intDispMode !== null) this.PageData["pvw_dispmode"] =
  1008. intDispMode;
  1009. if (intToolMode !== undefined && intToolMode !== null) this.PageData["pvw_toolmode"] =
  1010. intToolMode;
  1011. if (blDirectPrint !== undefined && blDirectPrint !== null) this.PageData["pvw_directprint"] =
  1012. blDirectPrint;
  1013. if (oWidth !== undefined && oWidth !== null) this.PageData["pvw_width"] = oWidth;
  1014. if (oHeight !== undefined && oHeight !== null) this.PageData["pvw_height"] = oHeight;
  1015. if (strPButtonCaptoin !== undefined && strPButtonCaptoin !== null) this.PageData[
  1016. "pvw_puttoncaptoin"] =
  1017. strPButtonCaptoin;
  1018. },
  1019. SET_PREVIEW_MODE: function(ModeValue) {
  1020. if (ModeValue !== undefined) this.PageData["pvw_preview_mode"] = ModeValue;
  1021. },
  1022. SET_SHOW_MODE: function(strModeType, ModeValue) {
  1023. if (strModeType === undefined || strModeType === null) strModeType = "";
  1024. if (ModeValue === undefined || ModeValue === null) ModeValue = "";
  1025. if (strModeType === "") return false;
  1026. strModeType = strModeType.toLowerCase();
  1027. this.PageData['shwmod_' + strModeType] = ModeValue;
  1028. },
  1029. SAVE_TO_FILE: function(strFileName) {
  1030. if (this.blWorking) {
  1031. console.info(this.altMessageBusy);
  1032. return null;
  1033. }
  1034. var tResult = null;
  1035. if (this.blIslocal) {
  1036. if (strFileName) {
  1037. this.PageData["stf_file_name"] = strFileName;
  1038. if (this.DoPostDatas("savetofile") == true) {
  1039. this.GetLastResult(false);
  1040. tResult = this.GetTaskID();
  1041. }
  1042. }
  1043. } else console.info(this.altMessageNoWriteFile);
  1044. this.DoInit();
  1045. this.blWorking = false;
  1046. return tResult;
  1047. },
  1048. SET_SAVE_MODE: function(strModeType, ModeValue) {
  1049. if (strModeType === undefined || strModeType === null) strModeType = "";
  1050. if (ModeValue === undefined || ModeValue === null) ModeValue = "";
  1051. if (strModeType === "") return false;
  1052. strModeType = strModeType.toLowerCase();
  1053. this.PageData['stfmod_' + strModeType] = ModeValue;
  1054. },
  1055. SEND_PRINT_RAWDATA: function(strRawData) {
  1056. if (this.blWorking) {
  1057. console.info(this.altMessageBusy);
  1058. return null;
  1059. }
  1060. var tResult = null;
  1061. if (strRawData !== undefined) {
  1062. this.PageData["raw_print_data"] = strRawData;
  1063. if (this.DoPostDatas("sendrawdata") == true) {
  1064. this.GetLastResult(false);
  1065. tResult = this.GetTaskID();
  1066. }
  1067. }
  1068. this.DoInit();
  1069. this.blWorking = false;
  1070. return tResult;
  1071. },
  1072. WRITE_FILE_TEXT: function(WriteMode, strFileName, strText) {
  1073. if (this.blWorking) {
  1074. console.info(this.altMessageBusy);
  1075. return null;
  1076. }
  1077. var tResult = null;
  1078. if (this.blIslocal) {
  1079. if (strFileName !== undefined && strText !== undefined) {
  1080. this.PageData["write_file_mode"] = WriteMode;
  1081. this.PageData["write_file_name"] = strFileName;
  1082. this.PageData["write_file_text"] = strText;
  1083. if (this.DoPostDatas("writefiletext") == true) {
  1084. this.GetLastResult(false);
  1085. tResult = this.GetTaskID();
  1086. }
  1087. }
  1088. } else console.info(this.altMessageNoWriteFile);
  1089. this.DoInit();
  1090. this.blWorking = false;
  1091. return tResult;
  1092. },
  1093. GET_DIALOG_VALUE: function(oType, oPreValue) {
  1094. if (this.blWorking) {
  1095. console.info(this.altMessageBusy);
  1096. return null;
  1097. }
  1098. var tResult = null;
  1099. if (oType !== undefined && oPreValue !== undefined) {
  1100. if (this.blIslocal) {
  1101. this.PageData["dialog_type"] = oType;
  1102. this.PageData["dialog_value"] = oPreValue;
  1103. if (this.DoPostDatas("dialog") == true) {
  1104. this.GetLastResult(true);
  1105. tResult = this.GetTaskID();
  1106. }
  1107. } else console.info(this.altMessageNoReadWriteFile);
  1108. }
  1109. this.DoInit();
  1110. this.blWorking = false;
  1111. return tResult;
  1112. },
  1113. WRITE_PORT_DATA: function(strPortName, strData) {
  1114. if (this.blWorking) {
  1115. console.info(this.altMessageBusy);
  1116. return null;
  1117. }
  1118. var tResult = null;
  1119. if (strPortName !== undefined && strData !== undefined) {
  1120. this.PageData["write_port_name"] = strPortName;
  1121. this.PageData["write_port_data"] = strData;
  1122. if (this.DoPostDatas("writeportdata") == true) {
  1123. this.GetLastResult(false);
  1124. tResult = this.GetTaskID();
  1125. }
  1126. }
  1127. this.DoInit();
  1128. this.blWorking = false;
  1129. return tResult;
  1130. },
  1131. READ_PORT_DATA: function(strPortName) {
  1132. if (this.blWorking) {
  1133. console.info(this.altMessageBusy);
  1134. return null;
  1135. }
  1136. var tResult = null;
  1137. if (strPortName !== undefined) {
  1138. this.PageData["read_port_name"] = strPortName;
  1139. if (this.DoPostDatas("readportdata") == true) {
  1140. this.GetLastResult(false);
  1141. tResult = this.GetTaskID();
  1142. }
  1143. }
  1144. this.DoInit();
  1145. this.blWorking = false;
  1146. return tResult;
  1147. },
  1148. GET_SYSTEM_INFO: function(InfoType) {
  1149. if (this.blWorking) {
  1150. console.info(this.altMessageBusy);
  1151. return null;
  1152. }
  1153. var tResult = null;
  1154. if (InfoType !== undefined) {
  1155. this.PageData["system_info_type"] = InfoType;
  1156. if (this.DoPostDatas("getsysteminfo") == true) {
  1157. this.GetLastResult(false);
  1158. tResult = this.GetTaskID();
  1159. }
  1160. }
  1161. this.DoInit();
  1162. this.blWorking = false;
  1163. return tResult;
  1164. },
  1165. GET_FILE_TEXT: function(strFileName) {
  1166. if (this.blWorking) {
  1167. console.info(this.altMessageBusy);
  1168. return null;
  1169. }
  1170. var tResult = null;
  1171. if (this.blIslocal) {
  1172. if (strFileName !== undefined) {
  1173. this.PageData["get_file_name"] = strFileName;
  1174. if (this.DoPostDatas("getfiletext") == true) {
  1175. this.GetLastResult(false);
  1176. tResult = this.GetTaskID();
  1177. }
  1178. }
  1179. } else console.info(this.altMessageNoReadFile);
  1180. this.DoInit();
  1181. this.blWorking = false;
  1182. return tResult;
  1183. },
  1184. IS_FILE_EXIST: function(strFileName) {
  1185. if (this.blWorking) {
  1186. console.info(this.altMessageBusy);
  1187. return null;
  1188. }
  1189. var tResult = null;
  1190. if (this.blIslocal) {
  1191. if (strFileName !== undefined) {
  1192. this.PageData["file_exist_name"] = strFileName;
  1193. if (this.DoPostDatas("isfileexist") == true) {
  1194. this.GetLastResult(false);
  1195. tResult = this.GetTaskID();
  1196. }
  1197. }
  1198. } else console.info(this.altMessageNoReadFile);
  1199. this.DoInit();
  1200. this.blWorking = false;
  1201. return tResult;
  1202. },
  1203. GET_FILE_TIME: function(strFileName) {
  1204. if (this.blWorking) {
  1205. console.info(this.altMessageBusy);
  1206. return null;
  1207. }
  1208. var tResult = null;
  1209. if (this.blIslocal) {
  1210. if (strFileName !== undefined) {
  1211. this.PageData["file_time_name"] = strFileName;
  1212. if (this.DoPostDatas("getfiletime") == true) {
  1213. this.GetLastResult(false);
  1214. tResult = this.GetTaskID();
  1215. }
  1216. }
  1217. } else console.info(this.altMessageNoReadFile);
  1218. this.DoInit();
  1219. this.blWorking = false;
  1220. return tResult;
  1221. },
  1222. GET_PRINT_INIFFNAME: function(strPrintTaskName) {
  1223. if (this.blWorking) {
  1224. console.info(this.altMessageBusy);
  1225. return null;
  1226. }
  1227. var tResult = null;
  1228. if (this.blIslocal) {
  1229. if (strPrintTaskName !== undefined) {
  1230. this.PageData["iniff_task_name"] = strPrintTaskName;
  1231. if (this.DoPostDatas("getiniffname") == true) {
  1232. this.GetLastResult(false);
  1233. tResult = this.GetTaskID();
  1234. }
  1235. }
  1236. } else console.info(this.altMessageNoReadFile);
  1237. this.DoInit();
  1238. this.blWorking = false;
  1239. return tResult;
  1240. },
  1241. GET_VALUE: function(ValueType, ValueIndex) {
  1242. if (this.blWorking) {
  1243. console.info(this.altMessageBusy);
  1244. return null;
  1245. }
  1246. var tResult = null;
  1247. if (ValueType !== undefined && ValueIndex !== undefined) {
  1248. this.PageData["get_value_type"] = ValueType;
  1249. this.PageData["get_value_index"] = ValueIndex;
  1250. if (this.DoPostDatas("dogetvalue") == true) {
  1251. this.GetLastResult(false);
  1252. tResult = this.GetTaskID();
  1253. }
  1254. }
  1255. this.DoInit();
  1256. this.blWorking = false;
  1257. return tResult;
  1258. },
  1259. ADD_PRINT_DATA: function(DataType, oValue) {
  1260. if (DataType !== undefined && oValue !== null) {
  1261. if (DataType.toLowerCase().indexOf("programdata") > -1) {
  1262. this.PageData["add_print_program_data"] = oValue;
  1263. return true;
  1264. }
  1265. }
  1266. },
  1267. SHOW_CHART: function() {},
  1268. DO_ACTION: function(strActName, strActValue) {
  1269. if (this.blWorking) {
  1270. console.info(this.altMessageBusy);
  1271. return null;
  1272. }
  1273. var tResult = null;
  1274. if (strActName !== undefined && strActValue !== undefined) {
  1275. this.PageData["do_action_name"] = strActName;
  1276. this.PageData["do_action_value"] = strActValue;
  1277. if (this.DoPostDatas("doaction") == true) {
  1278. this.GetLastResult(false);
  1279. tResult = this.GetTaskID();
  1280. }
  1281. }
  1282. this.DoInit();
  1283. this.blWorking = false;
  1284. return tResult;
  1285. },
  1286. Create_Printer_List: function(oElement, blNoDetailForAO) {
  1287. while (oElement.childNodes.length > 0) {
  1288. var children = oElement.childNodes;
  1289. for (var i = 0; i < children.length; i++)
  1290. oElement.removeChild(children[i]);
  1291. };
  1292. var iCount = this.GET_PRINTER_COUNT();
  1293. var iIndex = 0;
  1294. for (var i = 0; i < iCount; i++) {
  1295. var option = document.createElement('option');
  1296. option.innerHTML = this.GET_PRINTER_NAME(i);
  1297. option.value = iIndex;
  1298. oElement.appendChild(option);
  1299. iIndex++;
  1300. if (this.VERSION_EXT) {
  1301. if (this.Printers["list"][i]["subdevlist"].length > 0) {
  1302. if (blNoDetailForAO) option.innerHTML = option.innerHTML + ',..';
  1303. else {
  1304. var strDrivename = option.innerHTML;
  1305. for (var j = 0; j < this.Printers["list"][i]["subdevlist"].length; j++) {
  1306. var strDevID = this.Printers["list"][i]["subdevlist"][j].id;
  1307. var strDevName = this.Printers["list"][i]["subdevlist"][j].name;
  1308. if (j == 0) {
  1309. option.innerHTML = strDrivename + ',' + strDevName;
  1310. option.value = strDrivename + ',' + strDevID + ';' + strDevName;
  1311. } else {
  1312. option = document.createElement('option');
  1313. option.innerHTML = strDrivename + ',' + strDevName;
  1314. option.value = strDrivename + ',' + strDevID + ';' + strDevName;
  1315. oElement.appendChild(option);
  1316. iIndex++;
  1317. if (iIndex >= 100) return;
  1318. }
  1319. }
  1320. }
  1321. }
  1322. }
  1323. }
  1324. },
  1325. Create_PageSize_List: function(oElement, printIndex) {
  1326. while (oElement.childNodes.length > 0) {
  1327. var children = oElement.childNodes;
  1328. for (var i = 0; i < children.length; i++)
  1329. oElement.removeChild(children[i]);
  1330. };
  1331. var strPageSizeList = CLODOP.GET_PAGESIZES_LIST(printIndex, "\n");
  1332. var Options = new Array();
  1333. Options = strPageSizeList.split("\n");
  1334. for (var i in Options) {
  1335. var option = document.createElement('option');
  1336. option.innerHTML = Options[i];
  1337. option.value = Options[i];
  1338. oElement.appendChild(option);
  1339. }
  1340. },
  1341. SET_BRIDGE_INDEX: function(strValue) {
  1342. if (this.Printers === undefined) return false;
  1343. else {
  1344. strValue = (strValue + "").replace(/^\s+|\s+$/g, "");
  1345. for (var vNO in this.Printers["list"]) {
  1346. var strDriverOrName = this.Printers["list"][vNO].name;
  1347. if (strDriverOrName == "(AO)Client-Bridge Driver") {
  1348. this.PageData["printerindex"] = vNO;
  1349. this.PageData["printersubid"] = strValue;
  1350. return true;
  1351. }
  1352. }
  1353. return false;
  1354. }
  1355. },
  1356. Get_AOPrinters_List: function(DriverNameOrIndex, strListName, strSplit) {
  1357. if (!strSplit) strSplit = "\n";
  1358. if (!strListName) strListName = "name";
  1359. return CLODOP.GET_PAGESIZES_LIST(DriverNameOrIndex, strSplit, "subdevlist", strListName);
  1360. },
  1361. Get_AOBridges_List: function(DriverNameOrIndex, strListName, strSplit) {
  1362. return CLODOP.Get_AOPrinters_List(DriverNameOrIndex, strListName, strSplit);
  1363. },
  1364. Get_AOBridge_List: function(strListName, strSplit) {
  1365. return CLODOP.Get_AOPrinters_List("(AO)Client-Bridge Driver", strListName, strSplit);
  1366. },
  1367. Get_AOBridge_SubPrinters_List: function(BridgeNameOrIndex, strListName, strSplit, DriverNameOrIndex) {
  1368. if (!DriverNameOrIndex) DriverNameOrIndex = "(AO)Client-Bridge Driver";
  1369. if (!strSplit) strSplit = "\n";
  1370. if (!strListName) strListName = "name";
  1371. for (var iDrvNO in this.Printers["list"]) {
  1372. if (DriverNameOrIndex == iDrvNO || DriverNameOrIndex == this.Printers["list"][iDrvNO]
  1373. .name) {
  1374. for (var iBdgNO in this.Printers["list"][iDrvNO]["subdevlist"]) {
  1375. var BridgeID = this.Printers["list"][iDrvNO]["subdevlist"][iBdgNO].id;
  1376. var BridgeName = this.Printers["list"][iDrvNO]["subdevlist"][iBdgNO].name;
  1377. if (BridgeNameOrIndex == iBdgNO || BridgeNameOrIndex == BridgeID + ";" +
  1378. BridgeName) {
  1379. var strList = "";
  1380. for (var iSsbPNO in this.Printers["list"][iDrvNO]["subdevlist"][iBdgNO]
  1381. .ssbprinter[
  1382. "list"]) {
  1383. if (iSsbPNO != "0") strList = strList + strSplit;
  1384. if (strListName.toLowerCase() == "id") strList = strList + iSsbPNO;
  1385. else
  1386. strList = strList + this.Printers["list"][iDrvNO]["subdevlist"][iBdgNO]
  1387. .ssbprinter["list"][iSsbPNO].name;
  1388. }
  1389. return strList;
  1390. }
  1391. }
  1392. }
  1393. }
  1394. return "";
  1395. },
  1396. Get_AOBridge_SubPrinters_PageSize_List: function(BridgeNameOrIndex, SubPrinterNameOrIndex, strSplit,
  1397. DriverNameOrIndex) {
  1398. if (!DriverNameOrIndex) DriverNameOrIndex = "(AO)Client-Bridge Driver";
  1399. if (!strSplit) strSplit = "\n";
  1400. for (var iDrvNO in this.Printers["list"]) {
  1401. if (DriverNameOrIndex == iDrvNO || DriverNameOrIndex == this.Printers["list"][iDrvNO]
  1402. .name) {
  1403. for (var iBdgNO in this.Printers["list"][iDrvNO]["subdevlist"]) {
  1404. var BridgeID = this.Printers["list"][iDrvNO]["subdevlist"][iBdgNO].id;
  1405. var BridgeName = this.Printers["list"][iDrvNO]["subdevlist"][iBdgNO].name;
  1406. if (BridgeNameOrIndex == iBdgNO || BridgeNameOrIndex == BridgeID + ";" +
  1407. BridgeName) {
  1408. for (var iSsbPNO in this.Printers["list"][iDrvNO]["subdevlist"][iBdgNO]
  1409. .ssbprinter[
  1410. "list"]) {
  1411. if (SubPrinterNameOrIndex == iSsbPNO || SubPrinterNameOrIndex == this
  1412. .Printers[
  1413. "list"][iDrvNO]["subdevlist"]
  1414. [iBdgNO].ssbprinter["list"][iSsbPNO].name) {
  1415. var strList = "";
  1416. for (var iPageSizeNO in this.Printers["list"][iDrvNO]["subdevlist"][
  1417. iBdgNO
  1418. ].ssbprinter["list"][iSsbPNO][
  1419. "pagelist"
  1420. ]) {
  1421. if (iPageSizeNO != "0") strList = strList + strSplit;
  1422. strList = strList + this.Printers["list"][iDrvNO]["subdevlist"][
  1423. iBdgNO
  1424. ].ssbprinter["list"][iSsbPNO][
  1425. "pagelist"
  1426. ][iPageSizeNO].name;
  1427. }
  1428. return strList;
  1429. };
  1430. }
  1431. }
  1432. }
  1433. }
  1434. }
  1435. return "";
  1436. },
  1437. AddItemArray: function(type, top, left, width, height, strContent, itemname, ShapeType, intPenStyle,
  1438. intPenWidth,
  1439. intColor, isLinePosition, BarType, strChartTypess) {
  1440. if (top === undefined || left === undefined || width === undefined || height === undefined ||
  1441. strContent ===
  1442. undefined) {
  1443. return false;
  1444. }
  1445. var sCount = this.ItemDatas["count"];
  1446. sCount++;
  1447. var oneItem = {};
  1448. for (var vstyle in this.defStyleJson) {
  1449. oneItem[vstyle] = this.defStyleJson[vstyle];
  1450. }
  1451. oneItem["type"] = type;
  1452. oneItem["top"] = top;
  1453. oneItem["left"] = left;
  1454. oneItem["width"] = width;
  1455. oneItem["height"] = height;
  1456. if (strContent != null) {
  1457. if (typeof strContent === "string" && strContent.indexOf(this.DelimChar) > -1)
  1458. oneItem["content"] = strContent.replace(new RegExp(this.DelimChar, 'g'), '');
  1459. else
  1460. oneItem["content"] = strContent;
  1461. }
  1462. if ((itemname !== undefined) && (itemname != null)) oneItem["itemname"] = itemname + "";
  1463. if ((ShapeType !== undefined) && (ShapeType != null)) oneItem["shapetype"] = ShapeType;
  1464. if ((intPenStyle !== undefined) && (intPenStyle != null)) oneItem["penstyle"] = intPenStyle;
  1465. if ((intPenWidth !== undefined) && (intPenWidth != null)) oneItem["penwidth"] = intPenWidth;
  1466. if ((intColor !== undefined) && (intColor != null)) oneItem["fontcolor"] = intColor;
  1467. if ((isLinePosition !== undefined) && (isLinePosition != null)) oneItem["lineposition"] = "1";
  1468. if ((BarType !== undefined) && (BarType != null)) oneItem["fontname"] = BarType;
  1469. if ((strChartTypess !== undefined) && (strChartTypess != null)) oneItem["charttypess"] =
  1470. strChartTypess;
  1471. oneItem["beginpage"] = this.defStyleJson["beginpage"];
  1472. oneItem["beginpagea"] = this.defStyleJson["beginpagea"];
  1473. this.ItemDatas["count"] = sCount;
  1474. this.ItemDatas[sCount] = oneItem;
  1475. this.blNormalItemAdded = true;
  1476. return true;
  1477. },
  1478. RemoveIframes: function() {
  1479. // #ifndef APP-VUE
  1480. var obody = document.body || document.getElementsByTagName("body")[0] || document
  1481. .documentElement;
  1482. // #endif
  1483. try {
  1484. for (var i = 0; i < this.Iframes.length; i++) {
  1485. var now = (new Date()).getTime();
  1486. if ((now - this.Iframes[i]["time"]) > this.timeThreshold * 60000) {
  1487. // #ifndef APP-VUE
  1488. obody.removeChild(this.Iframes[i]["iframe"]);
  1489. // #endif
  1490. this.Iframes.splice(i, 1);
  1491. }
  1492. }
  1493. } catch (err) {};
  1494. },
  1495. AddInputElement: function(odocument, oform, name, value) {
  1496. if (value !== undefined) {
  1497. var oinput = odocument.createElement("input");
  1498. oinput.name = name;
  1499. oinput.type = "hidden";
  1500. oinput.value = value;
  1501. oform.appendChild(oinput);
  1502. }
  1503. },
  1504. createPostDataString: function(afterPostAction) {
  1505. var strData = "act=" + afterPostAction + this.DelimChar;
  1506. strData = strData + "browseurl=" + window.location.href + this.DelimChar;
  1507. for (var vMode in this.PageDataEx) {
  1508. strData = strData + vMode + "=" + this.PageDataEx[vMode] + this.DelimChar;
  1509. }
  1510. var PrintModeNamess = "";
  1511. for (var vMode in this.PageData) {
  1512. strData = strData + vMode + "=" + this.PageData[vMode] + this.DelimChar;
  1513. if (vMode != "top" && vMode != "left" && vMode != "width" && vMode != "height" && vMode !=
  1514. "printtask" && vMode !=
  1515. "printerindex" && vMode != "printerindexa" && vMode != "printersubid" && vMode !=
  1516. "orient" && vMode !=
  1517. "pagewidth" && vMode != "pageheight" && vMode != "pagename" && vMode != "printcopies" &&
  1518. vMode != "setup_bkimg"
  1519. )
  1520. PrintModeNamess = PrintModeNamess + ";" + vMode;
  1521. }
  1522. if (PrintModeNamess !== "")
  1523. strData = strData + "printmodenames=" + PrintModeNamess + this.DelimChar;
  1524. var StyleClassNamess = "";
  1525. for (var vClassStyle in this.ItemCNameStyles) {
  1526. strData = strData + vClassStyle + "=" + this.ItemCNameStyles[vClassStyle] + this.DelimChar;
  1527. StyleClassNamess = StyleClassNamess + ";" + vClassStyle;
  1528. }
  1529. if (StyleClassNamess !== "")
  1530. strData = strData + "printstyleclassnames=" + StyleClassNamess + this.DelimChar;
  1531. strData = strData + "itemcount=" + this.ItemDatas["count"] + this.DelimChar;
  1532. for (var vItemNO in this.ItemDatas) {
  1533. var ItemStyless = "";
  1534. for (var vItemxx in this.ItemDatas[vItemNO]) {
  1535. if (vItemxx != "beginpage" && vItemxx != "beginpagea" && vItemxx != "type" && vItemxx !=
  1536. "top" && vItemxx !=
  1537. "left" && vItemxx != "width" && vItemxx != "height")
  1538. ItemStyless = ItemStyless + ";" + vItemxx;
  1539. }
  1540. strData = strData + vItemNO + "_itemstylenames" + "=" + ItemStyless + this.DelimChar;
  1541. for (var vItemxx in this.ItemDatas[vItemNO]) {
  1542. strData = strData + vItemNO + "_" + vItemxx + "=" + this.ItemDatas[vItemNO][vItemxx] +
  1543. this.DelimChar;
  1544. }
  1545. }
  1546. return strData;
  1547. },
  1548. wsDoPostDatas: function(afterPostAction) {
  1549. var strData = "charset=丂" + this.DelimChar;
  1550. strData = strData + "tid=" + this.GetTaskID() + this.DelimChar;
  1551. strData = strData + this.createPostDataString(afterPostAction);
  1552. return this.wsSend("post:" + strData);
  1553. },
  1554. DoPostDatas: function(afterPostAction) {
  1555. if (this.OBO_Mode && this.blOneByone) {
  1556. console.info(this.altMessageSomeWindowExist);
  1557. return false;
  1558. }
  1559. this.blWorking = true;
  1560. if (this.blTmpSelectedIndex !== null)
  1561. this.SET_PRINTER_INDEX(this.blTmpSelectedIndex);
  1562. if (this.SocketEnable) {
  1563. return this.wsDoPostDatas(afterPostAction);
  1564. }
  1565. // #ifdef APP-VUE
  1566. return this.wsDoPostDatas(afterPostAction);
  1567. // #endif
  1568. this.RemoveIframes();
  1569. var obody = document.body || document.getElementsByTagName("body")[0] || document
  1570. .documentElement;
  1571. var oiframe = document.createElement("iframe");
  1572. oiframe.setAttribute("src", "about:blank");
  1573. oiframe.setAttribute("style", "display:none");
  1574. oiframe.height = 0;
  1575. obody.appendChild(oiframe);
  1576. var contentdocument = oiframe.contentWindow.document;
  1577. contentdocument.write("<form action='" + this.strHostURI +
  1578. "/c_dopostdatas' method='post' enctype='application/x-www-form-urlencoded'></form>");
  1579. var oform = contentdocument.getElementsByTagName("form")[0];
  1580. this.AddInputElement(contentdocument, oform, "charset", "丂");
  1581. this.AddInputElement(contentdocument, oform, "tid", this.GetTaskID());
  1582. this.AddInputElement(contentdocument, oform, "post", this.createPostDataString(
  1583. afterPostAction));
  1584. oform.submit();
  1585. var IframeMS = {};
  1586. IframeMS["time"] = (new Date()).getTime();
  1587. IframeMS["iframe"] = oiframe;
  1588. this.Iframes.push(IframeMS);
  1589. return true;
  1590. },
  1591. GetLastResult: function(blFOneByone) {
  1592. if (blFOneByone) this.blOneByone = true;
  1593. if (this.SocketEnable) {
  1594. return true;
  1595. }
  1596. var url = this.strHostURI + "/c_lastresult.js";
  1597. url = url + "?times=" + (new Date().getTime());
  1598. url = url + "&tid=" + this.GetTaskID();
  1599. url = encodeURI(url).replace("%20", "+");
  1600. var oscript = document.createElement("script");
  1601. oscript.src = url;
  1602. oscript.async = false;
  1603. oscript.type = "text/javascript";
  1604. oscript.charset = "utf-8";
  1605. var head = document.head || document.getElementsByTagName("head")[0] || document
  1606. .documentElement;
  1607. head.insertBefore(oscript, head.firstChild);
  1608. oscript.onload = oscript.onreadystatechange = function() {
  1609. if (!oscript.readyState || /loaded|complete/.test(oscript.readyState)) {
  1610. CLODOP.blOneByone = false;
  1611. if (CLodop_ACTLastResult)
  1612. var strResult = decodeURIComponent(CLodop_ACTLastResult);
  1613. var strResultTaskID = CLodop_ACTTaskID;
  1614. CLODOP.Result = strResult;
  1615. if (CLodop_ACTAlert) CLodop_ACTconsole.info();
  1616. if (CLODOP.On_Return)
  1617. try {
  1618. var selfFunc = CLODOP.On_Return;
  1619. if (strResult == "true" || strResult == "false")
  1620. CLODOP.On_Return(strResultTaskID, strResult == "true");
  1621. else
  1622. CLODOP.On_Return(strResultTaskID, strResult);
  1623. if (!CLODOP.On_Return_Remain && selfFunc === CLODOP.On_Return) CLODOP
  1624. .On_Return =
  1625. null;
  1626. } catch (err) {};
  1627. oscript.onload = oscript.onreadystatechange = null;
  1628. if (oscript.parentNode) {
  1629. oscript.parentNode.removeChild(oscript);
  1630. }
  1631. }
  1632. };
  1633. return true;
  1634. },
  1635. DoCPreview: function(sView, iW, iH) {
  1636. var obody = document.body || document.getElementsByTagName("body")[0] || document
  1637. .documentElement;
  1638. if (typeof iW !== "number") iW = Math.round(obody.offsetWidth * 2 / 3);
  1639. else
  1640. if (obody.offsetWidth < iW) iW = obody.offsetWidth;
  1641. if (typeof iH !== "number") iH = Math.round(window.screen.height - 200);
  1642. else
  1643. if (window.screen.height < iH) iH = window.screen.height;
  1644. var url = this.strHostURI + "/c_dopreview";
  1645. url = url + "?times=" + (new Date().getTime());
  1646. url = url + "&tid=" + this.GetTaskID();
  1647. url = url + "&iw=" + iW;
  1648. url = url + "&ih=" + iH;
  1649. url = encodeURI(url).replace("%20", "+");
  1650. this.PopView(sView, url, iW, iH);
  1651. },
  1652. PopView: function(sView, strPURL, iW, iH) {
  1653. try {
  1654. if (sView && typeof sView === "string" && sView.length > 0) {
  1655. if (sView === "_dialog") {
  1656. if (window.showModalDialog) {
  1657. window.showModalDialog(strPURL, 'dialog', 'center:yes');
  1658. } else {
  1659. window.open(strPURL, "",
  1660. "scrollbars=yes,toolbar=no,left=150,top=100,resizable=yes");
  1661. }
  1662. } else
  1663. if (sView === "_self" || sView === "_top" || sView === "_parent") {
  1664. window.location.href = strPURL;
  1665. } else
  1666. if (sView === "_blank") {
  1667. this.PreviewBox.create(strPURL, iW, iH);
  1668. } else
  1669. if (sView.indexOf("_winopen:") > -1) {
  1670. var strFeatures = sView.slice(sView.indexOf("_winopen:") + 9);
  1671. if (strFeatures.indexOf("_blank") > -1)
  1672. window.open(strPURL, "_blank", strFeatures.slice(strFeatures.indexOf("_blank") +
  1673. 6));
  1674. else
  1675. window.open(strPURL, "", strFeatures);
  1676. } else
  1677. if (document.getElementById(sView)) {
  1678. document.getElementById(sView).src = strPURL;
  1679. } else
  1680. console.info("iframe '" + sView + "' not exist!");
  1681. } else this.PreviewBox.create(strPURL, iW, iH);
  1682. } catch (err) {
  1683. console.info("CLODOP PopView " + err);
  1684. };
  1685. },
  1686. creatMyButtonElement: function(strType, strValue) {
  1687. try {
  1688. var oElement = document.createElement("<input type='" + strType + "' value='" + strValue +
  1689. "'></input>");
  1690. } catch (e) {};
  1691. if (!oElement) {
  1692. oElement = document.createElement("input");
  1693. oElement.type = strType;
  1694. oElement.value = strValue;
  1695. }
  1696. return oElement;
  1697. },
  1698. creatLabelElement: function(Type, Value, Width, Left, Top) {
  1699. var TxtLabel = document.createElement(Type);
  1700. TxtLabel.innerHTML = Value;
  1701. TxtLabel.style.cssText = "position:absolute;width:" + Width + "px;left:" + Left + "px;top:" +
  1702. Top + "px;";
  1703. return TxtLabel;
  1704. },
  1705. SelectBox: {
  1706. dragapproved: false,
  1707. offsetx: 0,
  1708. offsety: 0,
  1709. tempx: 0,
  1710. tempy: 0,
  1711. FrantDiv: undefined,
  1712. PopDiv: undefined,
  1713. selPrinter: undefined,
  1714. selCopies: undefined,
  1715. closeit: function() {
  1716. if (CLODOP.SelectBox.PopDiv && CLODOP.SelectBox.PopDiv.parentNode)
  1717. CLODOP.SelectBox.PopDiv.parentNode.removeChild(CLODOP.SelectBox.PopDiv);
  1718. if (this.FrantDiv && this.FrantDiv.parentNode)
  1719. this.FrantDiv.parentNode.removeChild(this.FrantDiv);
  1720. this.PopDiv = undefined;
  1721. },
  1722. initializedrag: function(e) {
  1723. var we = window.event || e;
  1724. this.offsetx = we.clientX;
  1725. this.offsety = we.clientY;
  1726. this.tempx = parseInt(this.PopDiv.style.left);
  1727. this.tempy = parseInt(this.PopDiv.style.top);
  1728. this.dragapproved = true;
  1729. },
  1730. drag_drop: function(e) {
  1731. if (!this.dragapproved) return;
  1732. var we = window.event || e;
  1733. this.PopDiv.style.left = we.clientX - this.offsetx + this.tempx + "px";
  1734. this.PopDiv.style.top = we.clientY - this.offsety + this.tempy + "px";
  1735. },
  1736. stopdrag: function() {
  1737. this.dragapproved = false;
  1738. },
  1739. clickOK: function(onlySelect) {
  1740. CLODOP.PRINTAOK(CLODOP.SelectBox.selPrinter.value, CLODOP.SelectBox.selCopies.value, 0, 0,
  1741. onlySelect);
  1742. this.closeit();
  1743. },
  1744. create: function(iW, iH, onlySelect) {
  1745. if (CLODOP.SelectBox.PopDiv) this.closeit();
  1746. var obody = document.body || document.getElementsByTagName("body")[0] || document
  1747. .documentElement;
  1748. var Boxdiv = document.createElement("div");
  1749. obody.appendChild(Boxdiv);
  1750. Boxdiv.style.cssText =
  1751. "position:absolute;z-index:91100;display:block;top:2px;border:1px solid #6B97C1;background:#F5F5F5;color:#000;font-size:13px;";
  1752. Boxdiv.style.width = iW + "px";
  1753. Boxdiv.style.left = Math.max((obody.offsetWidth - iW) / 2, 0) + "px";
  1754. Boxdiv.style.top = Math.max((obody.offsetHeight - iH) / 2, 0) + "px";
  1755. Boxdiv.style.height = iH + "px";
  1756. this.PopDiv = Boxdiv;
  1757. var titleDiv = document.createElement("div");
  1758. Boxdiv.appendChild(titleDiv);
  1759. titleDiv.style.cssText =
  1760. "font: bold 13px Arial;line-height:25px;height:27px;text-indent:5px;color: white;background:#8BACCF";
  1761. titleDiv.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;打印";
  1762. titleDiv.onmousedown = function(event) {
  1763. CLODOP.SelectBox.initializedrag(event);
  1764. };
  1765. titleDiv.onmousemove = function(event) {
  1766. CLODOP.SelectBox.drag_drop(event);
  1767. };
  1768. titleDiv.onmouseup = function() {
  1769. CLODOP.SelectBox.stopdrag();
  1770. };
  1771. var icoButton = document.createElement("button");
  1772. titleDiv.appendChild(icoButton);
  1773. icoButton.style.cssText = "background:transparent url(" + CLODOP.strHostURI +
  1774. "/c_favicon.ico) no-repeat scroll 0 0px;margin-left:5px;position:absolute;height:20px;line-height:100px;width:34px;left:3px;border:0;top:5px";
  1775. var CloseButton = document.createElement("button");
  1776. titleDiv.appendChild(CloseButton);
  1777. CloseButton.style.cssText = "background:transparent url(" + CLODOP.strHostURI +
  1778. "/images/c_winclose.png) no-repeat scroll 0 0px;margin-right:5px;position:absolute;height:20px;line-height:100px;width:34px;right:3px;border:0;top:4px";
  1779. CloseButton.onclick = function() {
  1780. CLODOP.SelectBox.closeit();
  1781. if (onlySelect && CLODOP.On_Return) {
  1782. var selfFunc = CLODOP.On_Return;
  1783. CLODOP.On_Return(0, -1);
  1784. if (!CLODOP.On_Return_Remain && selfFunc === CLODOP.On_Return) CLODOP
  1785. .On_Return =
  1786. null;
  1787. }
  1788. };
  1789. var areaDiv = document.createElement("div");
  1790. Boxdiv.appendChild(areaDiv);
  1791. areaDiv.style.cssText = "background:#F5F5F5;color:#000;border:0px;left:0px;top:0px;";
  1792. areaDiv.style.width = iW - 2 + "px";
  1793. areaDiv.style.height = (iH - 27) + "px";
  1794. var OKButton = CLODOP.creatMyButtonElement("button", "确定");
  1795. Boxdiv.appendChild(OKButton);
  1796. OKButton.style.cssText = "position:absolute;width:80px;height:23px;";
  1797. OKButton.style.left = "110px";
  1798. OKButton.style.top = (iH - 64) + "px";
  1799. OKButton.onclick = function() {
  1800. CLODOP.SelectBox.clickOK(onlySelect);
  1801. };
  1802. var CancelButton = CLODOP.creatMyButtonElement("button", "取消");
  1803. Boxdiv.appendChild(CancelButton);
  1804. CancelButton.style.cssText = "position:absolute;width:80px;;height:23px;";
  1805. CancelButton.style.left = "240px";
  1806. CancelButton.style.top = (iH - 64) + "px";
  1807. CancelButton.onclick = function() {
  1808. CLODOP.SelectBox.closeit();
  1809. if (onlySelect && CLODOP.On_Return) {
  1810. var selfFunc = CLODOP.On_Return;
  1811. CLODOP.On_Return(0, -1);
  1812. if (!CLODOP.On_Return_Remain && selfFunc === CLODOP.On_Return) CLODOP
  1813. .On_Return =
  1814. null;
  1815. }
  1816. };
  1817. areaDiv.appendChild(CLODOP.creatLabelElement("span", "选打印机:", 200, 46, 67));
  1818. var oSelect = document.createElement("select");
  1819. Boxdiv.appendChild(oSelect);
  1820. this.selPrinter = oSelect;
  1821. oSelect.style.cssText = "position:absolute;size:1;width:212px;left:110px;top:62px;";
  1822. CLODOP.Create_Printer_List(oSelect);
  1823. areaDiv.appendChild(CLODOP.creatLabelElement("span", "打印份数:", 200, 46, 121));
  1824. var oCopies = CLODOP.creatMyButtonElement("text", "1");
  1825. Boxdiv.appendChild(oCopies);
  1826. this.selCopies = oCopies;
  1827. oCopies.style.cssText = "position:absolute;size:1;width:30px;left:110px;top:117px;";
  1828. this.FrantDiv = document.createElement("div");
  1829. obody.appendChild(this.FrantDiv);
  1830. this.FrantDiv.style.cssText =
  1831. "border:0px;left:0px;top:0px;filter: alpha(opacity=20); position: fixed; opacity: 0.2;-moz-opacity: 0.2; _position: absolute;z-index:91009; over-flow: hidden;";
  1832. if (CLODOP.Browser.IE && (document.compatMode == "BackCompat" || navigator.userAgent
  1833. .indexOf(
  1834. "MSIE 6.0") > 0)) {
  1835. this.FrantDiv.style.width = obody.scrollWidth + "px";
  1836. this.FrantDiv.style.height = obody.scrollHeight + "px";
  1837. } else {
  1838. this.FrantDiv.style.width = "100%";
  1839. this.FrantDiv.style.height = "100%";
  1840. }
  1841. }
  1842. },
  1843. PreviewBox: {
  1844. dragapproved: false,
  1845. offsetx: 0,
  1846. offsety: 0,
  1847. tempx: 0,
  1848. tempy: 0,
  1849. FrantDiv: undefined,
  1850. PopDiv: undefined,
  1851. ContentFrame: undefined,
  1852. closeit: function(oSelf) {
  1853. if (CLODOP.PreviewBox.PopDiv && CLODOP.PreviewBox.PopDiv.parentNode)
  1854. CLODOP.PreviewBox.PopDiv.parentNode.removeChild(CLODOP.PreviewBox.PopDiv);
  1855. if (this.FrantDiv && this.FrantDiv.parentNode)
  1856. this.FrantDiv.parentNode.removeChild(this.FrantDiv);
  1857. this.PopDiv = undefined;
  1858. },
  1859. initializedrag: function(e, oSelf) {
  1860. var we = window.event || e;
  1861. this.offsetx = we.clientX;
  1862. this.offsety = we.clientY;
  1863. this.tempx = parseInt(oSelf.style.left);
  1864. this.tempy = parseInt(oSelf.style.top);
  1865. this.dragapproved = true;
  1866. },
  1867. drag_drop: function(e, oSelf) {
  1868. if (!this.dragapproved) return;
  1869. var we = window.event || e;
  1870. oSelf.style.left = we.clientX - this.offsetx + this.tempx + "px";
  1871. oSelf.style.top = we.clientY - this.offsety + this.tempy + "px";
  1872. },
  1873. stopdrag: function() {
  1874. this.dragapproved = false;
  1875. if (this.ContentFrame) this.ContentFrame.style.display = "block";
  1876. },
  1877. create: function(strURL, iW, iH) {
  1878. if (CLODOP.PreviewBox.PopDiv) this.closeit();
  1879. var obody = document.body || document.getElementsByTagName("body")[0] || document
  1880. .documentElement;
  1881. var vBoxDiv = document.createElement("div");
  1882. obody.appendChild(vBoxDiv);
  1883. vBoxDiv.style.cssText =
  1884. "position:absolute;z-index:91100;display:block;top:2px;border:1px solid #6B97C1;font-size:13px;";
  1885. vBoxDiv.style.width = iW + "px";
  1886. var iLeft = (obody.offsetWidth - iW) / 2;
  1887. if (window.screen.width < obody.offsetWidth) iLeft = (window.screen.width - iW) / 2;
  1888. if (iLeft < 0) iLeft = 0;
  1889. vBoxDiv.style.left = iLeft + "px";
  1890. vBoxDiv.style.height = iH + "px";
  1891. vBoxDiv.onmousedown = function(event) {
  1892. CLODOP.PreviewBox.initializedrag(event, this);
  1893. };
  1894. vBoxDiv.onmouseup = function() {
  1895. CLODOP.PreviewBox.stopdrag();
  1896. };
  1897. vBoxDiv.onmousemove = function(event) {
  1898. CLODOP.PreviewBox.drag_drop(event, this);
  1899. };
  1900. this.PopDiv = vBoxDiv;
  1901. var titleDiv = document.createElement("div");
  1902. vBoxDiv.appendChild(titleDiv);
  1903. titleDiv.style.cssText =
  1904. "position:absolute;left:0px;width:100%;font: bold 14px Arial;line-height:27px;height:27px;text-indent:26px;color: white;background:#8BACCF";
  1905. titleDiv.innerHTML = "打印预览";
  1906. var icoButton = document.createElement("button");
  1907. titleDiv.appendChild(icoButton);
  1908. icoButton.style.cssText = "background:transparent url(" + CLODOP.strHostURI +
  1909. "/c_favicon.ico) no-repeat scroll 0 0px;margin-left:5px;position:absolute;height:20px;line-height:100px;width:34px;left:3px;border:0;top:5px";
  1910. var CloseButton = document.createElement("button");
  1911. titleDiv.appendChild(CloseButton);
  1912. CloseButton.style.cssText = "background:transparent url(" + CLODOP.strHostURI +
  1913. "/images/c_winclose.png) no-repeat scroll 0 0px;margin-right:5px;position:absolute;height:20px;line-height:100px;width:34px;right:3px;border:0;top:4px";
  1914. CloseButton.onclick = function() {
  1915. CLODOP.PreviewBox.closeit(this);
  1916. };
  1917. var areaDiv = document.createElement("div");
  1918. vBoxDiv.appendChild(areaDiv);
  1919. areaDiv.style.cssText = "background:#F5F5F5;color:#000;border:0px;left:0px;top:0px;";
  1920. areaDiv.style.width = iW + "px";
  1921. areaDiv.style.height = (iH - 0) + "px";
  1922. this.ContentFrame = document.createElement("iframe");
  1923. areaDiv.appendChild(this.ContentFrame);
  1924. this.ContentFrame.style.cssText = "width:100%;height:100%;";
  1925. this.ContentFrame.src = strURL;
  1926. this.ContentFrame.frameBorder = "no";
  1927. this.FrantDiv = document.createElement("div");
  1928. obody.appendChild(this.FrantDiv);
  1929. this.FrantDiv.style.cssText =
  1930. "border:0px;left:0px;top:0px;filter: alpha(opacity=20); position: fixed; opacity: 0.2; -moz-opacity: 0.2; _position: absolute;z-index:91009; over-flow: hidden;";
  1931. if (CLODOP.Browser.IE && (document.compatMode == "BackCompat" || navigator.userAgent
  1932. .indexOf(
  1933. "MSIE 6.0") > 0)) {
  1934. this.FrantDiv.style.width = obody.scrollWidth + "px";
  1935. this.FrantDiv.style.height = obody.scrollHeight + "px";
  1936. } else {
  1937. this.FrantDiv.style.width = "100%";
  1938. this.FrantDiv.style.height = "100%";
  1939. }
  1940. }
  1941. }
  1942. };
  1943. if (win.CLODOP2015_7028 && win.CLODOP2015_7028.Priority && win.CLODOP2015_7028.Priority > CLODOP.Priority) {
  1944. CLODOP = win.CLODOP2015_7028;
  1945. win.CLODOP_OK_Priority = win.CLODOP2015_7028.Priority;
  1946. return;
  1947. }
  1948. win.LODOP = CLODOP;
  1949. win.CLODOP = CLODOP;
  1950. win.CLODOP2015_7028 = CLODOP;
  1951. win.CLODOP_OK_Priority = CLODOP.Priority;
  1952. // #ifndef APP-VUE
  1953. win.CLODOP.DoInit();
  1954. // #endif
  1955. if (navigator.userAgent.indexOf("Lodop") < 0) win.CLODOP.OpenWebSocket();
  1956. })(window);
  1957. function getCLodop() {
  1958. return window.CLODOP2015_7028;
  1959. }
  1960. export {
  1961. getCLodop
  1962. }; //导出getLodop