mp_objList.html 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta
  6. name="viewport"
  7. content="width=device-width, initial-scale=1.0, user-scalable=no"
  8. />
  9. <title>列表</title>
  10. <!-- 引入基础依赖(统一由 base.js 动态注入其他依赖) -->
  11. <script src="/js/mp_base/base.js?v=20261201-list-return-v1"></script>
  12. <style>
  13. #app {
  14. background: #f5f5f5;
  15. min-height: 100vh;
  16. }
  17. /* 防止Vue模板闪烁 */
  18. [v-cloak] {
  19. display: none !important;
  20. }
  21. /* 搜索筛选区域 */
  22. .search-filter-container {
  23. background: #f5f5f5;
  24. padding: 15px;
  25. position: sticky;
  26. top: 0;
  27. z-index: 100;
  28. display: flex;
  29. justify-content: flex-end;
  30. flex-wrap: wrap;
  31. gap: 10px;
  32. }
  33. .search-filter-container .ss-select-container {
  34. border: 1px solid #ccc;
  35. border-radius: 4px;
  36. padding: 0 10px;
  37. height: 34px;
  38. box-sizing: border-box;
  39. }
  40. /* 加载状态 */
  41. .loading-container {
  42. display: flex;
  43. flex-direction: column;
  44. align-items: center;
  45. justify-content: center;
  46. height: 200px;
  47. color: #666;
  48. }
  49. .loading-spinner {
  50. width: 40px;
  51. height: 40px;
  52. border: 4px solid #f3f3f3;
  53. border-top: 4px solid #40ac6d;
  54. border-radius: 50%;
  55. animation: spin 1s linear infinite;
  56. margin-bottom: 15px;
  57. }
  58. @keyframes spin {
  59. 0% {
  60. transform: rotate(0deg);
  61. }
  62. 100% {
  63. transform: rotate(360deg);
  64. }
  65. }
  66. .loading-text {
  67. font-size: 14px;
  68. }
  69. /* 列表容器 */
  70. .list-container {
  71. padding: 0 15px;
  72. }
  73. /* 空状态 */
  74. .empty-state {
  75. text-align: center;
  76. padding: 60px 20px;
  77. color: #999;
  78. }
  79. .empty-icon {
  80. font-size: 48px;
  81. margin-bottom: 15px;
  82. }
  83. .empty-text {
  84. font-size: 16px;
  85. }
  86. /* 卡片内容样式 - 按照小程序list.vue转换 */
  87. .card-content {
  88. display: flex;
  89. align-items: flex-start;
  90. gap: 12px;
  91. }
  92. .card-media {
  93. flex: 0 0 68px;
  94. }
  95. .card-avatar {
  96. width: 68px;
  97. height: 90px;
  98. display: block;
  99. object-fit: cover;
  100. border-radius: 8px;
  101. background: #eef2f3;
  102. }
  103. .card-body {
  104. min-width: 0;
  105. flex: 1;
  106. }
  107. .card-content .card-header {
  108. margin-bottom: 10px; /* 20rpx -> 10px */
  109. }
  110. .card-content .card-title {
  111. font-size: 16px; /* 32rpx -> 16px */
  112. font-weight: bold;
  113. color: #333;
  114. }
  115. .card-content .card-description {
  116. font-size: 14px; /* 28rpx -> 14px */
  117. color: #666;
  118. margin-bottom: 8px; /* 15rpx -> 8px */
  119. }
  120. .card-content .attribute-group {
  121. display: flex;
  122. flex-wrap: wrap;
  123. column-gap: 10px; /* 20rpx -> 10px */
  124. }
  125. .card-content .attribute-item {
  126. display: flex;
  127. margin-bottom: 5px; /* 10rpx -> 5px */
  128. }
  129. .card-content .attr-label {
  130. font-size: 13px; /* 26rpx -> 13px */
  131. color: #999;
  132. }
  133. .card-content .attr-value {
  134. font-size: 13px; /* 26rpx -> 13px */
  135. color: #333;
  136. flex: 1;
  137. }
  138. .card-content .attribute-group.attribute-group--stacked {
  139. flex-direction: column;
  140. column-gap: 0;
  141. }
  142. .card-content .attribute-group--stacked .attribute-item {
  143. display: flex;
  144. align-items: flex-start;
  145. width: 100%;
  146. margin-bottom: 6px;
  147. font-size: 15px;
  148. line-height: 1.45;
  149. }
  150. .card-content .attribute-group--stacked .attribute-item:last-child {
  151. margin-bottom: 0;
  152. }
  153. .card-content .attribute-group--stacked .attr-value {
  154. min-width: 0;
  155. word-break: break-all;
  156. }
  157. .card-content .attribute-group--stacked .attr-label,
  158. .card-content .attribute-group--stacked .attr-value {
  159. font-size: 15px;
  160. line-height: 1.45;
  161. }
  162. /* 状态文本样式 */
  163. .status-text {
  164. font-weight: bold;
  165. }
  166. /* 加载更多提示样式 */
  167. .load-more-container {
  168. text-align: center;
  169. padding: 20px;
  170. color: #999;
  171. font-size: 14px;
  172. }
  173. .load-more-loading {
  174. color: #007aff;
  175. }
  176. .load-more-end {
  177. color: #999;
  178. }
  179. .load-more-tip {
  180. color: #ccc;
  181. }
  182. /* 回到顶部按钮 */
  183. .back-to-top-btn {
  184. width: 50px;
  185. height: 50px;
  186. border-radius: 50%;
  187. background: rgba(87, 93, 109, 0.5);
  188. display: flex;
  189. justify-content: center;
  190. align-items: center;
  191. position: fixed;
  192. bottom: 200px;
  193. right: 15px;
  194. cursor: pointer;
  195. transition: all 0.3s ease;
  196. z-index: 999;
  197. }
  198. .back-to-top-btn:active {
  199. transform: scale(0.9);
  200. }
  201. .back-to-top-inner {
  202. width: 42px;
  203. height: 42px;
  204. border-radius: 50%;
  205. background: rgba(87, 93, 109, 0.5);
  206. display: flex;
  207. justify-content: center;
  208. align-items: center;
  209. }
  210. /* 搜索弹窗 */
  211. .search-modal-mask {
  212. position: fixed;
  213. top: 0;
  214. left: 0;
  215. right: 0;
  216. bottom: 0;
  217. background: rgba(0, 0, 0, 0.5);
  218. z-index: 1000;
  219. display: flex;
  220. align-items: flex-end;
  221. }
  222. .search-modal-content {
  223. width: 100%;
  224. background: white;
  225. animation: slideUp 0.3s ease-out;
  226. /* 让键盘弹起时自动上移 */
  227. position: relative;
  228. }
  229. @keyframes slideUp {
  230. from {
  231. transform: translateY(100%);
  232. }
  233. to {
  234. transform: translateY(0);
  235. }
  236. }
  237. .search-input-container {
  238. display: flex;
  239. align-items: center;
  240. height: 50px;
  241. background: white;
  242. border-top: 1px solid #e5e5e5;
  243. /* 适配iPhone底部安全区域 */
  244. /* padding-bottom: env(safe-area-inset-bottom); */
  245. }
  246. .search-input {
  247. flex: 1;
  248. height: 100%;
  249. border: none;
  250. padding: 0 15px;
  251. font-size: 16px;
  252. outline: none;
  253. background: transparent;
  254. }
  255. .search-divider {
  256. width: 1px;
  257. height: 30px;
  258. background: #d5d8dc;
  259. }
  260. .search-icon-btn {
  261. width: 60px;
  262. height: 100%;
  263. display: flex;
  264. align-items: center;
  265. justify-content: center;
  266. cursor: pointer;
  267. background: transparent;
  268. border: none;
  269. padding: 0;
  270. }
  271. .search-icon-btn:active {
  272. background: #f5f5f5;
  273. }
  274. </style>
  275. </head>
  276. <body>
  277. <div id="app" v-cloak>
  278. <!-- 搜索和筛选区域 -->
  279. <div class="search-filter-container">
  280. <!-- 动态下拉选择器 -->
  281. <template
  282. v-for="(options, fieldName) in filterSelectOptions"
  283. :key="fieldName"
  284. >
  285. <ss-select
  286. v-model="selectedFilters[fieldName]"
  287. :placeholder="`选择${getFieldDesc(fieldName)}`"
  288. :options="options"
  289. width="132px"
  290. inp="true"
  291. @change="handleFilterChange"
  292. >
  293. </ss-select>
  294. </template>
  295. <!-- 完全由buttonList决定的动态按钮组 -->
  296. <ss-search-button
  297. v-for="(button, index) in buttonList"
  298. :key="index"
  299. :text="getButtonText(button)"
  300. :options="getButtonOptions(button)"
  301. :suffix-icon="getButtonOptions(button).length > 1 ? 'icon-xiala' : ''"
  302. @click="handleButtonClick(button)"
  303. >
  304. </ss-search-button>
  305. </div>
  306. <!-- 加载状态 -->
  307. <div v-if="loading" class="loading-container">
  308. <div class="loading-spinner"></div>
  309. <div class="loading-text">加载中...</div>
  310. </div>
  311. <!-- 列表区域 -->
  312. <div v-else class="list-container">
  313. <!-- 空状态 -->
  314. <div v-if="list.length === 0" class="empty-state">
  315. <div class="empty-text">暂无数据</div>
  316. </div>
  317. <!-- 数据列表 -->
  318. <div v-else>
  319. <ss-card
  320. v-for="(item, index) in list"
  321. :key="index"
  322. :item="item"
  323. @click="handleCardClick(item)"
  324. @button-click="handleCardAction"
  325. >
  326. <!-- 卡片内容 - 按照小程序list.vue的结构,使用API数据 -->
  327. <div class="card-content">
  328. <div v-if="item.thumbPath" class="card-media">
  329. <img
  330. class="card-avatar"
  331. :src="item.thumbUrl"
  332. :alt="item.firstDisplay || '头像'"
  333. @error="handleThumbError"
  334. />
  335. </div>
  336. <div class="card-body">
  337. <!-- 主标题 (first) -->
  338. <div class="card-header" v-if="item.firstDisplay">
  339. <div class="card-title">{{ item.firstDisplay }}</div>
  340. </div>
  341. <!-- 描述 (second) -->
  342. <div class="card-description" v-if="item.secondDisplay">
  343. {{ item.secondDisplay }}
  344. </div>
  345. <!-- 属性列表 (third) -->
  346. <div
  347. class="card-attributes"
  348. v-if="item.thirdDisplay && item.thirdDisplay.length > 0"
  349. >
  350. <div
  351. v-for="(group, groupIndex) in item.thirdDisplay"
  352. :key="groupIndex"
  353. class="attribute-group"
  354. :class="{ 'attribute-group--stacked': item.stackedAttributes }"
  355. >
  356. <div
  357. v-for="(attr, attrIndex) in group"
  358. :key="attrIndex"
  359. class="attribute-item"
  360. >
  361. <span class="attr-label">{{ attr.field.desc }}:</span>
  362. <span class="attr-value">{{ attr.displayValue }}</span>
  363. </div>
  364. </div>
  365. </div>
  366. </div>
  367. </div>
  368. </ss-card>
  369. </div>
  370. </div>
  371. <!-- 加载更多提示 -->
  372. <div class="load-more-container" v-if="list.length > 0">
  373. <div v-if="isLoadingMore" class="load-more-loading">
  374. <span>正在加载更多...</span>
  375. </div>
  376. <div v-else-if="!hasMore" class="load-more-end">
  377. <span>没有更多数据了</span>
  378. </div>
  379. <div v-else class="load-more-tip">
  380. <span>滚动到底部加载更多</span>
  381. </div>
  382. </div>
  383. <!-- 回到顶部按钮 -->
  384. <div
  385. v-if="showBackToTop"
  386. class="back-to-top-btn"
  387. @touchstart="handleLongPressStart"
  388. @touchend="handleLongPressEnd"
  389. @touchcancel="handleLongPressCancel"
  390. @click.prevent="handleBackToTopClick"
  391. >
  392. <div class="back-to-top-inner">
  393. <Icon name="icon-huidaodingbu" size="40" color="#fff"></Icon>
  394. </div>
  395. </div>
  396. <!-- 搜索弹窗 -->
  397. <div
  398. v-if="showSearchModal"
  399. class="search-modal-mask"
  400. @click="closeSearchModal"
  401. >
  402. <div class="search-modal-content" @click.stop>
  403. <div class="search-input-container">
  404. <input
  405. ref="searchInput"
  406. v-model="searchKeyword"
  407. type="search"
  408. inputmode="search"
  409. class="search-input"
  410. placeholder="请输入关键词"
  411. @keyup.enter="performSearch"
  412. autocomplete="off"
  413. />
  414. <div class="search-divider"></div>
  415. <button class="search-icon-btn" @click="performSearch">
  416. <Icon name="icon-chazhao" size="24" color="#575d6d"></Icon>
  417. </button>
  418. </div>
  419. </div>
  420. </div>
  421. </div>
  422. <script>
  423. // 等待SS框架加载完成
  424. window.SS.ready(function () {
  425. // 使用SS框架的方式创建Vue实例
  426. window.SS.dom.initializeFormApp({
  427. el: "#app",
  428. data() {
  429. return {
  430. // 加载状态
  431. loading: true,
  432. // 列表数据
  433. list: [],
  434. originalList: [], // 原始数据,用于筛选
  435. // 分页相关
  436. currentPage: 1,
  437. pageSize: 10,
  438. hasMore: true,
  439. isLoadingMore: false,
  440. // 页面参数
  441. pageParams: {},
  442. service: "", // init服务名称
  443. // 功能说明:对接PC两段式接口(init 返回 home/list 服务名) by xu 2026-02-28
  444. ssSearchPobjHomeServName: "",
  445. ssSearchPobjListServName: "",
  446. // API返回的动态配置
  447. buttonList: [],
  448. fieldsList: [],
  449. ssPaging: null,
  450. // 动态搜索筛选选项
  451. filterOptions: [],
  452. sortOptions: [],
  453. // 下拉选择器数据
  454. selectedFilters: {}, // 动态筛选条件
  455. filterSelectOptions: {}, // 各个筛选字段的选项
  456. // 字典缓存
  457. dictCache: new Map(),
  458. // 显示字段配置 - 根据service动态设置
  459. displayFields: [],
  460. // 卡片操作按钮
  461. cardActions: [
  462. { text: "查看", name: "view" },
  463. { text: "编辑", name: "edit" },
  464. ],
  465. // 回到顶部按钮
  466. showBackToTop: false,
  467. // 是否存在关键词搜索
  468. hasKeyWord: false,
  469. // 搜索相关
  470. showSearchModal: false,
  471. searchKeyword: "",
  472. // 长按相关
  473. longPressTimer: null,
  474. isLongPress: false,
  475. };
  476. },
  477. mounted() {
  478. // 页面加载时初始化
  479. this.initPage();
  480. // 监听页面刷新通知
  481. this.setupRefreshListener();
  482. window.addEventListener("pageshow", this.handleListPageShow);
  483. document.addEventListener("visibilitychange", this.handleListPageVisibility);
  484. // 监听滚动事件,实现滚动加载
  485. this.setupScrollListener();
  486. // 开发模式:加载Mock数据(测试用)
  487. // this.loadMockData();
  488. },
  489. beforeUnmount() {
  490. // 清理刷新监听器
  491. if (this.refreshCleanup) {
  492. this.refreshCleanup();
  493. }
  494. // 清理滚动监听器
  495. if (this.scrollCleanup) {
  496. this.scrollCleanup();
  497. }
  498. window.removeEventListener("pageshow", this.handleListPageShow);
  499. document.removeEventListener("visibilitychange", this.handleListPageVisibility);
  500. },
  501. methods: {
  502. // 加载Mock数据(用于开发测试)
  503. loadMockData() {
  504. console.log("🎭 加载Mock数据...");
  505. const mockData = [
  506. {
  507. firstDisplay: "张三 - 2024级计算机科学与技术1班",
  508. secondDisplay: "学号:2024001 | 手机:138****1234",
  509. thirdDisplay: [
  510. [
  511. { field: { desc: "性别" }, displayValue: "男" },
  512. { field: { desc: "年龄" }, displayValue: "20" },
  513. { field: { desc: "状态" }, displayValue: "在读" },
  514. ],
  515. [
  516. {
  517. field: { desc: "入学时间" },
  518. displayValue: "2024-09-01",
  519. },
  520. { field: { desc: "辅导员" }, displayValue: "王老师" },
  521. ],
  522. ],
  523. },
  524. {
  525. firstDisplay: "李四 - 2024级软件工程2班",
  526. secondDisplay: "学号:2024002 | 手机:139****5678",
  527. thirdDisplay: [
  528. [
  529. { field: { desc: "性别" }, displayValue: "女" },
  530. { field: { desc: "年龄" }, displayValue: "19" },
  531. { field: { desc: "状态" }, displayValue: "在读" },
  532. ],
  533. [
  534. {
  535. field: { desc: "入学时间" },
  536. displayValue: "2024-09-01",
  537. },
  538. { field: { desc: "辅导员" }, displayValue: "李老师" },
  539. ],
  540. ],
  541. },
  542. {
  543. firstDisplay: "王五 - 2023级人工智能1班",
  544. secondDisplay: "学号:2023003 | 手机:136****9012",
  545. thirdDisplay: [
  546. [
  547. { field: { desc: "性别" }, displayValue: "男" },
  548. { field: { desc: "年龄" }, displayValue: "21" },
  549. { field: { desc: "状态" }, displayValue: "在读" },
  550. ],
  551. [
  552. {
  553. field: { desc: "入学时间" },
  554. displayValue: "2023-09-01",
  555. },
  556. { field: { desc: "辅导员" }, displayValue: "赵老师" },
  557. ],
  558. ],
  559. },
  560. {
  561. firstDisplay: "赵六 - 2024级数据科学与大数据技术1班",
  562. secondDisplay: "学号:2024004 | 手机:137****3456",
  563. thirdDisplay: [
  564. [
  565. { field: { desc: "性别" }, displayValue: "女" },
  566. { field: { desc: "年龄" }, displayValue: "20" },
  567. { field: { desc: "状态" }, displayValue: "在读" },
  568. ],
  569. [
  570. {
  571. field: { desc: "入学时间" },
  572. displayValue: "2024-09-01",
  573. },
  574. { field: { desc: "辅导员" }, displayValue: "刘老师" },
  575. ],
  576. ],
  577. },
  578. {
  579. firstDisplay: "钱七 - 2023级网络工程1班",
  580. secondDisplay: "学号:2023005 | 手机:135****7890",
  581. thirdDisplay: [
  582. [
  583. { field: { desc: "性别" }, displayValue: "男" },
  584. { field: { desc: "年龄" }, displayValue: "21" },
  585. { field: { desc: "状态" }, displayValue: "休学" },
  586. ],
  587. [
  588. {
  589. field: { desc: "入学时间" },
  590. displayValue: "2023-09-01",
  591. },
  592. { field: { desc: "辅导员" }, displayValue: "周老师" },
  593. ],
  594. ],
  595. },
  596. {
  597. firstDisplay: "孙八 - 2024级信息安全1班",
  598. secondDisplay: "学号:2024006 | 手机:133****2468",
  599. thirdDisplay: [
  600. [
  601. { field: { desc: "性别" }, displayValue: "女" },
  602. { field: { desc: "年龄" }, displayValue: "19" },
  603. { field: { desc: "状态" }, displayValue: "在读" },
  604. ],
  605. [
  606. {
  607. field: { desc: "入学时间" },
  608. displayValue: "2024-09-01",
  609. },
  610. { field: { desc: "辅导员" }, displayValue: "吴老师" },
  611. ],
  612. ],
  613. },
  614. {
  615. firstDisplay: "周九 - 2023级物联网工程1班",
  616. secondDisplay: "学号:2023007 | 手机:188****1357",
  617. thirdDisplay: [
  618. [
  619. { field: { desc: "性别" }, displayValue: "男" },
  620. { field: { desc: "年龄" }, displayValue: "22" },
  621. { field: { desc: "状态" }, displayValue: "在读" },
  622. ],
  623. [
  624. {
  625. field: { desc: "入学时间" },
  626. displayValue: "2023-09-01",
  627. },
  628. { field: { desc: "辅导员" }, displayValue: "郑老师" },
  629. ],
  630. ],
  631. },
  632. {
  633. firstDisplay: "吴十 - 2024级云计算1班",
  634. secondDisplay: "学号:2024008 | 手机:189****2468",
  635. thirdDisplay: [
  636. [
  637. { field: { desc: "性别" }, displayValue: "女" },
  638. { field: { desc: "年龄" }, displayValue: "20" },
  639. { field: { desc: "状态" }, displayValue: "在读" },
  640. ],
  641. [
  642. {
  643. field: { desc: "入学时间" },
  644. displayValue: "2024-09-01",
  645. },
  646. { field: { desc: "辅导员" }, displayValue: "冯老师" },
  647. ],
  648. ],
  649. },
  650. {
  651. firstDisplay: "郑十一 - 2023级区块链工程1班",
  652. secondDisplay: "学号:2023009 | 手机:180****3691",
  653. thirdDisplay: [
  654. [
  655. { field: { desc: "性别" }, displayValue: "男" },
  656. { field: { desc: "年龄" }, displayValue: "21" },
  657. { field: { desc: "状态" }, displayValue: "在读" },
  658. ],
  659. [
  660. {
  661. field: { desc: "入学时间" },
  662. displayValue: "2023-09-01",
  663. },
  664. { field: { desc: "辅导员" }, displayValue: "陈老师" },
  665. ],
  666. ],
  667. },
  668. {
  669. firstDisplay: "王十二 - 2024级电子商务1班",
  670. secondDisplay: "学号:2024010 | 手机:181****4802",
  671. thirdDisplay: [
  672. [
  673. { field: { desc: "性别" }, displayValue: "女" },
  674. { field: { desc: "年龄" }, displayValue: "19" },
  675. { field: { desc: "状态" }, displayValue: "在读" },
  676. ],
  677. [
  678. {
  679. field: { desc: "入学时间" },
  680. displayValue: "2024-09-01",
  681. },
  682. { field: { desc: "辅导员" }, displayValue: "褚老师" },
  683. ],
  684. ],
  685. },
  686. {
  687. firstDisplay: "陈十三 - 2023级金融科技1班",
  688. secondDisplay: "学号:2023011 | 手机:182****5913",
  689. thirdDisplay: [
  690. [
  691. { field: { desc: "性别" }, displayValue: "男" },
  692. { field: { desc: "年龄" }, displayValue: "22" },
  693. { field: { desc: "状态" }, displayValue: "毕业" },
  694. ],
  695. [
  696. {
  697. field: { desc: "入学时间" },
  698. displayValue: "2023-09-01",
  699. },
  700. { field: { desc: "辅导员" }, displayValue: "卫老师" },
  701. ],
  702. ],
  703. },
  704. {
  705. firstDisplay: "刘十四 - 2024级数字媒体技术1班",
  706. secondDisplay: "学号:2024012 | 手机:183****6024",
  707. thirdDisplay: [
  708. [
  709. { field: { desc: "性别" }, displayValue: "女" },
  710. { field: { desc: "年龄" }, displayValue: "20" },
  711. { field: { desc: "状态" }, displayValue: "在读" },
  712. ],
  713. [
  714. {
  715. field: { desc: "入学时间" },
  716. displayValue: "2024-09-01",
  717. },
  718. { field: { desc: "辅导员" }, displayValue: "蒋老师" },
  719. ],
  720. ],
  721. },
  722. ];
  723. // 设置数据
  724. this.list = mockData;
  725. this.originalList = [...mockData];
  726. this.loading = false;
  727. this.hasMore = false;
  728. console.log("✅ Mock数据加载完成,共", mockData.length, "条");
  729. },
  730. // 初始化页面
  731. async initPage() {
  732. try {
  733. console.log("🔄 初始化列表页面...");
  734. // 获取URL参数
  735. this.pageParams = this.getUrlParams();
  736. this.service = this.pageParams.service || "default";
  737. console.log("📋 页面参数:", this.pageParams);
  738. if (typeof window.ensureMiniProgramSessionFresh === "function") {
  739. try {
  740. await window.ensureMiniProgramSessionFresh({
  741. page: "mp_objList",
  742. service: this.service,
  743. force: this.isBzrXyService(this.service),
  744. });
  745. } catch (authError) {
  746. console.error("❌ H5会话刷新失败,停止加载列表:", authError);
  747. const message =
  748. "当前登录状态已过期,请重新登录后再进入学员列表。";
  749. if (typeof showToastEffect !== "undefined") {
  750. showToastEffect(message, 3000, "error");
  751. } else {
  752. this.showToast(message, "error");
  753. }
  754. return;
  755. }
  756. }
  757. // 功能说明:先调 init,再按 init 返回的 home/list 服务继续拉取数据 by xu 2026-02-28
  758. await this.loadInitAndHomeData();
  759. } catch (error) {
  760. console.log("❌ 页面初始化失败:", error);
  761. // this.showToast('页面初始化失败', 'error');
  762. } finally {
  763. this.loading = false;
  764. }
  765. },
  766. // 功能说明:调用 init 接口并解析 ssSearchPobjHomeServName/ssSearchPobjListServName by xu 2026-02-28
  767. async loadInitAndHomeData() {
  768. const initService = (this.service || "").trim();
  769. if (!initService) {
  770. await this.loadData(1, false);
  771. return;
  772. }
  773. const managementValue =
  774. this.resolveListManagementValue(initService);
  775. const initParams = {
  776. pageNo: 1,
  777. rowNumPer: this.pageSize,
  778. management: managementValue,
  779. isReady: "1",
  780. };
  781. const initResult = await request.post(
  782. `/service?ssServ=${initService}&management=${managementValue}&isReady=1`,
  783. initParams,
  784. {
  785. loading: false,
  786. formData: true,
  787. }
  788. );
  789. const initPayload = this.unwrapResponseData(
  790. this.extractResponseData(initResult)
  791. );
  792. this.ssSearchPobjHomeServName = String(
  793. initPayload?.ssSearchPobjHomeServName || ""
  794. ).trim();
  795. this.ssSearchPobjListServName = String(
  796. initPayload?.ssSearchPobjListServName || ""
  797. ).trim();
  798. if (
  799. !this.ssSearchPobjHomeServName &&
  800. !this.ssSearchPobjListServName
  801. ) {
  802. const derivedServices =
  803. this.deriveSearchServiceNames(initService);
  804. this.ssSearchPobjHomeServName = derivedServices.homeService;
  805. this.ssSearchPobjListServName = derivedServices.listService;
  806. }
  807. console.log("✅ init返回服务名:", {
  808. initService,
  809. ssSearchPobjHomeServName: this.ssSearchPobjHomeServName,
  810. ssSearchPobjListServName: this.ssSearchPobjListServName,
  811. });
  812. if (this.hasListPayload(initPayload)) {
  813. console.log("ℹ️ init接口直接返回列表数据,按列表结果处理");
  814. await this.processApiData(initPayload, false, initService);
  815. return;
  816. }
  817. const homeService = this.ssSearchPobjHomeServName || initService;
  818. await this.loadDataByService(homeService, 1, false);
  819. },
  820. // 功能说明:统一处理 /service 返回结构(兼容 {ssData} 与平铺结构) by xu 2026-02-28
  821. unwrapResponseData(data) {
  822. if (!data || typeof data !== "object") {
  823. return {};
  824. }
  825. const visited = new Set();
  826. let current = data;
  827. while (
  828. current &&
  829. typeof current === "object" &&
  830. !visited.has(current)
  831. ) {
  832. visited.add(current);
  833. if (current.ssData && typeof current.ssData === "object") {
  834. return current.ssData;
  835. }
  836. if (
  837. current.data &&
  838. typeof current.data === "object" &&
  839. current.data !== current
  840. ) {
  841. current = current.data;
  842. continue;
  843. }
  844. if (
  845. current.result &&
  846. typeof current.result === "object" &&
  847. !Array.isArray(current.result) &&
  848. current.result !== current
  849. ) {
  850. current = current.result;
  851. continue;
  852. }
  853. return current;
  854. }
  855. return {};
  856. },
  857. extractResponseData(result) {
  858. if (
  859. result &&
  860. typeof result === "object" &&
  861. Object.prototype.hasOwnProperty.call(result, "data")
  862. ) {
  863. return result.data;
  864. }
  865. return result;
  866. },
  867. hasListPayload(payload) {
  868. if (!payload || typeof payload !== "object") {
  869. return false;
  870. }
  871. return (
  872. Array.isArray(payload.objectList) ||
  873. Array.isArray(payload.objList) ||
  874. Array.isArray(payload.draftList)
  875. );
  876. },
  877. deriveSearchServiceNames(initService) {
  878. const normalized = String(initService || "").trim();
  879. if (!/_cx$/.test(normalized)) {
  880. return {
  881. homeService: "",
  882. listService: "",
  883. };
  884. }
  885. return {
  886. homeService: normalized.replace(/_cx$/, "_cxsy"),
  887. listService: normalized.replace(/_cx$/, "_cxlb"),
  888. };
  889. },
  890. // 功能说明:封装按指定 ssServ 拉取列表数据(home/list 共用) by xu 2026-02-28
  891. async loadDataByService(ssServ, pageNo = 1, isLoadMore = false) {
  892. const serviceName = String(ssServ || "").trim();
  893. if (!serviceName) {
  894. console.warn("⚠️ 缺少服务名,跳过请求");
  895. return;
  896. }
  897. // 防止重复加载:只有在非首次加载且正在加载时才阻止
  898. if (this.loading && !isLoadMore && this.list.length > 0) return;
  899. if (this.isLoadingMore && isLoadMore) return;
  900. try {
  901. console.log(
  902. `🔄 加载列表数据... 服务: ${serviceName}, 页码: ${pageNo}, 加载更多: ${isLoadMore}`
  903. );
  904. if (isLoadMore) {
  905. this.isLoadingMore = true;
  906. } else {
  907. this.loading = true;
  908. }
  909. const managementValue =
  910. this.resolveListManagementValue(serviceName);
  911. const requestParams = {
  912. pageNo: pageNo,
  913. rowNumPer: this.pageSize,
  914. management: managementValue,
  915. isReady: "1",
  916. // 功能说明:请求参数只保留有效筛选项(避免空值/旧值污染查询) by xu 2026-02-28
  917. ...this.getActiveFilterParams(this.selectedFilters),
  918. };
  919. const result = await request.post(
  920. `/service?ssServ=${serviceName}&management=${managementValue}&isReady=1`,
  921. requestParams,
  922. {
  923. loading: false,
  924. formData: true,
  925. }
  926. );
  927. console.log("✅ API响应数据:", result);
  928. const responseData = this.extractResponseData(result);
  929. if (responseData !== undefined && responseData !== null) {
  930. await this.processApiData(
  931. responseData,
  932. isLoadMore,
  933. serviceName
  934. );
  935. } else {
  936. console.warn("⚠️ API返回数据格式异常:", result);
  937. }
  938. } catch (error) {
  939. console.error("❌ 数据加载失败:", error);
  940. } finally {
  941. if (isLoadMore) {
  942. this.isLoadingMore = false;
  943. } else {
  944. this.loading = false;
  945. }
  946. }
  947. },
  948. // 加载数据
  949. async loadData(pageNo = 1, isLoadMore = false) {
  950. // 功能说明:翻页/筛选/搜索统一走 list 服务;未返回时回退 home/init by xu 2026-02-28
  951. const listService =
  952. this.ssSearchPobjListServName ||
  953. this.ssSearchPobjHomeServName ||
  954. this.service;
  955. await this.loadDataByService(listService, pageNo, isLoadMore);
  956. },
  957. // 处理API返回的数据
  958. async processApiData(
  959. data,
  960. isLoadMore = false,
  961. serviceName = ""
  962. ) {
  963. try {
  964. const payload = this.unwrapResponseData(data);
  965. const objectList = Array.isArray(payload.objectList)
  966. ? payload.objectList
  967. : Array.isArray(payload.objList)
  968. ? payload.objList
  969. : [];
  970. const draftList = Array.isArray(payload.draftList)
  971. ? payload.draftList
  972. : [];
  973. const combinedObjectList = draftList.concat(objectList);
  974. console.log("🔄 处理API数据...", {
  975. isLoadMore,
  976. objectListLength: combinedObjectList.length,
  977. fromObjList: Array.isArray(payload.objList),
  978. });
  979. // 保存API返回的配置信息
  980. if (!isLoadMore) {
  981. // 功能说明:列表接口通常不返回按钮/搜索字段,缺省时保留首屏(home)已加载配置,避免筛选后按钮消失 by xu 2026-02-28
  982. if (
  983. Array.isArray(payload.buttonList) ||
  984. Array.isArray(payload.rootFuncList)
  985. ) {
  986. this.buttonList =
  987. payload.buttonList || payload.rootFuncList || [];
  988. }
  989. if (
  990. Array.isArray(payload.fieldsList) ||
  991. Array.isArray(payload.searchFieldList)
  992. ) {
  993. this.fieldsList =
  994. payload.fieldsList || payload.searchFieldList || [];
  995. }
  996. }
  997. // ssPaging信息每次都要更新,因为包含当前页信息
  998. this.ssPaging = payload.ssPaging || this.ssPaging || null;
  999. // 功能说明:list接口未返回 hasKeyword 时沿用首屏值,避免长按搜索入口被错误隐藏 by xu 2026-02-28
  1000. if (
  1001. Object.prototype.hasOwnProperty.call(payload, "hasKeyWord") ||
  1002. Object.prototype.hasOwnProperty.call(payload, "hasKeyword")
  1003. ) {
  1004. this.hasKeyWord =
  1005. payload.hasKeyWord || payload.hasKeyword || false;
  1006. }
  1007. // 处理objectList数据
  1008. if (combinedObjectList.length > 0) {
  1009. // 使用field-formatter.js格式化列表数据
  1010. const formattedList = await window.formatObjectList(
  1011. combinedObjectList,
  1012. this.dictCache
  1013. );
  1014. // 功能说明:把后端 chg/chgRootFuncList 映射成卡片左滑操作按钮,标题取 desc,供 ss-card 左滑动作区使用 by xu 2026-03-06
  1015. const enhancedList = formattedList.map((item, index) => {
  1016. const rawItem = combinedObjectList[index] || {};
  1017. const rawActions =
  1018. Array.isArray(rawItem.chgRootFuncList) &&
  1019. rawItem.chgRootFuncList.length > 0
  1020. ? rawItem.chgRootFuncList
  1021. : rawItem.chg
  1022. ? [rawItem.chg]
  1023. : [];
  1024. const thumbPath =
  1025. item.thumbPath ||
  1026. window.pickObjectThumbPath?.(rawItem) ||
  1027. "";
  1028. const studentNoDisplay =
  1029. this.formatBzrXyStudentNoDisplay(
  1030. item,
  1031. rawItem,
  1032. serviceName
  1033. );
  1034. return {
  1035. ...item,
  1036. stackedAttributes:
  1037. this.isDisciplineAppearanceService(serviceName),
  1038. ...(studentNoDisplay
  1039. ? { secondDisplay: studentNoDisplay }
  1040. : {}),
  1041. ssObjId:
  1042. item.ssObjId ||
  1043. rawItem.ssObjId ||
  1044. rawItem.serviceParamData?.ssObjId ||
  1045. rawItem.play?.param_value ||
  1046. rawItem.ryid ||
  1047. rawItem.dxid ||
  1048. rawItem.id ||
  1049. "",
  1050. ssObjName:
  1051. item.ssObjName ||
  1052. rawItem.ssObjName ||
  1053. rawItem.dxm ||
  1054. "",
  1055. thumbPath,
  1056. thumbUrl: thumbPath
  1057. ? item.thumbUrl ||
  1058. window.resolveListImageUrl?.(thumbPath) ||
  1059. thumbPath
  1060. : "",
  1061. swipeActions: rawActions.map((action) => ({
  1062. ...action,
  1063. title: action.desc || action.title || "操作",
  1064. })),
  1065. };
  1066. });
  1067. const finalList = await this.enrichBzrXyThumbs(
  1068. enhancedList,
  1069. serviceName
  1070. );
  1071. if (isLoadMore) {
  1072. // 加载更多:追加到现有列表
  1073. this.list = [...this.list, ...finalList];
  1074. this.originalList = [...this.originalList, ...finalList];
  1075. } else {
  1076. // 首次加载或刷新:替换列表
  1077. this.originalList = finalList;
  1078. this.list = [...this.originalList];
  1079. }
  1080. console.log("✅ 列表数据处理完成:", this.list.length, "条");
  1081. // 更新分页状态
  1082. this.currentPage = isLoadMore ? this.currentPage + 1 : 1;
  1083. // 根据ssPaging信息判断是否还有更多数据
  1084. if (this.ssPaging && this.ssPaging.rowNum !== undefined) {
  1085. const totalRecords = this.ssPaging.rowNum;
  1086. const currentRecords = this.list.length;
  1087. this.hasMore = currentRecords < totalRecords;
  1088. console.log("📊 分页信息:", {
  1089. totalRecords,
  1090. currentRecords,
  1091. hasMore: this.hasMore,
  1092. currentPage: this.currentPage,
  1093. });
  1094. } else {
  1095. // 降级处理:根据当前页数据量判断
  1096. this.hasMore = formattedList.length >= this.pageSize;
  1097. console.log("⚠️ 使用降级分页判断:", {
  1098. returnedCount: formattedList.length,
  1099. pageSize: this.pageSize,
  1100. hasMore: this.hasMore,
  1101. });
  1102. }
  1103. } else {
  1104. // 没有更多数据
  1105. this.hasMore = false;
  1106. console.log("❌ 没有返回数据,设置hasMore为false");
  1107. }
  1108. // 根据fieldsList生成筛选选项(只在首次加载时生成)
  1109. if (!isLoadMore) {
  1110. await this.generateFilterOptions();
  1111. }
  1112. } catch (error) {
  1113. console.error("❌ 数据处理失败:", error);
  1114. throw error;
  1115. }
  1116. },
  1117. // 获取URL参数
  1118. getUrlParams() {
  1119. const params = {};
  1120. const urlSearchParams = new URLSearchParams(
  1121. window.location.search
  1122. );
  1123. for (const [key, value] of urlSearchParams) {
  1124. params[key] = decodeURIComponent(value);
  1125. }
  1126. return params;
  1127. },
  1128. isBzrXyService(serviceName) {
  1129. const candidateList = [
  1130. serviceName,
  1131. this.service,
  1132. this.pageParams?.service,
  1133. this.pageParams?.ssServ,
  1134. this.ssSearchPobjHomeServName,
  1135. this.ssSearchPobjListServName,
  1136. ];
  1137. return candidateList.some((candidate) =>
  1138. /^bzrXy(?:_|$)/.test(String(candidate || "").trim())
  1139. );
  1140. },
  1141. isSchoolRecordService(serviceName) {
  1142. const candidateList = [
  1143. serviceName,
  1144. this.service,
  1145. this.pageParams?.service,
  1146. this.pageParams?.ssServ,
  1147. this.ssSearchPobjHomeServName,
  1148. this.ssSearchPobjListServName,
  1149. ];
  1150. return candidateList.some((candidate) =>
  1151. /^(?:fjyrjc|xx(?:wj|hj)jl)(?:_|$)/.test(String(candidate || "").trim())
  1152. );
  1153. },
  1154. isDisciplineAppearanceService(serviceName) {
  1155. const candidateList = [
  1156. serviceName,
  1157. this.service,
  1158. this.pageParams?.service,
  1159. this.pageParams?.ssServ,
  1160. this.ssSearchPobjHomeServName,
  1161. this.ssSearchPobjListServName,
  1162. ];
  1163. return candidateList.some((candidate) =>
  1164. /^(?:fjyrjc|xxwjjl)(?:_|$)/.test(String(candidate || "").trim())
  1165. );
  1166. },
  1167. resolveListManagementValue(serviceName) {
  1168. return this.isBzrXyService(serviceName || this.service) ||
  1169. this.isSchoolRecordService(serviceName || this.service)
  1170. ? "99"
  1171. : "1";
  1172. },
  1173. formatBzrXyStudentNoDisplay(item, rawItem, serviceName) {
  1174. if (!this.isBzrXyService(serviceName || this.service)) {
  1175. return "";
  1176. }
  1177. const fieldName = String(
  1178. item?.second?.field?.name ||
  1179. rawItem?.second?.field?.name ||
  1180. ""
  1181. ).trim();
  1182. if (fieldName !== "ryh") {
  1183. return "";
  1184. }
  1185. const rawValue =
  1186. item?.secondDisplay ??
  1187. item?.second?.value ??
  1188. rawItem?.second?.value ??
  1189. rawItem?.ryh ??
  1190. "";
  1191. const studentNo = String(rawValue).trim();
  1192. if (!studentNo) {
  1193. return "";
  1194. }
  1195. if (/^学号[::]/.test(studentNo)) {
  1196. return studentNo;
  1197. }
  1198. return `学号:${studentNo}`;
  1199. },
  1200. async enrichBzrXyThumbs(list, serviceName) {
  1201. if (!Array.isArray(list) || list.length === 0) {
  1202. return list;
  1203. }
  1204. if (!this.isBzrXyService(serviceName || this.service)) {
  1205. return list;
  1206. }
  1207. const missingIds = list
  1208. .filter(
  1209. (item) =>
  1210. item &&
  1211. !item.thumbPath &&
  1212. item.ssObjId !== undefined &&
  1213. item.ssObjId !== null &&
  1214. String(item.ssObjId).trim() !== ""
  1215. )
  1216. .map((item) => String(item.ssObjId).trim());
  1217. if (missingIds.length === 0) {
  1218. return list;
  1219. }
  1220. try {
  1221. const managementValue =
  1222. this.resolveListManagementValue(serviceName);
  1223. const result = await request.post(
  1224. `/service?ssServ=bzrXy_selThumbMap&management=${managementValue}&isReady=1`,
  1225. {
  1226. ryids: [...new Set(missingIds)].join(","),
  1227. management: managementValue,
  1228. isReady: "1",
  1229. },
  1230. {
  1231. loading: false,
  1232. formData: true,
  1233. }
  1234. );
  1235. const thumbMap = this.unwrapResponseData(result?.data);
  1236. if (!thumbMap || typeof thumbMap !== "object") {
  1237. return list;
  1238. }
  1239. return list.map((item) => {
  1240. const ryid = String(item?.ssObjId || "").trim();
  1241. const thumbPath =
  1242. ryid && Object.prototype.hasOwnProperty.call(thumbMap, ryid)
  1243. ? String(thumbMap[ryid] || "").trim()
  1244. : "";
  1245. if (!thumbPath || item.thumbPath) {
  1246. return item;
  1247. }
  1248. return {
  1249. ...item,
  1250. thumbPath,
  1251. thumbUrl:
  1252. window.resolveListImageUrl?.(thumbPath) || thumbPath,
  1253. };
  1254. });
  1255. } catch (error) {
  1256. console.warn("⚠️ bzrXy 头像补取失败:", error);
  1257. return list;
  1258. }
  1259. },
  1260. // 处理buttonList按钮点击
  1261. handleButtonClick(button) {
  1262. console.log("🔘 按钮点击:", button);
  1263. if (this.hasButtonOptions(button)) {
  1264. return;
  1265. }
  1266. NavigationManager.goToFromButton(button);
  1267. },
  1268. // 跳转到目标页面
  1269. navigateToPage(button, destPage) {
  1270. const urlParams = new URLSearchParams(window.location.search);
  1271. // 添加按钮相关参数
  1272. if (button.function) {
  1273. urlParams.set("dest", destPage);
  1274. urlParams.set(
  1275. "title",
  1276. encodeURIComponent(button.function.desc || button.buttonName)
  1277. );
  1278. urlParams.set(
  1279. "service",
  1280. button.function.servName || button.service || ""
  1281. );
  1282. } else {
  1283. urlParams.set("dest", destPage);
  1284. urlParams.set("title", encodeURIComponent(button.buttonName));
  1285. urlParams.set("service", button.service || "");
  1286. }
  1287. const newUrl = `${destPage}.html?${urlParams.toString()}`;
  1288. console.log("� 跳转到:", newUrl);
  1289. window.location.href = newUrl;
  1290. },
  1291. // 根据fieldsList生成筛选选项
  1292. async generateFilterOptions() {
  1293. if (!this.fieldsList || this.fieldsList.length === 0) {
  1294. return;
  1295. }
  1296. for (const field of this.fieldsList) {
  1297. // 如果字段有cbName,生成下拉选项
  1298. if (field.cbName) {
  1299. try {
  1300. const options = await window.getDictOptions(
  1301. field.cbName,
  1302. this.dictCache
  1303. );
  1304. this.filterSelectOptions[field.name] = [
  1305. { n: "", v: "" },
  1306. ...options,
  1307. ];
  1308. } catch (error) {
  1309. console.error("获取筛选选项失败:", field.cbName, error);
  1310. }
  1311. }
  1312. }
  1313. console.log("🔽 生成筛选选项:", this.filterSelectOptions);
  1314. },
  1315. // 功能说明:统一处理卡片服务跳转,页面文件名按后端 dest 自动补 mp_,但传给业务页/后端的 dest 仍保持原始值 by xu 2026-03-06
  1316. openServicePage(action, item = {}) {
  1317. const target =
  1318. action && typeof action === "object" ? action : null;
  1319. if (!target) {
  1320. this.showToast("当前记录缺少操作配置", "warning");
  1321. return;
  1322. }
  1323. const serviceName = String(
  1324. target.servName || target.ssServ || ""
  1325. ).trim();
  1326. const rawDest = String(target.dest || "").trim();
  1327. const normalizedDest =
  1328. rawDest && rawDest.startsWith("mp_")
  1329. ? rawDest
  1330. : rawDest
  1331. ? `mp_${rawDest}`
  1332. : "";
  1333. const paramName = String(target.param_name || "").trim();
  1334. const paramValue = target.param_value;
  1335. const ssToken = String(target.ssToken || "").trim();
  1336. const paramText =
  1337. typeof target.parm === "string" ? target.parm : "";
  1338. if (!serviceName) {
  1339. this.showToast("缺少服务名", "warning");
  1340. return;
  1341. }
  1342. if (!normalizedDest) {
  1343. this.showToast("缺少目标页面", "warning");
  1344. return;
  1345. }
  1346. const managementValue =
  1347. this.resolveListManagementValue(serviceName);
  1348. const needsFreshViewPage =
  1349. normalizedDest === "mp_objPlay" &&
  1350. /^(?:xxwjjl|fjyrjc)(?:_|$)/.test(serviceName);
  1351. NavigationManager.goTo(normalizedDest, {
  1352. title: target.desc || target.title || "处理",
  1353. service: serviceName,
  1354. dest: rawDest,
  1355. ssDest: rawDest,
  1356. param: paramText,
  1357. playParamName: paramName,
  1358. playParamValue: paramValue,
  1359. ssToken: ssToken,
  1360. ssObjId: item.ssObjId || "",
  1361. ssObjName: item.ssObjName || "",
  1362. management: managementValue,
  1363. ...(needsFreshViewPage
  1364. ? { _v: "20261201-baseinfo-fix-v2" }
  1365. : {}),
  1366. [paramName || "param_value"]: paramValue,
  1367. });
  1368. },
  1369. // 卡片点击 - SsCard组件会自动传递item数据
  1370. handleCardClick(item) {
  1371. console.log("📄 卡片点击事件触发", item);
  1372. // 功能说明:卡片点击统一按 play 参数跳转到通用查看页 mp_objplay(兼容 play / service.play 两种结构) by xu 2026-03-04
  1373. const play =
  1374. (item && (item.play || (item.service && item.service.play))) ||
  1375. null;
  1376. this.openServicePage(play, item);
  1377. },
  1378. // 卡片操作 - SsCard组件的按钮点击事件
  1379. handleCardAction({ button, item, index }) {
  1380. console.log("⚡ 卡片操作:", button, item);
  1381. // 功能说明:左滑操作按钮按服务配置跳转(如 chg=变动),不再弹 Toast 占位 by xu 2026-03-06
  1382. this.openServicePage(button, item);
  1383. },
  1384. handleThumbError(event) {
  1385. const fallback =
  1386. window.resolveListImageUrl?.("") ||
  1387. "skin/easy/image/default-personalPhoto.png";
  1388. if (!event?.target) return;
  1389. if (event.target.dataset.fallbackApplied === "1") return;
  1390. event.target.dataset.fallbackApplied = "1";
  1391. event.target.src = fallback;
  1392. },
  1393. // 加载更多数据
  1394. async loadMore() {
  1395. if (!this.hasMore || this.isLoadingMore) {
  1396. console.log("🚫 无法加载更多:", {
  1397. hasMore: this.hasMore,
  1398. isLoadingMore: this.isLoadingMore,
  1399. });
  1400. return;
  1401. }
  1402. console.log("📄 加载更多数据...");
  1403. await this.loadData(this.currentPage + 1, true);
  1404. },
  1405. // 刷新数据
  1406. async refreshData() {
  1407. console.log("🔄 刷新数据...");
  1408. // 重置分页状态
  1409. this.currentPage = 1;
  1410. this.hasMore = true;
  1411. this.list = [];
  1412. this.originalList = [];
  1413. try {
  1414. await this.loadData(1, false);
  1415. this.showToast("刷新成功", "success");
  1416. } catch (error) {
  1417. this.showToast("刷新失败", "error");
  1418. }
  1419. },
  1420. // 获取字段描述
  1421. getFieldDesc(fieldName) {
  1422. const field = this.fieldsList.find((f) => f.name === fieldName);
  1423. return field ? field.desc : fieldName;
  1424. },
  1425. // 功能说明:统一按钮文案映射(兼容 rootFuncList/buttonList 不同字段) by xu 2026-02-28
  1426. getButtonText(button) {
  1427. if (!button || typeof button !== "object") return "";
  1428. return (
  1429. button.desc ||
  1430. button.title ||
  1431. button.buttonName ||
  1432. button.name ||
  1433. ""
  1434. );
  1435. },
  1436. getButtonOptions(button) {
  1437. if (!button || typeof button !== "object") return [];
  1438. const source =
  1439. Array.isArray(button.pluginList) && button.pluginList.length
  1440. ? button.pluginList
  1441. : Array.isArray(button.pageList)
  1442. ? button.pageList
  1443. : [];
  1444. return this.createNavOptions(source);
  1445. },
  1446. createNavOptions(buttonList) {
  1447. if (!Array.isArray(buttonList)) return [];
  1448. return buttonList
  1449. .filter((item) => item && typeof item === "object")
  1450. .map((item) => ({
  1451. text: this.getButtonText(item),
  1452. onclick: () => NavigationManager.goToFromButton(item),
  1453. }))
  1454. .filter((item) => item.text || item.onclick);
  1455. },
  1456. hasButtonOptions(button) {
  1457. return this.getButtonOptions(button).length > 0;
  1458. },
  1459. // 功能说明:提取有效筛选参数(过滤空串/null/undefined) by xu 2026-02-28
  1460. getActiveFilterParams(source) {
  1461. const params = {};
  1462. const obj = source && typeof source === "object" ? source : {};
  1463. Object.entries(obj).forEach(([key, value]) => {
  1464. if (value === "" || value === null || value === undefined)
  1465. return;
  1466. params[key] = value;
  1467. });
  1468. return params;
  1469. },
  1470. // 筛选选择器变化(立即搜索)
  1471. handleFilterChange(value) {
  1472. console.log("🔽 筛选条件变化,立即搜索:", value);
  1473. // 立即执行搜索
  1474. this.applyDynamicFilters();
  1475. },
  1476. // 应用动态筛选(重新调用API)
  1477. async applyDynamicFilters() {
  1478. try {
  1479. console.log("🔍 应用筛选条件:", this.selectedFilters);
  1480. // 功能说明:筛选参数先归一化,清理已取消的筛选条件 by xu 2026-02-28
  1481. const filterParams = this.getActiveFilterParams(
  1482. this.selectedFilters
  1483. );
  1484. // 功能说明:筛选后重置分页并走 list 服务 by xu 2026-02-28
  1485. this.currentPage = 1;
  1486. this.hasMore = true;
  1487. this.list = [];
  1488. this.originalList = [];
  1489. this.selectedFilters = { ...filterParams };
  1490. await this.loadData(1, false);
  1491. } catch (error) {
  1492. console.error("❌ 筛选失败:", error);
  1493. this.showToast("筛选失败", "error");
  1494. }
  1495. },
  1496. // 生成项目按钮
  1497. generateItemButtons(service) {
  1498. if (!service || !service.play) return [];
  1499. return [
  1500. {
  1501. title: service.play.name || "查看",
  1502. icon: "icon-chakan",
  1503. onclick: () => {
  1504. console.log("点击查看按钮:", service.play);
  1505. // 这里可以跳转到详情页面
  1506. this.showToast(`查看: ${service.play.title}`, "info");
  1507. },
  1508. },
  1509. ];
  1510. },
  1511. // 设置页面刷新监听
  1512. setupRefreshListener() {
  1513. // 监听子页面返回时的刷新通知
  1514. this.refreshCleanup = NavigationManager.onRefreshNotify(
  1515. (refreshData) => {
  1516. console.log("📢 收到刷新通知,重新加载数据");
  1517. this.refreshData();
  1518. }
  1519. );
  1520. },
  1521. handleListPageShow() {
  1522. this.refreshIfNeededOnReturn();
  1523. },
  1524. handleListPageVisibility() {
  1525. if (document.visibilityState === "visible")
  1526. this.refreshIfNeededOnReturn();
  1527. },
  1528. refreshIfNeededOnReturn() {
  1529. const refreshData = NavigationManager.consumeListRefresh();
  1530. if (!refreshData) return;
  1531. console.log("检测到提交返回,刷新列表:", refreshData);
  1532. this.refreshData();
  1533. },
  1534. // 设置滚动监听
  1535. setupScrollListener() {
  1536. let isThrottled = false;
  1537. const handleScroll = () => {
  1538. if (isThrottled) return;
  1539. isThrottled = true;
  1540. setTimeout(() => {
  1541. isThrottled = false;
  1542. }, 200); // 节流200ms
  1543. // 检查是否滚动到底部
  1544. const scrollTop =
  1545. window.pageYOffset || document.documentElement.scrollTop;
  1546. const windowHeight = window.innerHeight;
  1547. const documentHeight = document.documentElement.scrollHeight;
  1548. // 控制回到顶部按钮显示:滚动超过300px时显示
  1549. this.showBackToTop = scrollTop > 300;
  1550. // 距离底部50px时触发加载更多
  1551. if (scrollTop + windowHeight >= documentHeight - 50) {
  1552. console.log("📄 滚动到底部,尝试加载更多...");
  1553. this.loadMore();
  1554. }
  1555. };
  1556. // 添加滚动监听
  1557. window.addEventListener("scroll", handleScroll);
  1558. // 保存清理函数
  1559. this.scrollCleanup = () => {
  1560. window.removeEventListener("scroll", handleScroll);
  1561. };
  1562. },
  1563. // 返回顶部
  1564. scrollToTop() {
  1565. window.scrollTo({
  1566. top: 0,
  1567. behavior: "smooth",
  1568. });
  1569. },
  1570. // 处理回到顶部按钮点击
  1571. handleBackToTopClick() {
  1572. // 如果不是长按触发的搜索,则执行返回顶部
  1573. if (!this.isLongPress) {
  1574. this.scrollToTop();
  1575. }
  1576. // 重置长按标志
  1577. this.isLongPress = false;
  1578. },
  1579. // 长按开始
  1580. handleLongPressStart(event) {
  1581. if (this.hasKeyWord) {
  1582. // 有输入关键字才显示,否则不处理长按
  1583. this.isLongPress = false;
  1584. // 设置长按定时器(500ms)
  1585. this.longPressTimer = setTimeout(() => {
  1586. this.isLongPress = true;
  1587. this.openSearchModal();
  1588. // 震动反馈(如果支持)
  1589. if (navigator.vibrate) {
  1590. navigator.vibrate(50);
  1591. }
  1592. }, 500);
  1593. }
  1594. },
  1595. // 长按结束
  1596. handleLongPressEnd(event) {
  1597. // 清除长按定时器
  1598. if (this.longPressTimer) {
  1599. clearTimeout(this.longPressTimer);
  1600. this.longPressTimer = null;
  1601. }
  1602. },
  1603. // 长按取消(手指移出按钮区域)
  1604. handleLongPressCancel(event) {
  1605. // 清除长按定时器
  1606. if (this.longPressTimer) {
  1607. clearTimeout(this.longPressTimer);
  1608. this.longPressTimer = null;
  1609. }
  1610. this.isLongPress = false;
  1611. },
  1612. // 打开搜索弹窗
  1613. openSearchModal() {
  1614. this.showSearchModal = true;
  1615. this.searchKeyword = "";
  1616. // 延迟聚焦输入框,确保DOM已渲染和动画完成
  1617. this.$nextTick(() => {
  1618. // 使用 setTimeout 确保在移动端也能正常触发键盘
  1619. setTimeout(() => {
  1620. if (this.$refs.searchInput) {
  1621. // 先点击再聚焦,确保移动端键盘弹出
  1622. this.$refs.searchInput.click();
  1623. this.$refs.searchInput.focus();
  1624. console.log("✅ 输入框已聚焦");
  1625. }
  1626. }, 100); // 等待动画完成后再聚焦
  1627. });
  1628. },
  1629. // 关闭搜索弹窗
  1630. closeSearchModal() {
  1631. this.showSearchModal = false;
  1632. this.searchKeyword = "";
  1633. },
  1634. // 执行搜索
  1635. async performSearch() {
  1636. const keyword = this.searchKeyword.trim();
  1637. // 无关键词时,直接关闭弹窗,什么都不做
  1638. if (!keyword) {
  1639. // this.closeSearchModal();
  1640. return;
  1641. }
  1642. console.log("🔍 执行关键词搜索:", keyword);
  1643. // 关闭搜索弹窗
  1644. this.closeSearchModal();
  1645. // 设置 keyword 到筛选条件中
  1646. this.selectedFilters.ssKeyword = keyword;
  1647. // 调用 API 搜索
  1648. await this.applyDynamicFilters();
  1649. },
  1650. // 显示提示
  1651. showToast(message, type = "info") {
  1652. console.log(`${type.toUpperCase()}: ${message}`);
  1653. // 使用浏览器原生alert,后续可以替换为更好的提示组件
  1654. alert(message);
  1655. },
  1656. },
  1657. });
  1658. });
  1659. </script>
  1660. </body>
  1661. </html>