9
0

2 Коммиты dad130ef3d ... eb732185ff

Автор SHA1 Сообщение Дата
  gongtianxiao eb732185ff 修改"其他"为"更多" 1 месяц назад
  gongtianxiao 4bfd37cd8c 修改产证取得日期数据格式 1 месяц назад
3 измененных файлов с 44 добавлено и 4 удалено
  1. 2 2
      src/components/chart/PieChart.vue
  2. 15 1
      src/utils/assetDetailFields.js
  3. 27 1
      src/utils/fullAssetList.js

+ 2 - 2
src/components/chart/PieChart.vue

@@ -128,7 +128,7 @@ const buildTopic1LegendItems = (all) => {
     })),
     {
       key: '__legend_other__',
-      name: '其他',
+      name: '更多',
       legendKind: 'other',
       color: LEGEND_OTHER_COLOR,
       percent: tailPercent,
@@ -165,7 +165,7 @@ const buildIndexLegendFromHeadCount = (all, headCount) => {
     })),
     {
       key: '__legend_other__',
-      name: '其他',
+      name: '更多',
       legendKind: 'other',
       color: LEGEND_OTHER_COLOR,
       percent: tailPercent,

+ 15 - 1
src/utils/assetDetailFields.js

@@ -185,6 +185,17 @@ const formatAssetFieldValue = (val) => {
   return String(val);
 };
 
+const formatCertAcquisitionDateDisplay = (val) => {
+  if (val == null || val === '') return '—';
+  const text = String(val).trim();
+  const cnMatch = text.match(/^(\d{4})年(\d{1,2})月$/);
+  if (cnMatch) return `${cnMatch[1]}年${Number(cnMatch[2])}月`;
+  const dateInput = excelSerialToDateInput(val);
+  const match = String(dateInput).match(/^(\d{4})-(\d{2})-\d{2}$/);
+  if (!match) return formatAssetFieldValue(val);
+  return `${match[1]}年${Number(match[2])}月`;
+};
+
 export const getAssetFieldValue = (item, field) => {
   if (!item) return '—';
   const record = resolveAssetRecord(item);
@@ -195,7 +206,10 @@ export const getAssetFieldValue = (item, field) => {
   ];
   for (const key of keys) {
     const val = record[key];
-    if (val != null && val !== '') return formatAssetFieldValue(val);
+    if (val != null && val !== '') {
+      if (field.key === 'c_czqdrq') return formatCertAcquisitionDateDisplay(val);
+      return formatAssetFieldValue(val);
+    }
   }
   return '—';
 };

+ 27 - 1
src/utils/fullAssetList.js

@@ -93,6 +93,29 @@ const formatDisplay = (val) => {
   return String(val);
 };
 
+/** 产证取得日期:Excel 序列号 / yyyy-MM-dd → YYYY年M月 */
+const formatCertAcquisitionDate = (val) => {
+  if (val == null || val === '') return '—';
+  const text = String(val).trim();
+  const cnMatch = text.match(/^(\d{4})年(\d{1,2})月$/);
+  if (cnMatch) return `${cnMatch[1]}年${Number(cnMatch[2])}月`;
+  let year;
+  let month;
+  if (/^\d{4}-\d{2}-\d{2}/.test(text)) {
+    [, year, month] = text.slice(0, 10).match(/^(\d{4})-(\d{2})-\d{2}$/) ?? [];
+  } else if (/^\d+$/.test(text)) {
+    const serial = Number(text);
+    if (!Number.isFinite(serial)) return text;
+    const date = new Date(Date.UTC(1899, 11, 30) + serial * 86400000);
+    year = date.getUTCFullYear();
+    month = date.getUTCMonth() + 1;
+  } else {
+    return text;
+  }
+  if (!year || !month) return text;
+  return `${year}年${Number(month)}月`;
+};
+
 const getFieldKeys = (col) => {
   if (Array.isArray(col.fieldKeys)) return col.fieldKeys;
   if (typeof col.fieldKeys === 'string') return [col.fieldKeys];
@@ -103,7 +126,10 @@ const getFieldKeys = (col) => {
 export const getCellValue = (item, col) => {
   for (const fieldKey of getFieldKeys(col)) {
     const val = item[fieldKey];
-    if (val != null && val !== '') return formatDisplay(val);
+    if (val != null && val !== '') {
+      if (fieldKey === 'c_czqdrq') return formatCertAcquisitionDate(val);
+      return formatDisplay(val);
+    }
   }
   return '—';
 };