tsb_bsk_page.lua 13 KB

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