tsb_bsk_page.lua 13 KB

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