tsb_test_page.lua 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. --[[
  2. @module tsb_test_page
  3. @summary 报税口演示页面
  4. @version 1.0
  5. @date 2026.03.04
  6. @author 李一玮
  7. @usage
  8. 本文件是报税口演示页面,展示报税口的各种用法。
  9. ]]
  10. local tsb_test_page = {}
  11. -- 页面UI元素
  12. local main_container = nil
  13. local common_ui = require("tsb_common_page")
  14. -- 创建UI
  15. function tsb_test_page.create_ui()
  16. main_container = airui.container({
  17. x = 0,
  18. y = 0,
  19. w = 480,
  20. h = 320,
  21. color = 0xF5F5F5,
  22. })
  23. --------------------- 标题栏 ------------------------
  24. local title_bar = airui.container({
  25. parent = main_container,
  26. x = 0,
  27. y = 0,
  28. w = 480,
  29. h = 30,
  30. color = 0x007AFF,
  31. })
  32. airui.label({
  33. parent = title_bar,
  34. text = "报税口",
  35. x = 210,
  36. y = 8,
  37. w = 80,
  38. h = 20,
  39. font_size = 16,
  40. color = 0xFFFFFF,
  41. })
  42. -- 标题栏公共信息展示
  43. common_ui.add_battery_display(title_bar)
  44. common_ui.create_back_button(title_bar, tsb_test_page.cleanup)
  45. ---------------------------------------------------
  46. -- 滚动容器
  47. local scroll_container = airui.container({
  48. parent = main_container,
  49. x = 0,
  50. y = 30,
  51. w = 480,
  52. h = 270,
  53. color = 0xF5F5F5,
  54. })
  55. --common_ui.add_background_png(scroll_container)
  56. local keyboard1 = airui.keyboard({
  57. x = 0,
  58. y = 0,
  59. w = 480,
  60. h = 160, -- x, y, 键盘默认打开ALIGN_BOTTOM_MID,位置从中下方开始计算
  61. mode = "numeric", -- 键盘模式,可选 "text"/"upper"/"lower"/"numeric"
  62. auto_hide = true, -- 自动隐藏键盘
  63. preview = true,
  64. preview_height = 35,
  65. bg_color = 0xf1f1f1, -- 键盘背景颜色为灰色,可选,不设置则透明
  66. on_commit = function() -- 确认事件回调,只有在按下确认键时才会触发
  67. log.info("keyboard", "commit")
  68. end
  69. })
  70. --------------------- 接口号 ------------------------
  71. airui.label({
  72. parent = scroll_container,
  73. text = "接口号:",
  74. x = 5,
  75. y = 17,
  76. w = 55,
  77. h = 20,
  78. font_size = 15,
  79. })
  80. local tax_dropdown = airui.dropdown({
  81. parent = scroll_container,
  82. x = 60,
  83. y = 7,
  84. w = 55,
  85. h = 35,
  86. options = {"A", "B"},
  87. default_index = 0,
  88. on_change = function(self,idx)
  89. -- local texts = {"选项1", "选项2", "选项3", "选项4", "选项5"}
  90. -- selected_label1:set_text("当前选中: " .. texts[idx + 1])
  91. end
  92. })
  93. ---------------------------------------------------
  94. --------------------- 枪号 ------------------------
  95. airui.label({
  96. parent = scroll_container,
  97. text = "枪号:",
  98. x = 120,
  99. y = 17,
  100. w = 40,
  101. h = 20,
  102. font_size = 15,
  103. })
  104. local gunnum_input = airui.textarea({
  105. parent = scroll_container,
  106. x = 160,
  107. y = 7,
  108. w = 55,
  109. h = 35,
  110. text = "1",
  111. -- placeholder = "...",
  112. max_len = 1,
  113. keyboard = keyboard1
  114. })
  115. ---------------------------------------------------
  116. --------------------- 新国标开关 -------------------
  117. airui.label({
  118. parent = scroll_container,
  119. text = "新国标",
  120. x = 217,
  121. y = 17,
  122. w = 50,
  123. h = 20,
  124. font_size = 15,
  125. })
  126. local switch_new_tax = airui.switch({
  127. parent = scroll_container,
  128. x = 267,
  129. y = 12,
  130. w = 50,
  131. h = 25,
  132. checked = false,
  133. on_change = function(self)
  134. log.info("NEW_TAX", self:get_state() and "开启" or "关闭")
  135. end
  136. })
  137. ---------------------------------------------------
  138. -------------------- 新国标报税口 ------------------
  139. airui.label({
  140. parent = scroll_container,
  141. text = "新国标报税口",
  142. x = 320,
  143. y = 17,
  144. w = 95,
  145. h = 40,
  146. font_size = 15,
  147. })
  148. local new_tax_num_input = airui.textarea({
  149. parent = scroll_container,
  150. x = 415,
  151. y = 7,
  152. w = 55,
  153. h = 35,
  154. text = "1",
  155. -- placeholder = "...",
  156. max_len = 1,
  157. keyboard = keyboard1
  158. })
  159. ---------------------------------------------------
  160. ----------------- 查询税控序列号区域 ---------------
  161. local tax_serial_container = airui.container({
  162. parent = scroll_container,
  163. x = 10,
  164. y = 50,
  165. w = 160,
  166. h = 210,
  167. color = 0xFFFFFF,
  168. radius = 5,
  169. })
  170. local tax_serial_btn = airui.button({
  171. parent = tax_serial_container,
  172. x = 20,
  173. y = 12,
  174. w = 120,
  175. h = 35,
  176. text = "查询税控序列号",
  177. style = { bg_color = 0x2B6FF1,border_color = 0x2B6FF1, text_color = 0xFFFFFF, radius = 8 },
  178. on_click = function(self)
  179. log.info("button", "基本按钮被点击")
  180. end
  181. })
  182. -- 查询结果显示
  183. airui.label({
  184. parent = tax_serial_container,
  185. text = "税控序列号:",
  186. x = 10,
  187. y = 60,
  188. w = 120,
  189. h = 20,
  190. font_size = 14,
  191. })
  192. local label_tax_serial = airui.label({
  193. parent = tax_serial_container,
  194. text = "0123456789",
  195. x = 10,
  196. y = 80,
  197. w = 150,
  198. h = 20,
  199. font_size = 14,
  200. })
  201. airui.label({
  202. parent = tax_serial_container,
  203. text = "厂家:",
  204. x = 10,
  205. y = 110,
  206. w = 40,
  207. h = 20,
  208. font_size = 14,
  209. })
  210. local label_company = airui.label({
  211. parent = tax_serial_container,
  212. text = "拓盛",
  213. x = 50,
  214. y = 110,
  215. w = 90,
  216. h = 20,
  217. font_size = 14,
  218. })
  219. airui.label({
  220. parent = tax_serial_container,
  221. text = "枪个数:",
  222. x = 10,
  223. y = 150,
  224. w = 60,
  225. h = 20,
  226. font_size = 14,
  227. })
  228. local label_gunnum = airui.label({
  229. parent = tax_serial_container,
  230. text = "2",
  231. x = 70,
  232. y = 150,
  233. w = 80,
  234. h = 20,
  235. font_size = 14,
  236. })
  237. airui.label({
  238. parent = tax_serial_container,
  239. text = "执行结果:",
  240. x = 10,
  241. y = 190,
  242. w = 70,
  243. h = 20,
  244. font_size = 14,
  245. })
  246. local label_tax_serial_result = airui.label({
  247. parent = tax_serial_container,
  248. text = "执行成功",
  249. x = 80,
  250. y = 190,
  251. w = 80,
  252. h = 20,
  253. font_size = 14,
  254. })
  255. ---------------------------------------------------
  256. ----------------- 日累月累总累 ------------------
  257. local tax_msg_container = airui.container({
  258. parent = scroll_container,
  259. x = 180,
  260. y = 50,
  261. w = 290,
  262. h = 210,
  263. color = 0xFFFFFF,
  264. radius = 5,
  265. })
  266. local year_input = airui.textarea({
  267. parent = tax_msg_container,
  268. x = 10,
  269. y = 7,
  270. w = 70,
  271. h = 35,
  272. text = os.date('%Y'),
  273. -- placeholder = "...",
  274. max_len = 4,
  275. keyboard = keyboard1
  276. })
  277. airui.label({
  278. parent = tax_msg_container,
  279. text = "年",
  280. x = 85,
  281. y = 18,
  282. w = 20,
  283. h = 20,
  284. font_size = 15,
  285. })
  286. local month_dropdown = airui.dropdown({
  287. parent = tax_msg_container,
  288. x = 105,
  289. y = 7,
  290. w = 65,
  291. h = 35,
  292. options = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"},
  293. default_index = 0,
  294. on_change = function(self,idx)
  295. -- local texts = {"选项1", "选项2", "选项3", "选项4", "选项5"}
  296. -- selected_label1:set_text("当前选中: " .. texts[idx + 1])
  297. end
  298. })
  299. airui.label({
  300. parent = tax_msg_container,
  301. text = "月",
  302. x = 175,
  303. y = 18,
  304. w = 20,
  305. h = 20,
  306. font_size = 15,
  307. })
  308. local day_dropdown = airui.dropdown({
  309. parent = tax_msg_container,
  310. x = 195,
  311. y = 7,
  312. w = 65,
  313. h = 35,
  314. options = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"},
  315. default_index = 0,
  316. on_change = function(self,idx)
  317. -- local texts = {"选项1", "选项2", "选项3", "选项4", "选项5"}
  318. -- selected_label1:set_text("当前选中: " .. texts[idx + 1])
  319. end
  320. })
  321. airui.label({
  322. parent = tax_msg_container,
  323. text = "日",
  324. x = 265,
  325. y = 18,
  326. w = 20,
  327. h = 20,
  328. font_size = 15,
  329. })
  330. local check_total_btn = airui.button({
  331. parent = tax_msg_container,
  332. x = 10,
  333. y = 50,
  334. w = 120,
  335. h = 35,
  336. text = "查当次及总累",
  337. style = { bg_color = 0x2B6FF1,border_color = 0x2B6FF1, text_color = 0xFFFFFF, radius = 8 },
  338. on_click = function(self)
  339. log.info("button", "基本按钮被点击")
  340. end
  341. })
  342. local check_day_btn = airui.button({
  343. parent = tax_msg_container,
  344. x = 140,
  345. y = 50,
  346. w = 60,
  347. h = 35,
  348. text = "查日累",
  349. style = { bg_color = 0x2B6FF1,border_color = 0x2B6FF1, text_color = 0xFFFFFF, radius = 8 },
  350. on_click = function(self)
  351. log.info("button", "基本按钮被点击")
  352. end
  353. })
  354. local check_month_btn = airui.button({
  355. parent = tax_msg_container,
  356. x = 210,
  357. y = 50,
  358. w = 60,
  359. h = 35,
  360. text = "查月累",
  361. style = { bg_color = 0x2B6FF1,border_color = 0x2B6FF1, text_color = 0xFFFFFF, radius = 8 },
  362. on_click = function(self)
  363. log.info("button", "基本按钮被点击")
  364. end
  365. })
  366. airui.label({
  367. parent = tax_msg_container,
  368. text = "金额:",
  369. x = 10,
  370. y = 100,
  371. w = 50,
  372. h = 20,
  373. font_size = 14,
  374. })
  375. local label_money = airui.label({
  376. parent = tax_msg_container,
  377. text = "9999.99",
  378. x = 50,
  379. y = 100,
  380. w = 70,
  381. h = 20,
  382. font_size = 14,
  383. })
  384. airui.label({
  385. parent = tax_msg_container,
  386. text = "油量:",
  387. x = 10,
  388. y = 120,
  389. w = 50,
  390. h = 20,
  391. font_size = 14,
  392. })
  393. local label_oil = airui.label({
  394. parent = tax_msg_container,
  395. text = "9999.99",
  396. x = 50,
  397. y = 120,
  398. w = 70,
  399. h = 20,
  400. font_size = 14,
  401. })
  402. airui.label({
  403. parent = tax_msg_container,
  404. text = "单价:",
  405. x = 10,
  406. y = 140,
  407. w = 50,
  408. h = 20,
  409. font_size = 14,
  410. })
  411. local label_price = airui.label({
  412. parent = tax_msg_container,
  413. text = "99.99",
  414. x = 50,
  415. y = 140,
  416. w = 50,
  417. h = 20,
  418. font_size = 14,
  419. })
  420. airui.label({
  421. parent = tax_msg_container,
  422. text = "是否密文:",
  423. x = 10,
  424. y = 160,
  425. w = 70,
  426. h = 20,
  427. font_size = 14,
  428. })
  429. local label_encryption = airui.label({
  430. parent = tax_msg_container,
  431. text = "是",
  432. x = 80,
  433. y = 160,
  434. w = 30,
  435. h = 20,
  436. font_size = 14,
  437. })
  438. airui.label({
  439. parent = tax_msg_container,
  440. text = "总金额",
  441. x = 185,
  442. y = 100,
  443. w = 70,
  444. h = 20,
  445. font_size = 14,
  446. })
  447. local label_total_money = airui.label({
  448. parent = tax_msg_container,
  449. text = "1234567891234.99",
  450. x = 140,
  451. y = 120,
  452. w = 150,
  453. h = 30,
  454. font_size = 14,
  455. })
  456. airui.label({
  457. parent = tax_msg_container,
  458. text = "总油量",
  459. x = 185,
  460. y = 140,
  461. w = 70,
  462. h = 20,
  463. font_size = 14,
  464. })
  465. local label_total_oil = airui.label({
  466. parent = tax_msg_container,
  467. text = "1234567891234.99",
  468. x = 140,
  469. y = 160,
  470. w = 150,
  471. h = 30,
  472. font_size = 14,
  473. })
  474. airui.label({
  475. parent = tax_msg_container,
  476. text = "执行结果:",
  477. x = 10,
  478. y = 190,
  479. w = 70,
  480. h = 20,
  481. font_size = 14,
  482. })
  483. local label_check_result = airui.label({
  484. parent = tax_msg_container,
  485. text = "执行成功",
  486. x = 80,
  487. y = 190,
  488. w = 120,
  489. h = 20,
  490. font_size = 14,
  491. })
  492. -- 底部信息栏
  493. common_ui.create_status_bar(main_container)
  494. end
  495. -- 初始化页面
  496. function tsb_test_page.init(params)
  497. tsb_test_page.create_ui()
  498. end
  499. -- 清理页面
  500. function tsb_test_page.cleanup()
  501. if main_container then
  502. main_container:destroy()
  503. main_container = nil
  504. end
  505. end
  506. return tsb_test_page