diff --git a/supply.html b/supply.html
index 983e66d..fbb0bd5 100644
--- a/supply.html
+++ b/supply.html
@@ -1025,6 +1025,10 @@
flex: 1;
}
+ .costprice-input {
+ flex: 1;
+ }
+
.remove-quantity-btn {
width: 32px;
height: 32px;
@@ -1168,7 +1172,7 @@
+
货源类型: ${supply.sourceType || '无'}
+
品种: ${supply.category || '无'}
蛋黄: ${supply.yolk || '无'}
+
包装: ${supply.producting || '无'}
+
新鲜程度: ${supply.freshness || '无'}
货源状态: ${supply.supplyStatus || '未设置'}
货源描述: ${supply.description || '无'}
-
斤重: ${supply.grossWeight || ''}斤
地区: ${supply.region || '未设置'}
-
价格: ¥${supply.costprice || '0'}
+
创建时间: ${formatDate(supply.created_at)}
- ${supply.autoOfflineHours && supply.autoOfflineHours !== '' && supply.autoOfflineHours !== null ? `
剩余下架时间: 计算中...
` : ''}
+ ${supply.status === 'published' ? `
上架时间: ${formatDate(getPublishTime(supply))}
` : ''}
@@ -4678,9 +4697,82 @@
function formatDate(dateString) {
if (!dateString) return '未知';
const date = new Date(dateString);
+ // 检查是否为有效的日期
+ if (isNaN(date.getTime())) {
+ return '未知';
+ }
return `${date.getFullYear()}/${(date.getMonth() + 1).toString().padStart(2, '0')}/${date.getDate().toString().padStart(2, '0')} ${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}`;
}
+ // 判断是否为第一次上架
+ function isFirstPublish(supply) {
+ // 如果没有修改时间,使用创建时间
+ if (!supply.updated_at) {
+ return true;
+ }
+
+ // 如果没有创建时间,直接使用修改时间
+ if (!supply.created_at) {
+ return false;
+ }
+
+ // 将创建时间和修改时间转换为时间戳
+ try {
+ const createdAt = new Date(supply.created_at).getTime();
+ const updatedAt = new Date(supply.updated_at).getTime();
+
+ // 计算时间差(毫秒)
+ const diffMs = updatedAt - createdAt;
+
+ // 如果时间差小于60秒(1分钟),认为是第一次上架
+ // 因为创建货源时,系统可能会自动更新修改时间
+ return diffMs < 60 * 1000;
+ } catch (error) {
+ console.error('时间转换失败:', error);
+ // 如果转换失败,默认使用创建时间
+ return true;
+ }
+ }
+
+ // 获取上架时间
+ function getPublishTime(supply) {
+ try {
+ // 检查是否为第一次上架
+ if (isFirstPublish(supply)) {
+ // 第一次上架,使用创建时间
+ if (supply.created_at) {
+ return supply.created_at;
+ }
+ } else {
+ // 重新上架,使用修改时间
+ if (supply.updated_at) {
+ return supply.updated_at;
+ }
+ }
+
+ // 如果以上条件都不满足,尝试使用可用的时间
+ if (supply.created_at) {
+ return supply.created_at;
+ }
+ if (supply.updated_at) {
+ return supply.updated_at;
+ }
+ if (supply.onlineTime) {
+ return supply.onlineTime;
+ }
+ if (supply.publishTime) {
+ return supply.publishTime;
+ }
+
+ // 所有时间字段都不可用,返回null
+ return null;
+ } catch (error) {
+ console.error('获取上架时间失败:', error);
+ // 发生错误时,返回创建时间或null
+ return supply.created_at || null;
+ }
+ }
+
// 复制货源信息
function copySupply(supplyId) {
try {
@@ -4908,9 +5000,10 @@
supplyData.uploadedImages = supply.images || supply.imageUrls || supply.imageList || [];
renderUploadedImages();
- // 规格和件数 - 支持中文逗号分隔和英文逗号分隔字符串
- let specifications = [];
- let quantities = [];
+ // 规格、件数和采购价 - 支持中文逗号分隔和英文逗号分隔字符串
+ let specifications = [];
+ let quantities = [];
+ let costprices = [];
// 解析规格(中文逗号分隔字符串)
try {
@@ -4961,6 +5054,7 @@
pair.innerHTML = `