objList.jsp 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565
  1. <%@ taglib prefix="ss" uri="/ssTag" %>
  2. <%@ page language="java" pageEncoding="UTF-8" isELIgnored="false" %>
  3. <%@ taglib uri="/ssTag" prefix="ss" %>
  4. <%pageContext.setAttribute("wdpageinformation", "{'hastab':'0'}");%>
  5. <!DOCTYPE html>
  6. <html>
  7. <head>
  8. <meta http-equiv="pragma" content="no-cache">
  9. <meta http-equiv="cache-control" content="no-cache">
  10. <meta http-equiv="expires" content="0">
  11. <script>window.loginStatus = "${empty sessionScope['ssUser']?'0':'1'}"</script>
  12. <ss:skin file='main.css'/>
  13. <script type="text/javascript" src="/ss/jquery/jquery.js"></script>
  14. <script type="text/javascript" src="/ss/artdialog/artDialogUtil.js"></script>
  15. <script type="text/javascript" src="/ss/js/base.js"></script>
  16. <script> if (!window.wd) var wd = {};
  17. if (!wd.display) wd.display = {};
  18. wd.display.wdDialogId = "objList";
  19. if (!wd.app) wd.app = {};
  20. wd.app.name = 'pms';</script>
  21. <script type="text/javascript" src="/ss/js/masklayer.js"></script>
  22. <script type="text/javascript" src="/ss/js/wdDialogInit.js"></script>
  23. <script type="text/javascript" src="/ss/js/common.js"></script>
  24. <script type="text/javascript" src="/ss/js/display.js"></script>
  25. <script type="text/javascript" src="/ss/js/edit.js"></script>
  26. <script type="text/javascript" src="/ss/nicescroll/jquery.nicescroll.js"></script>
  27. <script type="text/javascript" src="/ss/nicescroll/jquery.nicescroll.iframehelper.min.js"></script>
  28. <link rel="stylesheet" type="text/css" href="/ss/window/theme/dhtmlxwindows.css">
  29. <link rel="stylesheet" type="text/css" href="/ss/window/theme/dhx_blue/dhtmlxwindows_dhx_blue.css">
  30. <script type="text/javascript" src="/ss/window/dhtmlxcommon.js"></script>
  31. <script type="text/javascript" src="/ss/window/dhtmlxwindows.js"></script>
  32. <script type="text/javascript" src="/ss/window/dhtmlxcontainer.js"></script>
  33. <script type="text/javascript" src="/ss/js/common.js"></script>
  34. <script type="text/javascript" src="/ss/js/display.js"></script>
  35. <script type="text/javascript" src="/ss/js/edit.js"></script>
  36. <ssDlg setPval="true"/>
  37. <%-- setValue="true" close="true"。Lin --%>
  38. <script type="text/javascript" src="/ss/jquery/jquery.ellipsis.js"></script>
  39. <%-- 新UI引入的JS --%>
  40. <script src="/js/load.js"></script>
  41. <%-- ="/newUI/ss/js/base.js"。Lin(新UI) --%>
  42. <script src="/js/pageC.js"></script>
  43. <%-- 对象变动、修改、查看页,左则选项卡宽度 在里面定义 Ben(20251213) --%>
  44. <%-- 改为 <data@ss name="prt"/>。Lin
  45. <tab@ss name="print" enable="viewobject.funcMap.play.print"/> --%>
  46. <ss:data name='prt'/><%-- 初始化弹出窗口的打印按钮的后台数据 Ben--%>
  47. <%@include file="/ss/clip/prtIcon.jsp" %>
  48. <%-- 引入初始化弹出窗口的打印按钮的JS Ben--%>
  49. <script>
  50. window.ss.dom.formElemConfig = window.ss.dom.formElemConfig || {};
  51. </script>
  52. <style>
  53. /* 首页 loading:没加载完不显示页面内容 */
  54. .pobj-loading-home {
  55. position: fixed;
  56. left: 50%;
  57. top: 50%;
  58. transform: translate(-50%, -50%);
  59. z-index: 9999;
  60. pointer-events: none;
  61. }
  62. /* 列表 loading:区域性(搜索条件和分页之间) */
  63. .pobj-list-loading {
  64. width: 100%;
  65. min-height: 260px;
  66. display: flex;
  67. align-items: center;
  68. justify-content: center;
  69. }
  70. .pobj-spinner {
  71. width: 18px;
  72. height: 18px;
  73. border-radius: 50%;
  74. border: 2px solid rgba(0, 0, 0, 0.2);
  75. border-top-color: rgba(0, 0, 0, 0.65);
  76. animation: pobjSpin 0.8s linear infinite;
  77. }
  78. @keyframes pobjSpin {
  79. from {
  80. transform: rotate(0deg);
  81. }
  82. to {
  83. transform: rotate(360deg);
  84. }
  85. }
  86. </style>
  87. </head>
  88. <body>
  89. <div id="app">
  90. <div v-show="loadingHome" class="pobj-loading-home" style="display:none;">
  91. <div class="pobj-spinner"></div>
  92. </div>
  93. <%-- 功能说明:移除 thnType 直出调试内容,避免进入页面即输出 by xu 20260123 --%>
  94. <%-- 功能说明:主布局容器(左侧表单 + 右侧 ss-sidebar);为首屏 rowNumPer 自适应计算需要,避免用 homeReady 把容器 display:none(否则无法测量宽高) by xu 20260123 --%>
  95. <div style="display: flex; height: 100%; ">
  96. <%-- 功能说明:左侧表单区域在 flex 中占满剩余宽度(避免挤掉右侧 ss-sidebar) by xu 20260113 --%>
  97. <form class="page-container" id="myForm" style="flex: 1; min-width: 0; width: auto;"
  98. action="<ss:serv name='${currentService.servName}' dest='${currentService.dest}' parm='${currentService.parm}'/>"
  99. method="post">
  100. <input type="hidden" name="isAnd" v-model="form.isAnd"/>
  101. <input name="management" type="hidden" v-model="form.management"/>
  102. <input name="isFulltext" type="hidden" v-model="form.isFulltext"/>
  103. <%-- 功能说明:分页已完全走 Vue+Ajax(ssPaging),不再依赖旧表单提交隐藏域 by xu 20260123 --%>
  104. <%--搜索条件start--%>
  105. <div class="search-bar">
  106. <ss-breadcrumb></ss-breadcrumb>
  107. <div class="search-bar-container">
  108. <template v-if="homeReady">
  109. <template v-for="field in searchFieldList" :key="field.name">
  110. <%-- 再增加,支持 ccp。Lin --%>
  111. <ss-ccp
  112. v-if="field.ccp"
  113. mode="2" <%-- 写死,暂不支持单个字段(地区码)的级联。Lin --%>
  114. :param="field.parm" <%-- ="{'fieldOrd':['jzwid','lcid'],'name':'jzw_lc','codebook':'jzw','combField':'jzwid_lcid'}"。Lin --%>
  115. url="/service?ssServ=loadObjpOpt" <%-- &objectpickerdropdown1=1"。Lin --%>
  116. v-model="form[field.name]"
  117. :name="field.name"
  118. :placeholder="field.desc"
  119. :width="field.width"
  120. :search="true" <%-- 再增加,增加 查询页查询条件录入框 标记 -- 紧挨录入行的下拉按钮。Lin --%>
  121. :inp="field.inp" <%-- 再增加,SsCcp 支持 inp="true"。Lin --%>
  122. ></ss-ccp>
  123. <%-- --%>
  124. <ss-objp
  125. v-else-if="field.cbName"
  126. v-model="form[field.name]"
  127. :name="field.name"
  128. :placeholder="field.desc"
  129. <%-- 再改,改由 <obj 下的 <field width= 设定。Lin
  130. width="150px"
  131. --%> :width="field.width"
  132. <%-- 再改,改由 <obj 下的 <field inp= 设定。Lin
  133. :inp="true"
  134. --%> :inp="field.inp"
  135. url="/service?ssServ=loadObjpOpt" <%-- &objectpickerdropdown1=1"。Lin --%>
  136. :cb="field.cbName"
  137. :search="true" <%-- 再增加,增加 查询页查询条件录入框 标记 -- 紧挨录入行的下拉按钮。Lin --%>
  138. ></ss-objp>
  139. <ss-search-date-picker
  140. v-else-if="field.type == 11"
  141. v-model="form[field.name]"
  142. :name="field.name"
  143. type="date"
  144. :placeholder="field.desc"
  145. width="140px"
  146. :fmt="field.fmt"
  147. ></ss-search-date-picker>
  148. <ss-search-date-picker
  149. v-else-if="field.type == 3"
  150. v-model="form[field.name]"
  151. :name="field.name"
  152. type="datetime"
  153. :placeholder="field.desc"
  154. width="200px"
  155. :fmt="field.fmt"
  156. ></ss-search-date-picker>
  157. <ss-search-input
  158. v-else
  159. :name="field.name"
  160. :placeholder="field.desc"
  161. v-model="form[field.name]"
  162. width="120px"
  163. @search="search"
  164. ></ss-search-input>
  165. </template>
  166. <ss-search-input
  167. v-if="hasKeyword"
  168. name="ssKeyword"
  169. placeholder="关键词"
  170. v-model="form.ssKeyword"
  171. width="120px"
  172. @search="search"
  173. ></ss-search-input>
  174. <ss-search-button
  175. v-if="hasScope"
  176. <%-- 再去掉,SsSearchButton = { > props: { 里没有定义。Lin
  177. :key="'scope-' + String(searchButtonConfigCheckId)"
  178. --%>
  179. text="所有"
  180. icon-class="nav-icon-search"
  181. :opt="searchButtonConfig"
  182. :check-id="searchButtonConfigCheckId"
  183. ></ss-search-button>
  184. <template v-for="func in rootFuncList" :key="func.id || func.servName">
  185. <ss-search-button
  186. :text="func.desc || func.title || ''"
  187. icon-class="nav-icon-add"
  188. <%-- 改,支持细分部件。Lin
  189. :opt="[]"
  190. :check-id="0"
  191. --%>
  192. :opt="subpageOpt"
  193. :check-id="selSubpage"
  194. @click="handleRootFuncClick(func)"
  195. ></ss-search-button>
  196. </template>
  197. </template>
  198. </div>
  199. </div>
  200. <%--搜索条件end--%>
  201. <%--搜索结果start--%>
  202. <%-- 功能说明:卡片区域使用 grid 自动分列,剩余宽度平分(不锁死 max-width) by xu 20260109 --%>
  203. <div v-show="userInteracted && loadingList" class="pobj-list-loading" style="display:none;">
  204. <div class="pobj-spinner"></div>
  205. </div>
  206. <div v-show="!(userInteracted && loadingList)"
  207. :class="['content-area','item-content-area', cardGridKind ? ('ss-card-grid--' + cardGridKind) : '']">
  208. <template v-for="(item, i) in listConfig.draftbox" :key="i">
  209. <ss-folder-card v-if="item.children" :item="item"></ss-folder-card>
  210. <!-- 功能说明:传入 ssObjName + cardClickAction(卡片主体点击 view/single;角标仍多选) by xu 20260109 -->
  211. <ss-list-card v-else :item="item" :ss-obj-name="ssObjName" :card-click-action="cardClickAction"
  212. @toggle-select="handleToggleSelect"></ss-list-card>
  213. </template>
  214. <template v-for="(item, i) in listConfig.list" :key="i">
  215. <ss-folder-card v-if="item.children" :item="item"></ss-folder-card>
  216. <!-- 功能说明:传入 ssObjName + cardClickAction(卡片主体点击 view/single;角标仍多选) by xu 20260109 -->
  217. <ss-list-card v-else :item="item" :ss-obj-name="ssObjName" :card-click-action="cardClickAction"
  218. @toggle-select="handleToggleSelect"></ss-list-card>
  219. </template>
  220. <ss-page
  221. :key="String(ssPaging?.pageNo || 1) + '-' + String(ssPaging?.rowNumPer || 0) + '-' + String(ssPaging?.rowNum || 0)" <%-- // 功能说明:分页 key 不再硬编码 12,仅用于触发分页组件重渲染 by xu 20260123 --%>
  222. :total="Number(ssPaging?.rowNum || 0)"
  223. :size="Number(ssPaging?.rowNumPer || 0)" <%-- // 功能说明:分页大小仅使用 ssPaging.rowNumPer(默认值由 data 初始化兜底一次) by xu 20260123 --%>
  224. :page="Number(ssPaging?.pageNo || 1)"
  225. @change="handlePageChange">
  226. </ss-page>
  227. </div>
  228. </form>
  229. <!-- 功能说明:右侧业务面板(ss-sidebar),用于已选/服务/预订/图表等;当无 rbarTabNameList/rbarFuncList/pstatList 时临时隐藏 by xu 20260122 -->
  230. <ss-sidebar v-if="showRightSidebar"
  231. :buttons="sidebarButtons"
  232. :panels="sidebarPanels"
  233. @remove="handleSidebarRemove"
  234. ></ss-sidebar>
  235. <!-- 功能说明:业务页编辑态右下角新增入口(+ hover 上拉:增加图/增加表) by xu 20260123 -->
  236. <div v-if="isSysEditMode && sysModeSource === 'biz'" class="ss-objlist-fab" @click.stop>
  237. <button type="button" class="ss-objlist-fab__btn" title="新增">
  238. <ss-icon class="menu-base-icon icon-add"></ss-icon> <%-- // 功能说明:新增按钮图标样式参考左侧菜单 by xu 20260123 --%>
  239. </button>
  240. <div class="ss-objlist-fab__menu">
  241. <div class="ss-objlist-fab__item" @click="openAddPcht">增加图</div>
  242. <div class="ss-objlist-fab__item" @click="openAddPform">增加表</div>
  243. </div>
  244. </div>
  245. </div>
  246. </div>
  247. </body>
  248. </html>
  249. <script type="module">
  250. <%-- 打印新UI相关json对象 --%>
  251. const data = {
  252. ssObjName: "${ssObjName}", // 对象名
  253. // 后端注入的 ssServ 接口名(用于 ajax 拉取查询首页/列表数据)
  254. ssSearchPobjHomeServName: "${ssSearchPobjHomeServName}", // <对象名>_cxsy
  255. ssSearchPobjListServName: "${ssSearchPobjListServName}", // <对象名>_cxlb
  256. // 接口返回(调试用,可删)
  257. ssHomeResp: null,
  258. ssListResp: null,
  259. // 页面状态
  260. homeReady: false,
  261. userInteracted: false, // 用户触发(搜索/翻页/切换范围)
  262. loadingHome: false,
  263. loadingList: false,
  264. isSysEditMode: false, // 功能说明:系统编辑态(业务页)控制右下角“新增”入口显隐 by xu 20260123
  265. sysModeSource: "unknown", // 功能说明:编辑态来源(desktop/biz/menu/unknown) by xu 20260123
  266. // 首页接口返回字段(按 page/objlist修改.txt)
  267. searchFieldList: [], // 查询条件字段
  268. rootFuncList: [], // 根功能
  269. hasKeyword: false, // 是否有关键词
  270. hasScope: false, // 是否带范围
  271. thnType: (() => { // 功能说明:首屏 thnType 优先从 JSP 注入(用于第一个接口前正确计算 rowNumPer);空/缺省回退 0 by xu 20260123
  272. try {
  273. const s = String("${thnType}" || "").trim();
  274. const n = parseInt(s, 10);
  275. return isNaN(n) ? 0 : n;
  276. } catch (_) {
  277. return 0;
  278. }
  279. })(), // 缩略图类型:1横向 2竖向 3方形 4圆形(目前仅用 1/2,其他先不处理)
  280. ssPaging: {pageNo: 1, rowNumPer: 12, rowNum: 0}, // 翻页信息 // 功能说明:分页默认每页12条(全文件仅此处兜底) by xu 20260123
  281. rbarFuncList: [], // 右侧栏功能
  282. rbarTabNameList: [], // 右侧栏选项卡
  283. pstatList: [], // 功能说明:个人统计图表配置(右侧图表区) by xu 20260114
  284. // 查询表单参数(用于接口入参)
  285. form: {management: "99", isFulltext: "0", isAnd: "", ssKeyword: ""},
  286. systemType: window.ss.dom.TYPE,
  287. listConfig: window.ss.dom.listConfig || {draftbox: [], list: []},
  288. formElemConfig: window.ss.dom.formElemConfig || {},
  289. // 卡片区域:自动分列/宽度平分 by xu 20260109
  290. cardGridKind: (() => { // 功能说明:首屏按 thnType 预设网格类型(决定 --ss-card-min),避免缩略图业务第一个接口仍按 300px 计算 by xu 20260123
  291. try {
  292. const t = (() => { const s = String("${thnType}" || "").trim(); const n = parseInt(s, 10); return isNaN(n) ? 0 : n; })();
  293. if (t === 1) return "thumbnail";
  294. if (t === 2) return "photo";
  295. return "none";
  296. } catch (_) {
  297. return "none";
  298. }
  299. })(), // none/photo/thumbnail by xu 20260109
  300. // 卡片主体点击动作:view=查看(调用 item.onclick);single=单选互斥;角标仍多选 by xu 20260109
  301. cardClickAction: "view", // 功能说明:默认先用 view,首页接口若返回预订面板则切到 single by xu 20260114
  302. hasBookPanel: false, // 功能说明:是否存在预订面板(驱动 cardClickAction + 选中后联动 cxycl) by xu 20260116
  303. hasServPanel: false, // 功能说明:是否存在服务面板(严格依赖首页 rbarTabNameList 是否返回 rbarServ) by xu 20260116
  304. hasObjPanel: false, // 功能说明:是否存在对象面板(严格依赖首页 rbarTabNameList 是否返回 rbarObj;无则不显示“已选”且禁止选中) by xu 20260122
  305. rbar: (String("${rbar}" || "").trim().toLowerCase() === "true") ? true : null, // 功能说明:JSP 注入 rbar:有字段且为 "true" 才展示;缺省/空串为 null,首页接口返回后会覆盖 by xu 20260123
  306. showRightSidebar: (String("${rbar}" || "").trim().toLowerCase() === "true"), // 功能说明:首屏右侧栏显隐以 JSP rbar 为准(用于首屏测量口径) by xu 20260123
  307. autoRowNumPer: 0, // 功能说明:动态计算的 rowNumPer(只记录,下次接口请求时生效;resize 不立即重拉) by xu 20260123
  308. yclLoading: false, // 功能说明:已选对象联动(cxycl)加载状态 by xu 20260114
  309. yclResp: null, // 功能说明:已选对象联动接口返回(调试/兜底) by xu 20260114
  310. // 右侧已选(用于未来接入 ss-sidebar 的已选面板) by xu 20260109
  311. selectedItems: [],
  312. // 右侧边栏:顶部按钮(由首页接口 rbarFuncList 初始化)
  313. sidebarButtons: [],
  314. // 右侧边栏:分区配置(由 initSidebarPanels 初始化) by xu 20260113
  315. sidebarPanels: [],
  316. <%-- 实际没用上,注释掉 Ben(20251225) btnElemConfig:window.ss.dom.btnElemConfig, --%>
  317. searchButtonConfigCheckId: "99",
  318. searchButtonConfig: [
  319. {
  320. id: "99",
  321. desc: "所有",
  322. callback: () => window.__objListVm && window.__objListVm.switchScope(99),
  323. },
  324. {
  325. id: "2",
  326. desc: "管理",
  327. callback: () => window.__objListVm && window.__objListVm.switchScope(2),
  328. },
  329. {
  330. id: "1",
  331. desc: "创建",
  332. callback: () => window.__objListVm && window.__objListVm.switchScope(1),
  333. },
  334. {
  335. id: "3",
  336. desc: "已办",
  337. callback: () => window.__objListVm && window.__objListVm.switchScope(3),
  338. },
  339. {
  340. id: "55",
  341. desc: "停用",
  342. callback: () => window.__objListVm && window.__objListVm.switchScope(55),
  343. }
  344. ],
  345. /// 增加,支持细分部件。Lin
  346. subpageOpt: [],
  347. selSubpage: "",
  348. ///
  349. }
  350. if (window.ss.dom.formElemConfig) {
  351. Object.entries(window.ss.dom.formElemConfig).forEach(([key, config]) => {
  352. data[key] = config.value;
  353. // 处理 objPicker
  354. if (config.type === window.ss.dom.TYPE.OBJPICKER) {
  355. data[key + "ObjPicker"] = true;
  356. data[key + "Option"] = [];
  357. data[key + "Url"] = config.optUrl;
  358. }
  359. })
  360. }
  361. SS.ready(function () {
  362. // 功能说明:右侧 ss-sidebar__inner 统一增加 padding-top=10px(撤回外层 wrapper 方案) by xu 20260114
  363. try {
  364. if (!document.getElementById("ss-objlist-sidebar-inner-padding")) {
  365. var st = document.createElement("style");
  366. st.id = "ss-objlist-sidebar-inner-padding";
  367. st.type = "text/css";
  368. st.appendChild(document.createTextNode("#app .ss-sidebar__inner{padding-top:10px;}"));
  369. document.head.appendChild(st);
  370. }
  371. } catch (e) {
  372. }
  373. window.ss.dom.initializeFormApp({
  374. el: "#app",
  375. data() {
  376. return data;
  377. },
  378. methods: {
  379. openAddPform() {
  380. // 功能说明:编辑态新增统计表(pformSet) by xu 20260123
  381. try {
  382. wd.display.showComponent({
  383. show: ["wdDialog"],
  384. url: "<ss:serv name='addPform' parm='{\"dxm\":\"${ssObjName}\"}' dest='pformSet'/>", // {\"wdConfirmationCaptchaService\":\"0\",。Lin
  385. title: "设置统计表",
  386. width: 800,
  387. height: 580
  388. });
  389. } catch (e) {
  390. console.error("openAddPform failed", e);
  391. }
  392. },
  393. openAddPcht() {
  394. // 功能说明:编辑态新增统计图(pchtSet) by xu 20260123
  395. try {
  396. wd.display.showComponent({
  397. show: ["wdDialog"],
  398. url: "<ss:serv name='addPcht' parm='{\"dxm\":\"${ssObjName}\",\"use_grtjmbid\":\"${use_grtjmbid}\"}' dest='pchtSet'/>", // {\"wdConfirmationCaptchaService\":\"0\",。Lin
  399. title: "设置统计图",
  400. width: 800,
  401. height: 580
  402. });
  403. } catch (e) {
  404. console.error("openAddPcht failed", e);
  405. }
  406. },
  407. openServiceDialog(srv) {
  408. // 功能说明:使用 tools.js 统一封装的 openServiceDialog,支持透传搜索条件 by xu 20260122
  409. if (!srv) return;
  410. const extraParams = window.ssTools.pickSearchParams(this.searchFieldList, this.form);
  411. // 功能说明:已选对象 ID 拼接为 rbarObjId=111,222 by xu 20260424
  412. const objIds = (this.selectedItems || [])
  413. .map((it) => it?.objNum || it?._raw?.ssObjId)
  414. .filter(Boolean)
  415. .join(',');
  416. if (objIds) extraParams.rbarObjId = objIds;
  417. // 功能说明:已选人员 ID 拼接为 rbarRyId=xxx,xxx by xu 20260424
  418. const ryPanel = (this.sidebarPanels || []).find((p) => p?._tabKey === 'rbarry');
  419. const ryIds = (ryPanel?.items || [])
  420. .map((it) => it?.id || it?.ryId || it?._raw?.ryId)
  421. .filter(Boolean)
  422. .join(',');
  423. if (ryIds) extraParams.rbarRyId = ryIds;
  424. window.ssTools.openServiceDialog(srv, { extraParams });
  425. },
  426. normalizeObjToCard(row) {
  427. const card = {
  428. _raw: row,
  429. ssObjName: row?.ssObjName,
  430. // 对象号只取后端按 <field sn="true"> 下发的 objNum,不再用数据库主键兜底。
  431. objNum: row?.objNum,
  432. title: "",
  433. desc: row?.abs || "",
  434. tags: [],
  435. buttons: [],
  436. stateIconList: row?.stateIconList || [],
  437. statusIcons: [],
  438. bigState: row?.bigState,
  439. bookState: row?.bookState,
  440. };
  441. // 功能说明:将后端 stateIconList 映射为卡片右上角 statusIcons(按 icon-state/icon-servType 规则转为 biz 图标组;无匹配则不展示;不使用 menu-*) by xu 20260123
  442. try {
  443. const rawList = Array.isArray(row?.stateIconList) ? row.stateIconList : [];
  444. const icons = [];
  445. const seen = new Set();
  446. rawList.forEach((s) => {
  447. const cls = String(s || "").trim();
  448. if (!cls) return;
  449. const m = cls.match(/-(\d+)$/);
  450. const code = m ? Number(m[1]) : NaN;
  451. if (code === 1) return; // 约定:后缀为 1 的不处理 by xu 20260116
  452. // 功能说明:icon-state-<对象名>-<状态码>:15=清洁中(icon-obj-qjz),275=维修中(icon-obj-wxz) by xu 20260123
  453. const stateMatch = cls.match(/^icon-state-[^-]+-(\d+)$/);
  454. if (stateMatch) {
  455. const stateCode = Number(stateMatch[1]);
  456. if (stateCode === 15) {
  457. const k = "ss-card-status-biz-icon icon-obj-qjz";
  458. if (!seen.has(k)) { seen.add(k); icons.push({ class: k, title: "清洁中" }); }
  459. return;
  460. }
  461. if (stateCode === 275) {
  462. const k = "ss-card-status-biz-icon icon-obj-wxz";
  463. if (!seen.has(k)) { seen.add(k); icons.push({ class: k, title: "维修中" }); }
  464. return;
  465. }
  466. return;
  467. }
  468. // 功能说明:icon-servType-<对象名>-<服务类别码>:只要类别码!=1 就显示服务图标 icon-obj-fw by xu 20260123
  469. const servTypeMatch = cls.match(/^icon-servType-[^-]+-(\d+)$/);
  470. if (servTypeMatch) {
  471. const servTypeCode = Number(servTypeMatch[1]);
  472. if (servTypeCode !== 1) {
  473. const k = "ss-card-status-biz-icon icon-obj-fw";
  474. if (!seen.has(k)) { seen.add(k); icons.push({ class: k, title: "服务中" }); }
  475. }
  476. return;
  477. }
  478. // 功能说明:兜底支持后端直接下发 icon-base 字形类(例如 icon-fauth),不再拼 menu-base-icon;不再用 icon-sauth 兜底 by xu 20260123
  479. try {
  480. const tokens = cls.match(/\bicon-[a-zA-Z0-9_-]+\b/g) || [];
  481. const glyph = tokens.find((t) => t && t.indexOf("icon-state-") !== 0 && t.indexOf("icon-servType-") !== 0);
  482. if (glyph) {
  483. if (glyph === "icon-sauth") return; // 功能说明:不再使用 icon-sauth 作为兜底/透传展示 by xu 20260123
  484. const k = "ss-card-status-base-icon " + glyph;
  485. if (!seen.has(k)) { seen.add(k); icons.push({ class: k, title: "使用中" }); }
  486. }
  487. } catch (_) {}
  488. });
  489. card.statusIcons = icons;
  490. } catch (e) {
  491. }
  492. // 功能说明:title 可能是 {val, fmt}(日期/时间),此处按 fmt 做格式化(避免显示英文时间串) by xu 20260114
  493. try {
  494. const t = row?.title;
  495. if (t && typeof t === "object" && t.val !== undefined) {
  496. card.title = String(window.ssTools.formatValByFmt(t.val, t.fmt) ?? "");
  497. } else {
  498. card.title = String(row?.title?.val || row?.title || "");
  499. }
  500. } catch (_) {
  501. card.title = String(row?.title?.val || row?.title || "");
  502. }
  503. // 功能说明:bookState 优先于 bigState(0绿空闲/1黄预订中/2红),映射到卡片 status by xu 20260116
  504. const hasBookState = row?.bookState !== undefined && row?.bookState !== null && row?.bookState !== "";
  505. const hasBigState = row?.bigState !== undefined && row?.bigState !== null && row?.bigState !== "";
  506. if (hasBookState || hasBigState) {
  507. const stateVal = hasBookState ? Number(row.bookState) : Number(row.bigState);
  508. card.status = stateVal === 2 ? "disabled" : stateVal === 1 ? "unavailable" : stateVal === 0 ? "available" : "";
  509. }
  510. // thnType:缩略图类型(目前仅处理 1=横向、2=竖向;其余先按无缩略图处理)
  511. // 注意:即使 thn 为空,只要 thnType 存在,也要保留缩略图区域,以显示“对象号_icon”占位
  512. const thnType = Number(this.thnType || 0);
  513. if (thnType === 1) card.thumbType = "thumbnail"; // 横向:180×100
  514. else if (thnType === 2) card.thumbType = "photo"; // 竖向:73×100(默认)
  515. // thn:缩略图不为空 => 有图片(否则 ss-list-card 会按 thumbType 显示占位 icon)
  516. if (row?.thn) card.thumb = window.ssTools.buildThumbUrl(row.thn);
  517. if (Array.isArray(row?.catList)) {
  518. row.catList.forEach((c) => {
  519. if (!c || !c.desc) return;
  520. // 功能说明:catList 存在 fmt 时格式化时间(yyyy-MM-dd / yyyy-MM-dd HH:mm:ss),避免直接显示英文时间串 by xu 20260114
  521. const val = window.ssTools.formatValByFmt(c.val, c.fmt);
  522. card.tags.push({[c.desc]: val});
  523. });
  524. }
  525. if (Array.isArray(row?.chgRootFuncList)) {
  526. row.chgRootFuncList.forEach((btn) => {
  527. card.buttons.push({
  528. id: btn.id,
  529. titlexxx: btn.title,
  530. class: "cart-list-setting",
  531. title: btn.desc || btn.title || "",
  532. onclick: () => this.openServiceDialog(btn),
  533. });
  534. });
  535. }
  536. if (row?.play) {
  537. card.onclick = () => this.openServiceDialog(row.play);
  538. }
  539. return card;
  540. },
  541. buildPstatChartPanels(bizIcon) {
  542. // 功能说明:根据 pstatList 构建右侧图表面板(type=chart),用于 ss-sidebar 底部图表区 by xu 20260114
  543. const list = Array.isArray(this.pstatList) ? this.pstatList : [];
  544. return list
  545. .filter((it) => Number(it?.grtjlbm) === 1)
  546. .map((it) => ({
  547. type: "chart",
  548. _grtjid: it?.grtjid,
  549. title: it?.mc || "",
  550. iconClass: bizIcon,
  551. // 功能说明:右侧面板图表高度做上限(避免后端 gd 过大导致 sidebar 竖向撑爆) by xu 20260114
  552. height: (() => {
  553. const gd = Number(it?.gd);
  554. const h = (isFinite(gd) && gd > 0) ? Math.max(160, Math.min(260, gd)) : 220;
  555. return String(h) + "px";
  556. })(),
  557. // 功能说明:统计图默认先用柱状图(后续可按后端类型再扩展) by xu 20260115
  558. options: {
  559. xAxis: {type: "category", data: []},
  560. yAxis: {type: "value"},
  561. series: [{type: "bar", data: []}]
  562. },
  563. }));
  564. },
  565. loadPstatChartData(panel) {
  566. // 功能说明:根据 grtjid 调 wrPchtPlay 获取真实数据,并写回 panel.options 触发渲染 by xu 20260114
  567. const grtjid = panel?._grtjid;
  568. if (!grtjid) return Promise.resolve(null);
  569. return this.callSsService("wrPchtPlay", {grtjid})
  570. .then((res) => {
  571. const payload = res && typeof res === "object" ? (res.ssData || res) : null;
  572. // 功能说明:兼容 wrPchtPlay 返回 dataArray(name=mc,value=sl) by xu 20260114
  573. let list =
  574. (payload && (payload.dataArray || payload.dataList || payload.list || payload.data)) ||
  575. payload;
  576. if (!Array.isArray(list)) list = [];
  577. const data = list
  578. .map((it) => {
  579. if (!it || typeof it !== "object") return null;
  580. const name = it.name ?? it.mc ?? it.desc ?? it.title;
  581. const value = it.value ?? it.sl ?? it.zrs ?? it.count ?? it.num;
  582. if (name === undefined || name === null) return null;
  583. const v = Number(value);
  584. return {name: String(name), value: isNaN(v) ? 0 : v};
  585. })
  586. .filter(Boolean);
  587. // 功能说明:统计图默认先用柱状图(tooltip/label 显示数值;全 0 也正常展示) by xu 20260115
  588. const xData = data.map((it) => it.name);
  589. const yData = data.map((it) => it.value);
  590. panel.options = {
  591. color: ["#5470C6", "#91CC75", "#FAC858", "#EE6666", "#73C0DE", "#3BA272", "#FC8452", "#9A60B4", "#EA7CCC"],
  592. tooltip: {trigger: "axis", axisPointer: {type: "shadow"}},
  593. grid: {left: "3%", right: "3%", top: 12, bottom: 24, containLabel: true},
  594. xAxis: {
  595. type: "category",
  596. data: xData,
  597. axisLabel: {interval: 0, rotate: xData.length > 6 ? 30 : 0}
  598. },
  599. yAxis: {type: "value"},
  600. series: [{
  601. type: "bar",
  602. barMaxWidth: 36,
  603. data: yData,
  604. label: {show: true, position: "top"},
  605. }],
  606. };
  607. // 功能说明:强制触发 sidebarPanels 更新(避免仅在选中卡片后才刷新图表) by xu 20260114
  608. try {
  609. this.sidebarPanels = (this.sidebarPanels || []).slice();
  610. } catch (e) {
  611. }
  612. // 功能说明:图表初次渲染时容器尺寸可能未稳定,nextTick 后触发 resize,避免“未选中=灰色圆” by xu 20260114
  613. try {
  614. const self = this;
  615. if (self && self.$nextTick) {
  616. self.$nextTick(function () {
  617. try {
  618. window.dispatchEvent(new Event("resize"));
  619. } catch (e) {
  620. }
  621. });
  622. }
  623. setTimeout(function () {
  624. try {
  625. window.dispatchEvent(new Event("resize"));
  626. } catch (e) {
  627. }
  628. }, 120);
  629. } catch (e) {
  630. }
  631. return res;
  632. })
  633. .catch((e) => {
  634. console.error("loadPstatChartData failed", grtjid, e);
  635. return null;
  636. });
  637. },
  638. applyPobjHomeData(ssData) {
  639. if (!ssData || typeof ssData !== "object") return;
  640. this.ssHomeResp = ssData;
  641. this.homeReady = true;
  642. this.userInteracted = false;
  643. this.ssObjName = ssData.ssObjName || this.ssObjName; // 对象名
  644. this.searchFieldList = Array.isArray(ssData.searchFieldList) ? ssData.searchFieldList : []; // 查询条件字段
  645. this.rootFuncList = Array.isArray(ssData.rootFuncList) ? ssData.rootFuncList : []; // 根功能
  646. this.hasKeyword = !!ssData.hasKeyword; // 是否有关键词
  647. this.hasScope = !!ssData.hasScope; // 是否带范围
  648. this.thnType = Number(ssData.thnType || 0); // 缩略图类型
  649. this.ssPaging = ssData.ssPaging || this.ssPaging; // 翻页信息
  650. this.rbarFuncList = Array.isArray(ssData.rbarFuncList) ? ssData.rbarFuncList : []; // 右侧栏功能
  651. this.rbarTabNameList = Array.isArray(ssData.rbarTabNameList) ? ssData.rbarTabNameList : []; // 右侧栏选项卡
  652. this.pstatList = Array.isArray(ssData.pstatList) ? ssData.pstatList : []; // 功能说明:个人统计图表配置 by xu 20260114
  653. // 功能说明:优先使用后端 0 服务字段 rbar 控制右侧栏显隐;若后端缺省未返回 rbar,则临时回退为 3 字段判空规则 by xu 20260123
  654. if (Object.prototype.hasOwnProperty.call(ssData, "rbar")) {
  655. this.rbar = !!ssData.rbar;
  656. this.showRightSidebar = !!ssData.rbar;
  657. } else {
  658. this.rbar = null;
  659. // 功能说明:临时规则——当 rbarTabNameList/rbarFuncList/pstatList 全为空时隐藏右侧栏,把宽度让给左侧列表;后续改为“无 rbarTabNameList && 无图表标记”再隐藏(等后端给图表标记) by xu 20260122
  660. this.showRightSidebar = (this.rbarTabNameList?.length > 0) || (this.rbarFuncList?.length > 0) || (this.pstatList?.length > 0);
  661. }
  662. // 功能说明:如果首页返回预订/服务面板(rbarBook/rbarbook/rbarServ),则卡片主体点击切到 single(单选互斥),否则保持 view(查看) by xu 20260116
  663. {
  664. const tabs = Array.isArray(this.rbarTabNameList) ? this.rbarTabNameList : [];
  665. const norm = (s) => String(s || "").trim().toLowerCase();
  666. this.hasBookPanel = tabs.some((t) => norm(t) === "rbarbook"); // 功能说明:预订tab存在才回显bookList by xu 20260116
  667. this.hasServPanel = tabs.some((t) => norm(t) === "rbarserv"); // 功能说明:服务tab存在才回显servList by xu 20260116
  668. this.hasObjPanel = tabs.some((t) => norm(t) === "rbarobj"); // 功能说明:无 rbarObj 时禁用选中能力 by xu 20260122
  669. this.cardClickAction = (this.hasObjPanel && (this.hasBookPanel || this.hasServPanel)) ? "single" : "view"; // 功能说明:仅允许选中时才启用单选联动 by xu 20260122
  670. }
  671. this.searchButtonConfigCheckId = String(this.form?.management || "99");
  672. // 用当前表单参数初始化 form(确保 v-model 有值)
  673. const curParams = this.getSearchFormParams();
  674. const nextForm = {...this.form, ...curParams};
  675. this.searchFieldList.forEach((f) => {
  676. if (f && f.name && !(f.name in nextForm)) nextForm[f.name] = "";
  677. });
  678. this.form = nextForm;
  679. this.searchButtonConfigCheckId = String(this.form?.management || "99");
  680. /// 增加,支持细分部件。Lin
  681. if (this.rootFuncList) {
  682. this.rootFuncList.forEach((func) => {
  683. if (func.pageList) {
  684. func.pageList.forEach((page) => {
  685. this.subpageOpt.push({
  686. id: page.id,
  687. desc: page.desc,
  688. callback: () => this.swSubpage(page),
  689. });
  690. });
  691. }
  692. });
  693. }
  694. ///
  695. // 初始化列表(objList/draftList)
  696. const nextDraft = Array.isArray(ssData.draftList) ? ssData.draftList.map((r) => this.normalizeObjToCard(r)) : [];
  697. const nextList = Array.isArray(ssData.objList) ? ssData.objList.map((r) => this.normalizeObjToCard(r)) : [];
  698. if (this.listConfig) {
  699. this.listConfig.draftbox = nextDraft;
  700. this.listConfig.list = nextList;
  701. }
  702. // 列表数据更新后,重新探测卡片网格类型
  703. this.cardGridKind = this.detectCardGridKind();
  704. // 功能说明:首页列表/右侧栏落地后,按当前容器尺寸更新 autoRowNumPer(不立即重拉;下次列表请求时生效) by xu 20260123
  705. if (this.$nextTick) this.$nextTick(() => this.scheduleAutoRowNumPer("home"));
  706. else this.scheduleAutoRowNumPer("home");
  707. // 初始化右侧栏(选项卡 + 功能)
  708. const bizIcon = this.ssObjName ? ("ss-sidebar-biz-icon icon-obj-" + this.ssObjName) : "";
  709. // 功能说明:右侧各 tab header 图标:预订/服务用固定业务图标,其余沿用当前对象图标 by xu 20260123
  710. const tabIconClassOf = (tabKeyLower) => {
  711. if (tabKeyLower === "rbarbook") return "ss-sidebar-biz-icon icon-obj-yd";
  712. if (tabKeyLower === "rbarserv") return "ss-sidebar-biz-icon icon-obj-fw";
  713. return bizIcon;
  714. };
  715. const pickedPanel = this.hasObjPanel ? { // 功能说明:仅 rbarObj 存在才显示“已选”tab by xu 20260122
  716. type: "list",
  717. title: "已选",
  718. count: this.selectedItems.length,
  719. iconClass: bizIcon,
  720. closable: true,
  721. itemLayout: "person",
  722. items: this.selectedItems,
  723. mode: "selected",
  724. itemAction: true,
  725. onClear: () => this.clearSelectedItems(),
  726. } : null;
  727. // 功能说明:面板 key 兼容后端大小写(rbarBook/rbarbook/rbarServ),并移除“对象”tab by xu 20260116
  728. const titleMap = {rbarry: "人员", rbarbook: "预订", rbarserv: "服务"};
  729. const tabs = Array.isArray(this.rbarTabNameList) ? this.rbarTabNameList : [];
  730. const normKey = (s) => String(s || "").trim().toLowerCase();
  731. const tabPanels = tabs.map((k) => {
  732. const nk = normKey(k);
  733. // 功能说明:右侧栏去掉“对象”tab(即使后端返回 rbarObj 也忽略) by xu 20260116
  734. if (nk === "rbarobj") return null;
  735. const p = {
  736. type: "list",
  737. _tabKey: nk, // 功能说明:保存原始 tab key(用于后续写回 items) by xu 20260114
  738. title: titleMap[nk] || k,
  739. iconClass: tabIconClassOf(nk),
  740. items: [],
  741. itemAction: false,
  742. };
  743. // 功能说明:右侧“预订/服务”面板复用“已选”tab 的 person 布局(title+meta),避免渲染 ss-sidebar-tag by xu 20260116
  744. if (nk === "rbarbook") {
  745. p.itemLayout = "person";
  746. }
  747. if (nk === "rbarserv") {
  748. p.itemLayout = "simple"; // 功能说明:服务面板只回显 mc(名称),不需要 meta 槽位 by xu 20260116
  749. }
  750. // 功能说明:右侧“人员”面板先做前端 mock 搜索头(仅展示,不接后端) by xu 20260114
  751. if (nk === "rbarry") {
  752. p.iconClass = "ss-sidebar-biz-icon icon-obj-ry"; // 功能说明:右侧“人员”tab 使用右侧栏 biz 图标基类 by xu 20260123
  753. p.count = 0;
  754. p.headerFilters = [
  755. {
  756. key: "keyword",
  757. component: "ss-search-input",
  758. props: {name: "keyword", placeholder: "人员", width: "140px"},
  759. value: "",
  760. },
  761. ];
  762. p.headerSearchButton = true;
  763. p.onSearch = function (payload) {
  764. try {
  765. console.log("人员搜索", payload);
  766. } catch (_) {
  767. }
  768. };
  769. p.mode = "selected";
  770. p.items = [];
  771. p.itemAction = false;
  772. }
  773. return p;
  774. }).filter(Boolean);
  775. this.sidebarPanels = pickedPanel ? [pickedPanel, ...tabPanels] : tabPanels; // 功能说明:无 rbarObj 时不注入“已选”tab by xu 20260122
  776. try {
  777. console.log("[pobj] sidebarPanels(init)", (this.sidebarPanels || []).map((p) => ({
  778. title: p?.title,
  779. type: p?.type,
  780. tab: p?._tabKey
  781. })));
  782. } catch (_) {
  783. } // 功能说明:打印初始化后的面板列表,排查缺少“对象/预订”tab by xu 20260116
  784. // 功能说明:将 pstatList=51 聚拢为一个“报表”面板(type=report-table),用于右侧报表区 by xu 20260115
  785. try {
  786. const reportList = (Array.isArray(this.pstatList) ? this.pstatList : []).filter((it) => Number(it?.grtjlbm) === 51);
  787. if (reportList.length) {
  788. this.sidebarPanels = this.sidebarPanels.concat([{
  789. type: "report-table",
  790. title: "报表",
  791. iconClass: bizIcon,
  792. items: reportList,
  793. // 功能说明:点击统计表单元格,优先按 fwm/bjm 组装后端 service 并弹窗 by xu 20260115
  794. onOpen: (srv) => this.openServiceDialog(srv),
  795. }]);
  796. }
  797. } catch (e) {
  798. }
  799. // 功能说明:将 pstatList=1 映射为右侧图表区(type=chart),并调 wrPchtPlay 拉取真实数据 by xu 20260114
  800. const chartPanels = this.buildPstatChartPanels(bizIcon);
  801. if (chartPanels.length) {
  802. this.sidebarPanels = this.sidebarPanels.concat(chartPanels);
  803. chartPanels.forEach((p) => this.loadPstatChartData(p));
  804. // 功能说明:追加 chartPanels 后触发一次 resize,避免首次进入图表为灰色圆(布局未完成) by xu 20260114
  805. try {
  806. setTimeout(function () {
  807. window.dispatchEvent(new Event("resize"));
  808. }, 0);
  809. } catch (_) {
  810. }
  811. }
  812. this.sidebarButtons = this.rbarFuncList.map((f) => ({
  813. id: f.id || f.servName,
  814. text: f.desc || f.title || "",
  815. onClick: () => this.openServiceDialog(f),
  816. }));
  817. if (!this.showRightSidebar) { // 功能说明:右侧栏隐藏时清空面板/按钮,避免残留旧数据误导(临时规则) by xu 20260122
  818. this.sidebarPanels = [];
  819. this.sidebarButtons = [];
  820. }
  821. },
  822. handleRootFuncClick(func) {
  823. this.openServiceDialog(func);
  824. },
  825. // 切换范围(所有/管理/创建/已办/停用)=> 刷新列表(不刷新右侧栏)
  826. switchScope(management) {
  827. if (this.loadingList) return;
  828. this.form.management = String(management);
  829. this.searchButtonConfigCheckId = String(management);
  830. this.ssPaging.pageNo = 1;
  831. this.userInteracted = true;
  832. this.loadPobjList({ source: "scope" });
  833. },
  834. /// 增加,支持细分部件。Lin
  835. swSubpage(page) {
  836. this.selSubpage = String(page.id);
  837. this.openServiceDialog(page)
  838. },
  839. ///
  840. // 提取当前表单参数(用于 ajax 调用 /service?ssServ=...)
  841. getSearchFormParams() {
  842. const params = {};
  843. try {
  844. const arr = $("#myForm").serializeArray();
  845. arr.forEach(({name, value}) => {
  846. if (!name) return;
  847. if (name === "pageNo" || name === "rowNumPer" || name === "rowNum") return; // 功能说明:分页参数不再从表单序列化读取(完全由 ssPaging 驱动) by xu 20260123
  848. if (Object.prototype.hasOwnProperty.call(params, name)) {
  849. const cur = params[name];
  850. params[name] = Array.isArray(cur) ? cur.concat([value]) : [cur, value];
  851. } else {
  852. params[name] = value;
  853. }
  854. });
  855. } catch (e) {
  856. console.error("getSearchFormParams failed", e);
  857. }
  858. return params;
  859. },
  860. // 以 Vue data 为准,组装列表/搜索请求参数(避免依赖组件内部 input 的实现)
  861. getPobjParams() {
  862. const params = {};
  863. const form = this.form || {};
  864. Object.keys(form).forEach((k) => {
  865. const v = form[k];
  866. if (v === undefined || v === null) return;
  867. if (typeof v === "object") return;
  868. params[k] = v;
  869. });
  870. if (this.ssPaging) {
  871. params.pageNo = this.ssPaging.pageNo;
  872. params.rowNumPer = this.ssPaging.rowNumPer;
  873. params.rowNum = this.ssPaging.rowNum;
  874. }
  875. return params;
  876. },
  877. // 通用:调用后端 service(统一返回原生 Promise,避免 jqXHR 不支持 finally/catch)
  878. callSsService(ssServ, extraParams = {}) {
  879. if (!ssServ) return Promise.resolve(null);
  880. return new Promise((resolve) => {
  881. $.ajax({
  882. type: "get",
  883. url: "/service",
  884. data: {ssServ, ...extraParams},
  885. dataType: "text",
  886. })
  887. .done((text) => {
  888. if (typeof text !== "string") return resolve(text);
  889. const t = text.trim();
  890. if (!t) return resolve(null);
  891. try {
  892. return resolve(JSON.parse(t));
  893. } catch (_) {
  894. return resolve(text);
  895. }
  896. })
  897. .fail((xhr, status, err) => {
  898. console.error("callSsService failed", ssServ, status, err);
  899. resolve(null);
  900. });
  901. });
  902. },
  903. // 初始化:拉取查询首页数据(搜索条件/初始列表/右侧面板等)
  904. loadPobjHome() {
  905. const ssServ = this.ssSearchPobjHomeServName;
  906. if (!ssServ) return Promise.resolve(null);
  907. if (this.loadingHome) return Promise.resolve(null);
  908. const startedAt = Date.now();
  909. this.loadingHome = true;
  910. this.homeReady = false;
  911. this.userInteracted = false;
  912. const params = this.getPobjParams();
  913. // 功能说明:打印首屏请求参数,确认 rowNumPer 是否在第一个接口前写入 by xu 20260123
  914. try { console.log("[objList][自适应分页] 首页请求参数", { ssServ, pageNo: params?.pageNo, rowNumPer: params?.rowNumPer, rowNum: params?.rowNum, autoRowNumPer: this.autoRowNumPer }); } catch (_) {}
  915. return this.callSsService(ssServ, params)
  916. .then((res) => {
  917. const payload = res && typeof res === "object" ? (res.ssData || res) : null;
  918. this.applyPobjHomeData(payload);
  919. console.log("[pobj] home", ssServ, res);
  920. return res;
  921. })
  922. .finally(() => {
  923. const delay = Math.max(0, 200 - (Date.now() - startedAt));
  924. setTimeout(() => {
  925. this.loadingHome = false;
  926. }, delay);
  927. });
  928. },
  929. applyPobjListData(ssData) {
  930. if (!ssData || typeof ssData !== "object") return;
  931. // thnType(若列表接口也返回,则更新;一般由首页接口返回)
  932. if (ssData.thnType != null) this.thnType = Number(ssData.thnType || 0);
  933. if (ssData.ssPaging) {
  934. this.ssPaging = {
  935. ...this.ssPaging,
  936. ...ssData.ssPaging,
  937. pageNo: Number(ssData.ssPaging.pageNo || 1),
  938. rowNumPer: Number(this.ssPaging?.rowNumPer || ssData.ssPaging.rowNumPer || 0), // 功能说明:rowNumPer 由 loadPobjList 按 autoRowNumPer 统一生效;这里只在当前为空时回退后端值 by xu 20260123
  939. rowNum: Number(ssData.ssPaging.rowNum || 0),
  940. };
  941. }
  942. const nextList = Array.isArray(ssData.objList) ? ssData.objList.map((r) => this.normalizeObjToCard(r)) : [];
  943. if (this.listConfig) this.listConfig.list = nextList;
  944. this.cardGridKind = this.detectCardGridKind();
  945. // 功能说明:列表接口返回后不再每次重算 autoRowNumPer,避免翻页过程中 rowNumPer 在 15/16 间抖动;仅在 autoRowNumPer 尚未得到时兜底计算一次 by xu 20260303
  946. if (!Number(this.autoRowNumPer || 0)) {
  947. if (this.$nextTick) this.$nextTick(() => this.scheduleAutoRowNumPer("list-init"));
  948. else this.scheduleAutoRowNumPer("list-init");
  949. }
  950. },
  951. // 功能说明:将 <对象名>_cxycl 返回的 bookList 写回右侧预订面板 by xu 20260114
  952. applyPobjYclData(ssData) {
  953. // 功能说明:兼容返回结构(ssData 可能是整包 {ssCode,ssData} 或直接 ssData),避免“预订tab不回显” by xu 20260116
  954. if (!ssData) return;
  955. const data = (ssData && typeof ssData === "object" && ssData.ssData && typeof ssData.ssData === "object") ? ssData.ssData : ssData;
  956. if (!data || typeof data !== "object") return;
  957. const ensurePanel = (tabKeyLower, title) => {
  958. // 功能说明:严格依赖首页 rbarTabNameList 决定是否允许创建面板:未返回 rbarServ 时即使 cxycl 有 servList 也不处理 by xu 20260116
  959. if (tabKeyLower === "rbarbook" && !this.hasBookPanel) return null;
  960. if (tabKeyLower === "rbarserv" && !this.hasServPanel) return null;
  961. const panels = Array.isArray(this.sidebarPanels) ? this.sidebarPanels : [];
  962. let p = panels.find((it) => String(it?._tabKey || "").toLowerCase() === tabKeyLower);
  963. if (p) return p;
  964. const idx = panels.findIndex((it) => it?.type === "chart");
  965. const insertAt = idx >= 0 ? idx : panels.length;
  966. p = {
  967. type: "list",
  968. _tabKey: tabKeyLower,
  969. title,
  970. // 功能说明:预订/服务面板 iconClass 与首页初始化保持一致(避免 cxycl 兜底创建时图标错误) by xu 20260123
  971. iconClass: (tabKeyLower === "rbarbook")
  972. ? "ss-sidebar-biz-icon icon-obj-yd"
  973. : (tabKeyLower === "rbarserv")
  974. ? "ss-sidebar-biz-icon icon-obj-fw"
  975. : (this.ssObjName ? ("ss-sidebar-biz-icon icon-obj-" + this.ssObjName) : ""),
  976. items: [],
  977. itemAction: false,
  978. };
  979. // 功能说明:预订面板默认使用 person 布局(title+meta) by xu 20260116
  980. if (tabKeyLower === "rbarbook") p.itemLayout = "person";
  981. if (tabKeyLower === "rbarserv") p.itemLayout = "simple"; // 功能说明:服务面板只回显 mc(名称) by xu 20260116
  982. panels.splice(insertAt, 0, p);
  983. this.sidebarPanels = panels;
  984. return p;
  985. };
  986. const fmtDt = (v) => { // 功能说明:JSP 页面避免使用 JS 模板字符串插值(可能被 JSP EL 干扰),统一用字符串拼接 by xu 20260114
  987. if (v === undefined || v === null || v === "") return "";
  988. const d = new Date(v);
  989. if (!isNaN(d.getTime())) {
  990. const pad2 = (n) => String(n).padStart(2, "0");
  991. return (
  992. String(d.getFullYear()) +
  993. "-" +
  994. pad2(d.getMonth() + 1) +
  995. "-" +
  996. pad2(d.getDate()) +
  997. " " +
  998. pad2(d.getHours()) +
  999. ":" +
  1000. pad2(d.getMinutes())
  1001. );
  1002. }
  1003. return String(v);
  1004. };
  1005. const bookList = Array.isArray(data.bookList) ? data.bookList : [];
  1006. const servList = Array.isArray(data.servList) ? data.servList : []; // 功能说明:将 <对象名>_cxycl 返回的 servList 写回右侧服务面板 by xu 20260116
  1007. try {
  1008. console.log("[pobj] cxycl bookList", {len: bookList.length, bookList: bookList});
  1009. } catch (_) {
  1010. } // 功能说明:打印 cxycl 返回,排查“预订tab不回显” by xu 20260116
  1011. // 功能说明:无论 bookList 是否为空,都要写回面板(为空则清空旧数据),避免“切换对象但仍显示上一次预订人” by xu 20260114
  1012. const bookPanel = ensurePanel("rbarbook", "预订");
  1013. if (bookPanel) {
  1014. bookPanel.itemLayout = "person"; // 功能说明:预订面板复用“已选”tab 的 person 布局(title+中间 meta 槽位),不走 tags by xu 20260114
  1015. bookPanel.items = bookList.map((b) => ({
  1016. _raw: b,
  1017. id: b?.id,
  1018. title: String(b?.ydr ?? ""), // 功能说明:预订面板 title=预订人 by xu 20260114
  1019. meta: String(b?.ydrdh ?? ""), // 功能说明:预订面板中间槽位 meta=电话(同“已选”tab) by xu 20260114
  1020. tags: [], // 功能说明:预订面板不使用 tags(避免自定义标签样式) by xu 20260114
  1021. }));
  1022. bookPanel.count = bookPanel.items.length;
  1023. }
  1024. // 功能说明:服务面板按预订(book)回显逻辑写回(title+meta),为空也要清空 by xu 20260116
  1025. const servPanel = ensurePanel("rbarserv", "服务");
  1026. if (servPanel) {
  1027. servPanel.itemLayout = "simple"; // 功能说明:服务面板字段只有 id/mc,仅回显 mc(名称) by xu 20260116
  1028. servPanel.items = servList.map((s) => ({
  1029. _raw: s,
  1030. id: s?.id, // 功能说明:服务面板 id=数据库ID by xu 20260116
  1031. title: String(s?.mc ?? ""), // 功能说明:服务面板 title=mc(名称) by xu 20260116
  1032. tags: [],
  1033. }));
  1034. servPanel.count = servPanel.items.length;
  1035. }
  1036. // 功能说明:强制触发 sidebarPanels 更新,避免仅修改子对象导致视图未刷新(预订tab回显不更新) by xu 20260116
  1037. try {
  1038. this.sidebarPanels = (this.sidebarPanels || []).slice();
  1039. } catch (e) {
  1040. }
  1041. try {
  1042. console.log("[pobj] cxycl bookPanel(after)", {
  1043. title: bookPanel.title,
  1044. tab: bookPanel._tabKey,
  1045. count: bookPanel.count,
  1046. first: bookPanel.items?.[0],
  1047. });
  1048. } catch (_) {
  1049. } // 功能说明:打印写回后的面板状态,排查“预订tab不回显” by xu 20260116
  1050. },
  1051. // 功能说明:选中对象后联动调用 <对象名>_cxycl,填充右侧预订/服务面板 by xu 20260114
  1052. loadPobjYclByItem(item) {
  1053. if (!(this.hasBookPanel || this.hasServPanel)) return Promise.resolve(null); // 功能说明:预订/服务任一存在才调用 cxycl;否则不联动 by xu 20260116
  1054. const objNum = item?.objNum || item?._raw?.ssObjId || item?._raw?.ssObjId;
  1055. if (!objNum) return Promise.resolve(null);
  1056. const ssServ = this.ssObjName ? (String(this.ssObjName) + "_cxycl") : "";
  1057. if (!ssServ) return Promise.resolve(null);
  1058. const reqId = (this.__yclReqId = (this.__yclReqId || 0) + 1);
  1059. this.yclLoading = true;
  1060. // 功能说明:cxycl 需要同时传入 ssObjIdName=<对象名>id,且把对象ID用该字段名提交(如 cdid=90052) by xu 20260114
  1061. const ssObjIdName = String(this.ssObjName || "") + "id";
  1062. const params = {ssObjName: this.ssObjName, ssObjIdName: ssObjIdName, ssObjId: objNum};
  1063. params[ssObjIdName] = objNum;
  1064. return this.callSsService(ssServ, params)
  1065. .then((res) => {
  1066. if (reqId !== this.__yclReqId) return null;
  1067. // 功能说明:兼容 $.ajax/axios 等不同返回结构,避免取错层级导致 bookList 为空 by xu 20260116
  1068. const payload = res && typeof res === "object" ? (res.ssData || res?.data?.ssData || res?.data || res) : null;
  1069. this.yclResp = payload;
  1070. this.applyPobjYclData(payload);
  1071. return res;
  1072. })
  1073. .finally(() => {
  1074. if (reqId !== this.__yclReqId) return;
  1075. this.yclLoading = false;
  1076. });
  1077. },
  1078. // 拉取列表数据(分页/搜索等)
  1079. loadPobjList(options = {}) {
  1080. const ssServ = this.ssSearchPobjListServName;
  1081. if (!ssServ) return Promise.resolve(null);
  1082. // 只有用户操作后才允许请求列表(避免初始化阶段出现第二个 loading)
  1083. if (!this.userInteracted) return Promise.resolve(null);
  1084. if (this.loadingList) return Promise.resolve(null);
  1085. const opts = (options && typeof options === "object") ? options : {};
  1086. const source = String(opts.source || "general");
  1087. const lockRowNumPer = !!opts.lockRowNumPer;
  1088. this.__lastListLoadSource = source;
  1089. // 功能说明:rowNumPer 按 autoRowNumPer 生效(resize 只记录,不立即请求;下次接口请求时才更新) by xu 20260123
  1090. // 功能说明:翻页/刷新请求锁定当前 rowNumPer,避免在翻页链路中被 autoRowNumPer 覆盖导致 pageNo 重置 by xu 20260303
  1091. if (!lockRowNumPer) {
  1092. try {
  1093. const next = Number(this.autoRowNumPer || 0);
  1094. const cur = Number(this.ssPaging?.rowNumPer || 0);
  1095. if (next > 0 && next !== cur) {
  1096. try { console.log("[objList][自适应分页] 列表请求前应用 rowNumPer", { source, cur, next, pageNo: this.ssPaging?.pageNo }); } catch (_) {}
  1097. this.ssPaging.rowNumPer = next;
  1098. // 功能说明:仅在非翻页来源下,页大小变化时回到第一页;翻页来源必须保持当前页码 by xu 20260303
  1099. if (source !== "page") {
  1100. this.ssPaging.pageNo = 1;
  1101. }
  1102. }
  1103. } catch (_) {
  1104. }
  1105. }
  1106. const startedAt = Date.now();
  1107. this.loadingList = true;
  1108. // 点击后立即清空列表区域,避免用户误以为没点到
  1109. if (this.listConfig) {
  1110. this.listConfig.draftbox = [];
  1111. this.listConfig.list = [];
  1112. }
  1113. const params = this.getPobjParams();
  1114. try { console.log("[objList][分页请求]", { source, lockRowNumPer, pageNo: params?.pageNo, rowNumPer: params?.rowNumPer, rowNum: params?.rowNum }); } catch (_) {}
  1115. return this.callSsService(ssServ, params)
  1116. .then((res) => {
  1117. const payload = res && typeof res === "object" ? (res.ssData || res) : null;
  1118. this.ssListResp = payload;
  1119. this.applyPobjListData(payload);
  1120. console.log("[pobj] list", ssServ, res);
  1121. return res;
  1122. })
  1123. .finally(() => {
  1124. const delay = Math.max(0, 200 - (Date.now() - startedAt));
  1125. setTimeout(() => {
  1126. this.loadingList = false;
  1127. }, delay);
  1128. });
  1129. },
  1130. // 初始化右侧边栏分区(已选 items 指向 selectedItems) by xu 20260113
  1131. initSidebarPanels() {
  1132. const bizIcon = this.ssObjName ? ('ss-sidebar-biz-icon icon-obj-' + this.ssObjName) : ''; // 功能说明:右侧栏 iconClass 使用右侧栏 biz 图标基类 by xu 20260123
  1133. // 初始只放“已选”,其他分区由首页接口(rbarTabNameList)初始化
  1134. this.sidebarPanels = [];
  1135. this.sidebarButtons = [];
  1136. },
  1137. // 更新已选分区计数 by xu 20260113
  1138. updatePickedPanelCount() {
  1139. const pickedPanel = this.sidebarPanels?.find?.((p) => p?.title === '已选');
  1140. if (pickedPanel) pickedPanel.count = this.selectedItems.length;
  1141. },
  1142. // 清空已选(右侧 header 清空按钮) by xu 20260113
  1143. clearSelectedItems() {
  1144. // 功能说明:按稳定 key 反向同步当前列表卡片选中态(避免列表刷新后对象引用变化导致取消选中失效) by xu 20260122
  1145. const keyOf = (it) => String(it?.objNum || it?.ssObjId || it?._raw?.ssObjId || it?._raw?.objNum || "");
  1146. const keys = new Set((this.selectedItems || []).map(keyOf).filter(Boolean));
  1147. const all = [].concat(this.listConfig?.draftbox || []).concat(this.listConfig?.list || []);
  1148. all.forEach((it) => {
  1149. const k = keyOf(it);
  1150. if (!k) return;
  1151. if (keys.has(k)) it._ssSelected = false;
  1152. });
  1153. this.selectedItems.forEach((it) => {
  1154. if (it) it._ssSelected = false;
  1155. });
  1156. this.selectedItems.splice(0, this.selectedItems.length);
  1157. this.updatePickedPanelCount();
  1158. // 功能说明:强制触发 sidebarPanels 更新,避免 count 未刷新 by xu 20260122
  1159. try { this.sidebarPanels = (this.sidebarPanels || []).slice(); } catch (_) {}
  1160. },
  1161. // 右侧边栏移除 -> 反向同步左侧卡片状态 by xu 20260113
  1162. handleSidebarRemove(item) {
  1163. if (!item) return;
  1164. // 功能说明:按稳定 key 移除,避免列表刷新后 selectedItems/indexOf 引用不一致导致 count 不更新/取消失败 by xu 20260122
  1165. const keyOf = (it) => String(it?.objNum || it?.ssObjId || it?._raw?.ssObjId || it?._raw?.objNum || "");
  1166. const key = keyOf(item);
  1167. item._ssSelected = false;
  1168. const idx = key ? this.selectedItems.findIndex((it) => keyOf(it) === key) : this.selectedItems.indexOf(item);
  1169. if (idx > -1) this.selectedItems.splice(idx, 1);
  1170. // 反向同步当前列表里同 key 的卡片状态
  1171. if (key) {
  1172. const all = [].concat(this.listConfig?.draftbox || []).concat(this.listConfig?.list || []);
  1173. const cur = all.find((it) => keyOf(it) === key);
  1174. if (cur) cur._ssSelected = false;
  1175. }
  1176. this.updatePickedPanelCount();
  1177. // 功能说明:强制触发 sidebarPanels 更新,避免 count 未刷新 by xu 20260122
  1178. try { this.sidebarPanels = (this.sidebarPanels || []).slice(); } catch (_) {}
  1179. },
  1180. // 功能说明:动态计算 rowNumPer(让分页视觉上在最后一行出现),以 DOM 实测为准;返回明细用于调试 by xu 20260123
  1181. calcAutoRowNumPerDetail() {
  1182. try {
  1183. // 功能说明:Vue3 根节点可能是 Fragment(this.$el 不是 Element),统一从 #app 下查找内容区 by xu 20260123
  1184. const host = (this.$el && this.$el.nodeType === 1 && this.$el.querySelector)
  1185. ? this.$el
  1186. : (document.getElementById && document.getElementById("app")) || document.body;
  1187. const area = host && host.querySelector ? host.querySelector(".item-content-area") : null;
  1188. if (!area) return { err: "no_area" };
  1189. const cs = window.getComputedStyle ? window.getComputedStyle(area) : null;
  1190. // 功能说明:内容区宽度以 item-content-area 为准;若右侧栏与内容区发生覆盖(非并排布局),按重叠宽度扣减 by xu 20260123
  1191. let W = Math.max(0, area.clientWidth || 0);
  1192. let overlap = 0;
  1193. try {
  1194. if (this.showRightSidebar) {
  1195. const sidebar = host && host.querySelector ? host.querySelector(".ss-sidebar") : null;
  1196. if (sidebar && area.getBoundingClientRect && sidebar.getBoundingClientRect) {
  1197. const ar = area.getBoundingClientRect();
  1198. const sr = sidebar.getBoundingClientRect();
  1199. overlap = Math.max(0, Math.min(ar.right, sr.right) - Math.max(ar.left, sr.left));
  1200. if (overlap > 0) W = Math.max(0, W - overlap);
  1201. }
  1202. }
  1203. } catch (_) {
  1204. }
  1205. const H = Math.max(0, area.clientHeight || 0);
  1206. if (!W || !H) {
  1207. // 功能说明:首屏 homeReady=false 时容器 display:none,W/H 为 0;此处回退用 viewport 估算 by xu 20260123
  1208. const vw = Math.max(0, document.documentElement?.clientWidth || window.innerWidth || 0);
  1209. const vhRaw = Math.max(0, document.documentElement?.clientHeight || window.innerHeight || 0);
  1210. // 功能说明:首屏高度按 URL 上的 removeHigh 扣减(弹窗/iframe 会预留顶部/底部区域),否则 rows 会偏大 by xu 20260123
  1211. let removeHigh = 0;
  1212. try {
  1213. const qs = window.location && window.location.search ? window.location.search : "";
  1214. const m = String(qs).match(/(?:\\?|&)removeHigh=([^&]+)/);
  1215. if (m && m[1] != null) {
  1216. const v = parseFloat(decodeURIComponent(m[1]));
  1217. if (!isNaN(v) && v > 0) removeHigh = v;
  1218. }
  1219. } catch (_) {
  1220. }
  1221. const vh = Math.max(0, vhRaw - removeHigh);
  1222. // 功能说明:右侧栏宽度用 rbar 判定(JSP 注入已写入 this.rbar;首页接口返回后会覆盖) by xu 20260123
  1223. const rbarFlag = (this.rbar === true);
  1224. const sidebarW = rbarFlag ? 380 : 0;
  1225. const minW = (Number(this.thnType || 0) === 1) ? 400 : (Number(this.thnType || 0) === 2) ? 320 : 300;
  1226. const gap = 20;
  1227. const padLeft = 20;
  1228. const padRight = 20;
  1229. const padTop = 0;
  1230. const padBottom = 100;
  1231. const pagerH = 32; // 功能说明:分页高度以 .pager-container .pager-content 的 32px 为准(首屏未渲染时用该值预留) by xu 20260123
  1232. let cardH = Number(this.__autoCardH || 0) || Number(this.measureAutoCardHeight?.() || 0);
  1233. if (cardH) this.__autoCardH = cardH;
  1234. if (!vw || !vh || !cardH) return { err: "zero_size", W, H, overlap, vw, vh, cardH, showRightSidebar: !!this.showRightSidebar };
  1235. const Wcontent = Math.max(0, (vw - sidebarW) - padLeft - padRight);
  1236. const cols = Math.max(1, Math.floor((Wcontent + gap) / (minW + gap)));
  1237. const availH = Math.max(0, (vh - 75) - padTop - padBottom - pagerH); // 75=search/预留(与 CSS 对齐) by xu 20260123
  1238. const rows = Math.max(1, Math.floor((availH + gap) / (cardH + gap)));
  1239. const n = Math.max(1, cols * rows);
  1240. return { n, cols, rows, W: 0, H: 0, overlap, gap, padTop, padBottom, padLeft, padRight, minW, pagerH, cardH, vw, vhRaw, vh, removeHigh, sidebarW, rbarFlag, fallback: "viewport" };
  1241. }
  1242. const gap = cs ? (parseFloat(cs.gap) || 0) : 0;
  1243. const padLeft = cs ? (parseFloat(cs.paddingLeft) || 0) : 0;
  1244. const padRight = cs ? (parseFloat(cs.paddingRight) || 0) : 0;
  1245. const padTop = cs ? (parseFloat(cs.paddingTop) || 0) : 0;
  1246. const padBottom = cs ? (parseFloat(cs.paddingBottom) || 0) : 0;
  1247. const minW = cs ? (parseFloat(cs.getPropertyValue("--ss-card-min")) || 300) : 300;
  1248. const Wcontent = Math.max(0, W - padLeft - padRight);
  1249. const cols = Math.max(1, Math.floor((Wcontent + gap) / (minW + gap)));
  1250. const pagerEl = area.querySelector ? (area.querySelector(".pager-bar, .pager-container") || null) : null;
  1251. const pagerH = pagerEl && pagerEl.getBoundingClientRect ? (pagerEl.getBoundingClientRect().height || 0) : 0;
  1252. const cardEl = area.querySelector ? (area.querySelector(".knowledge-item-container") || null) : null;
  1253. let cardH = cardEl && cardEl.getBoundingClientRect ? (cardEl.getBoundingClientRect().height || 0) : 0;
  1254. if (!cardH) {
  1255. // 功能说明:首屏/空列表时通过 probe 实测卡片高度并缓存,避免 rowNumPer 只能等列表接口返回后才可计算 by xu 20260123
  1256. cardH = Number(this.__autoCardH || 0) || Number(this.measureAutoCardHeight?.() || 0);
  1257. if (cardH) this.__autoCardH = cardH;
  1258. }
  1259. if (!cardH) return { err: "no_card_height", W, H, overlap, showRightSidebar: !!this.showRightSidebar };
  1260. const availH = Math.max(0, H - padTop - padBottom - pagerH);
  1261. const rows = Math.max(1, Math.floor((availH + gap) / (cardH + gap)));
  1262. const n = Math.max(1, cols * rows);
  1263. return { n, cols, rows, W, H, overlap, gap, padTop, padBottom, padLeft, padRight, minW, pagerH, cardH, showRightSidebar: !!this.showRightSidebar };
  1264. } catch (_) {
  1265. return { err: "exception" };
  1266. }
  1267. },
  1268. // 功能说明:仅返回 rowNumPer 数值(兼容旧调用点) by xu 20260123
  1269. calcAutoRowNumPer() {
  1270. const d = this.calcAutoRowNumPerDetail?.();
  1271. return d && d.n ? d.n : 0;
  1272. },
  1273. measureAutoCardHeight() { // 功能说明:用 DOM probe 实测 ss-list-card 的稳定高度(不依赖接口数据) by xu 20260123
  1274. try {
  1275. const probe = document.createElement("div");
  1276. const kind = Number(this.thnType || 0) === 1 ? "card-thumbnail" : "card-photo";
  1277. probe.className = "knowledge-item-container " + kind;
  1278. probe.style.position = "fixed";
  1279. probe.style.left = "-99999px";
  1280. probe.style.top = "0";
  1281. probe.style.visibility = "hidden";
  1282. probe.style.pointerEvents = "none";
  1283. probe.style.zIndex = "-1";
  1284. // 让 probe 按最小列宽测量(min-width 对高度几乎无影响,但保持一致) by xu 20260123
  1285. try {
  1286. // 功能说明:同 calcAutoRowNumPerDetail,优先从 #app 下取 item-content-area by xu 20260123
  1287. const host = (this.$el && this.$el.nodeType === 1 && this.$el.querySelector)
  1288. ? this.$el
  1289. : (document.getElementById && document.getElementById("app")) || document.body;
  1290. const area = host && host.querySelector ? host.querySelector(".item-content-area") : null;
  1291. const cs = area && window.getComputedStyle ? window.getComputedStyle(area) : null;
  1292. const minW = cs ? (parseFloat(cs.getPropertyValue("--ss-card-min")) || 300) : 300;
  1293. probe.style.width = String(minW) + "px";
  1294. } catch (_) {
  1295. }
  1296. probe.innerHTML =
  1297. '<div class="body">' +
  1298. ' <div class="box-header"><div>_</div></div>' +
  1299. ' <div class="box-body">' +
  1300. ' <div class="left ss-objlist-thumbPlaceholder"><div class="ss-objlist-thumbIcon">_</div></div>' +
  1301. ' <div class="right"></div>' +
  1302. " </div>" +
  1303. "</div>";
  1304. document.body.appendChild(probe);
  1305. const h = probe.getBoundingClientRect ? (probe.getBoundingClientRect().height || 0) : 0;
  1306. document.body.removeChild(probe);
  1307. return Math.max(0, h);
  1308. } catch (_) {
  1309. return 0;
  1310. }
  1311. },
  1312. // 功能说明:延迟/去抖触发自动 rowNumPer 计算(避免 resize 频繁触发请求) by xu 20260123
  1313. scheduleAutoRowNumPer(reason) {
  1314. if (this.__autoRowNumTimer) clearTimeout(this.__autoRowNumTimer);
  1315. this.__autoRowNumTimer = setTimeout(() => {
  1316. this.__autoRowNumTimer = null;
  1317. this.applyAutoRowNumPer(reason || "");
  1318. }, 150);
  1319. },
  1320. // 功能说明:应用自动 rowNumPer;只记录到 data(下次接口请求时生效),resize 不立即重拉 by xu 20260123
  1321. applyAutoRowNumPer(reason) {
  1322. const d = this.calcAutoRowNumPerDetail?.();
  1323. const next = Number(d?.n || 0);
  1324. if (!next) return;
  1325. const cur = Number(this.autoRowNumPer || 0);
  1326. if (cur === next) return;
  1327. this.autoRowNumPer = next;
  1328. // 功能说明:打印计算明细,便于排查“为什么还是12” by xu 20260123
  1329. try { console.log("[objList][自适应分页] 计算更新", { reason, cur, next, detail: d }); } catch (_) {}
  1330. },
  1331. // 功能:探测当前业务列表卡片类型,用于网格列最小宽度 by xu 20260109
  1332. detectCardGridKind() {
  1333. const all = [].concat(this.listConfig?.draftbox || []).concat(this.listConfig?.list || []);
  1334. if (all.some(it => String(it?.thumbType || '').trim() === 'thumbnail')) return 'thumbnail';
  1335. if (all.some(it => !!it?.thumb || !!it?.thumbType)) return 'photo';
  1336. return 'none';
  1337. },
  1338. // 左侧卡片角标选中(多选)+ 卡片主体单选互斥(exclusive) by xu 20260109
  1339. handleToggleSelect({item, selected, exclusive}) {
  1340. if (!item) return;
  1341. if (!this.hasObjPanel) return; // 功能说明:无 rbarObj 时禁止选中(已选tab也不显示) by xu 20260122
  1342. // 已选分区:中间槽位 meta(可按业务改为后端字段) by xu 20260113
  1343. if (!item.meta) item.meta = String(item.objNum || '');
  1344. // 功能说明:按稳定 key 管理 selectedItems,避免列表刷新后对象引用变化导致取消选中/计数异常 by xu 20260122
  1345. const keyOf = (it) => String(it?.objNum || it?.ssObjId || it?._raw?.ssObjId || it?._raw?.objNum || "");
  1346. const key = keyOf(item);
  1347. const idx = key ? this.selectedItems.findIndex((it) => keyOf(it) === key) : this.selectedItems.indexOf(item);
  1348. if (exclusive && selected && this.cardClickAction === 'single') {
  1349. this.selectedItems.forEach((it) => {
  1350. if (it && it !== item) it._ssSelected = false;
  1351. });
  1352. // 不要重新赋值数组,保留引用(供右侧面板使用) by xu 20260109
  1353. this.selectedItems.splice(0, this.selectedItems.length);
  1354. this.selectedItems.push(item);
  1355. this.updatePickedPanelCount();
  1356. // 功能说明:预订模式下,单选互斥选中后联动加载右侧预订/服务数据 by xu 20260114
  1357. this.loadPobjYclByItem(item);
  1358. // 功能说明:强制触发 sidebarPanels 更新,避免 count 未刷新 by xu 20260122
  1359. try { this.sidebarPanels = (this.sidebarPanels || []).slice(); } catch (_) {}
  1360. return;
  1361. }
  1362. if (selected) {
  1363. if (idx === -1) {
  1364. this.selectedItems.push(item);
  1365. } else if (idx > -1 && this.selectedItems[idx] !== item) {
  1366. // 功能说明:用最新的 item 对象替换旧引用,确保侧边栏操作能反向同步到当前卡片 by xu 20260122
  1367. this.selectedItems.splice(idx, 1, item);
  1368. }
  1369. // 功能说明:预订模式下,多选角标选中也可触发联动(以最近选中项为准) by xu 20260114
  1370. this.loadPobjYclByItem(item);
  1371. } else {
  1372. if (idx > -1) this.selectedItems.splice(idx, 1);
  1373. }
  1374. this.updatePickedPanelCount();
  1375. // 功能说明:强制触发 sidebarPanels 更新,避免 count 未刷新 by xu 20260122
  1376. try { this.sidebarPanels = (this.sidebarPanels || []).slice(); } catch (_) {}
  1377. },
  1378. handlePageChange({pageNo, rowNumPer, rowNum}) {
  1379. // 翻页:调用列表接口刷新(不刷新右侧栏)
  1380. if (this.loadingList) return;
  1381. this.ssPaging.pageNo = pageNo;
  1382. this.ssPaging.rowNumPer = rowNumPer;
  1383. this.ssPaging.rowNum = rowNum;
  1384. this.userInteracted = true;
  1385. this.loadPobjList({ source: "page", lockRowNumPer: true });
  1386. },
  1387. search() {
  1388. // 搜索:回到第一页,调用列表接口刷新(不刷新右侧栏)
  1389. if (this.loadingList) return;
  1390. this.ssPaging.pageNo = 1;
  1391. this.userInteracted = true;
  1392. this.loadPobjList({ source: "search" });
  1393. }
  1394. },
  1395. mounted() {
  1396. // 功能说明:临时将 vm 暴露到 window,供 searchButtonConfig.opt.callback 调用(后续再改为事件回传方式) by xu 20260123
  1397. try { window.__objListVm = this; } catch (_) {}
  1398. // 功能说明:弹窗保存后只刷新列表数据(走 Ajax),禁止走 form.submit/reload 以免跳到 /service 返回内容导致白屏 by xu 20260202
  1399. try {
  1400. const vm = this;
  1401. window.wdRefresh = function () {
  1402. try {
  1403. if (vm.loadingList) return;
  1404. // 保持当前筛选/页码,仅刷新列表数据
  1405. vm.userInteracted = true;
  1406. vm.loadPobjList({ source: "refresh", lockRowNumPer: true });
  1407. } catch (e) {
  1408. console.error("[objList] wdRefresh failed", e);
  1409. }
  1410. };
  1411. } catch (_) {}
  1412. // 初始化:把 URL/form 上已有的参数合并到 form/ssPaging(支持回显 + ajax)
  1413. const curParams = this.getSearchFormParams();
  1414. this.form = {...this.form, ...curParams};
  1415. // 功能说明:分页参数不再从表单读取/初始化(完全由 ssPaging 驱动,且页面不再输出分页隐藏域) by xu 20260123
  1416. this.searchButtonConfigCheckId = String(this.form?.management || "99");
  1417. // 功能说明:首屏在列表数据未到达前,按 thnType 预设 cardGridKind(决定 --ss-card-min),避免 detectCardGridKind 在空列表时把缩略图场景误判为 none by xu 20260123
  1418. try {
  1419. const t = Number(this.thnType || 0);
  1420. if (t === 1) this.cardGridKind = "thumbnail";
  1421. else if (t === 2) this.cardGridKind = "photo";
  1422. else this.cardGridKind = "none";
  1423. } catch (_) {
  1424. this.cardGridKind = "none";
  1425. }
  1426. // 初始化右侧边栏分区 by xu 20260113
  1427. this.initSidebarPanels();
  1428. // 功能说明:订阅系统编辑模式变化(来自 home 顶部按钮/菜单切换),用于业务页右下角“新增”入口显隐 by xu 20260123
  1429. try {
  1430. const bus = window.parent?.sharedEventBus;
  1431. if (bus?.subscribe) {
  1432. const applySysMode = (payload) => {
  1433. const mode = (payload && typeof payload === "object") ? payload.mode : payload;
  1434. const source = (payload && typeof payload === "object") ? payload.source : "unknown";
  1435. this.isSysEditMode = (mode === "edit");
  1436. this.sysModeSource = String(source || "unknown");
  1437. };
  1438. this.__sysEditSub = bus.subscribe("systemEditModelChange", applySysMode);
  1439. try { applySysMode(bus.getState?.("systemEditModelChange")); } catch (_) {}
  1440. }
  1441. } catch (_) {}
  1442. this.userInteracted = false;
  1443. // 功能说明:首屏在第一个接口调用前,按当前容器尺寸预先计算 rowNumPer,并写入 ssPaging(使首页接口直接返回“刚好铺满”的条数) by xu 20260123
  1444. const startHome = () => {
  1445. // 功能说明:首屏以 JSP 注入的 rbar 作为右侧栏存在与否的唯一依据 by xu 20260123
  1446. try { this.showRightSidebar = (this.rbar === true); } catch (_) {}
  1447. // 功能说明:打印首屏关键输入(thnType/cardGridKind/rbar),排查“有缩略图首屏 rowNumPer 偏大” by xu 20260123
  1448. try { console.log("[objList][自适应分页] 首屏输入", { thnType: this.thnType, cardGridKind: this.cardGridKind, rbar: this.rbar, showRightSidebar: this.showRightSidebar }); } catch (_) {}
  1449. // 功能说明:首屏首次渲染时容器可能尚未有尺寸(W/H=0),用 rAF 重试几帧再发第一个接口,确保 rowNumPer 能在首屏生效 by xu 20260123
  1450. let tries = 0;
  1451. const maxTries = 20;
  1452. const tick = () => {
  1453. let d = null;
  1454. try { d = this.calcAutoRowNumPerDetail?.(); } catch (_) {}
  1455. if (tries === 0 || tries === maxTries - 1) {
  1456. try { console.log("[objList][自适应分页] 首屏计算", { tries, detail: d }); } catch (_) {}
  1457. }
  1458. const n = Number(d?.n || 0);
  1459. if (n > 0) {
  1460. this.autoRowNumPer = n;
  1461. this.ssPaging.rowNumPer = n;
  1462. this.ssPaging.pageNo = 1;
  1463. try { console.log("[objList][自适应分页] 首屏应用 rowNumPer", { rowNumPer: n, ssPaging: this.ssPaging, fallback: d?.fallback }); } catch (_) {}
  1464. this.loadPobjHome();
  1465. return;
  1466. }
  1467. tries += 1;
  1468. if (tries >= maxTries) {
  1469. // 达到重试上限仍无法计算,回退按当前 ssPaging.rowNumPer 发请求 by xu 20260123
  1470. try { console.log("[objList][自适应分页] 首屏计算放弃", { ssPaging: this.ssPaging, autoRowNumPer: this.autoRowNumPer, last: d }); } catch (_) {}
  1471. this.loadPobjHome();
  1472. return;
  1473. }
  1474. requestAnimationFrame(tick);
  1475. };
  1476. requestAnimationFrame(tick);
  1477. };
  1478. if (this.$nextTick) this.$nextTick(() => startHome());
  1479. else startHome();
  1480. // 功能说明:监听窗口变化,触发 rowNumPer 自动计算(resize 只记录,下次接口请求时生效) by xu 20260123
  1481. this.__autoRowNumResizeHandler = () => this.scheduleAutoRowNumPer("resize");
  1482. window.addEventListener && window.addEventListener("resize", this.__autoRowNumResizeHandler);
  1483. }
  1484. ,beforeUnmount() {
  1485. // 功能说明:清理 resize 监听与 timer,避免页面切换残留 by xu 20260123
  1486. // 功能说明:清理 window.__objListVm(避免切页后回调指向旧 vm) by xu 20260123
  1487. try { if (window.__objListVm === this) window.__objListVm = null; } catch (_) {}
  1488. if (this.__autoRowNumResizeHandler && window.removeEventListener) {
  1489. window.removeEventListener("resize", this.__autoRowNumResizeHandler);
  1490. this.__autoRowNumResizeHandler = null;
  1491. }
  1492. if (this.__autoRowNumTimer) {
  1493. clearTimeout(this.__autoRowNumTimer);
  1494. this.__autoRowNumTimer = null;
  1495. }
  1496. // 功能说明:解绑系统编辑态订阅,避免多次进入页面累积回调 by xu 20260123
  1497. try { this.__sysEditSub?.unSubscribe?.(); } catch (_) {}
  1498. this.__sysEditSub = null;
  1499. }
  1500. });
  1501. });
  1502. <%-- 原有的清令牌 --%>
  1503. tokenCleanser("<ss:serv name='clearPageToken'/>", {tokenList: "<%= pageContext.getAttribute(ss.page.PageC.PAGE_tokenList)%>"});
  1504. </script>