mp_cobjList.html 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
  6. <title>二级列表</title>
  7. <script src="/js/mp_base/base.js?v=20261127-auth-refresh-v1"></script>
  8. <style>
  9. #app {
  10. background: #f5f5f5;
  11. min-height: 100vh;
  12. }
  13. [v-cloak] {
  14. display: none !important;
  15. }
  16. .search-filter-container {
  17. background: #f5f5f5;
  18. padding: 15px;
  19. position: sticky;
  20. top: 0;
  21. z-index: 100;
  22. display: flex;
  23. flex-wrap: wrap;
  24. gap: 10px;
  25. align-items: center;
  26. /* 搜索条件右对齐,和 mp_objList 保持一致 by xu 2026-03-06 */
  27. justify-content: flex-end;
  28. }
  29. .search-filter-container .ss-select-container,
  30. .search-filter-container .input,
  31. .search-filter-container .ss-search-date-picker {
  32. border-radius: 6px;
  33. overflow: hidden;
  34. }
  35. .loading-container,
  36. .error-container {
  37. display: flex;
  38. flex-direction: column;
  39. align-items: center;
  40. justify-content: center;
  41. min-height: 220px;
  42. color: #666;
  43. padding: 24px;
  44. text-align: center;
  45. }
  46. .loading-spinner {
  47. width: 40px;
  48. height: 40px;
  49. border: 4px solid #f3f3f3;
  50. border-top: 4px solid #40ac6d;
  51. border-radius: 50%;
  52. animation: spin 1s linear infinite;
  53. margin-bottom: 15px;
  54. }
  55. @keyframes spin {
  56. 0% { transform: rotate(0deg); }
  57. 100% { transform: rotate(360deg); }
  58. }
  59. .error-text {
  60. color: #d03050;
  61. line-height: 1.7;
  62. }
  63. .list-container {
  64. padding: 0 15px 8px;
  65. }
  66. .empty-state {
  67. text-align: center;
  68. padding: 60px 20px;
  69. color: #999;
  70. }
  71. .empty-icon {
  72. font-size: 48px;
  73. margin-bottom: 15px;
  74. }
  75. .empty-text {
  76. font-size: 16px;
  77. }
  78. .card-content .card-header {
  79. display: flex;
  80. align-items: center;
  81. gap: 8px;
  82. margin-bottom: 10px;
  83. }
  84. .card-content .card-title {
  85. font-size: 16px;
  86. font-weight: bold;
  87. color: #333;
  88. line-height: 1.5;
  89. word-break: break-all;
  90. }
  91. .draft-tag {
  92. flex: 0 0 auto;
  93. padding: 2px 8px;
  94. border-radius: 999px;
  95. background: rgba(64, 172, 109, 0.12);
  96. color: #2a8f58;
  97. font-size: 12px;
  98. }
  99. .card-content .card-description {
  100. font-size: 14px;
  101. color: #666;
  102. margin-bottom: 8px;
  103. line-height: 1.6;
  104. word-break: break-all;
  105. }
  106. .card-content .attribute-group {
  107. display: flex;
  108. flex-wrap: wrap;
  109. column-gap: 10px;
  110. }
  111. .card-content .attribute-item {
  112. display: flex;
  113. margin-bottom: 5px;
  114. max-width: 100%;
  115. }
  116. .card-content .attr-label {
  117. font-size: 13px;
  118. color: #999;
  119. flex: 0 0 auto;
  120. }
  121. .card-content .attr-value {
  122. font-size: 13px;
  123. color: #333;
  124. word-break: break-all;
  125. }
  126. .load-more-container {
  127. text-align: center;
  128. padding: 20px;
  129. color: #999;
  130. font-size: 14px;
  131. }
  132. .load-more-loading {
  133. color: #007aff;
  134. }
  135. .load-more-end {
  136. color: #999;
  137. }
  138. .load-more-tip {
  139. color: #ccc;
  140. }
  141. .back-to-top-btn {
  142. width: 50px;
  143. height: 50px;
  144. border-radius: 50%;
  145. background: rgba(87, 93, 109, 0.5);
  146. display: flex;
  147. justify-content: center;
  148. align-items: center;
  149. position: fixed;
  150. bottom: 200px;
  151. right: 15px;
  152. cursor: pointer;
  153. transition: all 0.3s ease;
  154. z-index: 999;
  155. }
  156. .back-to-top-btn:active {
  157. transform: scale(0.9);
  158. }
  159. .back-to-top-inner {
  160. width: 42px;
  161. height: 42px;
  162. border-radius: 50%;
  163. background: rgba(87, 93, 109, 0.5);
  164. display: flex;
  165. justify-content: center;
  166. align-items: center;
  167. }
  168. .search-modal-mask {
  169. position: fixed;
  170. top: 0;
  171. left: 0;
  172. right: 0;
  173. bottom: 0;
  174. background: rgba(0, 0, 0, 0.5);
  175. z-index: 1000;
  176. display: flex;
  177. align-items: flex-end;
  178. }
  179. .search-modal-content {
  180. width: 100%;
  181. background: white;
  182. animation: slideUp 0.3s ease-out;
  183. position: relative;
  184. }
  185. @keyframes slideUp {
  186. from { transform: translateY(100%); }
  187. to { transform: translateY(0); }
  188. }
  189. .search-input-container {
  190. display: flex;
  191. align-items: center;
  192. height: 50px;
  193. background: white;
  194. border-top: 1px solid #e5e5e5;
  195. }
  196. .search-input {
  197. flex: 1;
  198. height: 100%;
  199. border: none;
  200. outline: none;
  201. padding: 0 15px;
  202. font-size: 16px;
  203. background: transparent;
  204. }
  205. .search-divider {
  206. width: 1px;
  207. height: 24px;
  208. background: #e5e5e5;
  209. }
  210. .search-icon-btn {
  211. width: 56px;
  212. height: 100%;
  213. border: none;
  214. background: white;
  215. display: flex;
  216. align-items: center;
  217. justify-content: center;
  218. }
  219. .search-icon-btn:active {
  220. background: #f5f5f5;
  221. }
  222. </style>
  223. </head>
  224. <body>
  225. <div id="app" v-cloak>
  226. <!-- 二级列表筛选条:兼容 PC 的搜索字段、范围按钮和根功能按钮 by xu 2026-03-06 -->
  227. <div class="search-filter-container">
  228. <template v-for="field in searchFieldList" :key="field.name">
  229. <ss-select
  230. v-if="field.cbName"
  231. v-model="selectedFilters[field.name]"
  232. :placeholder="field.desc || '请选择'"
  233. :options="filterSelectOptions[field.name] || []"
  234. @change="handleFilterChange"
  235. ></ss-select>
  236. <ss-search-date-picker
  237. v-else-if="isDateField(field)"
  238. v-model="selectedFilters[field.name]"
  239. :name="field.name"
  240. :placeholder="field.desc || ''"
  241. width="140px"
  242. @change="applyFilters"
  243. ></ss-search-date-picker>
  244. <ss-search-input
  245. v-else
  246. v-model="selectedFilters[field.name]"
  247. :name="field.name"
  248. :placeholder="field.desc || ''"
  249. width="120px"
  250. @search="applyFilters"
  251. ></ss-search-input>
  252. </template>
  253. <ss-search-button
  254. :text="getCurrentScopeText()"
  255. :options="scopeButtonOptions"
  256. ></ss-search-button>
  257. <ss-search-button
  258. v-if="hasKeyWord"
  259. text="关键词"
  260. @click="openSearchModal"
  261. ></ss-search-button>
  262. <ss-search-button
  263. v-for="(button, index) in rootFuncList"
  264. :key="`${getButtonText(button)}-${index}`"
  265. :text="getButtonText(button)"
  266. :options="getButtonOptions(button)"
  267. :suffix-icon="getButtonOptions(button).length > 1 ? 'icon-xiala' : ''"
  268. @click="handleRootButtonClick(button)"
  269. ></ss-search-button>
  270. </div>
  271. <div v-if="loading" class="loading-container">
  272. <div class="loading-spinner"></div>
  273. <div class="loading-text">加载中...</div>
  274. </div>
  275. <div v-else-if="errorMessage" class="error-container">
  276. <div class="error-text">{{ errorMessage }}</div>
  277. </div>
  278. <div v-else class="list-container">
  279. <div v-if="list.length === 0" class="empty-state">
  280. <div class="empty-icon">📋</div>
  281. <div class="empty-text">暂无数据</div>
  282. </div>
  283. <div v-else>
  284. <!-- 二级列表卡片:兼容 draftList/objList 与 catList/title 结构 by xu 2026-03-06 -->
  285. <ss-card
  286. v-for="(item, index) in list"
  287. :key="`${index}-${item.ssObjId || item.id || item.firstDisplay || ''}`"
  288. :item="item"
  289. @click="handleCardClick(item)"
  290. @button-click="handleCardAction"
  291. >
  292. <div class="card-content">
  293. <div class="card-header" v-if="item.firstDisplay || item.isDraft">
  294. <span v-if="item.isDraft" class="draft-tag">草稿</span>
  295. <div class="card-title">{{ item.firstDisplay || '未命名记录' }}</div>
  296. </div>
  297. <div class="card-description" v-if="item.secondDisplay">
  298. {{ item.secondDisplay }}
  299. </div>
  300. <div class="card-attributes" v-if="item.thirdDisplay && item.thirdDisplay.length > 0">
  301. <div
  302. v-for="(group, groupIndex) in item.thirdDisplay"
  303. :key="groupIndex"
  304. class="attribute-group"
  305. >
  306. <div
  307. v-for="(attr, attrIndex) in group"
  308. :key="attrIndex"
  309. class="attribute-item"
  310. >
  311. <span class="attr-label">{{ getAttrLabel(attr) }}:</span>
  312. <span class="attr-value">{{ attr.displayValue }}</span>
  313. </div>
  314. </div>
  315. </div>
  316. </div>
  317. </ss-card>
  318. </div>
  319. </div>
  320. <div class="load-more-container" v-if="list.length > 0">
  321. <div v-if="isLoadingMore" class="load-more-loading">
  322. <span>正在加载更多...</span>
  323. </div>
  324. <div v-else-if="!hasMore" class="load-more-end">
  325. <span>没有更多数据了</span>
  326. </div>
  327. <div v-else class="load-more-tip">
  328. <span>滚动到底部加载更多</span>
  329. </div>
  330. </div>
  331. <div
  332. v-if="showBackToTop"
  333. class="back-to-top-btn"
  334. @touchstart="handleLongPressStart"
  335. @touchend="handleLongPressEnd"
  336. @touchcancel="handleLongPressCancel"
  337. @click.prevent="handleBackToTopClick"
  338. >
  339. <div class="back-to-top-inner">
  340. <Icon name="icon-huidaodingbu" size="40" color="#fff"></Icon>
  341. </div>
  342. </div>
  343. <div v-if="showSearchModal" class="search-modal-mask" @click="closeSearchModal">
  344. <div class="search-modal-content" @click.stop>
  345. <div class="search-input-container">
  346. <input
  347. ref="searchInput"
  348. v-model="searchKeyword"
  349. type="search"
  350. inputmode="search"
  351. class="search-input"
  352. placeholder="请输入关键词"
  353. @keyup.enter="performSearch"
  354. autocomplete="off"
  355. />
  356. <div class="search-divider"></div>
  357. <button class="search-icon-btn" @click="performSearch">
  358. <Icon name="icon-chazhao" size="24" color="#575d6d"></Icon>
  359. </button>
  360. </div>
  361. </div>
  362. </div>
  363. </div>
  364. <script>
  365. window.SS.ready(function () {
  366. window.SS.dom.initializeFormApp({
  367. el: '#app',
  368. data() {
  369. return {
  370. loading: true,
  371. errorMessage: '',
  372. list: [],
  373. currentPage: 1,
  374. pageSize: 12,
  375. hasMore: true,
  376. isLoadingMore: false,
  377. pageParams: {},
  378. service: '',
  379. ssSearchCobjServName: '',
  380. requestParentViewObject: '',
  381. ssObjName: '',
  382. ssObjId: '',
  383. ssPobjIdName: '',
  384. management: '1',
  385. searchFieldList: [],
  386. rootFuncList: [],
  387. selectedFilters: {},
  388. filterSelectOptions: {},
  389. dictCache: new Map(),
  390. ssPaging: null,
  391. hasKeyWord: false,
  392. scopeButtonOptions: [],
  393. showBackToTop: false,
  394. showSearchModal: false,
  395. searchKeyword: '',
  396. longPressTimer: null,
  397. isLongPress: false,
  398. requestSeq: 0,
  399. };
  400. },
  401. mounted() {
  402. this.setupScopeButtons();
  403. this.initPage();
  404. this.setupRefreshListener();
  405. this.setupScrollListener();
  406. },
  407. beforeUnmount() {
  408. if (this.refreshCleanup) {
  409. this.refreshCleanup();
  410. }
  411. if (this.scrollCleanup) {
  412. this.scrollCleanup();
  413. }
  414. },
  415. methods: {
  416. // 二级列表初始化:同时兼容直接传 cobj 服务和先走 init 再拿 ssSearchCobjServName 的两种入口 by xu 2026-03-06
  417. async initPage() {
  418. try {
  419. this.pageParams = this.getUrlParams();
  420. this.service = String(this.pageParams.service || '').trim();
  421. this.ssSearchCobjServName = String(this.pageParams.ssSearchCobjServName || '').trim();
  422. this.requestParentViewObject = String(this.pageParams.requestParentViewObject || '').trim();
  423. this.ssObjName = String(this.pageParams.ssObjName || this.pageParams.ssobjname || '').trim();
  424. this.ssObjId = String(this.pageParams.ssObjId || this.pageParams.ssobjid || '').trim();
  425. this.ssPobjIdName = String(this.pageParams.ssPobjIdName || '').trim();
  426. this.management = String(this.pageParams.management || '1');
  427. this.searchKeyword = String(this.pageParams.ssKeyword || '').trim();
  428. this.setupScopeButtons();
  429. if (this.searchKeyword) {
  430. this.selectedFilters = {
  431. ...this.selectedFilters,
  432. ssKeyword: this.searchKeyword,
  433. };
  434. }
  435. if (this.ssSearchCobjServName) {
  436. await this.loadData(1, false);
  437. return;
  438. }
  439. if (!this.service) {
  440. this.errorMessage = '缺少服务名,无法加载二级列表';
  441. return;
  442. }
  443. await this.resolveInitService();
  444. } catch (error) {
  445. console.error('❌ 二级列表初始化失败:', error);
  446. this.errorMessage = '页面初始化失败,请稍后重试';
  447. } finally {
  448. this.loading = false;
  449. }
  450. },
  451. async resolveInitService() {
  452. const reqId = ++this.requestSeq;
  453. this.loading = true;
  454. this.errorMessage = '';
  455. try {
  456. const requestParams = this.buildRequestParams(1);
  457. const result = await request.post(
  458. `/service?ssServ=${this.service}&management=${encodeURIComponent(this.management)}&isReady=1`,
  459. requestParams,
  460. {
  461. loading: false,
  462. formData: true,
  463. }
  464. );
  465. if (reqId !== this.requestSeq) return;
  466. const rawData = result && result.data ? result.data : {};
  467. if (this.isBizError(rawData)) {
  468. this.errorMessage = this.formatBizError(rawData);
  469. return;
  470. }
  471. const payload = this.unwrapResponseData(rawData);
  472. const resolvedCobjService = String(payload.ssSearchCobjServName || '').trim();
  473. if (resolvedCobjService) {
  474. this.ssSearchCobjServName = resolvedCobjService;
  475. if (!this.requestParentViewObject) {
  476. this.requestParentViewObject = String(payload.requestParentViewObject || '').trim();
  477. }
  478. if (!this.ssPobjIdName) {
  479. this.ssPobjIdName = String(payload.ssPobjIdName || '').trim();
  480. }
  481. if (!this.ssObjName) {
  482. this.ssObjName = String(payload.ssObjName || payload.objName || '').trim();
  483. }
  484. if (!this.ssObjId) {
  485. this.ssObjId = String(payload.ssObjId || payload.objId || '').trim();
  486. }
  487. await this.loadData(1, false);
  488. return;
  489. }
  490. await this.applyApiData(payload, false);
  491. } catch (error) {
  492. console.error('❌ 初始化服务请求失败:', error);
  493. this.errorMessage = '初始化失败,请稍后重试';
  494. }
  495. },
  496. async loadData(pageNo = 1, isLoadMore = false) {
  497. const serviceName = String(this.ssSearchCobjServName || this.service || '').trim();
  498. if (!serviceName) {
  499. this.errorMessage = '缺少二级列表服务名';
  500. return;
  501. }
  502. if (isLoadMore && this.isLoadingMore) return;
  503. if (!isLoadMore && this.loading && this.list.length > 0) return;
  504. const reqId = ++this.requestSeq;
  505. this.errorMessage = '';
  506. if (isLoadMore) {
  507. this.isLoadingMore = true;
  508. } else {
  509. this.loading = true;
  510. }
  511. try {
  512. const requestParams = this.buildRequestParams(pageNo);
  513. const result = await request.post(
  514. `/service?ssServ=${serviceName}&management=${encodeURIComponent(this.management)}&isReady=1`,
  515. requestParams,
  516. {
  517. loading: false,
  518. formData: true,
  519. }
  520. );
  521. if (reqId !== this.requestSeq) return;
  522. const rawData = result && result.data ? result.data : {};
  523. if (this.isBizError(rawData)) {
  524. this.errorMessage = this.formatBizError(rawData);
  525. return;
  526. }
  527. const payload = this.unwrapResponseData(rawData);
  528. await this.applyApiData(payload, isLoadMore);
  529. } catch (error) {
  530. console.error('❌ 二级列表加载失败:', error);
  531. this.errorMessage = '加载失败,请稍后重试';
  532. } finally {
  533. if (reqId === this.requestSeq) {
  534. this.loading = false;
  535. this.isLoadingMore = false;
  536. }
  537. }
  538. },
  539. async applyApiData(payload, isLoadMore = false) {
  540. const data = payload && typeof payload === 'object' ? payload : {};
  541. if (Array.isArray(data.searchFieldList)) {
  542. this.searchFieldList = data.searchFieldList;
  543. }
  544. if (Array.isArray(data.rootFuncList) || Array.isArray(data.buttonList)) {
  545. this.rootFuncList = data.rootFuncList || data.buttonList || [];
  546. }
  547. if (Object.prototype.hasOwnProperty.call(data, 'hasKeyWord') || Object.prototype.hasOwnProperty.call(data, 'hasKeyword')) {
  548. this.hasKeyWord = !!(data.hasKeyWord || data.hasKeyword);
  549. }
  550. if (data.ssPaging && typeof data.ssPaging === 'object') {
  551. this.ssPaging = {
  552. pageNo: Number(data.ssPaging.pageNo || 1),
  553. rowNumPer: Number(data.ssPaging.rowNumPer || this.pageSize || 12),
  554. rowNum: Number(data.ssPaging.rowNum || 0),
  555. };
  556. if (this.ssPaging.rowNumPer > 0) {
  557. this.pageSize = this.ssPaging.rowNumPer;
  558. }
  559. }
  560. this.ensureSelectedFilters();
  561. await this.generateFilterOptions();
  562. const draftList = Array.isArray(data.draftList)
  563. ? data.draftList.map(item => ({ ...item, __isDraft: true }))
  564. : [];
  565. const objList = Array.isArray(data.objList)
  566. ? data.objList.map(item => ({ ...item, __isDraft: false }))
  567. : Array.isArray(data.objectList)
  568. ? data.objectList.map(item => ({ ...item, __isDraft: false }))
  569. : [];
  570. const formattedList = await this.formatCobjItems(draftList.concat(objList));
  571. if (isLoadMore) {
  572. this.list = this.list.concat(formattedList);
  573. this.currentPage = Number(this.currentPage || 1) + 1;
  574. } else {
  575. this.list = formattedList;
  576. this.currentPage = Number(this.ssPaging && this.ssPaging.pageNo ? this.ssPaging.pageNo : 1);
  577. }
  578. if (this.ssPaging && this.ssPaging.rowNum) {
  579. this.hasMore = this.list.length < Number(this.ssPaging.rowNum || 0);
  580. } else {
  581. this.hasMore = formattedList.length >= this.pageSize;
  582. }
  583. this.errorMessage = '';
  584. },
  585. async formatCobjItems(rawList) {
  586. const list = Array.isArray(rawList) ? rawList : [];
  587. const formattedList = await window.formatObjectList(list, this.dictCache);
  588. return formattedList.map((item, index) => {
  589. const rawItem = list[index] || {};
  590. const nextItem = {
  591. ...item,
  592. isDraft: !!rawItem.__isDraft,
  593. buttons: [],
  594. };
  595. if (Array.isArray(rawItem.catList) && rawItem.catList.length) {
  596. nextItem.thirdDisplay = [
  597. rawItem.catList
  598. .map(catItem => {
  599. if (!catItem || typeof catItem !== 'object') return null;
  600. const rawValue = catItem.val;
  601. let displayValue = rawValue === undefined || rawValue === null ? '' : String(rawValue);
  602. if (catItem.fmt && window.H5FieldFormatter && typeof window.H5FieldFormatter.formatDate === 'function') {
  603. displayValue = window.H5FieldFormatter.formatDate(rawValue, catItem.fmt) || displayValue;
  604. }
  605. return {
  606. field: {
  607. desc: String(catItem.desc || ''),
  608. },
  609. value: rawValue,
  610. displayValue,
  611. };
  612. })
  613. .filter(Boolean),
  614. ].filter(group => group.length > 0);
  615. }
  616. if (rawItem.chg) {
  617. nextItem.buttons = [{
  618. title: '变动',
  619. onclick: () => this.handleServiceAction(rawItem.chg),
  620. }];
  621. }
  622. return nextItem;
  623. });
  624. },
  625. unwrapResponseData(data) {
  626. if (!data || typeof data !== 'object') return {};
  627. return data.ssData && typeof data.ssData === 'object' ? data.ssData : data;
  628. },
  629. isBizError(data) {
  630. return !!(data && typeof data === 'object' && Object.prototype.hasOwnProperty.call(data, 'ssCode') && Object.prototype.hasOwnProperty.call(data, 'ssMsg') && !data.ssData);
  631. },
  632. formatBizError(data) {
  633. return `错误(${data.ssCode}):${data.ssMsg == null ? '' : data.ssMsg}`;
  634. },
  635. getUrlParams() {
  636. return NavigationManager.getUrlParam();
  637. },
  638. buildRequestParams(pageNo = 1) {
  639. const params = {
  640. pageNo,
  641. rowNumPer: this.pageSize,
  642. management: this.management,
  643. isReady: '1',
  644. ...this.getActiveFilterParams(this.selectedFilters),
  645. };
  646. if (this.ssObjId) {
  647. const objIdKey = String(this.ssPobjIdName || '').trim() || (this.ssObjName ? `${this.ssObjName}id` : 'ssObjId');
  648. params[objIdKey] = this.ssObjId;
  649. }
  650. if (this.requestParentViewObject) {
  651. params.requestParentViewObject = this.requestParentViewObject;
  652. }
  653. return params;
  654. },
  655. getActiveFilterParams(source) {
  656. const params = {};
  657. const data = source && typeof source === 'object' ? source : {};
  658. Object.entries(data).forEach(([key, value]) => {
  659. if (value === '' || value === null || value === undefined) return;
  660. params[key] = value;
  661. });
  662. return params;
  663. },
  664. ensureSelectedFilters() {
  665. const nextFilters = { ...this.selectedFilters };
  666. (this.searchFieldList || []).forEach(field => {
  667. if (!field || !field.name) return;
  668. if (nextFilters[field.name] !== undefined) return;
  669. const pageValue = this.pageParams[field.name];
  670. nextFilters[field.name] = pageValue !== undefined ? String(pageValue) : '';
  671. });
  672. if (this.hasKeyWord) {
  673. if (nextFilters.ssKeyword === undefined) {
  674. nextFilters.ssKeyword = this.searchKeyword || '';
  675. }
  676. this.searchKeyword = String(nextFilters.ssKeyword || '');
  677. }
  678. this.selectedFilters = nextFilters;
  679. },
  680. async generateFilterOptions() {
  681. for (const field of this.searchFieldList || []) {
  682. if (!field || !field.name || !field.cbName) continue;
  683. if (Array.isArray(this.filterSelectOptions[field.name]) && this.filterSelectOptions[field.name].length > 0) continue;
  684. try {
  685. const options = await window.getDictOptions(field.cbName, this.dictCache);
  686. this.filterSelectOptions = {
  687. ...this.filterSelectOptions,
  688. [field.name]: [{ n: `全部${field.desc || ''}`, v: '' }].concat(options || []),
  689. };
  690. } catch (error) {
  691. console.error('❌ 获取筛选选项失败:', field.cbName, error);
  692. }
  693. }
  694. },
  695. isDateField(field) {
  696. const type = Number(field && field.type);
  697. return type === 3 || type === 11;
  698. },
  699. getFieldDesc(fieldName) {
  700. const field = (this.searchFieldList || []).find(item => item && item.name === fieldName);
  701. return field ? field.desc : fieldName;
  702. },
  703. getAttrLabel(attr) {
  704. if (!attr || typeof attr !== 'object') return '';
  705. return attr.field && attr.field.desc ? attr.field.desc : '';
  706. },
  707. getButtonText(button) {
  708. if (!button || typeof button !== 'object') return '';
  709. return button.desc || button.title || button.buttonName || button.name || button.function?.desc || '';
  710. },
  711. getButtonOptions(button) {
  712. if (!button || typeof button !== 'object') return [];
  713. const source = Array.isArray(button.pluginList) && button.pluginList.length
  714. ? button.pluginList
  715. : Array.isArray(button.pageList)
  716. ? button.pageList
  717. : [];
  718. return this.createNavOptions(source);
  719. },
  720. createNavOptions(buttonList) {
  721. if (!Array.isArray(buttonList)) return [];
  722. return buttonList
  723. .filter(item => item && typeof item === 'object')
  724. .map(item => ({
  725. text: this.getButtonText(item),
  726. onclick: () => NavigationManager.goToFromButton(item),
  727. }))
  728. .filter(item => item.text || item.onclick);
  729. },
  730. hasButtonOptions(button) {
  731. return this.getButtonOptions(button).length > 0;
  732. },
  733. setupScopeButtons() {
  734. const scopeList = [
  735. { id: '99', text: '所有' },
  736. { id: '2', text: '管理' },
  737. { id: '1', text: '创建' },
  738. { id: '3', text: '已办' },
  739. { id: '55', text: '停用' },
  740. ];
  741. this.scopeButtonOptions = scopeList.map(item => ({
  742. text: item.text,
  743. onclick: () => this.switchScope(item.id),
  744. }));
  745. },
  746. getCurrentScopeText() {
  747. const scopeMap = {
  748. '99': '所有',
  749. '2': '管理',
  750. '1': '创建',
  751. '3': '已办',
  752. '55': '停用',
  753. };
  754. return scopeMap[String(this.management || '1')] || '所有';
  755. },
  756. async switchScope(scopeId) {
  757. this.management = String(scopeId || '1');
  758. await this.applyFilters();
  759. },
  760. handleFilterChange() {
  761. this.applyFilters();
  762. },
  763. async applyFilters() {
  764. this.currentPage = 1;
  765. this.hasMore = true;
  766. this.list = [];
  767. await this.loadData(1, false);
  768. },
  769. handleRootButtonClick(button) {
  770. if (this.hasButtonOptions(button)) {
  771. return;
  772. }
  773. if (!NavigationManager.goToFromButton(button)) {
  774. this.handleServiceAction(button.function || button);
  775. }
  776. },
  777. handleServiceAction(serviceAction) {
  778. if (!serviceAction || typeof serviceAction !== 'object') {
  779. this.showToast('当前操作缺少配置', 'warning');
  780. return;
  781. }
  782. const navButton = {
  783. ...serviceAction,
  784. dest: serviceAction.dest || serviceAction.ssDest || '',
  785. servName: serviceAction.servName || serviceAction.ssServ || serviceAction.service || '',
  786. service: serviceAction.servName || serviceAction.ssServ || serviceAction.service || '',
  787. title: serviceAction.desc || serviceAction.title || '',
  788. desc: serviceAction.desc || serviceAction.title || '',
  789. };
  790. if (NavigationManager.goToFromButton(navButton)) {
  791. return;
  792. }
  793. this.showToast('暂不支持当前操作跳转', 'warning');
  794. },
  795. handleCardClick(item) {
  796. const play = (item && (item.play || (item.service && item.service.play))) || null;
  797. if (!play) {
  798. this.showToast('当前记录缺少查看配置', 'warning');
  799. return;
  800. }
  801. const serviceName = String(play.servName || play.ssServ || '').trim();
  802. const destName = String(play.dest || 'objPlay').trim();
  803. const paramName = String(play.param_name || '').trim();
  804. const paramValue = play.param_value;
  805. const ssToken = String(play.ssToken || '').trim();
  806. const paramText = typeof play.parm === 'string' ? play.parm : '';
  807. if (!serviceName) {
  808. this.showToast('缺少查看服务名', 'warning');
  809. return;
  810. }
  811. NavigationManager.goTo('mp_objplay', {
  812. title: play.desc || play.title || '查看',
  813. service: serviceName,
  814. dest: destName,
  815. ssDest: destName,
  816. param: paramText,
  817. playParamName: paramName,
  818. playParamValue: paramValue,
  819. ssToken,
  820. ssObjId: item.ssObjId || this.ssObjId || '',
  821. ssObjName: item.ssObjName || this.ssObjName || '',
  822. });
  823. },
  824. handleCardAction() {
  825. },
  826. async loadMore() {
  827. if (!this.hasMore || this.isLoadingMore) return;
  828. await this.loadData(Number(this.currentPage || 1) + 1, true);
  829. },
  830. setupRefreshListener() {
  831. this.refreshCleanup = NavigationManager.onRefreshNotify(() => {
  832. this.applyFilters();
  833. });
  834. },
  835. setupScrollListener() {
  836. let timer = null;
  837. const handleScroll = () => {
  838. clearTimeout(timer);
  839. timer = setTimeout(() => {
  840. const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
  841. const windowHeight = window.innerHeight;
  842. const documentHeight = document.documentElement.scrollHeight;
  843. this.showBackToTop = scrollTop > 300;
  844. if (scrollTop + windowHeight >= documentHeight - 50) {
  845. this.loadMore();
  846. }
  847. }, 200);
  848. };
  849. window.addEventListener('scroll', handleScroll);
  850. this.scrollCleanup = () => {
  851. window.removeEventListener('scroll', handleScroll);
  852. };
  853. },
  854. scrollToTop() {
  855. window.scrollTo({ top: 0, behavior: 'smooth' });
  856. },
  857. handleBackToTopClick() {
  858. if (!this.isLongPress) {
  859. this.scrollToTop();
  860. }
  861. this.isLongPress = false;
  862. },
  863. handleLongPressStart() {
  864. if (!this.hasKeyWord) return;
  865. this.isLongPress = false;
  866. this.longPressTimer = setTimeout(() => {
  867. this.isLongPress = true;
  868. this.openSearchModal();
  869. if (navigator.vibrate) {
  870. navigator.vibrate(50);
  871. }
  872. }, 500);
  873. },
  874. handleLongPressEnd() {
  875. if (this.longPressTimer) {
  876. clearTimeout(this.longPressTimer);
  877. this.longPressTimer = null;
  878. }
  879. },
  880. handleLongPressCancel() {
  881. if (this.longPressTimer) {
  882. clearTimeout(this.longPressTimer);
  883. this.longPressTimer = null;
  884. }
  885. this.isLongPress = false;
  886. },
  887. openSearchModal() {
  888. this.showSearchModal = true;
  889. this.$nextTick(() => {
  890. setTimeout(() => {
  891. if (this.$refs.searchInput) {
  892. this.$refs.searchInput.click();
  893. this.$refs.searchInput.focus();
  894. }
  895. }, 100);
  896. });
  897. },
  898. closeSearchModal() {
  899. this.showSearchModal = false;
  900. },
  901. async performSearch() {
  902. const keyword = String(this.searchKeyword || '').trim();
  903. this.selectedFilters = {
  904. ...this.selectedFilters,
  905. ssKeyword: keyword,
  906. };
  907. this.closeSearchModal();
  908. await this.applyFilters();
  909. },
  910. showToast(message, type = 'info') {
  911. console.log(`${type.toUpperCase()}: ${message}`);
  912. alert(message);
  913. },
  914. },
  915. });
  916. });
  917. </script>
  918. </body>
  919. </html>