Browse Source

Merge remote-tracking branch 'origin/Boss' into Boss

Boss3
Default User 1 month ago
parent
commit
96caf124c7
  1. 51
      Reject.js
  2. 4
      supply.html

51
Reject.js

@ -1965,9 +1965,14 @@ app.get('/api/admin/stats/supplies', async (req, res) => {
const weekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000); const weekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
timeCondition = `AND created_at >= '${weekAgo.toISOString().slice(0, 19).replace('T', ' ')}'`; timeCondition = `AND created_at >= '${weekAgo.toISOString().slice(0, 19).replace('T', ' ')}'`;
} else if (filter === 'month') { } else if (filter === 'month') {
// 本月 // 本月(从本月1日到当前日期)
const monthAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000); const monthStart = new Date(now.getFullYear(), now.getMonth(), 1);
timeCondition = `AND created_at >= '${monthAgo.toISOString().slice(0, 19).replace('T', ' ')}'`; timeCondition = `AND created_at >= '${monthStart.toISOString().slice(0, 19).replace('T', ' ')}'`;
} else if (filter === 'lastMonth') {
// 上个月(从上月1日到上月最后一天)
const lastMonthStart = new Date(now.getFullYear(), now.getMonth() - 1, 1);
const lastMonthEnd = new Date(now.getFullYear(), now.getMonth(), 0, 23, 59, 59, 999);
timeCondition = `AND created_at >= '${lastMonthStart.toISOString().slice(0, 19).replace('T', ' ')}' AND created_at <= '${lastMonthEnd.toISOString().slice(0, 19).replace('T', ' ')}'`;
} else if (filter === 'custom') { } else if (filter === 'custom') {
// 自定义时间范围 // 自定义时间范围
const { startDate, endDate } = req.query; const { startDate, endDate } = req.query;
@ -2012,12 +2017,6 @@ app.get('/api/admin/stats/supplies', async (req, res) => {
connection.release(); connection.release();
// 调试日志:检查API返回数据结构
console.log('stats API返回的chartData:', chartData);
console.log('stats API返回的totalSupplies:', totalSupplies);
console.log('stats API返回的totalUsers:', totalUsers);
console.log('stats API返回的avgPerUser:', avgPerUser);
sendResponse(res, true, { sendResponse(res, true, {
chartData, chartData,
stats: { stats: {
@ -2064,9 +2063,14 @@ app.get('/api/admin/supplies', async (req, res) => {
const weekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000); const weekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
timeCondition = `AND created_at >= '${weekAgo.toISOString().slice(0, 19).replace('T', ' ')}'`; timeCondition = `AND created_at >= '${weekAgo.toISOString().slice(0, 19).replace('T', ' ')}'`;
} else if (filter === 'month') { } else if (filter === 'month') {
// 本月 // 本月(从本月1日到当前日期)
const monthAgo = new Date(now.getTime() - 30 * 24 * 60 * 60 * 1000); const monthStart = new Date(now.getFullYear(), now.getMonth(), 1);
timeCondition = `AND created_at >= '${monthAgo.toISOString().slice(0, 19).replace('T', ' ')}'`; timeCondition = `AND created_at >= '${monthStart.toISOString().slice(0, 19).replace('T', ' ')}'`;
} else if (filter === 'lastMonth') {
// 上个月(从上月1日到上月最后一天)
const lastMonthStart = new Date(now.getFullYear(), now.getMonth() - 1, 1);
const lastMonthEnd = new Date(now.getFullYear(), now.getMonth(), 0, 23, 59, 59, 999);
timeCondition = `AND created_at >= '${lastMonthStart.toISOString().slice(0, 19).replace('T', ' ')}' AND created_at <= '${lastMonthEnd.toISOString().slice(0, 19).replace('T', ' ')}'`;
} else if (filter === 'custom') { } else if (filter === 'custom') {
// 自定义时间范围 // 自定义时间范围
const { startDate, endDate } = req.query; const { startDate, endDate } = req.query;
@ -2107,23 +2111,6 @@ app.get('/api/admin/supplies', async (req, res) => {
connection.release(); connection.release();
// 调试日志:检查查询结果中是否包含product_log字段
console.log('查询到的货源数量:', supplies.length);
if (supplies.length > 0) {
console.log('第一个货源的所有字段和值:', JSON.stringify(supplies[0], null, 2));
console.log('第一个货源的字段:', Object.keys(supplies[0]));
console.log('第一个货源是否包含product_log字段:', 'product_log' in supplies[0]);
if ('product_log' in supplies[0]) {
console.log('第一个货源的product_log值:', supplies[0].product_log);
console.log('第一个货源的product_log类型:', typeof supplies[0].product_log);
} else {
console.log('第一个货源不包含product_log字段,可能的原因:');
console.log('1. 数据库中products表可能没有product_log字段');
console.log('2. 字段名称可能拼写错误');
console.log('3. 查询语句可能有问题');
}
}
sendResponse(res, true, { supplies }, '获取货源列表成功'); sendResponse(res, true, { supplies }, '获取货源列表成功');
} catch (error) { } catch (error) {
console.error('获取货源列表失败:', error.message); console.error('获取货源列表失败:', error.message);
@ -2159,9 +2146,6 @@ app.post('/api/supplies/log', async (req, res) => {
); );
userLoginConnection.release(); userLoginConnection.release();
// 打印查询结果,查看是否包含company和organization字段
console.log('查询到的personnel信息:', personnelResult[0]);
// 自动计算变更字段 // 自动计算变更字段
let calculatedChangedFields = changedFields; let calculatedChangedFields = changedFields;
if (operationEvent.includes('编辑') && originalData && modifiedData && !changedFields) { if (operationEvent.includes('编辑') && originalData && modifiedData && !changedFields) {
@ -2199,9 +2183,6 @@ app.post('/api/supplies/log', async (req, res) => {
// 如果找到了员工信息,使用真实的员工数据 // 如果找到了员工信息,使用真实的员工数据
if (personnelResult.length > 0) { if (personnelResult.length > 0) {
const personnelInfo = personnelResult[0]; const personnelInfo = personnelResult[0];
// 检查personnelInfo中的字段名,确保使用正确的字段名
console.log('personnelInfo的所有字段:', Object.keys(personnelInfo));
// 使用正确的字段名:managercompany(公司)、managerdepartment(部门)、organization(组织) // 使用正确的字段名:managercompany(公司)、managerdepartment(部门)、organization(组织)
logData.tracompany = personnelInfo.managercompany || personnelInfo.managerCompany || personnelInfo.MANAGERCOMPANY || ''; logData.tracompany = personnelInfo.managercompany || personnelInfo.managerCompany || personnelInfo.MANAGERCOMPANY || '';
logData.tradepartment = personnelInfo.managerdepartment || personnelInfo.managerDepartment || personnelInfo.MANAGERDEPARTMENT || ''; logData.tradepartment = personnelInfo.managerdepartment || personnelInfo.managerDepartment || personnelInfo.MANAGERDEPARTMENT || '';

4
supply.html

@ -2280,7 +2280,7 @@
let editAllSourceTypes = ['平台货源', '鸡场直销', '第三方货源']; let editAllSourceTypes = ['平台货源', '鸡场直销', '第三方货源'];
let editFilteredSourceTypes = [...editAllSourceTypes]; let editFilteredSourceTypes = [...editAllSourceTypes];
let editSelectedSourceType = ''; let editSelectedSourceType = '';
let editAllCategories = ['粉壳', '褐壳', '绿壳', '白壳']; let editAllCategories = ['粉壳', '褐壳', '绿壳', '白壳', '土鸡蛋'];
let editFilteredCategories = [...editAllCategories]; let editFilteredCategories = [...editAllCategories];
let editSelectedCategory = ''; let editSelectedCategory = '';
let editAllProductNames = ['罗曼粉', '伊莎粉', '罗曼灰', '海蓝灰', '海蓝褐', '绿壳', '粉一', '粉三', '粉六', '粉八', '京粉1号', '京红', '京粉6号', '京粉3号', '农二', '农三', '农五', '农六', '黑鸡土蛋', '大午金凤', '黑凤']; let editAllProductNames = ['罗曼粉', '伊莎粉', '罗曼灰', '海蓝灰', '海蓝褐', '绿壳', '粉一', '粉三', '粉六', '粉八', '京粉1号', '京红', '京粉6号', '京粉3号', '农二', '农三', '农五', '农六', '黑鸡土蛋', '大午金凤', '黑凤'];
@ -3099,7 +3099,7 @@
let selectedYolk = ''; let selectedYolk = '';
// 种类选择功能 // 种类选择功能
let allCategoryOptions = ['粉壳', '褐壳', '绿壳', '白壳']; let allCategoryOptions = ['粉壳', '褐壳', '绿壳', '白壳', '土鸡蛋'];
let filteredCategoryOptions = [...allCategoryOptions]; let filteredCategoryOptions = [...allCategoryOptions];
let selectedCategory = ''; let selectedCategory = '';

Loading…
Cancel
Save