mp_chgList.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta
  6. name="viewport"
  7. content="width=device-width, initial-scale=1.0, user-scalable=no"
  8. />
  9. <title>变动情况3</title>
  10. <script src="/js/mp_base/base.js"></script>
  11. <style>
  12. [v-cloak] {
  13. display: none !important;
  14. }
  15. #app {
  16. background: #f5f5f5;
  17. min-height: 100vh;
  18. padding: 8px;
  19. box-sizing: border-box;
  20. }
  21. /* 新增变动详情页纯转圈加载态 by xu 2026-03-06 */
  22. .loading {
  23. min-height: 40vh;
  24. display: flex;
  25. align-items: center;
  26. justify-content: center;
  27. }
  28. .loading-spinner {
  29. width: 30px;
  30. height: 30px;
  31. border: 3px solid #e8f3ed;
  32. border-top-color: #40ac6d;
  33. border-radius: 50%;
  34. animation: page-spin 0.9s linear infinite;
  35. }
  36. @keyframes page-spin {
  37. from { transform: rotate(0deg); }
  38. to { transform: rotate(360deg); }
  39. }
  40. .error-card,
  41. .summary-card,
  42. .list-card,
  43. .compare-card {
  44. background: #fff;
  45. border-radius: 8px;
  46. overflow: hidden;
  47. margin-bottom: 10px;
  48. }
  49. .error-card,
  50. .summary-card {
  51. padding: 16px;
  52. }
  53. .error-text {
  54. color: #ff4d4f;
  55. line-height: 1.6;
  56. }
  57. .summary-form,
  58. .compare-table {
  59. width: 100%;
  60. border-collapse: collapse;
  61. }
  62. .summary-form th,
  63. .compare-table th {
  64. width: 110px;
  65. color: #4b5563;
  66. font-weight: 600;
  67. text-align: left;
  68. vertical-align: top;
  69. }
  70. .section-title {
  71. padding: 14px 16px 10px;
  72. font-size: 15px;
  73. font-weight: 600;
  74. color: #242835;
  75. }
  76. .compare-table thead th {
  77. padding: 12px 10px;
  78. background: #f7f8fa;
  79. text-align: center;
  80. width: auto;
  81. }
  82. .compare-table tbody td,
  83. .compare-table tbody th,
  84. .summary-form td,
  85. .summary-form th {
  86. padding: 12px 10px;
  87. border-top: 1px solid #eef0f3;
  88. line-height: 1.6;
  89. word-break: break-all;
  90. }
  91. .compare-table tbody tr:first-child td,
  92. .compare-table tbody tr:first-child th,
  93. .summary-form tbody tr:first-child td,
  94. .summary-form tbody tr:first-child th {
  95. border-top: none;
  96. }
  97. .value-empty {
  98. color: #9ca3af;
  99. }
  100. .compare-col {
  101. width: 34%;
  102. }
  103. .label-col {
  104. width: 32%;
  105. }
  106. .file-link {
  107. color: #2563eb;
  108. text-decoration: underline;
  109. }
  110. .cms-list {
  111. display: flex;
  112. flex-direction: column;
  113. gap: 6px;
  114. }
  115. .cms-item {
  116. padding: 8px 10px;
  117. border-radius: 6px;
  118. background: #f7f8fa;
  119. }
  120. .desc-text {
  121. white-space: pre-wrap;
  122. }
  123. .image-mask {
  124. position: fixed;
  125. inset: 0;
  126. background: rgba(0, 0, 0, 0.68);
  127. z-index: 1200;
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. padding: 12px;
  132. box-sizing: border-box;
  133. }
  134. .image-dialog {
  135. width: 100%;
  136. max-width: 720px;
  137. max-height: 88vh;
  138. background: #fff;
  139. border-radius: 10px;
  140. overflow: auto;
  141. }
  142. .image-dialog__head {
  143. display: flex;
  144. align-items: center;
  145. justify-content: space-between;
  146. padding: 12px 14px;
  147. border-bottom: 1px solid #eef0f3;
  148. }
  149. .image-dialog__title {
  150. font-size: 14px;
  151. font-weight: 600;
  152. color: #242835;
  153. }
  154. .image-dialog__close {
  155. border: none;
  156. background: transparent;
  157. font-size: 20px;
  158. color: #6b7280;
  159. }
  160. .image-compare {
  161. display: flex;
  162. gap: 10px;
  163. padding: 12px;
  164. box-sizing: border-box;
  165. }
  166. .image-panel {
  167. flex: 1;
  168. min-width: 0;
  169. }
  170. .image-label {
  171. margin-bottom: 8px;
  172. font-size: 13px;
  173. color: #4b5563;
  174. text-align: center;
  175. }
  176. .image-preview {
  177. width: 100%;
  178. min-height: 180px;
  179. background: #f7f8fa;
  180. border-radius: 8px;
  181. display: flex;
  182. align-items: center;
  183. justify-content: center;
  184. overflow: hidden;
  185. }
  186. .image-preview img {
  187. width: 100%;
  188. height: auto;
  189. display: block;
  190. }
  191. </style>
  192. </head>
  193. <body>
  194. <div id="app" v-cloak>
  195. <div v-if="loading" class="loading">
  196. <div class="loading-spinner"></div>
  197. </div>
  198. <div v-else-if="error" class="error-card">
  199. <div class="error-text">{{ error }}</div>
  200. </div>
  201. <!-- 新增变动详情摘要卡片 by xu 2026-03-06 -->
  202. <div v-else-if="showSummaryOnly" class="summary-card">
  203. <table class="summary-form">
  204. <tr>
  205. <th>变动类型</th>
  206. <td>{{ summaryData.bdlb || pageParams.bdlbm || '-' }}</td>
  207. </tr>
  208. <tr>
  209. <th>申报名称</th>
  210. <td>{{ summaryData.mc || '-' }}</td>
  211. </tr>
  212. <tr>
  213. <th>申报描述</th>
  214. <td class="desc-text">{{ summaryData.ms || '-' }}</td>
  215. </tr>
  216. </table>
  217. </div>
  218. <!-- 新增变动详情对比表 by xu 2026-03-06 -->
  219. <div v-else class="list-card">
  220. <div class="section-title">变动属性对比</div>
  221. <table class="compare-table">
  222. <thead>
  223. <tr>
  224. <th class="label-col">字段</th>
  225. <th class="compare-col">变动后</th>
  226. <th class="compare-col">变动前</th>
  227. </tr>
  228. </thead>
  229. <tbody>
  230. <tr v-for="(item, index) in displayList" :key="`${index}-${item.desc || ''}`">
  231. <th>{{ item.desc || '-' }}</th>
  232. <td>
  233. <template v-if="item.renderType === 'cms'">
  234. <div class="cms-list">
  235. <div v-for="(child, childIndex) in item.newCmsList" :key="`new-${childIndex}`" class="cms-item">
  236. {{ child || '(无)' }}
  237. </div>
  238. <div v-if="!item.newCmsList.length" class="value-empty">(无)</div>
  239. </div>
  240. </template>
  241. <template v-else-if="item.renderType === 'image'">
  242. <span
  243. class="file-link"
  244. v-if="item.newDisplay && item.newDisplay !== '(无)'"
  245. @click="openImageCompare(item)"
  246. >{{ item.newDisplay }}</span>
  247. <span v-else class="value-empty">(无)</span>
  248. </template>
  249. <template v-else>
  250. <span :class="{ 'value-empty': !item.newDisplay || item.newDisplay === '(无)' }">{{ item.newDisplay || '(无)' }}</span>
  251. </template>
  252. </td>
  253. <td>
  254. <template v-if="item.renderType === 'cms'">
  255. <div class="cms-list">
  256. <div v-for="(child, childIndex) in item.oldCmsList" :key="`old-${childIndex}`" class="cms-item">
  257. {{ child || '(无)' }}
  258. </div>
  259. <div v-if="!item.oldCmsList.length" class="value-empty">(无)</div>
  260. </div>
  261. </template>
  262. <template v-else-if="item.renderType === 'image'">
  263. <span
  264. class="file-link"
  265. v-if="item.oldDisplay && item.oldDisplay !== '(无)'"
  266. @click="openImageCompare(item)"
  267. >{{ item.oldDisplay }}</span>
  268. <span v-else class="value-empty">(无)</span>
  269. </template>
  270. <template v-else>
  271. <span :class="{ 'value-empty': !item.oldDisplay || item.oldDisplay === '(无)' }">{{ item.oldDisplay || '(无)' }}</span>
  272. </template>
  273. </td>
  274. </tr>
  275. </tbody>
  276. </table>
  277. </div>
  278. <div v-if="imagePreview.visible" class="image-mask" @click="closeImageCompare">
  279. <div class="image-dialog" @click.stop>
  280. <div class="image-dialog__head">
  281. <span class="image-dialog__title">图片对比</span>
  282. <button class="image-dialog__close" type="button" @click="closeImageCompare">×</button>
  283. </div>
  284. <div class="image-compare">
  285. <div class="image-panel">
  286. <div class="image-label">变动后</div>
  287. <div class="image-preview">
  288. <img v-if="imagePreview.newUrl" :src="imagePreview.newUrl" alt="new" />
  289. <span v-else class="value-empty">(无)</span>
  290. </div>
  291. </div>
  292. <div class="image-panel">
  293. <div class="image-label">变动前</div>
  294. <div class="image-preview">
  295. <img v-if="imagePreview.oldUrl" :src="imagePreview.oldUrl" alt="old" />
  296. <span v-else class="value-empty">(无)</span>
  297. </div>
  298. </div>
  299. </div>
  300. </div>
  301. </div>
  302. </div>
  303. <script>
  304. window.SS.ready(function () {
  305. window.SS.dom.initializeFormApp({
  306. el: '#app',
  307. data() {
  308. return {
  309. pageParams: {},
  310. loading: false,
  311. error: '',
  312. rawData: {},
  313. displayList: [],
  314. summaryData: {
  315. bdlb: '',
  316. mc: '',
  317. ms: '',
  318. },
  319. imagePreview: {
  320. visible: false,
  321. newUrl: '',
  322. oldUrl: '',
  323. },
  324. };
  325. },
  326. computed: {
  327. showSummaryOnly() {
  328. return ['51', '55'].includes(String(this.pageParams.bdlbm || this.rawData.bdlbm || ''));
  329. },
  330. },
  331. mounted() {
  332. this.pageParams = this.getUrlParams();
  333. this.loadData();
  334. },
  335. methods: {
  336. getUrlParams() {
  337. const params = {};
  338. const urlSearchParams = new URLSearchParams(window.location.search);
  339. for (const [key, value] of urlSearchParams) {
  340. try {
  341. params[key] = decodeURIComponent(value);
  342. } catch (_) {
  343. params[key] = String(value);
  344. }
  345. }
  346. return params;
  347. },
  348. parseParamObject(paramStr) {
  349. if (!paramStr) return {};
  350. if (typeof paramStr === 'object') return paramStr;
  351. try {
  352. return JSON.parse(paramStr);
  353. } catch (_) {
  354. try {
  355. return JSON.parse(
  356. String(paramStr)
  357. .replace(/([{,]\s*)([A-Za-z0-9_]+)\s*:/g, '$1"$2":')
  358. .replace(/'/g, '"')
  359. );
  360. } catch (error) {
  361. console.error('解析param失败:', error);
  362. return {};
  363. }
  364. }
  365. },
  366. async loadData() {
  367. // 加载变动详情并转成移动端对比结构 by xu 2026-03-06
  368. this.loading = true;
  369. this.error = '';
  370. try {
  371. const service = String(this.pageParams.service || this.pageParams.ssServ || 'selChgInfo').trim();
  372. const dest = String(this.pageParams.dest || this.pageParams.ssDest || 'chgList').trim();
  373. const requestData = {
  374. ...this.parseParamObject(this.pageParams.param),
  375. };
  376. if (!requestData.sqid && this.pageParams.sqid) requestData.sqid = this.pageParams.sqid;
  377. if (!requestData.ssObjId && this.pageParams.ssObjId) requestData.ssObjId = this.pageParams.ssObjId;
  378. if (!requestData.ssObjName && this.pageParams.ssObjName) requestData.ssObjName = this.pageParams.ssObjName;
  379. if (!requestData.bdlbm && this.pageParams.bdlbm) requestData.bdlbm = this.pageParams.bdlbm;
  380. const response = await request.post(
  381. `/service?ssServ=${encodeURIComponent(service)}&ssDest=${encodeURIComponent(dest)}`,
  382. requestData,
  383. { loading: false, formData: true }
  384. );
  385. const data = response && response.data ? response.data : response;
  386. this.rawData = data || {};
  387. await this.buildSummaryData(data || {});
  388. await this.buildDisplayList(data || {});
  389. } catch (error) {
  390. console.error('加载变动详情失败:', error);
  391. this.error = (error && error.message) || '加载失败,请稍后重试';
  392. } finally {
  393. this.loading = false;
  394. }
  395. },
  396. async buildSummaryData(data) {
  397. const bdlbm = String(this.pageParams.bdlbm || data.bdlbm || '');
  398. this.summaryData = {
  399. bdlb: await this.translateDict('bdlb', bdlbm, bdlbm),
  400. mc: data.sq && data.sq.mc ? data.sq.mc : '',
  401. ms: this.normalizeDesc(data.sq && (data.sq.ms || data.sq.mswj) ? (data.sq.ms || data.sq.mswj) : ''),
  402. };
  403. },
  404. async buildDisplayList(data) {
  405. const list = Array.isArray(data.bdList) ? data.bdList : [];
  406. const result = [];
  407. for (let i = 0; i < list.length; i += 1) {
  408. const item = list[i] || {};
  409. const renderType = this.resolveRenderType(item);
  410. const nextItem = {
  411. desc: item.desc || item.field?.desc || item.name || '',
  412. renderType,
  413. newDisplay: await this.formatCompareValue(item, item.newVal),
  414. oldDisplay: await this.formatCompareValue(item, item.origVal),
  415. newPath: item.newVal || '',
  416. oldPath: item.origVal || '',
  417. newCmsList: this.extractCmsNames(item, 'newVal'),
  418. oldCmsList: this.extractCmsNames(item, 'origVal'),
  419. };
  420. result.push(nextItem);
  421. }
  422. this.displayList = result;
  423. },
  424. resolveRenderType(item) {
  425. const type = String(item && item.type !== undefined ? item.type : '');
  426. if (['5', '6'].includes(type)) return 'image';
  427. if (type === '9') return 'cms';
  428. return 'text';
  429. },
  430. extractCmsNames(item) {
  431. const list = Array.isArray(item && item.cmsChgList) ? item.cmsChgList : [];
  432. return list.map((child) => {
  433. const newVal = child && child.newVal && child.newVal.mc ? child.newVal.mc : '';
  434. const oldVal = child && child.origVal && child.origVal.mc ? child.origVal.mc : '';
  435. return newVal || oldVal || '';
  436. }).filter(Boolean);
  437. },
  438. async formatCompareValue(item, value) {
  439. if (value === undefined || value === null || value === '') return '(无)';
  440. if (item && item.cbName) {
  441. return this.translateDict(item.cbName, value, String(value));
  442. }
  443. const type = String(item && item.type !== undefined ? item.type : '');
  444. if (type === '8') return '查看对比';
  445. if (type === '9') return '查看内容';
  446. if (['5', '6'].includes(type)) return this.extractFileName(value);
  447. if ((type === '3' || type === '11' || item.fmt) && window.H5FieldFormatter) {
  448. return window.H5FieldFormatter.formatDate(value, item.fmt || 'YYYY-MM-DD HH:mm:ss') || String(value);
  449. }
  450. return this.normalizeDesc(String(value));
  451. },
  452. extractFileName(path) {
  453. if (!path) return '(无)';
  454. const parts = String(path).split('/');
  455. return parts[parts.length - 1] || String(path);
  456. },
  457. normalizeDesc(value) {
  458. if (!value) return '';
  459. return String(value)
  460. .replace(/<br\s*\/?\>/gi, '\n')
  461. .replace(/<[^>]+>/g, '')
  462. .trim();
  463. },
  464. async translateDict(dictName, value, fallbackName) {
  465. if (fallbackName && String(fallbackName).trim() && dictName === 'bdlb' && String(fallbackName) !== String(value)) {
  466. return fallbackName;
  467. }
  468. if (value === undefined || value === null || value === '') return '';
  469. try {
  470. if (typeof window.getDictOptions === 'function') {
  471. const options = await window.getDictOptions(dictName);
  472. const target = (options || []).find((item) => String(item.v) === String(value));
  473. if (target && target.n) return target.n;
  474. }
  475. } catch (error) {
  476. console.error(`${dictName} 字典翻译失败:`, error);
  477. }
  478. return fallbackName || String(value);
  479. },
  480. buildImageUrl(path) {
  481. if (!path) return '';
  482. if (typeof window.getImageUrl === 'function') {
  483. return window.getImageUrl(path);
  484. }
  485. return `/service?ssServ=dlByHttp&type=img&path=${encodeURIComponent(path)}`;
  486. },
  487. openImageCompare(item) {
  488. this.imagePreview = {
  489. visible: true,
  490. newUrl: this.buildImageUrl(item.newPath),
  491. oldUrl: this.buildImageUrl(item.oldPath),
  492. };
  493. },
  494. closeImageCompare() {
  495. this.imagePreview.visible = false;
  496. },
  497. },
  498. });
  499. });
  500. </script>
  501. </body>
  502. </html>