af-mobile-client-vue3 1.3.30 → 1.3.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/.claude/settings.local.json +10 -0
  2. package/.cursorrules +60 -60
  3. package/.editorconfig +9 -9
  4. package/.env +10 -10
  5. package/.env.development +1 -1
  6. package/.env.production +1 -1
  7. package/.node-version +1 -1
  8. package/.vscode/extensions.json +12 -12
  9. package/.vscode/settings.json +68 -66
  10. package/CLAUDE.md +218 -189
  11. package/README.md +182 -182
  12. package/af-example-mobile-vue-web.iml +9 -9
  13. package/build/vite/index.ts +98 -98
  14. package/build/vite/optimize.ts +34 -34
  15. package/build/vite/vconsole.ts +47 -47
  16. package/commitlint.config.ts +32 -32
  17. package/compress.js +36 -36
  18. package/eslint.config.ts +31 -30
  19. package/index.html +23 -23
  20. package/mock/data.ts +20 -20
  21. package/mock/index.ts +7 -7
  22. package/mock/modules/prose.mock.ts +13 -13
  23. package/mock/modules/user.mock.ts +95 -152
  24. package/mock/util.ts +19 -19
  25. package/netlify.toml +12 -12
  26. package/package.json +114 -114
  27. package/postcss.config.ts +27 -27
  28. package/public/favicon.svg +4 -4
  29. package/public/safari-pinned-tab.svg +4 -4
  30. package/scripts/verifyCommit.js +19 -19
  31. package/src/App.vue +79 -79
  32. package/src/api/auth/index.ts +77 -0
  33. package/src/api/auth/types.ts +200 -0
  34. package/src/api/mock/index.ts +30 -30
  35. package/src/api/user/index.ts +40 -40
  36. package/src/assets/img/user/login/background-shadow-1.svg +20 -20
  37. package/src/assets/img/user/login/logo-background.svg +20 -20
  38. package/src/bootstrap.ts +26 -26
  39. package/src/components/core/BeautifulLoading/index.vue +52 -52
  40. package/src/components/core/ImageUploader/index.vue +251 -251
  41. package/src/components/core/NavBar/index.vue +53 -53
  42. package/src/components/core/Tabbar/index.vue +32 -32
  43. package/src/components/core/Uploader/index.vue +124 -124
  44. package/src/components/core/XGridDropOption/index.vue +154 -154
  45. package/src/components/core/XMultiSelect/index.vue +183 -183
  46. package/src/components/core/XSelect/index.vue +149 -149
  47. package/src/components/data/CardContainer/CardContainer.vue +118 -118
  48. package/src/components/data/CardContainer/CardHeader.vue +99 -99
  49. package/src/components/data/InfoDisplay/index.vue +132 -132
  50. package/src/components/data/UserDetail/api.ts +24 -24
  51. package/src/components/data/UserDetail/index.vue +620 -620
  52. package/src/components/data/UserDetail/recordEntries.ts +159 -159
  53. package/src/components/data/UserDetail/types.ts +26 -26
  54. package/src/components/data/XBadge/index.vue +82 -82
  55. package/src/components/data/XCellDetail/index.vue +105 -105
  56. package/src/components/data/XCellList/XCellList.md +432 -432
  57. package/src/components/data/XCellList/index.vue +1436 -1436
  58. package/src/components/data/XCellListFilter/QrScanner/index.vue +207 -207
  59. package/src/components/data/XCellListFilter/QrScanner/startScanAnimation.ts +53 -53
  60. package/src/components/data/XCellListFilter/VpnRecognition/index.vue +119 -119
  61. package/src/components/data/XCellListFilter/index.vue +705 -705
  62. package/src/components/data/XForm/index.vue +659 -659
  63. package/src/components/data/XFormGroup/doc/DeviceForm.vue +122 -122
  64. package/src/components/data/XFormGroup/doc/FormGroupDemo.vue +56 -56
  65. package/src/components/data/XFormGroup/doc/README.md +286 -286
  66. package/src/components/data/XFormGroup/doc/UserForm.vue +102 -102
  67. package/src/components/data/XFormGroup/index.vue +240 -240
  68. package/src/components/data/XFormItem/index.vue +1310 -1310
  69. package/src/components/data/XOlMap/README.md +227 -227
  70. package/src/components/data/XOlMap/XLocationPicker/index.vue +226 -226
  71. package/src/components/data/XOlMap/index.vue +1490 -1490
  72. package/src/components/data/XOlMap/types.ts +149 -149
  73. package/src/components/data/XOlMap/utils/{wgs84ToGcj02.js → wgs84ToGcj02.ts} +171 -154
  74. package/src/components/data/XReportForm/DateTimeSecondsPicker.vue +208 -208
  75. package/src/components/data/XReportForm/XReportFormJsonRender.vue +220 -220
  76. package/src/components/data/XReportForm/index.vue +1393 -1393
  77. package/src/components/data/XReportGrid/XAddReport/XAddReport.vue +198 -198
  78. package/src/components/data/XReportGrid/XAddReport/index.js +3 -3
  79. package/src/components/data/XReportGrid/XAddReport/index.md +53 -53
  80. package/src/components/data/XReportGrid/XAddReport/index.ts +10 -10
  81. package/src/components/data/XReportGrid/XReport.vue +960 -960
  82. package/src/components/data/XReportGrid/XReportDemo.vue +33 -33
  83. package/src/components/data/XReportGrid/XReportDesign.vue +597 -597
  84. package/src/components/data/XReportGrid/XReportDrawer/XReportDrawer.vue +148 -148
  85. package/src/components/data/XReportGrid/XReportDrawer/index.js +3 -3
  86. package/src/components/data/XReportGrid/XReportDrawer/index.ts +10 -10
  87. package/src/components/data/XReportGrid/XReportJsonRender.vue +399 -399
  88. package/src/components/data/XReportGrid/XReportTrGroup.vue +592 -592
  89. package/src/components/data/XReportGrid/index.md +46 -46
  90. package/src/components/data/XReportGrid/print.js +184 -184
  91. package/src/components/data/XSignature/index.vue +284 -284
  92. package/src/components/data/XTag/index.vue +10 -10
  93. package/src/components/layout/NormalDataLayout/index.vue +69 -69
  94. package/src/components/layout/TabBarLayout/index.vue +40 -40
  95. package/src/composables/dark.ts +5 -5
  96. package/src/config/routes.ts +9 -9
  97. package/src/constants/index.ts +2 -2
  98. package/src/enums/requestEnum.ts +25 -25
  99. package/src/expression/ExpressionRunner.ts +28 -28
  100. package/src/expression/TestExpression.ts +510 -510
  101. package/src/expression/core/Delegate.ts +116 -116
  102. package/src/expression/core/Expression.ts +1359 -1359
  103. package/src/expression/core/Program.ts +985 -985
  104. package/src/expression/core/Token.ts +29 -29
  105. package/src/expression/enums/ExpressionType.ts +81 -81
  106. package/src/expression/enums/TokenType.ts +11 -11
  107. package/src/expression/exception/BreakWayException.ts +2 -2
  108. package/src/expression/exception/ContinueWayException.ts +2 -2
  109. package/src/expression/exception/ExpressionException.ts +29 -29
  110. package/src/expression/exception/ReturnWayException.ts +14 -14
  111. package/src/expression/exception/ServiceException.ts +22 -22
  112. package/src/expression/instances/JSONArray.ts +52 -52
  113. package/src/expression/instances/JSONObject.ts +118 -118
  114. package/src/expression/instances/LogicConsole.ts +31 -31
  115. package/src/font-style/font.css +4 -4
  116. package/src/hooks/useBoolean.ts +26 -26
  117. package/src/hooks/useCommon.ts +9 -9
  118. package/src/hooks/useLoading.ts +16 -16
  119. package/src/hooks/useLogin.ts +97 -97
  120. package/src/icons/svg/check-in.svg +32 -32
  121. package/src/icons/svg/dark.svg +4 -4
  122. package/src/icons/svg/github.svg +4 -4
  123. package/src/icons/svg/light.svg +4 -4
  124. package/src/icons/svg/link.svg +4 -4
  125. package/src/icons/svgo.yml +22 -22
  126. package/src/layout/GridView/index.vue +16 -16
  127. package/src/layout/PageLayout.vue +9 -9
  128. package/src/layout/SingleLayout.vue +9 -9
  129. package/src/locales/en-US.json +128 -128
  130. package/src/locales/zh-CN.json +128 -128
  131. package/src/logic/LogicRunner.ts +67 -67
  132. package/src/logic/TestLogic.ts +13 -13
  133. package/src/logic/plugins/common/DateTools.ts +35 -35
  134. package/src/logic/plugins/common/VueTools.ts +30 -30
  135. package/src/logic/plugins/index.ts +7 -7
  136. package/src/main.ts +44 -44
  137. package/src/plugins/AppData.ts +38 -38
  138. package/src/plugins/GetLoginInfoService.ts +10 -10
  139. package/src/plugins/collectIcons.ts +10 -10
  140. package/src/plugins/index.ts +11 -11
  141. package/src/router/README.md +8 -8
  142. package/src/router/external-routes.ts +60 -0
  143. package/src/router/guards.ts +131 -59
  144. package/src/router/index.ts +35 -35
  145. package/src/router/invoiceRoutes.ts +33 -33
  146. package/src/router/routes.ts +426 -347
  147. package/src/services/api/Login.ts +6 -6
  148. package/src/services/api/common.ts +109 -109
  149. package/src/services/api/index.ts +7 -7
  150. package/src/services/api/manage.ts +8 -8
  151. package/src/services/api/search.ts +16 -16
  152. package/src/services/api/user.ts +17 -17
  153. package/src/services/restTools.ts +56 -56
  154. package/src/services/v3Api.ts +147 -147
  155. package/src/stores/index.ts +13 -13
  156. package/src/stores/modules/counter.ts +19 -19
  157. package/src/stores/modules/homeApp.ts +55 -55
  158. package/src/stores/modules/routeCache.ts +22 -23
  159. package/src/stores/modules/setting.ts +87 -87
  160. package/src/stores/modules/user.ts +326 -235
  161. package/src/stores/mutation-type.ts +12 -7
  162. package/src/styles/app.less +36 -36
  163. package/src/styles/login.less +109 -109
  164. package/src/styles/var.less +25 -25
  165. package/src/types/auth.ts +85 -0
  166. package/src/types/env.d.ts +16 -16
  167. package/src/types/platform.ts +194 -0
  168. package/src/types/settings.ts +1 -1
  169. package/src/types/vue-router.d.ts +13 -9
  170. package/src/utils/Storage.ts +124 -124
  171. package/src/utils/authority-utils.ts +84 -84
  172. package/src/utils/common.ts +41 -41
  173. package/src/utils/crypto.ts +39 -39
  174. package/src/utils/dataUtil.ts +42 -42
  175. package/src/utils/dictUtil.ts +52 -52
  176. package/src/utils/http/index.ts +201 -199
  177. package/src/utils/i18n.ts +72 -72
  178. package/src/utils/indexedDB.ts +195 -195
  179. package/src/utils/inline-px-to-vw.ts +28 -28
  180. package/src/utils/mobileUtil.ts +33 -34
  181. package/src/utils/platform-auth.ts +134 -0
  182. package/src/utils/progress.ts +19 -19
  183. package/src/utils/routerUtil.ts +271 -271
  184. package/src/utils/runEvalFunction.ts +13 -13
  185. package/src/utils/secureStorage.ts +70 -71
  186. package/src/utils/set-page-title.ts +5 -5
  187. package/src/utils/validate.ts +6 -6
  188. package/src/views/chat/index.vue +153 -153
  189. package/src/views/common/Forbidden.vue +97 -0
  190. package/src/views/common/LoadError.vue +63 -63
  191. package/src/views/common/NotFound.vue +67 -67
  192. package/src/views/component/EvaluateRecordView/index.vue +40 -40
  193. package/src/views/component/IconifyView/index.vue +504 -504
  194. package/src/views/component/UserDetailView/UserDetailPage.vue +77 -77
  195. package/src/views/component/UserDetailView/index.vue +234 -234
  196. package/src/views/component/XCellDetailView/index.vue +217 -217
  197. package/src/views/component/XCellListView/index.vue +108 -129
  198. package/src/views/component/XFormAppraiseView/index.vue +174 -174
  199. package/src/views/component/XFormGroupView/index.vue +78 -82
  200. package/src/views/component/XFormView/index.vue +27 -27
  201. package/src/views/component/XOlMapView/XLocationPicker/index.vue +118 -118
  202. package/src/views/component/XOlMapView/index.vue +434 -434
  203. package/src/views/component/XOlMapView/testData.ts +64 -64
  204. package/src/views/component/XReportFormIframeView/index.vue +47 -47
  205. package/src/views/component/XReportFormView/index.vue +13 -13
  206. package/src/views/component/XReportGridView/index.vue +17 -17
  207. package/src/views/component/XRequestView/index.vue +234 -234
  208. package/src/views/component/XSignatureView/index.vue +50 -50
  209. package/src/views/component/index.vue +181 -181
  210. package/src/views/component/menu.vue +117 -117
  211. package/src/views/component/notice.vue +46 -46
  212. package/src/views/component/topNav.vue +36 -36
  213. package/src/views/external/index.vue +152 -0
  214. package/src/views/invoiceShow/index.vue +61 -61
  215. package/src/views/loading/AuthLoading.vue +345 -0
  216. package/src/views/user/login/ForgetPasswordForm.vue +94 -94
  217. package/src/views/user/login/LoginForm.vue +350 -347
  218. package/src/views/user/login/LoginTitle.vue +76 -76
  219. package/src/views/user/login/LoginWave.vue +109 -109
  220. package/src/views/user/login/index.vue +22 -22
  221. package/src/views/user/my/comm/ModifyPassword.vue +346 -346
  222. package/src/views/user/my/index.vue +507 -507
  223. package/src/views/user/register/index.vue +952 -952
  224. package/src/views/userRecords/AbnormalAlarmRecords.vue +21 -21
  225. package/src/views/userRecords/CardReplacementRecords.vue +21 -21
  226. package/src/views/userRecords/ChangeRecords.vue +19 -19
  227. package/src/views/userRecords/CommandViewRecords.vue +20 -20
  228. package/src/views/userRecords/GasCompensationRecords.vue +20 -20
  229. package/src/views/userRecords/InstrumentCollectionRecords.vue +21 -21
  230. package/src/views/userRecords/MeterRecords.vue +20 -20
  231. package/src/views/userRecords/OperateRecords.vue +51 -51
  232. package/src/views/userRecords/OtherChargeRecords.vue +19 -19
  233. package/src/views/userRecords/PaymentRecords.vue +28 -28
  234. package/src/views/userRecords/PriceAdjustmentRecords.vue +19 -19
  235. package/src/views/userRecords/ReplacementRecords.vue +19 -19
  236. package/src/views/userRecords/SafetyRecords.vue +19 -19
  237. package/src/views/userRecords/TransactionRecords.vue +21 -21
  238. package/src/views/userRecords/TransferRecords.vue +19 -19
  239. package/src/views/userRecords/operateRecordDetail/index.vue +316 -316
  240. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/AddUserDetail.vue +124 -124
  241. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/AdvanceDeliveryDetail.vue +88 -88
  242. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/AutoAccountsCancelDetail.vue +205 -205
  243. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/AutoAccountsDetail.vue +192 -192
  244. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/BankDkDetail.vue +192 -192
  245. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/BankPayDetail.vue +192 -192
  246. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/BlacklistDetail.vue +153 -153
  247. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/CancellationDetail.vue +101 -101
  248. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/CardMeterCenterCancelDetail.vue +127 -127
  249. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/CardMeterCenterDetail.vue +153 -153
  250. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/CardOverUserDetail.vue +153 -153
  251. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/ChangeMeterCancelDetail.vue +166 -166
  252. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/ChangeMeterDetail.vue +205 -205
  253. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/DisableManageDetail.vue +127 -127
  254. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/EnableManageDetail.vue +114 -114
  255. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/FaZheChangeDetail.vue +124 -124
  256. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/FeeDeductionDetail.vue +153 -153
  257. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/GasPriceChangeDetail.vue +126 -126
  258. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/InputtorChangeDetail.vue +126 -126
  259. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/IotMeterCenterCancelDetail.vue +114 -114
  260. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/IotMeterCenterDetail.vue +127 -127
  261. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/IotOpenDetail.vue +88 -88
  262. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/MachineCardDetail.vue +101 -101
  263. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/MachineMeterCenterCancelDetail.vue +218 -218
  264. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/MachineMeterCenterDetail.vue +153 -153
  265. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/OffGasAddGasDetail.vue +140 -140
  266. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/OtherChargeCancelDetail.vue +127 -127
  267. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/OtherChargeDetail.vue +114 -114
  268. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/OverUserChangeDetail.vue +127 -127
  269. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/ReBillDetail.vue +127 -127
  270. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/RefundDetail.vue +114 -114
  271. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/ReplaceCardManageCancelDetail.vue +127 -127
  272. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/ReplaceCardManageDetail.vue +114 -114
  273. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/SaleCardGasDetail.vue +140 -140
  274. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/TransferManageCancelDetail.vue +152 -152
  275. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/TransferManageDetail.vue +178 -178
  276. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/UserChangeDetail.vue +123 -123
  277. package/src/views/userRecords/operateRecordDetail/operateRecordDetails/WechatPayDetail.vue +192 -192
  278. package/src/views/userRecords/types.ts +66 -66
  279. package/tsconfig.json +39 -39
  280. package/uno.config.ts +82 -82
  281. package/vite.config.ts +119 -118
  282. package/src/router/types.ts +0 -7
  283. package/src/utils/wechatUtil.ts +0 -9
@@ -1,705 +1,705 @@
1
- <script setup lang="ts">
2
- import XGridDropOption from '@af-mobile-client-vue3/components/core/XGridDropOption/index.vue'
3
- import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
4
- import useUserStore from '@af-mobile-client-vue3/stores/modules/user'
5
- import { Icon } from '@iconify/vue'
6
- import {
7
- showFailToast,
8
- Button as VanButton,
9
- Col as VanCol,
10
- DropdownItem as VanDropdownItem,
11
- DropdownMenu as VanDropdownMenu,
12
- Icon as VanIcon,
13
- Row as VanRow,
14
- } from 'vant'
15
- import { computed, defineEmits, defineModel, defineProps, nextTick, onMounted, ref } from 'vue'
16
- import QrScanner from './QrScanner/index.vue'
17
- import VpnRecognition from './VpnRecognition/index.vue'
18
-
19
- const props = defineProps<{
20
- fixQueryForm?: object
21
- serviceName?: string
22
- orderVal?: string
23
- sortordVal?: string
24
- orderList?: any[]
25
- formQuery?: any[]
26
- buttonState?: any
27
- buttonPermissions?: any[]
28
- scanOptions?: {
29
- show?: boolean // 是否显示扫码按钮
30
- type?: string | string[] // 显示类型:可以是单个类型,也可以是类型数组
31
- defaultMode?: string // 默认模式
32
- }
33
- }>()
34
-
35
- const emit = defineEmits([
36
- 'update:orderVal',
37
- 'update:sortordVal',
38
- 'update:conditionParams',
39
- 'onRefresh',
40
- 'addOption',
41
- 'toggleView',
42
- 'onScan',
43
- 'onNFC',
44
- ])
45
-
46
- const userState = useUserStore().getLogin()
47
-
48
- // 定义扫描模式枚举,便于扩展
49
- const SCAN_MODES = {
50
- SCAN: 'scan', // 扫码模式
51
- NFC: 'nfc', // NFC读取模式
52
- // 可扩展
53
- }
54
-
55
- // 定义扫描模式配置
56
- const SCAN_MODE_CONFIGS = {
57
- [SCAN_MODES.SCAN]: {
58
- icon: 'scan',
59
- title: '扫码',
60
- component: QrScanner,
61
- closeText: '关闭扫描',
62
- },
63
- [SCAN_MODES.NFC]: {
64
- icon: 'wifi',
65
- title: 'NFC',
66
- component: VpnRecognition,
67
- closeText: '关闭读取',
68
- },
69
- // 可扩展
70
- }
71
-
72
- // 获取所有可用的扫描模式列表
73
- const AVAILABLE_MODES = Object.keys(SCAN_MODE_CONFIGS)
74
-
75
- // 排序字段
76
- const currentOrderVal = defineModel('orderVal')
77
- // 排序规则
78
- const currentSortordVal = defineModel('sortordVal')
79
- // 下拉菜单元素
80
- const listFilterMenu = ref(null)
81
- // 排序规则列表
82
- const sortordList = ref([
83
- { title: '正序', value: 'ascend' },
84
- { title: '倒序', value: 'descend' },
85
- ])
86
- const colFieldNames = {
87
- text: 'title',
88
- value: 'value',
89
- }
90
-
91
- // 查询条件参数 !!!!!建议最后点击确认的时候完成这个的整理
92
- const conditionParams = ref({})
93
-
94
- // 用于存储每个 XFormItem 的 ref
95
- const formItemRefs = ref([])
96
-
97
- // 视图模式 - 当前选中的扫描模式
98
- const scanType = ref(getDefaultScanType())
99
-
100
- const scanMenuShow = ref(false)
101
- const filterMenuShow = ref(false)
102
- const showScanner = ref(true)
103
-
104
- onMounted(async () => {
105
- // 监听应用状态变化
106
- window.addEventListener('appstate-change', handleAppStateChange as EventListener)
107
- })
108
-
109
- // 定义应用状态事件的类型
110
- interface AppStateEvent extends CustomEvent {
111
- detail: {
112
- appState: 'afterhidden' | 'beforeshow' | 'aftershow'
113
- }
114
- }
115
- // 处理应用状态变化
116
- function handleAppStateChange(e: AppStateEvent) {
117
- if (e.detail.appState === 'afterhidden') {
118
- // console.log('>>>> 组件 已卸载')
119
- filterMenuShow.value = false
120
- }
121
- else if (e.detail.appState === 'beforeshow') {
122
- // console.log('>>>> 组件 即将重新渲染')
123
- }
124
- else if (e.detail.appState === 'aftershow') {
125
- // console.log('>>>> 组件 已经重新渲染')
126
- }
127
- }
128
-
129
- // 获取默认扫描模式
130
- function getDefaultScanType() {
131
- // 如果指定了默认模式且该模式有效,则使用默认模式
132
- if (props.scanOptions?.defaultMode && isModeAvailable(props.scanOptions.defaultMode))
133
- return props.scanOptions.defaultMode
134
-
135
- // 确定启用的模式列表
136
- const enabledModes = getEnabledModes()
137
-
138
- // 如果有可用模式,使用第一个可用模式
139
- if (enabledModes.length > 0)
140
- return enabledModes[0]
141
-
142
- // 兜底默认为扫码模式
143
- return SCAN_MODES.SCAN
144
- }
145
-
146
- // 获取启用的模式列表
147
- function getEnabledModes() {
148
- // 如果没有指定type,则默认全部可用
149
- if (!props.scanOptions?.type)
150
- return AVAILABLE_MODES
151
-
152
- // 如果type是字符串,转换为数组处理
153
- const typeList = Array.isArray(props.scanOptions.type)
154
- ? props.scanOptions.type
155
- : [props.scanOptions.type]
156
-
157
- // 过滤出有效的模式
158
- return typeList.filter(mode => isModeAvailable(mode))
159
- }
160
-
161
- // 检查模式是否有效
162
- function isModeAvailable(mode) {
163
- return AVAILABLE_MODES.includes(mode)
164
- }
165
-
166
- // 是否显示扫码按钮
167
- const showScanButton = computed(() => {
168
- // 如果没有传递scanOptions,默认不显示
169
- if (!props.scanOptions)
170
- return false
171
-
172
- // 如果定义了scanOptions.show,优先使用它
173
- if (props.scanOptions.show !== undefined)
174
- return props.scanOptions.show
175
-
176
- // 其次检查buttonState.scan
177
- if (props.buttonState?.scan !== undefined)
178
- return props.buttonState.scan !== false
179
-
180
- // 默认不显示
181
- return false
182
- })
183
-
184
- // 获取启用的扫描模式列表
185
- const enabledScanModes = computed(() => getEnabledModes())
186
-
187
- // 处理扫码菜单显示
188
- function handleScanMenuChange(value: boolean) {
189
- scanMenuShow.value = value
190
- if (value) {
191
- filterMenuShow.value = false
192
-
193
- // 确保当前模式在启用列表中
194
- if (!enabledScanModes.value.includes(scanType.value))
195
- scanType.value = getDefaultScanType()
196
-
197
- // 重新挂载组件
198
- showScanner.value = false
199
- setTimeout(() => {
200
- showScanner.value = true
201
- }, 10)
202
- }
203
- else {
204
- showScanner.value = false
205
- }
206
- }
207
-
208
- // 切换到指定的扫描模式
209
- function switchToMode(mode) {
210
- // 确保模式有效且已启用
211
- if (isModeAvailable(mode) && enabledScanModes.value.includes(mode)) {
212
- scanType.value = mode
213
- // 重新挂载组件
214
- showScanner.value = false
215
- setTimeout(() => {
216
- showScanner.value = true
217
- }, 10)
218
- // 发出对应事件
219
- if (mode === SCAN_MODES.SCAN)
220
- emit('onScan')
221
- else if (mode === SCAN_MODES.NFC)
222
- emit('onNFC')
223
- // 可扩展
224
- }
225
- }
226
-
227
- // 重置某个选项
228
- function resetOptionItem(type) {
229
- if (conditionParams.value[type] !== undefined)
230
- conditionParams.value[type] = undefined
231
- }
232
- // 重置所有选项
233
- function resetOption() {
234
- currentOrderVal.value = undefined
235
- currentSortordVal.value = undefined
236
- // 条件参数
237
- Object.keys(conditionParams.value).forEach((key) => {
238
- conditionParams.value[key] = undefined
239
- })
240
- // 关键:调用所有 XFormItem 的 reset 方法
241
- nextTick(() => {
242
- formItemRefs.value.forEach((refItem) => {
243
- if (refItem && typeof refItem.reset === 'function') {
244
- refItem.reset()
245
- }
246
- })
247
- })
248
- console.log('conditionParams.value重置', conditionParams.value)
249
- }
250
- function checkOrderOption() {
251
- let isCheck = true
252
- if (currentOrderVal.value) {
253
- if (!currentSortordVal.value) {
254
- showFailToast('排序规则不能为空')
255
- isCheck = false
256
- }
257
- }
258
- else if (currentSortordVal.value) {
259
- if (!currentOrderVal.value) {
260
- showFailToast('排序字段不能为空')
261
- isCheck = false
262
- }
263
- }
264
- return isCheck
265
- }
266
- // 清理查询条件参数,删除无效内容
267
- function cleanConditionParams(params) {
268
- const cleanedParams = {}
269
-
270
- for (const key of Object.keys(params)) {
271
- const value = params[key]
272
-
273
- // 跳过无效值
274
- if (value === null || value === undefined || value === '') {
275
- continue
276
- }
277
-
278
- // 处理数组
279
- if (Array.isArray(value)) {
280
- // 过滤掉空字符串、null、undefined
281
- const filteredArray = value.filter(item =>
282
- item !== null && item !== undefined && item !== '',
283
- )
284
- // 只有当数组不为空时才添加
285
- if (filteredArray.length > 0) {
286
- cleanedParams[key] = filteredArray
287
- }
288
- continue
289
- }
290
-
291
- // 处理对象
292
- if (typeof value === 'object' && value !== null) {
293
- // 检查对象是否为空
294
- const objectKeys = Object.keys(value)
295
- if (objectKeys.length === 0) {
296
- continue
297
- }
298
-
299
- // 递归清理对象内部
300
- const cleanedObject = {}
301
- let hasValidValue = false
302
-
303
- for (const objKey of objectKeys) {
304
- const objValue = value[objKey]
305
- if (objValue !== null && objValue !== undefined && objValue !== '') {
306
- cleanedObject[objKey] = objValue
307
- hasValidValue = true
308
- }
309
- }
310
-
311
- // 只有当对象有有效值时才添加
312
- if (hasValidValue) {
313
- cleanedParams[key] = cleanedObject
314
- }
315
- continue
316
- }
317
-
318
- // 处理基本类型
319
- if (value !== null && value !== undefined && value !== '') {
320
- cleanedParams[key] = value
321
- }
322
- }
323
-
324
- return cleanedParams
325
- }
326
-
327
- // 确认筛选条件
328
- function confirmOption() {
329
- const isCheck = checkOrderOption()
330
- if (isCheck) {
331
- // 清理查询条件参数
332
- const cleanedParams = cleanConditionParams(conditionParams.value)
333
-
334
- const isEmptyObject = Object.keys(cleanedParams).length === 0
335
- emit('update:conditionParams', isEmptyObject ? undefined : cleanedParams)
336
- emit('onRefresh', {})
337
- listFilterMenu.value.close(false)
338
- }
339
- }
340
-
341
- // 处理筛选菜单显示
342
- function handleFilterMenuChange(value: boolean) {
343
- filterMenuShow.value = value
344
- if (value) {
345
- scanMenuShow.value = false
346
- showScanner.value = false
347
- }
348
- }
349
-
350
- // 处理关闭扫描按钮点击
351
- function handleCloseScanButton() {
352
- listFilterMenu.value.close(false)
353
- }
354
-
355
- // 按钮权限信息筛选
356
- function filterButtonPermissions(btn) {
357
- return props.buttonPermissions.find(item => item.btnName === btn)
358
- }
359
- </script>
360
-
361
- <template>
362
- <div id="XCellListFilter">
363
- <div class="filter-buttons">
364
- <VanDropdownMenu ref="listFilterMenu" :close-on-click-outside="false" class="filter-dropdown-menu">
365
- <VanDropdownItem v-if="showScanButton" v-model="scanMenuShow" @change="handleScanMenuChange">
366
- <template #title>
367
- <div class="filter-icon-box">
368
- <Icon icon="ri:qr-scan-2-line" :width="24" />
369
- </div>
370
- </template>
371
-
372
- <!-- 显示选项卡 -->
373
- <div class="scan-tab-wrapper">
374
- <div class="dropdown-title">
375
- <VanIcon name="scan" class="title-icon" />
376
- <span class="title-text">扫码功能</span>
377
- </div>
378
- <div class="scan-tabs">
379
- <!-- 动态生成扫描模式选项卡 -->
380
- <div
381
- v-for="mode in enabledScanModes"
382
- :key="mode"
383
- class="scan-tab-item"
384
- :class="{ active: scanType === mode }"
385
- @click="switchToMode(mode)"
386
- >
387
- <VanIcon :name="SCAN_MODE_CONFIGS[mode].icon" class="tab-icon" />
388
- {{ SCAN_MODE_CONFIGS[mode].title }}
389
- </div>
390
- </div>
391
- </div>
392
-
393
- <!-- 动态显示当前选中的扫描组件 -->
394
- <div v-if="showScanner" class="scanORnfc">
395
- <component
396
- :is="SCAN_MODE_CONFIGS[scanType].component"
397
- @close="handleCloseScanButton"
398
- />
399
- </div>
400
-
401
- <div class="closeItem">
402
- <VanButton
403
- type="primary"
404
- size="normal"
405
- class="close-scan-btn"
406
- icon="cross"
407
- @click="handleCloseScanButton"
408
- >
409
- {{ SCAN_MODE_CONFIGS[scanType].closeText }}
410
- </VanButton>
411
- </div>
412
- </VanDropdownItem>
413
-
414
- <!-- 筛选按钮 -->
415
- <VanDropdownItem v-if="!props.buttonState || props.buttonState.filter !== false" v-model="filterMenuShow" @change="handleFilterMenuChange">
416
- <template #title>
417
- <div class="filter-icon-box">
418
- <Icon icon="mdi:filter" :width="24" />
419
- </div>
420
- </template>
421
- <div class="dropdown-title">
422
- <VanIcon name="filter-o" class="title-icon" />
423
- <span class="title-text">筛选条件</span>
424
- </div>
425
- <div class="order-condition">
426
- <template v-if="props.orderList.length > 0">
427
- <VanRow justify="space-between" class="filter-title">
428
- <VanCol span="10">
429
- 排序字段
430
- </VanCol>
431
- <!-- <VanCol span="2">
432
- <div class="reset-item" @click.stop="currentOrderVal = undefined">
433
- 重置
434
- </div>
435
- </VanCol> -->
436
- </VanRow>
437
- <XGridDropOption :columns="props.orderList" :columns-field-names="colFieldNames" />
438
- <VanRow justify="space-between" class="filter-title">
439
- <VanCol span="10">
440
- 排序规则
441
- </VanCol>
442
- <!-- <VanCol span="2">
443
- <div class="reset-item" @click.stop="currentSortordVal = undefined">
444
- 重置
445
- </div>
446
- </VanCol> -->
447
- </VanRow>
448
- <XGridDropOption :columns="sortordList" :columns-field-names="colFieldNames" />
449
- </template>
450
- <template v-for="(item, index) in props.formQuery" :key="`${item.model}${index}`">
451
- <VanRow justify="space-between" class="filter-title">
452
- <VanCol span="10">
453
- {{ item.name }}
454
- </VanCol>
455
- <!-- <VanCol span="2">
456
- <div class="reset-item" @click.stop="resetOptionItem(item.model)">
457
- 重置
458
- </div>
459
- </VanCol> -->
460
- </VanRow>
461
- <XFormItem
462
- ref="formItemRefs"
463
- v-model="conditionParams[item.model]"
464
- :form="conditionParams"
465
- :attr="item"
466
- :service-name="props.serviceName"
467
- :show-label="false"
468
- />
469
- </template>
470
- </div>
471
- <div class="operations-panel">
472
- <VanButton type="default" @click="resetOption">
473
- 重置
474
- </VanButton>
475
- <VanButton type="primary" @click="confirmOption">
476
- 查询
477
- </VanButton>
478
- </div>
479
- </VanDropdownItem>
480
- </VanDropdownMenu>
481
- </div>
482
- </div>
483
- </template>
484
-
485
- <style scoped lang="less">
486
- #XCellListFilter {
487
- --van-cell-horizontal-padding: 0;
488
- width: 100%;
489
- .filter-buttons {
490
- display: flex;
491
- align-items: center;
492
- justify-content: flex-end;
493
- gap: 8px;
494
- }
495
-
496
- .dropdown-title {
497
- padding: 16px;
498
- background-color: #fff;
499
- border-bottom: 1px solid #ebedf0;
500
- margin-bottom: 8px;
501
- display: flex;
502
- align-items: center;
503
- gap: 8px;
504
- .title-icon {
505
- font-size: 20px;
506
- color: #646566;
507
- }
508
- .title-text {
509
- font-size: 18px;
510
- font-weight: 600;
511
- color: #323233;
512
- line-height: 1.4;
513
- }
514
- }
515
-
516
- .scan-tab-wrapper {
517
- padding: 0;
518
- background-color: #fff;
519
- .scan-tabs {
520
- display: flex;
521
- background: #f5f5f5;
522
- border-radius: 8px;
523
- padding: 2px;
524
- margin-top: 8px;
525
- .scan-tab-item {
526
- flex: 1;
527
- height: 44px;
528
- display: flex;
529
- align-items: center;
530
- justify-content: center;
531
- font-size: 15px;
532
- color: #646566;
533
- cursor: pointer;
534
- border-radius: 6px;
535
- gap: 4px;
536
-
537
- .tab-icon {
538
- font-size: 20px;
539
- }
540
-
541
- &.active {
542
- background-color: #1989fa;
543
- color: #fff;
544
- .tab-icon {
545
- color: #fff;
546
- }
547
- }
548
- }
549
- }
550
- }
551
-
552
- .filter-dropdown-menu {
553
- :deep(.van-dropdown-menu__bar) {
554
- box-shadow: none;
555
- height: auto;
556
- position: relative;
557
- z-index: 1;
558
- }
559
- :deep(.van-dropdown-menu__item) {
560
- display: flex;
561
- align-items: center;
562
- justify-content: center;
563
- position: relative;
564
- z-index: 1;
565
- }
566
- // 隐藏下拉箭头
567
- :deep(.van-dropdown-menu__title::after) {
568
- display: none !important;
569
- }
570
- // 下拉菜单内容
571
- :deep(.van-dropdown-item__content) {
572
- position: fixed;
573
- z-index: 10;
574
- background-color: white;
575
- }
576
- // 下拉菜单遮罩层
577
- :deep(.van-overlay) {
578
- z-index: 9;
579
- }
580
- }
581
-
582
- .filter-icon-box {
583
- display: flex;
584
- align-items: center;
585
- justify-content: center;
586
- width: 40px;
587
- height: 40px;
588
- border-radius: 10px;
589
- background-color: rgba(245, 245, 245);
590
- cursor: pointer;
591
- position: relative;
592
- z-index: 1;
593
- &:active {
594
- opacity: 0.7;
595
- }
596
- }
597
- .order-condition {
598
- padding: 0 16px 16px;
599
- max-height: calc(var(--van-picker-toolbar-height) + var(--van-padding-base) + var(--van-tabs-line-height) + 35vh);
600
- overflow-y: auto;
601
- width: 100%;
602
- background-color: white;
603
- .filter-title {
604
- height: 2rem;
605
- font-size: 13px;
606
- font-weight: 600;
607
- line-height: 2rem;
608
- margin: 5px 5px 1px 0px;
609
- color: black;
610
- }
611
- .range-picker-list {
612
- .range-picker-title {
613
- height: 2rem;
614
- font-size: 13px;
615
- font-weight: 600;
616
- line-height: 2rem;
617
- margin: 5px 1rem 1px 1rem;
618
- color: black;
619
- }
620
- .range-picker-time {
621
- display: inline-block;
622
- background: #f8f8f8;
623
- border-radius: 8px;
624
- font-size: 13px;
625
- margin: 0 1rem;
626
- height: 2rem;
627
- line-height: 2rem;
628
- width: 40vw;
629
- text-align: center;
630
- }
631
- /* 已完成选择的时间 */
632
- .active-picker-time {
633
- color: blue;
634
- }
635
- }
636
- /* 重置元素按钮 */
637
- .reset-item {
638
- font-weight: 500;
639
- color: blue;
640
- }
641
- }
642
- /* 下拉菜单的操作面板 */
643
- .operations-panel {
644
- display: flex;
645
- overflow: hidden;
646
- user-select: none;
647
- padding: 10px;
648
- gap: 12px;
649
-
650
- & > .van-button {
651
- flex: 1;
652
- margin: 0;
653
-
654
- //&:first-child {
655
- // margin-right: 12px;
656
- //}
657
- }
658
- }
659
- /* 时间范围组件 */
660
- .rangePicker-comp-box {
661
- :deep(.van-calendar) {
662
- height: 58vh;
663
- }
664
- :deep(.van-calendar__header-title) {
665
- background-color: rgba(25, 137, 250, 0.1);
666
- height: 8vh;
667
- line-height: 8vh;
668
- }
669
- :deep(.van-calendar__month-mark) {
670
- color: rgba(25, 137, 250, 0.1);
671
- }
672
- }
673
- .scanORnfc {
674
- height: 50vh;
675
- width: 100%;
676
- position: relative;
677
- background-color: #f0f0f0;
678
- border-radius: 8px;
679
- }
680
- .closeItem {
681
- display: flex;
682
- justify-content: center;
683
- margin-top: 16px;
684
- margin-bottom: 20px;
685
-
686
- .close-scan-btn {
687
- width: 140px;
688
- height: 40px;
689
- background-color: #1989fa;
690
- border-radius: 4px;
691
- font-size: 14px;
692
- border: none;
693
- display: flex;
694
- align-items: center;
695
- justify-content: center;
696
- padding: 0;
697
-
698
- :deep(.van-button__icon) {
699
- margin-right: 4px;
700
- font-size: 16px;
701
- }
702
- }
703
- }
704
- }
705
- </style>
1
+ <script setup lang="ts">
2
+ import XGridDropOption from '@af-mobile-client-vue3/components/core/XGridDropOption/index.vue'
3
+ import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
4
+ import useUserStore from '@af-mobile-client-vue3/stores/modules/user'
5
+ import { Icon } from '@iconify/vue'
6
+ import {
7
+ showFailToast,
8
+ Button as VanButton,
9
+ Col as VanCol,
10
+ DropdownItem as VanDropdownItem,
11
+ DropdownMenu as VanDropdownMenu,
12
+ Icon as VanIcon,
13
+ Row as VanRow,
14
+ } from 'vant'
15
+ import { computed, defineEmits, defineModel, defineProps, nextTick, onMounted, ref } from 'vue'
16
+ import QrScanner from './QrScanner/index.vue'
17
+ import VpnRecognition from './VpnRecognition/index.vue'
18
+
19
+ const props = defineProps<{
20
+ fixQueryForm?: object
21
+ serviceName?: string
22
+ orderVal?: string
23
+ sortordVal?: string
24
+ orderList?: any[]
25
+ formQuery?: any[]
26
+ buttonState?: any
27
+ buttonPermissions?: any[]
28
+ scanOptions?: {
29
+ show?: boolean // 是否显示扫码按钮
30
+ type?: string | string[] // 显示类型:可以是单个类型,也可以是类型数组
31
+ defaultMode?: string // 默认模式
32
+ }
33
+ }>()
34
+
35
+ const emit = defineEmits([
36
+ 'update:orderVal',
37
+ 'update:sortordVal',
38
+ 'update:conditionParams',
39
+ 'onRefresh',
40
+ 'addOption',
41
+ 'toggleView',
42
+ 'onScan',
43
+ 'onNFC',
44
+ ])
45
+
46
+ const userState = useUserStore().getLogin()
47
+
48
+ // 定义扫描模式枚举,便于扩展
49
+ const SCAN_MODES = {
50
+ SCAN: 'scan', // 扫码模式
51
+ NFC: 'nfc', // NFC读取模式
52
+ // 可扩展
53
+ }
54
+
55
+ // 定义扫描模式配置
56
+ const SCAN_MODE_CONFIGS = {
57
+ [SCAN_MODES.SCAN]: {
58
+ icon: 'scan',
59
+ title: '扫码',
60
+ component: QrScanner,
61
+ closeText: '关闭扫描',
62
+ },
63
+ [SCAN_MODES.NFC]: {
64
+ icon: 'wifi',
65
+ title: 'NFC',
66
+ component: VpnRecognition,
67
+ closeText: '关闭读取',
68
+ },
69
+ // 可扩展
70
+ }
71
+
72
+ // 获取所有可用的扫描模式列表
73
+ const AVAILABLE_MODES = Object.keys(SCAN_MODE_CONFIGS)
74
+
75
+ // 排序字段
76
+ const currentOrderVal = defineModel('orderVal')
77
+ // 排序规则
78
+ const currentSortordVal = defineModel('sortordVal')
79
+ // 下拉菜单元素
80
+ const listFilterMenu = ref(null)
81
+ // 排序规则列表
82
+ const sortordList = ref([
83
+ { title: '正序', value: 'ascend' },
84
+ { title: '倒序', value: 'descend' },
85
+ ])
86
+ const colFieldNames = {
87
+ text: 'title',
88
+ value: 'value',
89
+ }
90
+
91
+ // 查询条件参数 !!!!!建议最后点击确认的时候完成这个的整理
92
+ const conditionParams = ref({})
93
+
94
+ // 用于存储每个 XFormItem 的 ref
95
+ const formItemRefs = ref([])
96
+
97
+ // 视图模式 - 当前选中的扫描模式
98
+ const scanType = ref(getDefaultScanType())
99
+
100
+ const scanMenuShow = ref(false)
101
+ const filterMenuShow = ref(false)
102
+ const showScanner = ref(true)
103
+
104
+ onMounted(async () => {
105
+ // 监听应用状态变化
106
+ window.addEventListener('appstate-change', handleAppStateChange as EventListener)
107
+ })
108
+
109
+ // 定义应用状态事件的类型
110
+ interface AppStateEvent extends CustomEvent {
111
+ detail: {
112
+ appState: 'afterhidden' | 'beforeshow' | 'aftershow'
113
+ }
114
+ }
115
+ // 处理应用状态变化
116
+ function handleAppStateChange(e: AppStateEvent) {
117
+ if (e.detail.appState === 'afterhidden') {
118
+ // console.log('>>>> 组件 已卸载')
119
+ filterMenuShow.value = false
120
+ }
121
+ else if (e.detail.appState === 'beforeshow') {
122
+ // console.log('>>>> 组件 即将重新渲染')
123
+ }
124
+ else if (e.detail.appState === 'aftershow') {
125
+ // console.log('>>>> 组件 已经重新渲染')
126
+ }
127
+ }
128
+
129
+ // 获取默认扫描模式
130
+ function getDefaultScanType() {
131
+ // 如果指定了默认模式且该模式有效,则使用默认模式
132
+ if (props.scanOptions?.defaultMode && isModeAvailable(props.scanOptions.defaultMode))
133
+ return props.scanOptions.defaultMode
134
+
135
+ // 确定启用的模式列表
136
+ const enabledModes = getEnabledModes()
137
+
138
+ // 如果有可用模式,使用第一个可用模式
139
+ if (enabledModes.length > 0)
140
+ return enabledModes[0]
141
+
142
+ // 兜底默认为扫码模式
143
+ return SCAN_MODES.SCAN
144
+ }
145
+
146
+ // 获取启用的模式列表
147
+ function getEnabledModes() {
148
+ // 如果没有指定type,则默认全部可用
149
+ if (!props.scanOptions?.type)
150
+ return AVAILABLE_MODES
151
+
152
+ // 如果type是字符串,转换为数组处理
153
+ const typeList = Array.isArray(props.scanOptions.type)
154
+ ? props.scanOptions.type
155
+ : [props.scanOptions.type]
156
+
157
+ // 过滤出有效的模式
158
+ return typeList.filter(mode => isModeAvailable(mode))
159
+ }
160
+
161
+ // 检查模式是否有效
162
+ function isModeAvailable(mode) {
163
+ return AVAILABLE_MODES.includes(mode)
164
+ }
165
+
166
+ // 是否显示扫码按钮
167
+ const showScanButton = computed(() => {
168
+ // 如果没有传递scanOptions,默认不显示
169
+ if (!props.scanOptions)
170
+ return false
171
+
172
+ // 如果定义了scanOptions.show,优先使用它
173
+ if (props.scanOptions.show !== undefined)
174
+ return props.scanOptions.show
175
+
176
+ // 其次检查buttonState.scan
177
+ if (props.buttonState?.scan !== undefined)
178
+ return props.buttonState.scan !== false
179
+
180
+ // 默认不显示
181
+ return false
182
+ })
183
+
184
+ // 获取启用的扫描模式列表
185
+ const enabledScanModes = computed(() => getEnabledModes())
186
+
187
+ // 处理扫码菜单显示
188
+ function handleScanMenuChange(value: boolean) {
189
+ scanMenuShow.value = value
190
+ if (value) {
191
+ filterMenuShow.value = false
192
+
193
+ // 确保当前模式在启用列表中
194
+ if (!enabledScanModes.value.includes(scanType.value))
195
+ scanType.value = getDefaultScanType()
196
+
197
+ // 重新挂载组件
198
+ showScanner.value = false
199
+ setTimeout(() => {
200
+ showScanner.value = true
201
+ }, 10)
202
+ }
203
+ else {
204
+ showScanner.value = false
205
+ }
206
+ }
207
+
208
+ // 切换到指定的扫描模式
209
+ function switchToMode(mode) {
210
+ // 确保模式有效且已启用
211
+ if (isModeAvailable(mode) && enabledScanModes.value.includes(mode)) {
212
+ scanType.value = mode
213
+ // 重新挂载组件
214
+ showScanner.value = false
215
+ setTimeout(() => {
216
+ showScanner.value = true
217
+ }, 10)
218
+ // 发出对应事件
219
+ if (mode === SCAN_MODES.SCAN)
220
+ emit('onScan')
221
+ else if (mode === SCAN_MODES.NFC)
222
+ emit('onNFC')
223
+ // 可扩展
224
+ }
225
+ }
226
+
227
+ // 重置某个选项
228
+ function resetOptionItem(type) {
229
+ if (conditionParams.value[type] !== undefined)
230
+ conditionParams.value[type] = undefined
231
+ }
232
+ // 重置所有选项
233
+ function resetOption() {
234
+ currentOrderVal.value = undefined
235
+ currentSortordVal.value = undefined
236
+ // 条件参数
237
+ Object.keys(conditionParams.value).forEach((key) => {
238
+ conditionParams.value[key] = undefined
239
+ })
240
+ // 关键:调用所有 XFormItem 的 reset 方法
241
+ nextTick(() => {
242
+ formItemRefs.value.forEach((refItem) => {
243
+ if (refItem && typeof refItem.reset === 'function') {
244
+ refItem.reset()
245
+ }
246
+ })
247
+ })
248
+ console.log('conditionParams.value重置', conditionParams.value)
249
+ }
250
+ function checkOrderOption() {
251
+ let isCheck = true
252
+ if (currentOrderVal.value) {
253
+ if (!currentSortordVal.value) {
254
+ showFailToast('排序规则不能为空')
255
+ isCheck = false
256
+ }
257
+ }
258
+ else if (currentSortordVal.value) {
259
+ if (!currentOrderVal.value) {
260
+ showFailToast('排序字段不能为空')
261
+ isCheck = false
262
+ }
263
+ }
264
+ return isCheck
265
+ }
266
+ // 清理查询条件参数,删除无效内容
267
+ function cleanConditionParams(params) {
268
+ const cleanedParams = {}
269
+
270
+ for (const key of Object.keys(params)) {
271
+ const value = params[key]
272
+
273
+ // 跳过无效值
274
+ if (value === null || value === undefined || value === '') {
275
+ continue
276
+ }
277
+
278
+ // 处理数组
279
+ if (Array.isArray(value)) {
280
+ // 过滤掉空字符串、null、undefined
281
+ const filteredArray = value.filter(item =>
282
+ item !== null && item !== undefined && item !== '',
283
+ )
284
+ // 只有当数组不为空时才添加
285
+ if (filteredArray.length > 0) {
286
+ cleanedParams[key] = filteredArray
287
+ }
288
+ continue
289
+ }
290
+
291
+ // 处理对象
292
+ if (typeof value === 'object' && value !== null) {
293
+ // 检查对象是否为空
294
+ const objectKeys = Object.keys(value)
295
+ if (objectKeys.length === 0) {
296
+ continue
297
+ }
298
+
299
+ // 递归清理对象内部
300
+ const cleanedObject = {}
301
+ let hasValidValue = false
302
+
303
+ for (const objKey of objectKeys) {
304
+ const objValue = value[objKey]
305
+ if (objValue !== null && objValue !== undefined && objValue !== '') {
306
+ cleanedObject[objKey] = objValue
307
+ hasValidValue = true
308
+ }
309
+ }
310
+
311
+ // 只有当对象有有效值时才添加
312
+ if (hasValidValue) {
313
+ cleanedParams[key] = cleanedObject
314
+ }
315
+ continue
316
+ }
317
+
318
+ // 处理基本类型
319
+ if (value !== null && value !== undefined && value !== '') {
320
+ cleanedParams[key] = value
321
+ }
322
+ }
323
+
324
+ return cleanedParams
325
+ }
326
+
327
+ // 确认筛选条件
328
+ function confirmOption() {
329
+ const isCheck = checkOrderOption()
330
+ if (isCheck) {
331
+ // 清理查询条件参数
332
+ const cleanedParams = cleanConditionParams(conditionParams.value)
333
+
334
+ const isEmptyObject = Object.keys(cleanedParams).length === 0
335
+ emit('update:conditionParams', isEmptyObject ? undefined : cleanedParams)
336
+ emit('onRefresh', {})
337
+ listFilterMenu.value.close(false)
338
+ }
339
+ }
340
+
341
+ // 处理筛选菜单显示
342
+ function handleFilterMenuChange(value: boolean) {
343
+ filterMenuShow.value = value
344
+ if (value) {
345
+ scanMenuShow.value = false
346
+ showScanner.value = false
347
+ }
348
+ }
349
+
350
+ // 处理关闭扫描按钮点击
351
+ function handleCloseScanButton() {
352
+ listFilterMenu.value.close(false)
353
+ }
354
+
355
+ // 按钮权限信息筛选
356
+ function filterButtonPermissions(btn) {
357
+ return props.buttonPermissions.find(item => item.btnName === btn)
358
+ }
359
+ </script>
360
+
361
+ <template>
362
+ <div id="XCellListFilter">
363
+ <div class="filter-buttons">
364
+ <VanDropdownMenu ref="listFilterMenu" :close-on-click-outside="false" class="filter-dropdown-menu">
365
+ <VanDropdownItem v-if="showScanButton" v-model="scanMenuShow" @change="handleScanMenuChange">
366
+ <template #title>
367
+ <div class="filter-icon-box">
368
+ <Icon icon="ri:qr-scan-2-line" :width="24" />
369
+ </div>
370
+ </template>
371
+
372
+ <!-- 显示选项卡 -->
373
+ <div class="scan-tab-wrapper">
374
+ <div class="dropdown-title">
375
+ <VanIcon name="scan" class="title-icon" />
376
+ <span class="title-text">扫码功能</span>
377
+ </div>
378
+ <div class="scan-tabs">
379
+ <!-- 动态生成扫描模式选项卡 -->
380
+ <div
381
+ v-for="mode in enabledScanModes"
382
+ :key="mode"
383
+ class="scan-tab-item"
384
+ :class="{ active: scanType === mode }"
385
+ @click="switchToMode(mode)"
386
+ >
387
+ <VanIcon :name="SCAN_MODE_CONFIGS[mode].icon" class="tab-icon" />
388
+ {{ SCAN_MODE_CONFIGS[mode].title }}
389
+ </div>
390
+ </div>
391
+ </div>
392
+
393
+ <!-- 动态显示当前选中的扫描组件 -->
394
+ <div v-if="showScanner" class="scanORnfc">
395
+ <component
396
+ :is="SCAN_MODE_CONFIGS[scanType].component"
397
+ @close="handleCloseScanButton"
398
+ />
399
+ </div>
400
+
401
+ <div class="closeItem">
402
+ <VanButton
403
+ type="primary"
404
+ size="normal"
405
+ class="close-scan-btn"
406
+ icon="cross"
407
+ @click="handleCloseScanButton"
408
+ >
409
+ {{ SCAN_MODE_CONFIGS[scanType].closeText }}
410
+ </VanButton>
411
+ </div>
412
+ </VanDropdownItem>
413
+
414
+ <!-- 筛选按钮 -->
415
+ <VanDropdownItem v-if="!props.buttonState || props.buttonState.filter !== false" v-model="filterMenuShow" @change="handleFilterMenuChange">
416
+ <template #title>
417
+ <div class="filter-icon-box">
418
+ <Icon icon="mdi:filter" :width="24" />
419
+ </div>
420
+ </template>
421
+ <div class="dropdown-title">
422
+ <VanIcon name="filter-o" class="title-icon" />
423
+ <span class="title-text">筛选条件</span>
424
+ </div>
425
+ <div class="order-condition">
426
+ <template v-if="props.orderList.length > 0">
427
+ <VanRow justify="space-between" class="filter-title">
428
+ <VanCol span="10">
429
+ 排序字段
430
+ </VanCol>
431
+ <!-- <VanCol span="2">
432
+ <div class="reset-item" @click.stop="currentOrderVal = undefined">
433
+ 重置
434
+ </div>
435
+ </VanCol> -->
436
+ </VanRow>
437
+ <XGridDropOption :columns="props.orderList" :columns-field-names="colFieldNames" />
438
+ <VanRow justify="space-between" class="filter-title">
439
+ <VanCol span="10">
440
+ 排序规则
441
+ </VanCol>
442
+ <!-- <VanCol span="2">
443
+ <div class="reset-item" @click.stop="currentSortordVal = undefined">
444
+ 重置
445
+ </div>
446
+ </VanCol> -->
447
+ </VanRow>
448
+ <XGridDropOption :columns="sortordList" :columns-field-names="colFieldNames" />
449
+ </template>
450
+ <template v-for="(item, index) in props.formQuery" :key="`${item.model}${index}`">
451
+ <VanRow justify="space-between" class="filter-title">
452
+ <VanCol span="10">
453
+ {{ item.name }}
454
+ </VanCol>
455
+ <!-- <VanCol span="2">
456
+ <div class="reset-item" @click.stop="resetOptionItem(item.model)">
457
+ 重置
458
+ </div>
459
+ </VanCol> -->
460
+ </VanRow>
461
+ <XFormItem
462
+ ref="formItemRefs"
463
+ v-model="conditionParams[item.model]"
464
+ :form="conditionParams"
465
+ :attr="item"
466
+ :service-name="props.serviceName"
467
+ :show-label="false"
468
+ />
469
+ </template>
470
+ </div>
471
+ <div class="operations-panel">
472
+ <VanButton type="default" @click="resetOption">
473
+ 重置
474
+ </VanButton>
475
+ <VanButton type="primary" @click="confirmOption">
476
+ 查询
477
+ </VanButton>
478
+ </div>
479
+ </VanDropdownItem>
480
+ </VanDropdownMenu>
481
+ </div>
482
+ </div>
483
+ </template>
484
+
485
+ <style scoped lang="less">
486
+ #XCellListFilter {
487
+ --van-cell-horizontal-padding: 0;
488
+ width: 100%;
489
+ .filter-buttons {
490
+ display: flex;
491
+ align-items: center;
492
+ justify-content: flex-end;
493
+ gap: 8px;
494
+ }
495
+
496
+ .dropdown-title {
497
+ padding: 16px;
498
+ background-color: #fff;
499
+ border-bottom: 1px solid #ebedf0;
500
+ margin-bottom: 8px;
501
+ display: flex;
502
+ align-items: center;
503
+ gap: 8px;
504
+ .title-icon {
505
+ font-size: 20px;
506
+ color: #646566;
507
+ }
508
+ .title-text {
509
+ font-size: 18px;
510
+ font-weight: 600;
511
+ color: #323233;
512
+ line-height: 1.4;
513
+ }
514
+ }
515
+
516
+ .scan-tab-wrapper {
517
+ padding: 0;
518
+ background-color: #fff;
519
+ .scan-tabs {
520
+ display: flex;
521
+ background: #f5f5f5;
522
+ border-radius: 8px;
523
+ padding: 2px;
524
+ margin-top: 8px;
525
+ .scan-tab-item {
526
+ flex: 1;
527
+ height: 44px;
528
+ display: flex;
529
+ align-items: center;
530
+ justify-content: center;
531
+ font-size: 15px;
532
+ color: #646566;
533
+ cursor: pointer;
534
+ border-radius: 6px;
535
+ gap: 4px;
536
+
537
+ .tab-icon {
538
+ font-size: 20px;
539
+ }
540
+
541
+ &.active {
542
+ background-color: #1989fa;
543
+ color: #fff;
544
+ .tab-icon {
545
+ color: #fff;
546
+ }
547
+ }
548
+ }
549
+ }
550
+ }
551
+
552
+ .filter-dropdown-menu {
553
+ :deep(.van-dropdown-menu__bar) {
554
+ box-shadow: none;
555
+ height: auto;
556
+ position: relative;
557
+ z-index: 1;
558
+ }
559
+ :deep(.van-dropdown-menu__item) {
560
+ display: flex;
561
+ align-items: center;
562
+ justify-content: center;
563
+ position: relative;
564
+ z-index: 1;
565
+ }
566
+ // 隐藏下拉箭头
567
+ :deep(.van-dropdown-menu__title::after) {
568
+ display: none !important;
569
+ }
570
+ // 下拉菜单内容
571
+ :deep(.van-dropdown-item__content) {
572
+ position: fixed;
573
+ z-index: 10;
574
+ background-color: white;
575
+ }
576
+ // 下拉菜单遮罩层
577
+ :deep(.van-overlay) {
578
+ z-index: 9;
579
+ }
580
+ }
581
+
582
+ .filter-icon-box {
583
+ display: flex;
584
+ align-items: center;
585
+ justify-content: center;
586
+ width: 40px;
587
+ height: 40px;
588
+ border-radius: 10px;
589
+ background-color: rgba(245, 245, 245);
590
+ cursor: pointer;
591
+ position: relative;
592
+ z-index: 1;
593
+ &:active {
594
+ opacity: 0.7;
595
+ }
596
+ }
597
+ .order-condition {
598
+ padding: 0 16px 16px;
599
+ max-height: calc(var(--van-picker-toolbar-height) + var(--van-padding-base) + var(--van-tabs-line-height) + 35vh);
600
+ overflow-y: auto;
601
+ width: 100%;
602
+ background-color: white;
603
+ .filter-title {
604
+ height: 2rem;
605
+ font-size: 13px;
606
+ font-weight: 600;
607
+ line-height: 2rem;
608
+ margin: 5px 5px 1px 0px;
609
+ color: black;
610
+ }
611
+ .range-picker-list {
612
+ .range-picker-title {
613
+ height: 2rem;
614
+ font-size: 13px;
615
+ font-weight: 600;
616
+ line-height: 2rem;
617
+ margin: 5px 1rem 1px 1rem;
618
+ color: black;
619
+ }
620
+ .range-picker-time {
621
+ display: inline-block;
622
+ background: #f8f8f8;
623
+ border-radius: 8px;
624
+ font-size: 13px;
625
+ margin: 0 1rem;
626
+ height: 2rem;
627
+ line-height: 2rem;
628
+ width: 40vw;
629
+ text-align: center;
630
+ }
631
+ /* 已完成选择的时间 */
632
+ .active-picker-time {
633
+ color: blue;
634
+ }
635
+ }
636
+ /* 重置元素按钮 */
637
+ .reset-item {
638
+ font-weight: 500;
639
+ color: blue;
640
+ }
641
+ }
642
+ /* 下拉菜单的操作面板 */
643
+ .operations-panel {
644
+ display: flex;
645
+ overflow: hidden;
646
+ user-select: none;
647
+ padding: 10px;
648
+ gap: 12px;
649
+
650
+ & > .van-button {
651
+ flex: 1;
652
+ margin: 0;
653
+
654
+ //&:first-child {
655
+ // margin-right: 12px;
656
+ //}
657
+ }
658
+ }
659
+ /* 时间范围组件 */
660
+ .rangePicker-comp-box {
661
+ :deep(.van-calendar) {
662
+ height: 58vh;
663
+ }
664
+ :deep(.van-calendar__header-title) {
665
+ background-color: rgba(25, 137, 250, 0.1);
666
+ height: 8vh;
667
+ line-height: 8vh;
668
+ }
669
+ :deep(.van-calendar__month-mark) {
670
+ color: rgba(25, 137, 250, 0.1);
671
+ }
672
+ }
673
+ .scanORnfc {
674
+ height: 50vh;
675
+ width: 100%;
676
+ position: relative;
677
+ background-color: #f0f0f0;
678
+ border-radius: 8px;
679
+ }
680
+ .closeItem {
681
+ display: flex;
682
+ justify-content: center;
683
+ margin-top: 16px;
684
+ margin-bottom: 20px;
685
+
686
+ .close-scan-btn {
687
+ width: 140px;
688
+ height: 40px;
689
+ background-color: #1989fa;
690
+ border-radius: 4px;
691
+ font-size: 14px;
692
+ border: none;
693
+ display: flex;
694
+ align-items: center;
695
+ justify-content: center;
696
+ padding: 0;
697
+
698
+ :deep(.van-button__icon) {
699
+ margin-right: 4px;
700
+ font-size: 16px;
701
+ }
702
+ }
703
+ }
704
+ }
705
+ </style>