|
|
@@ -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 '—';
|
|
|
};
|