constants.js 2.8 KB
import {
	formatJournalDate,
	formatJournalDateTime,
	JOURNAL_EMPTY_TEXT,
} from "./utils/journalDateTime";

export const JOURNAL_TABS = [
	{ key: "storeDaily", label: "门店日报", journalType: 2 },
];

export const BIZ_TYPE_TOOLTIP = "轻改:1.1精品升级、1.2次新车升配、1.3售后众筹;延保:2.3.1售前延保、2.3.2售后延保;权益:2.1.1售前会员权益升级、2.1.2售后会员权益升级";

export const BIZ_TYPE_STYLE = {
	1: { label: "轻改", bg: "#E8F3FF", color: "#1677FF" },
	2: { label: "权益", bg: "#F3E8FF", color: "#722ED1" },
	轻改: { label: "轻改", bg: "#E8F3FF", color: "#1677FF" },
	延保: { label: "延保", bg: "#FFF7E6", color: "#D46B08" },
	权益: { label: "权益", bg: "#F3E8FF", color: "#722ED1" },
};

export const TAB_TRACK_CODE_MAP = {
	storeDaily: "journal_web_tab_click_store_daily",
};

export const LIST_API_MAP = {
	storeDaily: "getDailyReportOverviewPage",
};

export function getTemplateTypeByTabKey(tabKey) {
	const tab = JOURNAL_TABS.find(item => item.key === tabKey);
	return tab?.journalType ?? 2;
}

export function getTabKeyByTemplateType(templateType) {
	const tab = JOURNAL_TABS.find(item => item.journalType === templateType);
	return tab?.key ?? "storeDaily";
}

export { formatJournalDate, formatJournalDateTime } from "./utils/journalDateTime";

const bizTypeColumn = {
	label: "业务大类",
	prop: "bizTypeName",
	minWidth: "100px",
	width: "100px",
	addHtml: "bizType",
	isPopConfig: {
		width: 320,
		text: BIZ_TYPE_TOOLTIP,
	},
};

function createDateTimeColumn(label, prop) {
	return {
		label,
		prop,
		minWidth: "170px",
		formatter: row => formatJournalDateTime(row[prop]),
	};
}

function createEmptyTextColumn(label, prop, options = {}) {
	return {
		label,
		prop,
		formatter: (row) => {
			const value = row[prop];
			return value != null && value !== "" ? value : "—";
		},
		...options,
	};
}

export const TABLE_COLUMNS_MAP = {
	storeDaily: [
		{
			label: "所属门店",
			prop: "merchantName",
			minWidth: "160px",
			showOverFlow: true,
			align: "center",
		},
		bizTypeColumn,
		{
			label: "今日驻店人数",
			prop: "staffCount",
			width: "120px",
			formatter: row => (row.staffCount != null ? `${row.staffCount}人` : "—"),
		},
		createDateTimeColumn("最近保存时间", "lastSaveTime"),
		createDateTimeColumn("上报时间", "submissionDate"),
		createEmptyTextColumn("提交人", "staffName", {
			minWidth: "100px",
			width: "120px",
			showOverFlow: true,
		}),
	],
};

export function getDetailTitle(detail, journalType) {
	const { merchantName, reportDate } = detail;
	const formattedDate = formatJournalDate(reportDate);
	const dateText = formattedDate !== JOURNAL_EMPTY_TEXT ? `(${formattedDate})` : "";
	const titleMap = {
		storeDaily: `${merchantName}的门店日报${dateText}`,
	};
	return titleMap[journalType] || "";
}